Author: stsp
Date: Mon Aug  8 16:05:24 2011
New Revision: 1155001

URL: http://svn.apache.org/viewvc?rev=1155001&view=rev
Log:
Show moved-to/moved-from information in 'svn info' output.

* subversion/include/svn_wc.h
  (svn_wc_info_t): New fields MOVED_FROM_RELPATH and MOVED_TO_RELPATH.

* subversion/svn/info-cmd.c
  (print_info_xml, print_info): Show move information in wc info, if any.

* subversion/svn/schema/info.rnc
  (wc-info): Add moved-from and moved-to tags.

* subversion/libsvn_wc/info.c
  (svn_wc_info_dup): Dup the new fields.
  (build_info_for_node): Obtain move information from DB and put it into
   the returned wc-info structure.

Modified:
    subversion/trunk/subversion/include/svn_wc.h
    subversion/trunk/subversion/libsvn_wc/info.c
    subversion/trunk/subversion/svn/info-cmd.c
    subversion/trunk/subversion/svn/schema/info.rnc

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1155001&r1=1155000&r2=1155001&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Mon Aug  8 16:05:24 2011
@@ -3068,6 +3068,15 @@ typedef struct svn_wc_info_t
   /** The local absolute path of the working copy root.  */
   const char *wcroot_abspath;
 
+  /** The path the node was moved from, if it was moved here. Else NULL.
+   * This path is relative to the working copy root.
+   * @since New in 1.8. */
+  const char *moved_from_relpath;
+
+  /** The path the node was moved to, if it was moved away. Else NULL.
+   * This path is relative to the working copy root.
+   * @since New in 1.8. */
+  const char *moved_to_relpath;
 } svn_wc_info_t;
 
 /**

Modified: subversion/trunk/subversion/libsvn_wc/info.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/info.c?rev=1155001&r1=1155000&r2=1155001&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/info.c (original)
+++ subversion/trunk/subversion/libsvn_wc/info.c Mon Aug  8 16:05:24 2011
@@ -63,6 +63,11 @@ svn_wc_info_dup(const svn_wc_info_t *inf
     new_info->copyfrom_url = apr_pstrdup(pool, info->copyfrom_url);
   if (info->wcroot_abspath)
     new_info->wcroot_abspath = apr_pstrdup(pool, info->wcroot_abspath);
+  if (info->moved_from_relpath)
+    new_info->moved_from_relpath = apr_pstrdup(pool, info->moved_from_relpath);
+  if (info->moved_to_relpath)
+    new_info->moved_to_relpath = apr_pstrdup(pool, info->moved_to_relpath);
+
   return new_info;
 }
 
@@ -133,6 +138,8 @@ build_info_for_node(svn_wc__info2_t **in
 
       if (original_repos_relpath)
         {
+          const char *moved_from_abspath;
+
           /* Root or child of copy */
           tmpinfo->rev = original_revision;
           repos_relpath = original_repos_relpath;
@@ -146,6 +153,26 @@ build_info_for_node(svn_wc__info2_t **in
 
               wc_info->copyfrom_rev = original_revision;
             }
+
+          SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL, NULL, NULL, NULL,
+                                           NULL, NULL, NULL,
+                                           &moved_from_abspath, NULL,
+                                           db, local_abspath,
+                                           result_pool, scratch_pool));
+          if (moved_from_abspath)
+            {
+              const char *wcroot_abspath;
+              const char *relpath;
+
+              SVN_ERR(svn_wc__db_get_wcroot(&wcroot_abspath, db, local_abspath,
+                                            scratch_pool, scratch_pool));
+              relpath = svn_dirent_skip_ancestor(wcroot_abspath,
+                                                 moved_from_abspath);
+              wc_info->moved_from_relpath = apr_pstrdup(result_pool,
+                                                        relpath);
+            }
+          else
+            wc_info->moved_from_relpath = NULL;
         }
       else if (op_root)
         {
@@ -187,6 +214,7 @@ build_info_for_node(svn_wc__info2_t **in
   else if (status == svn_wc__db_status_deleted)
     {
       const char *work_del_abspath;
+      const char *moved_to_abspath;
 
       SVN_ERR(svn_wc__db_read_pristine_info(NULL, NULL,
                                             &tmpinfo->last_changed_rev,
@@ -199,7 +227,7 @@ build_info_for_node(svn_wc__info2_t **in
                                             result_pool, scratch_pool));
 
       /* And now fetch the url and revision of what will be deleted */
-      SVN_ERR(svn_wc__db_scan_deletion(NULL, NULL,
+      SVN_ERR(svn_wc__db_scan_deletion(NULL, &moved_to_abspath,
                                        &work_del_abspath, NULL,
                                        db, local_abspath,
                                        scratch_pool, scratch_pool));
@@ -242,6 +270,19 @@ build_info_for_node(svn_wc__info2_t **in
                                                      result_pool);
         }
 
+      if (moved_to_abspath)
+        {
+          const char *wcroot_abspath;
+          const char *relpath;
+
+          SVN_ERR(svn_wc__db_get_wcroot(&wcroot_abspath, db, local_abspath,
+                                        scratch_pool, scratch_pool));
+          relpath = svn_dirent_skip_ancestor(wcroot_abspath, moved_to_abspath);
+          wc_info->moved_to_relpath = apr_pstrdup(result_pool, relpath);
+        }
+      else
+        wc_info->moved_to_relpath = NULL;
+
       wc_info->schedule = svn_wc_schedule_delete;
     }
   else if (status == svn_wc__db_status_not_present

Modified: subversion/trunk/subversion/svn/info-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/info-cmd.c?rev=1155001&r1=1155000&r2=1155001&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/info-cmd.c (original)
+++ subversion/trunk/subversion/svn/info-cmd.c Mon Aug  8 16:05:24 2011
@@ -172,6 +172,16 @@ print_info_xml(void *baton,
         svn_cl__xml_tagged_cdata(&sb, pool, "changelist",
                                  info->wc_info->changelist);
 
+      if (info->wc_info->moved_from_relpath)
+        /* <moved-from> xx </moved-from> */
+        svn_cl__xml_tagged_cdata(&sb, pool, "moved-from",
+                                 info->wc_info->moved_from_relpath);
+
+      if (info->wc_info->moved_to_relpath)
+        /* <moved-to> xx </moved-to> */
+        svn_cl__xml_tagged_cdata(&sb, pool, "moved-to",
+                                 info->wc_info->moved_to_relpath);
+
       /* "</wc-info>" */
       svn_xml_make_close_tag(&sb, pool, "wc-info");
     }
@@ -376,6 +386,12 @@ print_info(void *baton,
       if (SVN_IS_VALID_REVNUM(info->wc_info->copyfrom_rev))
         SVN_ERR(svn_cmdline_printf(pool, _("Copied From Rev: %ld\n"),
                                    info->wc_info->copyfrom_rev));
+      if (info->wc_info->moved_from_relpath)
+        SVN_ERR(svn_cmdline_printf(pool, _("Moved from: %s\n"),
+                                   info->wc_info->moved_from_relpath));
+      if (info->wc_info->moved_to_relpath)
+        SVN_ERR(svn_cmdline_printf(pool, _("Moved to: %s\n"),
+                                   info->wc_info->moved_to_relpath));
     }
 
   if (info->last_changed_author)

Modified: subversion/trunk/subversion/svn/schema/info.rnc
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/schema/info.rnc?rev=1155001&r1=1155000&r2=1155001&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/schema/info.rnc (original)
+++ subversion/trunk/subversion/svn/schema/info.rnc Mon Aug  8 16:05:24 2011
@@ -61,7 +61,9 @@ wc-info =
     depth?,
     text-updated?,
     prop-updated?,
-    checksum?
+    checksum?,
+    moved-from?,
+    moved-to?
   }
 
 wcroot-abspath = element wcroot-abspath { string }


Reply via email to