Patchwork [2,of,7,V4] resolve: choose where .orig file locations are kept

login
register
mail settings
Submitter Christian Delahousse
Date Nov. 11, 2015, 12:59 a.m.
Message ID <1ecc53f8ab6aaed27313.1447203593@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11352/
State Accepted
Commit 50d2389a2e490bf5d1804990b6dc386024926965
Headers show

Comments

Christian Delahousse - Nov. 11, 2015, 12:59 a.m.
# HG changeset patch
# User Christian Delahousse <cdelahousse@fb.com>
# Date 1447194379 28800
#      Tue Nov 10 14:26:19 2015 -0800
# Node ID 1ecc53f8ab6aaed2731343b5a3fac18ad4243f04
# Parent  5ee6aa63a694b3f8b4aba1c7b23561fba77dd78b
resolve: choose where .orig file locations are kept

Having your working copy littered with .orig files is a common HG complaint.
This patch uses the cmd.origpath helper function to let the user
specify where they should be kept when using the resolve command.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3082,7 +3082,7 @@ 
                     xlist.append(abs)
                     if dobackup and (backup <= dobackup
                                      or wctx[abs].cmp(ctx[abs])):
-                            bakname = _origpath(ui, repo, rel)
+                            bakname = origpath(ui, repo, rel)
                             ui.note(_('saving current version of %s as %s\n') %
                                     (rel, bakname))
                             if not opts.get('dry_run'):
@@ -3114,7 +3114,7 @@ 
     finally:
         wlock.release()
 
-def _origpath(ui, repo, filepath):
+def origpath(ui, repo, filepath):
     '''customize where .orig files are created
 
     Fetch user defined path from config file: [ui] origbackuppath = <path>
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5673,7 +5673,7 @@ 
                 # replace filemerge's .orig file with our resolve file
                 # for files in tocomplete, ms.resolve will not overwrite
                 # .orig -- only preresolve does
-                util.rename(a + ".resolve", a + ".orig")
+                util.rename(a + ".resolve", cmdutil.origpath(ui, repo, a))
 
         for f in tocomplete:
             try:
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -197,6 +197,18 @@ 
   $ cat file2.orig
   foo
   baz
+
+.orig files should exists where specified
+  $ hg resolve --all --verbose --config 'ui.origbackuppath=.hg/origbackups'
+  merging file1
+  creating directory: $TESTTMP/repo/.hg/origbackups
+  merging file2
+  warning: conflicts while merging file1! (edit, then use 'hg resolve --mark')
+  warning: conflicts while merging file2! (edit, then use 'hg resolve --mark')
+  [1]
+  $ ls .hg/origbackups
+  file1.orig
+  file2.orig
   $ grep '<<<' file1 > /dev/null
   $ grep '<<<' file2 > /dev/null