Patchwork [3,of,6,V3] merge: refactor initialization of variables in update

login
register
mail settings
Submitter Sean Farley
Date Jan. 16, 2014, 12:34 a.m.
Message ID <c545df40daa10ff9200c.1389832458@laptop.local>
Download mbox | patch
Permalink /patch/3333/
State Superseded
Commit 5b4f963d21ccb04ca3779adf20501031166c46aa
Headers show

Comments

Sean Farley - Jan. 16, 2014, 12:34 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1383778927 21600
#      Wed Nov 06 17:02:07 2013 -0600
# Node ID c545df40daa10ff9200c81ba566db6329175280b
# Parent  32cd4060a08668fcde726193990bc59c4cc0356a
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.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -677,10 +677,16 @@  def update(repo, node, branchmerge, forc
 
     onode = node
     wlock = repo.wlock()
     try:
         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 +695,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