revert: allow configuring the .orig file location
authorChristian Delahousse <cdelahousse@fb.com>
Thu, 12 Nov 2015 17:00:08 -0600
changeset 26938 080276d377d9
parent 26937 dda0aa3baedd
child 26939 50d2389a2e49
revert: allow configuring the .orig file location
mercurial/cmdutil.py
tests/test-revert.t
--- a/mercurial/cmdutil.py	Thu Nov 12 16:56:06 2015 -0600
+++ b/mercurial/cmdutil.py	Thu Nov 12 17:00:08 2015 -0600
@@ -3082,7 +3082,7 @@
                     xlist.append(abs)
                     if dobackup and (backup <= dobackup
                                      or wctx[abs].cmp(ctx[abs])):
-                            bakname = "%s.orig" % rel
+                            bakname = origpath(ui, repo, rel)
                             ui.note(_('saving current version of %s as %s\n') %
                                     (rel, bakname))
                             if not opts.get('dry_run'):
--- a/tests/test-revert.t	Thu Nov 12 16:56:06 2015 -0600
+++ b/tests/test-revert.t	Thu Nov 12 17:00:08 2015 -0600
@@ -86,6 +86,16 @@
   saving current version of e as e.orig
   reverting e
 
+Test creation of backup (.orig) file in configured file location
+----------------------------------------------------------------
+
+  $ echo z > e
+  $ hg revert --all -v --config 'ui.origbackuppath=.hg/origbackups'
+  creating directory: $TESTTMP/repo/.hg/origbackups
+  saving current version of e as $TESTTMP/repo/.hg/origbackups/e.orig
+  reverting e
+  $ rm -rf .hg/origbackups
+
 revert on clean file (no change)
 --------------------------------