changeset 5239:8860f29447c1

imerge: fix ancestor calculation If wctx already has two parents, ancestor calculation is wrong. Normally merge is called before wctx gets the second parent, so we simulate this in imerge by temporarily popping the second parent before calling filemerge. Highly dirty. This patch also handles the ParseError move from cmdutil to dispatch.
author Brendan Cully <brendan@kublai.com>
date Thu, 23 Aug 2007 19:51:59 -0700
parents 988ed47d9d65
children 85ba6ab5bd3a
files hgext/imerge.py
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/imerge.py	Thu Aug 23 13:59:52 2007 -0700
+++ b/hgext/imerge.py	Thu Aug 23 19:51:59 2007 -0700
@@ -7,7 +7,7 @@
 
 from mercurial.i18n import _
 from mercurial.node import *
-from mercurial import commands, cmdutil, fancyopts, hg, merge, util
+from mercurial import commands, cmdutil, dispatch, fancyopts, hg, merge, util
 import os, tarfile
 
 class InvalidStateFileException(Exception): pass
@@ -113,8 +113,15 @@
         wlock = self.repo.wlock()
 
         (fd, fo) = self.conflicts[fn]
-        p2 = self.wctx.parents()[1]
-        return merge.filemerge(self.repo, fn, fd, fo, self.wctx, p2)
+        p1, p2 = self.wctx.parents()
+        # The filemerge ancestor algorithm does not work if self.wctx
+        # already has two parents (in normal merge it doesn't yet). But
+        # this is very dirty.
+        self.wctx._parents.pop()
+        try:
+            return merge.filemerge(self.repo, fn, fd, fo, self.wctx, p2)
+        finally:
+            self.wctx._parents.append(p2)
 
     def start(self, rev=None):
         _filemerge = merge.filemerge
@@ -269,7 +276,7 @@
     'unresolve': (unresolve, [])
 }
 
-def dispatch(im, args, opts):
+def dispatch_(im, args, opts):
     def complete(s, choices):
         candidates = []
         for choice in choices:
@@ -292,9 +299,9 @@
         args = fancyopts.fancyopts(args, optlist, opts)
         return func(im, *args, **opts)
     except fancyopts.getopt.GetoptError, inst:
-        raise cmdutil.ParseError('imerge', '%s: %s' % (cmd, inst))
+        raise dispatch.ParseError('imerge', '%s: %s' % (cmd, inst))
     except TypeError:
-        raise cmdutil.ParseError('imerge', _('%s: invalid arguments') % cmd)
+        raise dispatch.ParseError('imerge', _('%s: invalid arguments') % cmd)
 
 def imerge(ui, repo, *args, **opts):
     '''interactive merge
@@ -317,6 +324,10 @@
 
     status:
       show the current state of the merge
+      options:
+        -n --no-status:  do not print the status prefix
+           --resolved:   only print resolved conflicts
+           --unresolved: only print unresolved conflicts
     next:
       show the next unresolved file merge
     merge [<file>]:
@@ -353,7 +364,7 @@
     if not args:
         args = ['merge']
 
-    return dispatch(im, args, opts)
+    return dispatch_(im, args, opts)
 
 cmdtable = {
     '^imerge':