You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2017/08/24 08:33:46 UTC
svn commit: r1806002 - in /subversion/branches/shelve-checkpoint3: ./
subversion/include/svn_client.h subversion/libsvn_client/shelve.c
subversion/svn/shelve-cmd.c subversion/svn/svn.c
Author: julianfoad
Date: Thu Aug 24 08:33:46 2017
New Revision: 1806002
URL: http://svn.apache.org/viewvc?rev=1806002&view=rev
Log:
On the 'shelve-checkpoint3' branch: Catch up with 'shelve' branch.
Modified:
subversion/branches/shelve-checkpoint3/ (props changed)
subversion/branches/shelve-checkpoint3/subversion/include/svn_client.h
subversion/branches/shelve-checkpoint3/subversion/libsvn_client/shelve.c
subversion/branches/shelve-checkpoint3/subversion/svn/shelve-cmd.c
subversion/branches/shelve-checkpoint3/subversion/svn/svn.c
Propchange: subversion/branches/shelve-checkpoint3/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 24 08:33:46 2017
@@ -75,7 +75,7 @@
/subversion/branches/revprop-cache:1298521-1326293
/subversion/branches/revprop-caching-ng:1620597,1620599
/subversion/branches/revprop-packing:1143907,1143971,1143997,1144017,1144499,1144568,1146145
-/subversion/branches/shelve:1802592-1802596
+/subversion/branches/shelve:1802592-1806000
/subversion/branches/shelve-checkpoint:1801970
/subversion/branches/subtree-mergeinfo:876734-878766
/subversion/branches/svn-auth-x509:1603509-1655900
Modified: subversion/branches/shelve-checkpoint3/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint3/subversion/include/svn_client.h?rev=1806002&r1=1806001&r2=1806002&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint3/subversion/include/svn_client.h (original)
+++ subversion/branches/shelve-checkpoint3/subversion/include/svn_client.h Thu Aug 24 08:33:46 2017
@@ -6861,6 +6861,7 @@ svn_client_shelves_list(apr_hash_t **dir
*/
svn_error_t *
svn_client_shelf_write_patch(const char *shelf_name,
+ const char *message,
const char *wc_root_abspath,
svn_boolean_t overwrite_existing,
const apr_array_header_t *paths,
Modified: subversion/branches/shelve-checkpoint3/subversion/libsvn_client/shelve.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint3/subversion/libsvn_client/shelve.c?rev=1806002&r1=1806001&r2=1806002&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint3/subversion/libsvn_client/shelve.c (original)
+++ subversion/branches/shelve-checkpoint3/subversion/libsvn_client/shelve.c Thu Aug 24 08:33:46 2017
@@ -73,6 +73,7 @@ get_patch_abspath(char **patch_abspath,
svn_error_t *
svn_client_shelf_write_patch(const char *shelf_name,
+ const char *message,
const char *wc_root_abspath,
svn_boolean_t overwrite_existing,
const apr_array_header_t *paths,
@@ -99,14 +100,25 @@ svn_client_shelf_write_patch(const char
/* ### svn_stream_open_writable() doesn't work here: the buffering
goes wrong so that diff headers appear after their hunks.
For now, fix by opening the file without APR_BUFFERED. */
- flag = APR_WRITE | APR_CREATE;
+ flag = APR_FOPEN_WRITE | APR_FOPEN_CREATE;
if (! overwrite_existing)
- flag |= APR_EXCL;
+ flag |= APR_FOPEN_EXCL;
SVN_ERR(svn_io_file_open(&outfile, patch_abspath,
flag, APR_FPROT_OS_DEFAULT, scratch_pool));
outstream = svn_stream_from_aprfile2(outfile, FALSE /*disown*/, scratch_pool);
SVN_ERR(svn_stream_for_stderr(&errstream, scratch_pool));
+ /* Write the patch file header (log message, etc.) */
+ if (message)
+ {
+ SVN_ERR(svn_stream_printf(outstream, scratch_pool, "%s\n",
+ message));
+ }
+ SVN_ERR(svn_stream_printf(outstream, scratch_pool,
+ "--This line, and those below, will be ignored--\n\n"));
+ SVN_ERR(svn_stream_printf(outstream, scratch_pool,
+ "--This patch was generated by 'svn shelve'--\n\n"));
+
for (i = 0; i < paths->nelts; i++)
{
const char *path = APR_ARRAY_IDX(paths, i, const char *);
@@ -191,6 +203,7 @@ svn_client_shelve(const char *shelf_name
{
const char *local_abspath;
const char *wc_root_abspath;
+ const char *message = "";
svn_error_t *err;
SVN_ERR(validate_shelf_name(shelf_name, pool));
@@ -201,7 +214,19 @@ svn_client_shelve(const char *shelf_name
SVN_ERR(svn_client_get_wc_root(&wc_root_abspath,
local_abspath, ctx, pool, pool));
- err = svn_client_shelf_write_patch(shelf_name, wc_root_abspath,
+ /* Fetch the log message and any other revprops */
+ if (SVN_CLIENT__HAS_LOG_MSG_FUNC(ctx))
+ {
+ const char *tmp_file;
+ apr_array_header_t *commit_items = apr_array_make(pool, 1, sizeof(void *));
+
+ SVN_ERR(svn_client__get_log_msg(&message, &tmp_file, commit_items,
+ ctx, pool));
+ if (! message)
+ return SVN_NO_ERROR;
+ }
+
+ err = svn_client_shelf_write_patch(shelf_name, message, wc_root_abspath,
FALSE /*overwrite_existing*/,
paths, depth, changelists,
ctx, pool);
Modified: subversion/branches/shelve-checkpoint3/subversion/svn/shelve-cmd.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint3/subversion/svn/shelve-cmd.c?rev=1806002&r1=1806001&r2=1806002&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint3/subversion/svn/shelve-cmd.c (original)
+++ subversion/branches/shelve-checkpoint3/subversion/svn/shelve-cmd.c Thu Aug 24 08:33:46 2017
@@ -48,6 +48,28 @@ get_shelf_name(const char **shelf_name,
return SVN_NO_ERROR;
}
+/* ### Currently just reads the first line.
+ */
+static svn_error_t *
+read_logmsg_from_patch(const char **logmsg,
+ const char *patch_abspath,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ apr_file_t *file;
+ svn_stream_t *stream;
+ svn_boolean_t eof;
+ svn_stringbuf_t *line;
+
+ SVN_ERR(svn_io_file_open(&file, patch_abspath,
+ APR_FOPEN_READ, APR_FPROT_OS_DEFAULT, scratch_pool));
+ stream = svn_stream_from_aprfile2(file, FALSE /*disown*/, scratch_pool);
+ SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, scratch_pool));
+ SVN_ERR(svn_stream_close(stream));
+ *logmsg = line->data;
+ return SVN_NO_ERROR;
+}
+
/* Display a list of shelves */
static svn_error_t *
shelves_list(const char *local_abspath,
@@ -66,12 +88,21 @@ shelves_list(const char *local_abspath,
const char *name = apr_hash_this_key(hi);
svn_io_dirent2_t *dirent = apr_hash_this_val(hi);
int age = (apr_time_now() - dirent->mtime) / 1000000 / 60;
+ const char *patch_abspath;
+ const char *logmsg;
if (! strstr(name, ".patch"))
continue;
+ patch_abspath = svn_dirent_join_many(scratch_pool,
+ local_abspath, ".svn", "shelves", name,
+ SVN_VA_NULL);
+ SVN_ERR(read_logmsg_from_patch(&logmsg, patch_abspath,
+ scratch_pool, scratch_pool));
printf("%-30s %6d mins old %10ld bytes\n",
name, age, (long)dirent->filesize);
+ printf(" %.50s\n",
+ logmsg);
if (diffstat)
{
@@ -137,6 +168,7 @@ svn_cl__shelve(apr_getopt_t *os,
{
svn_depth_t depth = opt_state->depth;
+ svn_error_t *err;
/* shelve has no implicit dot-target `.', so don't you put that
code here! */
@@ -150,10 +182,20 @@ svn_cl__shelve(apr_getopt_t *os,
SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
- SVN_ERR(svn_client_shelve(shelf_name,
- targets, depth, opt_state->changelists,
- opt_state->dry_run,
- ctx, pool));
+ if (ctx->log_msg_func3)
+ SVN_ERR(svn_cl__make_log_msg_baton(&ctx->log_msg_baton3,
+ opt_state, NULL, ctx->config,
+ pool));
+ err = svn_client_shelve(shelf_name,
+ targets, depth, opt_state->changelists,
+ opt_state->dry_run,
+ ctx, pool);
+ if (ctx->log_msg_func3)
+ SVN_ERR(svn_cl__cleanup_log_msg(ctx->log_msg_baton3,
+ err, pool));
+ else
+ SVN_ERR(err);
+
if (! opt_state->quiet)
SVN_ERR(svn_cmdline_printf(pool, "shelved '%s'\n", shelf_name));
}
@@ -169,13 +211,25 @@ svn_cl__unshelve(apr_getopt_t *os,
{
svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
+ const char *local_abspath;
const char *shelf_name;
apr_array_header_t *targets;
- const char *local_abspath;
- SVN_ERR(get_shelf_name(&shelf_name, os, pool, pool));
SVN_ERR(svn_dirent_get_absolute(&local_abspath, "", pool));
+ if (opt_state->list)
+ {
+ if (os->ind < os->argc)
+ return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, 0, NULL);
+
+ SVN_ERR(shelves_list(local_abspath,
+ ! opt_state->quiet /*diffstat*/,
+ ctx, pool));
+ return SVN_NO_ERROR;
+ }
+
+ SVN_ERR(get_shelf_name(&shelf_name, os, pool, pool));
+
/* There should be no remaining arguments. */
SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
opt_state->targets,
Modified: subversion/branches/shelve-checkpoint3/subversion/svn/svn.c
URL: http://svn.apache.org/viewvc/subversion/branches/shelve-checkpoint3/subversion/svn/svn.c?rev=1806002&r1=1806001&r2=1806002&view=diff
==============================================================================
--- subversion/branches/shelve-checkpoint3/subversion/svn/svn.c (original)
+++ subversion/branches/shelve-checkpoint3/subversion/svn/svn.c Thu Aug 24 08:33:46 2017
@@ -144,6 +144,8 @@ typedef enum svn_cl__longopt_t {
opt_pin_externals,
opt_show_item,
opt_adds_as_modification,
+ opt_delete,
+ opt_keep_shelved,
opt_list
} svn_cl__longopt_t;
@@ -461,10 +463,8 @@ const apr_getopt_option_t svn_cl__option
"resolve tree conflicts instead.")},
{"list", opt_list, 0, N_("list shelved patches")},
-
- /* ### should have new option codes, and not be aliases */
- {"keep", opt_keep_local, 0, N_("do not delete the shelved patch")},
- {"delete", opt_remove, 0, N_("just delete the shelved patch")},
+ {"keep-shelved", opt_keep_shelved, 0, N_("do not delete the shelved patch")},
+ {"delete", opt_delete, 0, N_("delete the shelved patch")},
/* Long-opt Aliases
*
@@ -1670,13 +1670,19 @@ const svn_opt_subcommand_desc2_t svn_cl_
" 1. Shelve as NAME the local changes in the given PATHs.\n"
" 2. Delete the shelved patch NAME.\n"
" 3. List shelved patches.\n"),
- {'q', opt_remove, opt_list, opt_dry_run,
- 'N', opt_depth, opt_targets, opt_changelist} },
+ {opt_delete, opt_list, 'q', opt_dry_run,
+ 'N', opt_depth, opt_targets, opt_changelist,
+ SVN_CL__LOG_MSG_OPTIONS} },
{ "unshelve", svn_cl__unshelve, {0}, N_
("Unshelve changes.\n"
- "usage: unshelve [--keep] NAME\n"),
- {'q', opt_keep_local, opt_dry_run} },
+ "usage: 1. unshelve [--keep-shelved] NAME\n"
+ " 2. unshelve --list\n"
+ "\n"
+ " 1. Apply the shelved patch NAME to the working copy.\n"
+ " Delete the patch unless the '--keep-shelved' option is given.\n"
+ " 2. List shelved patches.\n"),
+ {opt_keep_shelved, opt_list, 'q', opt_dry_run} },
{ "shelves", svn_cl__shelves, {0}, N_
("List shelved patches.\n"
@@ -2412,6 +2418,7 @@ sub_main(int *exit_code, int argc, const
opt_state.diff.summarize = TRUE;
break;
case opt_remove:
+ case opt_delete:
opt_state.remove = TRUE;
break;
case opt_changelist:
@@ -2427,6 +2434,7 @@ sub_main(int *exit_code, int argc, const
opt_state.keep_changelists = TRUE;
break;
case opt_keep_local:
+ case opt_keep_shelved:
opt_state.keep_local = TRUE;
break;
case opt_with_all_revprops:
@@ -2928,7 +2936,8 @@ sub_main(int *exit_code, int argc, const
|| subcommand->cmd_func == svn_cl__mkdir
|| subcommand->cmd_func == svn_cl__move
|| subcommand->cmd_func == svn_cl__lock
- || subcommand->cmd_func == svn_cl__propedit))
+ || subcommand->cmd_func == svn_cl__propedit
+ || subcommand->cmd_func == svn_cl__shelve))
{
/* If the -F argument is a file that's under revision control,
that's probably not what the user intended. */