changeset 12789:24999db620cd

Merge with mpm
author Steve Borho <steve@borho.org>
date Wed, 20 Oct 2010 15:36:42 -0500
parents de793925862e (diff) e8a8993b625e (current diff)
children 6c619c2e8778
files
diffstat 6 files changed, 70 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Oct 20 15:09:38 2010 -0500
+++ b/mercurial/commands.py	Wed Oct 20 15:36:42 2010 -0500
@@ -2586,12 +2586,6 @@
     if not node:
         node = opts.get('rev')
 
-    t = opts.get('tool')
-    if t:
-        if 'HGMERGE' in os.environ:
-            os.environ['HGMERGE'] = ''
-        ui.setconfig('ui', 'merge', t)
-
     if not node:
         branch = repo.changectx(None).branch()
         bheads = repo.branchheads(branch)
@@ -2632,7 +2626,12 @@
         displayer.close()
         return 0
 
-    return hg.merge(repo, node, force=opts.get('force'))
+    try:
+        # ui.forcemerge is an internal variable, do not document
+        ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+        return hg.merge(repo, node, force=opts.get('force'))
+    finally:
+        ui.setconfig('ui', 'forcemerge', '')
 
 def outgoing(ui, repo, dest=None, **opts):
     """show changesets not found in the destination
@@ -2979,12 +2978,6 @@
         raise util.Abort(_('no files or directories specified; '
                            'use --all to remerge all files'))
 
-    t = opts.get('tool')
-    if t:
-        if 'HGMERGE' in os.environ:
-            os.environ['HGMERGE'] = ''
-        ui.setconfig('ui', 'merge', t)
-
     ms = mergemod.mergestate(repo)
     m = cmdutil.match(repo, pats, opts)
     ret = 0
@@ -3010,9 +3003,13 @@
                 a = repo.wjoin(f)
                 util.copyfile(a, a + ".resolve")
 
-                # resolve file
-                if ms.resolve(f, wctx, mctx):
-                    ret = 1
+                try:
+                    # resolve file
+                    ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
+                    if ms.resolve(f, wctx, mctx):
+                        ret = 1
+                finally:
+                    ui.setconfig('ui', 'forcemerge', '')
 
                 # replace filemerge's .orig file with our resolve file
                 util.rename(a + ".resolve", a + ".orig")
--- a/mercurial/filemerge.py	Wed Oct 20 15:09:38 2010 -0500
+++ b/mercurial/filemerge.py	Wed Oct 20 15:36:42 2010 -0500
@@ -54,7 +54,17 @@
             return True
         return False
 
-    # HGMERGE takes precedence
+    # forcemerge comes from command line arguments, highest priority
+    force = ui.config('ui', 'forcemerge')
+    if force:
+        toolpath = _findtool(ui, force)
+        if toolpath:
+            return (force, '"' + toolpath + '"')
+        else:
+            # mimic HGMERGE if given tool not found
+            return (force, force)
+
+    # HGMERGE takes next precedence
     hgmerge = os.environ.get("HGMERGE")
     if hgmerge:
         return (hgmerge, hgmerge)
--- a/tests/test-merge-symlinks.t	Wed Oct 20 15:09:38 2010 -0500
+++ b/tests/test-merge-symlinks.t	Wed Oct 20 15:36:42 2010 -0500
@@ -37,7 +37,7 @@
 Merge them and display *_ISLINK vars
 merge heads
 
-  $ HGMERGE="python ../echo.py" hg merge
+  $ hg merge --tool="python ../echo.py"
   HG_FILE l
   HG_MY_ISLINK 1
   HG_OTHER_ISLINK 0
--- a/tests/test-merge-tools.t	Wed Oct 20 15:09:38 2010 -0500
+++ b/tests/test-merge-tools.t	Wed Oct 20 15:36:42 2010 -0500
@@ -506,6 +506,49 @@
   $ echo
   
 
+ui.merge specifies internal:other but is overruled by --tool=false
+
+  $ domerge -r 2 --config ui.merge=internal:other --tool=false
+  [merge-tools]
+  false.whatever=
+  true.priority=1
+  true.executable=cat
+  # hg update -C 1
+  # hg merge -r 2 --config ui.merge=internal:other --tool=false
+  merging f
+  merging f failed!
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  # cat f
+  revision 1
+  space
+  # hg stat
+  M f
+  ? f.orig
+  
+HGMERGE specifies internal:other but is overruled by --tool=false
+
+  $ HGMERGE=internal:other ; export HGMERGE
+  $ domerge -r 2 --tool=false
+  [merge-tools]
+  false.whatever=
+  true.priority=1
+  true.executable=cat
+  # hg update -C 1
+  # hg merge -r 2 --tool=false
+  merging f
+  merging f failed!
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  # cat f
+  revision 1
+  space
+  # hg stat
+  M f
+  ? f.orig
+  
+  $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests
+
 Default is silent simplemerge:
 
   $ domerge -r 3
--- a/tests/test-rename-merge2.t	Wed Oct 20 15:09:38 2010 -0500
+++ b/tests/test-rename-merge2.t	Wed Oct 20 15:36:42 2010 -0500
@@ -7,7 +7,6 @@
   > f.write("merge %s %s %s" % (sys.argv[1], sys.argv[2], sys.argv[3]))
   > f.close()
   > EOF
-  $ HGMERGE="python ../merge"; export HGMERGE
 
 perform a test merge with possible renaming
 args:
@@ -49,7 +48,7 @@
   >     echo "--------------"
   >     echo "test L:$1 R:$2 W:$3 - $4"
   >     echo "--------------"
-  >     hg merge -y --debug --traceback
+  >     hg merge -y --debug --traceback --tool="python ../merge"
   > 
   >     echo "--------------"
   >     hg status -camC -X rev
--- a/tests/test-resolve.t	Wed Oct 20 15:09:38 2010 -0500
+++ b/tests/test-resolve.t	Wed Oct 20 15:36:42 2010 -0500
@@ -21,7 +21,7 @@
 
 failing merge
 
-  $ HGMERGE=internal:fail hg merge
+  $ hg merge --tool=internal:fail
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]