Author: stsp
Date: Thu Aug 11 01:35:42 2011
New Revision: 1156434

URL: http://svn.apache.org/viewvc?rev=1156434&view=rev
Log:
Use absolute paths for moved-from and moved-to in the svn_wc_info_t struct.

Suggested by: rhuijben

* subversion/include/svn_wc.h
  (svn_wc_info_t): Rename MOVED_FROM_RELPATH and MOVED_TO_RELPATH to
   MOVED_FROM_ABSPATH and MOVED_TO_ABSPATH.

* subversion/svn/info-cmd.c
  (print_info_xml, print_info): Convert moved-from/moved-to absolute paths
   to relative paths for display. Fall back to showing absolute paths if
   conversion to relative paths fails.

* subversion/libsvn_wc/info.c
  (svn_wc_info_dup, build_info_for_node): Track struct member renames and
   do not convert absolute moved-from/moved-to paths to relative paths
   before putting them into wc-info.

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

Modified: subversion/trunk/subversion/include/svn_wc.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_wc.h?rev=1156434&r1=1156433&r2=1156434&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_wc.h (original)
+++ subversion/trunk/subversion/include/svn_wc.h Thu Aug 11 01:35:42 2011
@@ -3069,14 +3069,12 @@ typedef struct svn_wc_info_t
   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;
+  const char *moved_from_abspath;
 
   /** 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;
+  const char *moved_to_abspath;
 } 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=1156434&r1=1156433&r2=1156434&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/info.c (original)
+++ subversion/trunk/subversion/libsvn_wc/info.c Thu Aug 11 01:35:42 2011
@@ -63,10 +63,10 @@ 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);
+  if (info->moved_from_abspath)
+    new_info->moved_from_abspath = apr_pstrdup(pool, info->moved_from_abspath);
+  if (info->moved_to_abspath)
+    new_info->moved_to_abspath = apr_pstrdup(pool, info->moved_to_abspath);
 
   return new_info;
 }
@@ -138,8 +138,6 @@ 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;
@@ -156,23 +154,9 @@ build_info_for_node(svn_wc__info2_t **in
 
           SVN_ERR(svn_wc__db_scan_addition(NULL, NULL, NULL, NULL, NULL, NULL,
                                            NULL, NULL, NULL,
-                                           &moved_from_abspath, NULL,
+                                           &wc_info->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)
         {
@@ -214,7 +198,6 @@ 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,
@@ -227,7 +210,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, &moved_to_abspath,
+      SVN_ERR(svn_wc__db_scan_deletion(NULL, &wc_info->moved_to_abspath,
                                        &work_del_abspath, NULL,
                                        db, local_abspath,
                                        scratch_pool, scratch_pool));
@@ -270,19 +253,6 @@ 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=1156434&r1=1156433&r2=1156434&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/info-cmd.c (original)
+++ subversion/trunk/subversion/svn/info-cmd.c Thu Aug 11 01:35:42 2011
@@ -172,15 +172,34 @@ 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);
+      if (info->wc_info->moved_from_abspath)
+        {
+          const char *relpath;
+
+          relpath = svn_dirent_skip_ancestor(info->wc_info->wcroot_abspath,
+                                             
info->wc_info->moved_from_abspath);
+
+          /* <moved-from> xx </moved-from> */
+          if (relpath && relpath[0] != '\0')
+            svn_cl__xml_tagged_cdata(&sb, pool, "moved-from", relpath);
+          else
+            svn_cl__xml_tagged_cdata(&sb, pool, "moved-from",
+                                     info->wc_info->moved_from_abspath);
+        }
+
+      if (info->wc_info->moved_to_abspath)
+        {
+          const char *relpath;
+
+          relpath = svn_dirent_skip_ancestor(info->wc_info->wcroot_abspath,
+                                             info->wc_info->moved_to_abspath);
+          /* <moved-to> xx </moved-to> */
+          if (relpath && relpath[0] != '\0')
+            svn_cl__xml_tagged_cdata(&sb, pool, "moved-to", relpath);
+          else
+            svn_cl__xml_tagged_cdata(&sb, pool, "moved-to",
+                                     info->wc_info->moved_to_abspath);
+        }
 
       /* "</wc-info>" */
       svn_xml_make_close_tag(&sb, pool, "wc-info");
@@ -386,12 +405,31 @@ 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->wc_info->moved_from_abspath)
+        {
+          const char *relpath;
+
+          relpath = svn_dirent_skip_ancestor(info->wc_info->wcroot_abspath,
+                                             
info->wc_info->moved_from_abspath);
+          if (relpath && relpath[0] != '\0')
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved from: %s\n"), relpath));
+          else
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved from: %s\n"),
+                                       info->wc_info->moved_from_abspath));
+        }
+
+      if (info->wc_info->moved_to_abspath)
+        {
+          const char *relpath;
+
+          relpath = svn_dirent_skip_ancestor(info->wc_info->wcroot_abspath,
+                                             info->wc_info->moved_to_abspath);
+          if (relpath && relpath[0] != '\0')
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved to: %s\n"), relpath));
+          else
+            SVN_ERR(svn_cmdline_printf(pool, _("Moved to: %s\n"),
+                                       info->wc_info->moved_to_abspath));
+        }
     }
 
   if (info->last_changed_author)


Reply via email to