Patchwork [4,of,7,V4] filemerge: choose where .orig files are kept

login
register
mail settings
Submitter Christian Delahousse
Date Nov. 11, 2015, 12:59 a.m.
Message ID <478865c9f9d44b5da48d.1447203595@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11354/
State Accepted
Commit 454deda24315feb786a3864e433db58be5293fa0
Headers show

Comments

Christian Delahousse - Nov. 11, 2015, 12:59 a.m.
# HG changeset patch
# User Christian Delahousse <cdelahousse@fb.com>
# Date 1447201559 28800
#      Tue Nov 10 16:25:59 2015 -0800
# Node ID 478865c9f9d44b5da48d75f9e562c55b22a6d340
# Parent  5b514003a1afb3e9823a6849f11a77fe98b6f5d0
filemerge: choose where .orig files are kept

Having .orig files litter your working copy is a common complaint. This patch
uses cmdutil.orig to let the user determine where those files should reside.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -16,6 +16,7 @@ 
 from .node import short
 
 from . import (
+    cmdutil,
     error,
     match,
     simplemerge,
@@ -510,7 +511,7 @@ 
     a = repo.wjoin(fd)
     b = temp("base", fca)
     c = temp("other", fco)
-    back = a + ".orig"
+    back = cmdutil.origpath(ui, repo, a)
     if premerge:
         util.copyfile(a, back)
     files = (a, b, c, back)
diff --git a/tests/test-merge-local.t b/tests/test-merge-local.t
--- a/tests/test-merge-local.t
+++ b/tests/test-merge-local.t
@@ -91,7 +91,7 @@ 
   use 'hg resolve' to retry unresolved file merges
   [1]
 
-  $ hg co 0
+  $ hg co 0 --config 'ui.origbackuppath=.hg/origbackups'
   merging zzz1_merge_ok
   merging zzz2_merge_bad
   warning: conflicts while merging zzz2_merge_bad! (edit, then use 'hg resolve --mark')
@@ -99,6 +99,10 @@ 
   use 'hg resolve' to retry unresolved file merges
   [1]
 
+Are orig files from the last commit where we want them?
+  $ ls .hg/origbackups
+  zzz2_merge_bad.orig
+
   $ hg diff --nodates | grep "^[+-][^<>]"
   --- a/zzz1_merge_ok
   +++ b/zzz1_merge_ok