changeset 4264:bda63383d529

Make import opportunistically use merge information
author Brendan Cully <brendan@kublai.com>
date Wed, 21 Mar 2007 14:06:25 -0700
parents 47ba52121433
children 94bb953b43e5 29eb88bd5c8d
files mercurial/commands.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Mar 22 10:44:59 2007 -0700
+++ b/mercurial/commands.py	Wed Mar 21 14:06:25 2007 -0700
@@ -1526,18 +1526,26 @@
                 message = None
             ui.debug(_('message:\n%s\n') % message)
 
-            files = {}
+            wp = repo.workingctx().parents()
             if opts.get('exact'):
                 if not nodeid or not p1:
                     raise util.Abort(_('not a mercurial patch'))
                 p1 = repo.lookup(p1)
                 p2 = repo.lookup(p2 or hex(nullid))
 
-                wctx = repo.workingctx()
-                wp = repo.workingctx().parents()
                 if p1 != wp[0].node():
                     hg.clean(repo, p1, wlock=wlock)
                 repo.dirstate.setparents(p1, p2)
+            elif p2:
+                try:
+                    p1 = repo.lookup(p1)
+                    p2 = repo.lookup(p2)
+                    if p1 == wp[0].node():
+                        repo.dirstate.setparents(p1, p2)
+                except RepoError:
+                    pass
+
+            files = {}
             try:
                 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
                                    files=files)