subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1817320 - in /subversion/branches/shelve-checkpoint/subversion: include/svn_client.h libsvn_client/shelve.c svn/shelve-cmd.c
Date Wed, 06 Dec 2017 21:36:57 GMT
Author: julianfoad
Date: Wed Dec  6 21:36:57 2017
New Revision: 1817320

URL: http://svn.apache.org/viewvc?rev=1817320&view=rev
Log:
On the 'shelve-checkpoint' branch: Add an API to get the affected paths.
Use it in 'svn shelves' to print how many paths are affected.

* subversion/include/svn_client.h,
  subversion/libsvn_client/shelve.c
  (svn_client_shelf_version_get_info,
   svn_client_shelves_list): Minor fixes to doc-strings.
  (svn_client_shelf_get_paths): New.

* subversion/svn/shelve-cmd.c
  (shelves_list): Use it.

Modified:
    subversion/branches/shelve-checkpoint/subversion/include/svn_client.h
    subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c
    subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c

Modified: subversion/branches/shelve-checkpoint/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/include/svn_client.h?rev=1817320&r1=1817319&r2=1817320&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/include/svn_client.h (original)
+++ subversion/branches/shelve-checkpoint/subversion/include/svn_client.h Wed Dec  6 21:36:57
2017
@@ -6839,7 +6839,7 @@ typedef struct svn_client_shelf_version_
   apr_time_t mtime;  /* mtime of the patch file */
 } svn_client_shelf_version_info_t;
 
-/** Set @a *info to the files affected by the current version of SHELF.
+/** Set @a *info to the files affected by the current version of @a shelf.
  *
  * @since New in 1.X.
  */
@@ -6851,7 +6851,21 @@ svn_client_shelf_version_get_info(svn_cl
                                   apr_pool_t *result_pool,
                                   apr_pool_t *scratch_pool);
 
-/** Set the log message in SHELF, using the log message callbacks in
+/** Set @a *affected_paths to a hash with one entry for each path affected
+ * by the @a shelf @a version. The hash key is the old path and value is
+ * the new path, both relative to the WC root. The key and value are the
+ * same except when a path is moved or copied.
+ *
+ * @since New in 1.X.
+ */
+svn_error_t *
+svn_client_shelf_get_paths(apr_hash_t **affected_paths,
+                           svn_client_shelf_t *shelf,
+                           int version,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool);
+
+/** Set the log message in @a shelf, using the log message callbacks in
  * the client context.
  *
  * @since New in 1.X.
@@ -6871,7 +6885,7 @@ typedef struct svn_client_shelf_info_t
   apr_time_t mtime;  /* mtime of the latest change */
 } svn_client_shelf_info_t;
 
-/** Set *shelved_patches to a hash, keyed by shelf name, of pointers to
+/** Set @a *shelved_patch_infos to a hash, keyed by shelf name, of pointers to
  * @c svn_client_shelf_info_t structures.
  *
  * @a local_abspath is any path in the WC and is used to find the WC root.

Modified: subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c?rev=1817320&r1=1817319&r2=1817320&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/libsvn_client/shelve.c Wed Dec  6 21:36:57
2017
@@ -361,6 +361,44 @@ svn_client_shelf_delete(const char *name
 }
 
 svn_error_t *
+svn_client_shelf_get_paths(apr_hash_t **affected_paths,
+                           svn_client_shelf_t *shelf,
+                           int version,
+                           apr_pool_t *result_pool,
+                           apr_pool_t *scratch_pool)
+{
+  const char *patch_abspath;
+  svn_patch_file_t *patch_file;
+  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
+  apr_hash_t *paths = apr_hash_make(result_pool);
+
+  SVN_ERR(get_existing_patch_abspath(&patch_abspath, shelf, version,
+                                     result_pool, result_pool));
+  SVN_ERR(svn_diff_open_patch_file(&patch_file, patch_abspath, result_pool));
+
+  while (1)
+    {
+      svn_patch_t *patch;
+
+      svn_pool_clear(iterpool);
+      SVN_ERR(svn_diff_parse_next_patch(&patch, patch_file,
+                                        FALSE /*reverse*/,
+                                        FALSE /*ignore_whitespace*/,
+                                        iterpool, iterpool));
+      if (! patch)
+        break;
+      svn_hash_sets(paths,
+                    apr_pstrdup(result_pool, patch->old_filename),
+                    apr_pstrdup(result_pool, patch->new_filename));
+    }
+  SVN_ERR(svn_diff_close_patch_file(patch_file, iterpool));
+  svn_pool_destroy(iterpool);
+
+  *affected_paths = paths;
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
 svn_client_shelf_apply(svn_client_shelf_t *shelf,
                        int version,
                        svn_boolean_t dry_run,

Modified: subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c?rev=1817320&r1=1817319&r2=1817320&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c (original)
+++ subversion/branches/shelve-checkpoint/subversion/svn/shelve-cmd.c Wed Dec  6 21:36:57
2017
@@ -123,6 +123,7 @@ shelves_list(const char *local_abspath,
       svn_client_shelf_version_info_t *info;
       int age_mins;
       char *age_str;
+      apr_hash_t *paths;
 
       SVN_ERR(svn_client_shelf_open(&shelf,
                                     name, local_abspath, ctx, scratch_pool));
@@ -132,9 +133,14 @@ shelves_list(const char *local_abspath,
       age_mins = (apr_time_now() - info->mtime) / 1000000 / 60;
       age_str = friendly_duration_str(age_mins, scratch_pool);
 
+      SVN_ERR(svn_client_shelf_get_paths(&paths,
+                                         shelf, shelf->max_version,
+                                         scratch_pool, scratch_pool));
+
       SVN_ERR(svn_cmdline_printf(scratch_pool,
-                                 _("%-30s %s ago,  %d versions\n"),
-                                 name, age_str, shelf->max_version));
+                                 _("%-30s %s ago,  %d versions,  %d paths changed\n"),
+                                 name, age_str, shelf->max_version,
+                                 apr_hash_count(paths)));
       if (with_logmsg)
         {
           SVN_ERR(svn_cmdline_printf(scratch_pool,



Mime
View raw message