[PATCH 2 of 5] merge: refactor initialization of variables in update

Sean Farley sean.michael.farley at gmail.com
Wed Nov 27 15:59:27 CST 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1383778927 21600
#      Wed Nov 06 17:02:07 2013 -0600
# Node ID 38f0fd90e66237b2b3395605e3ef23516ecebae7
# Parent  c660a47b8fdb184ad2933a852485af815a014dfe
merge: refactor initialization of variables in update

There is no code change here but this helps prepare for future commits that
will fix a bare update with obsolete markers.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -676,11 +676,18 @@
     """
 
     onode = node
     wlock = repo.wlock()
     try:
+        foreground = None
         wc = repo[None]
+        pl = wc.parents()
+        p1 = pl[0]
+        pa = None
+        if ancestor:
+            pa = repo[ancestor]
+
         if node is None:
             # Here is where we should consider bookmarks, divergent bookmarks,
             # foreground changesets (successors), and tip of current branch;
             # but currently we are only checking the branch tips.
             try:
@@ -689,15 +696,13 @@
                 if wc.branch() == "default": # no default branch!
                     node = repo.lookup("tip") # update to tip
                 else:
                     raise util.Abort(_("branch %s not found") % wc.branch())
         overwrite = force and not branchmerge
-        pl = wc.parents()
-        p1, p2 = pl[0], repo[node]
-        if ancestor:
-            pa = repo[ancestor]
-        else:
+
+        p2 = repo[node]
+        if pa is None:
             pa = p1.ancestor(p2)
 
         fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
 
         ### check phase


More information about the Mercurial-devel mailing list