Author: julianfoad
Date: Tue Aug 29 12:40:32 2017
New Revision: 1806583
URL: http://svn.apache.org/viewvc?rev=1806583&view=rev
Log:
On the 'shelve' branch: Keep a backup when deleting a patch.
* subversion/svn/svn.c
(svn_cl__cmd_table): Mention the backup in the help text.
* subversion/libsvn_client/shelve.c
(svn_client_shelf_delete_patch): Keep a backup, removing any previous
backup.
(svn_client_shelves_list): Ignore backups.
Modified:
subversion/branches/shelve/subversion/libsvn_client/shelve.c
subversion/branches/shelve/subversion/svn/svn.c
Modified: subversion/branches/shelve/subversion/libsvn_client/shelve.c
URL:
http://svn.apache.org/viewvc/subversion/branches/shelve/subversion/libsvn_client/shelve.c?rev=1806583&r1=1806582&r2=1806583&view=diff
==============================================================================
--- subversion/branches/shelve/subversion/libsvn_client/shelve.c (original)
+++ subversion/branches/shelve/subversion/libsvn_client/shelve.c Tue Aug 29
12:40:32 2017
@@ -183,11 +183,18 @@ svn_client_shelf_delete_patch(const char
svn_client_ctx_t *ctx,
apr_pool_t *scratch_pool)
{
- char *patch_abspath;
+ char *patch_abspath, *to_abspath;
SVN_ERR(get_patch_abspath(&patch_abspath, shelf_name, wc_root_abspath,
ctx, scratch_pool, scratch_pool));
- SVN_ERR(svn_io_remove_file2(patch_abspath, FALSE /*ignore_enoent*/,
+ to_abspath = apr_pstrcat(scratch_pool, patch_abspath, ".bak", SVN_VA_NULL);
+
+ /* remove any previous backup */
+ SVN_ERR(svn_io_remove_file2(to_abspath, TRUE /*ignore_enoent*/,
+ scratch_pool));
+
+ /* move the patch to a backup file */
+ SVN_ERR(svn_io_file_rename2(patch_abspath, to_abspath, FALSE
/*flush_to_disk*/,
scratch_pool));
return SVN_NO_ERROR;
}
@@ -350,8 +357,9 @@ svn_client_shelves_list(apr_hash_t **dir
for (hi = apr_hash_first(scratch_pool, *dirents); hi; hi = apr_hash_next(hi))
{
const char *name = apr_hash_this_key(hi);
+ int len = strlen(name);
- if (! strstr(name, ".patch"))
+ if (len < 6 || strcmp(name + len - 6, ".patch") != 0)
{
svn_hash_sets(*dirents, name, NULL);
}
Modified: subversion/branches/shelve/subversion/svn/svn.c
URL:
http://svn.apache.org/viewvc/subversion/branches/shelve/subversion/svn/svn.c?rev=1806583&r1=1806582&r2=1806583&view=diff
==============================================================================
--- subversion/branches/shelve/subversion/svn/svn.c (original)
+++ subversion/branches/shelve/subversion/svn/svn.c Tue Aug 29 12:40:32 2017
@@ -1661,6 +1661,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
" beginning of the patch file.\n"
"\n"
" 2. Delete the shelved change NAME.\n"
+ " (A backup is kept, named with a '.bak' extension.)\n"
"\n"
" 3. List shelved changes. Include the first line of any log message\n"
" and some details about the contents of the change, unless '-q' is\n"
@@ -1688,6 +1689,7 @@ const svn_opt_subcommand_desc2_t svn_cl_
"\n"
" 1. Apply the shelved change NAME to the working copy.\n"
" Delete the patch unless the '--keep-shelved' option is given.\n"
+ " (A backup is kept, named with a '.bak' extension.)\n"
"\n"
" 2. List shelved changes. Include the first line of any log message\n"
" and some details about the contents of the change, unless '-q' is\n"