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

login
register
mail settings
Submitter Sean Farley
Date Jan. 17, 2014, 8:14 p.m.
Message ID <ff1a93158e097797c485.1389989669@laptop.local>
Download mbox | patch
Permalink /patch/3376/
State Accepted
Commit 5b4f963d21ccb04ca3779adf20501031166c46aa
Headers show

Comments

Sean Farley - Jan. 17, 2014, 8:14 p.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 ff1a93158e097797c485bba97ba2eae9e4763be4
# Parent  1fea5d10467ba9af2e1083a43df290749fdf5bcf
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