[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Implement svn rm --keep-local

From: Ivan Zhakov <chemodax_at_gmail.com>
Date: 2006-12-29 18:12:54 CET

Attached patch adds option "--keep-local" to svn rm command. With this
option files and directories will be removed only from repository, but
it will remain in *current* working copy. This means that path will be
removed in other working copies after performing update.

Implementation details
Keeping files is very easy: just don't remove them if --keep-local
option is specified.

Handling directories a little bit harder, because they are removed
after commit. So I've implemented storing boolean flag keep_local in
"this_dir" entry. When Subversion is processing log_do_commited
command for deletion it looks for keep_local flag and remove only
administrative directory if keep_local is TRUE.

I have only one question: is format bump required in such situation? I
added only new field to entries file and special meaning for contents
of killme file. So if older client will use new working copy, it will
just ignore new entry field (keep_local) and ignore contents of killme
Of course directory will be removed from disk after commit, but I
think it's not a problem.

I've not been writing Subversion code for several month so I'm posting
my patch here :)

Add option "--keep-local" to svn rm command to keep deleted path in
current working copy.

To keep files just don't remove them. For directories set keep_local
flag to TRUE on "this_dir" entry and use it in log_do_commited.

* subversion/include/svn_wc.h
  (svn_wc_delete3): New function declaration.
  (svn_wc_delete2): Deprecate.
  (svn_wc_entry_t): Add new field keep_local.
* subversion/include/svn_client.h
  (svn_client_delete3): New function.
  (svn_client_delete2): Deprecate.
* subversion/libsvn_wc/entries.h
  (SVN_WC__ENTRY_ATTR_KEEP_LOCAL): New entry attribute...
  (SVN_WC__ENTRY_MODIFY_KEEP_LOCAL): ...And new modification flag for it.
* subversion/libsvn_wc/entries.c
  (svn_wc__atts_to_entry): Parse 'keep-local'.
  (read_entry, write_entry): Read and write new entry field keep_local.
  (fold_entry): Reset keep_local to FALSE if not scheduled for deletion.
* subversion/libsvn_wc/wc.h (SVN_WC__KILL_ADM_ONLY): New.
* subversion/libsvn_wc/log.c
  (log_do_committed): Use svn_wc__make_killme and pass keep_local to it.
  (handle_killme): Destroy only administrative area if kill_adm_only is TRUE.
  (run_log, svn_wc_cleanup2): Check for killme file using
  svn_wc__check_killme and pass kill_adm_only flag to
  handle_killme function.
* subversion/libsvn_wc/adm_ops.c
  (svn_wc_delete2): Reimplement via wrapper to svn_wc_delete3.
  (svn_wc_delete3): Copied from svn_wc_delete2. Add with keep_local flag
  and pass it to mark_tree. Keep files on disk if keep_local is TRUE.
  (mark_tree): Set keep_local on "this_dir" if requested.
* subversion/libsvn_wc/adm_files.h
* subversion/libsvn_wc/adm_files.c
  (svn_wc__make_killme, svn_wc__check_killme): New functions to make
  and check killme file.
* subversion/libsvn_client/delete.c
  (svn_client__wc_delete): Add keep_local parameter and pass it to
  svn_wc_delete3. Don't check for "awkward" files if keep_local is TRUE.
  (svn_client_delete2): Reimplement via wrapper to svn_client_delete3.
  (svn_client_delete3): New function, takes keep_local.
* subversion/libsvn_client/client.h
  (svn_client__wc_delete): Add keep_local parameter.
* subversion/libsvn_client/diff.c
  (merge_file_deleted, merge_dir_deleted): Adjusted calls to
* subversion/svn/cl.h
  (svn_cl__longopt_t): Add svn_cl__keep_local_opt.
  (svn_cl__opt_state_t): Add keep_local flag.
* subversion/svn/delete-cmd.c
  (svn_cl__delete): Use svn_client_delete3 and pass keep_local to it.
* svn/trunk/subversion/svn/main.c
  (svn_cl__options, svn_opt_subcommand_desc2_t): Add "--keep-local" option
  for delete command.
  (main): Handle '--keep-local' option.
* subversion/tests/cmdline/basic_tests.py
  (delete_keep_local): New test for deletion with --keep-local.
  (test_list): Add test delete_keep_local.

Ivan Zhakov

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Fri Dec 29 18:13:06 2006

This is an archived mail posted to the Subversion Dev mailing list.