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

Sean Farley sean.michael.farley at gmail.com
Sun Jan 12 16:25:50 CST 2014


# 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 1908bcdb50a7b4be9eca3e90274365355783efe7
# Parent  da355d69f9830a83f2f8a5efa869a16019c389e4
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 @@ def update(repo, node, branchmerge, forc
     """
 
     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 @@ def update(repo, node, branchmerge, forc
                 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