Patchwork [3,of,5] merge: include obsolete calculation for branchtips

login
register
mail settings
Submitter Sean Farley
Date Nov. 27, 2013, 9:59 p.m.
Message ID <0043392ae4bbb546a9c0.1385593168@laptop.local>
Download mbox | patch
Permalink /patch/3182/
State Superseded
Headers show

Comments

Sean Farley - Nov. 27, 2013, 9:59 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1383779296 21600
#      Wed Nov 06 17:08:16 2013 -0600
# Node ID 0043392ae4bbb546a9c0a14ca35d76c0f299e2f1
# Parent  38f0fd90e66237b2b3395605e3ef23516ecebae7
merge: include obsolete calculation for branchtips

This logic was initially done by Pierre-Yves David in a59e575c6ff8 but
branchtips, which are calculated at the beginning of the function, were not
included. This patch moves that logic forward and preserves the no-op update
clause added by Siddharth Agarwal in ab2362e1672e.

Tests will be updated in the next patch because it requires a non-obvious fix
to the test case.
Pierre-Yves David - Dec. 21, 2013, 1:27 a.m.
On 11/27/2013 01:59 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1383779296 21600
> #      Wed Nov 06 17:08:16 2013 -0600
> # Node ID 0043392ae4bbb546a9c0a14ca35d76c0f299e2f1
> # Parent  38f0fd90e66237b2b3395605e3ef23516ecebae7
> merge: include obsolete calculation for branchtips
>
> This logic was initially done by Pierre-Yves David in a59e575c6ff8 but
> branchtips, which are calculated at the beginning of the function, were not
> included. This patch moves that logic forward and preserves the no-op update
> clause added by Siddharth Agarwal in ab2362e1672e.
>
> Tests will be updated in the next patch because it requires a non-obvious fix
> to the test case.

This series does complicated stuff in complicated code. you need much 
more detailed description.

- What behavior are you trying to achieve
- What was the prior behavior

- How does the code achieve this
- What kind of change you are doing in the code.

The probability of breakage or performance regression are high. We need 
to people to be able to undestand what is going on.
This series is supposed to be the result of a discussion between you and 
I, and -I-'m not sure what it is doing exactly…

I'll keep looking at the actual code while you are reworking your 
description.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -695,10 +695,26 @@ 
             except error.RepoLookupError:
                 if wc.branch() == "default": # no default branch!
                     node = repo.lookup("tip") # update to tip
                 else:
                     raise util.Abort(_("branch %s not found") % wc.branch())
+
+            # We only check for foreground (successor) changesets if the node
+            # found by the above logic is obsolete
+            if repo[node].obsolete():
+                # Branching is a bit strange to ensure we do the minimal
+                # amount of call to obsolete.background.
+                foreground = obsolete.foreground(repo, [p1.node()])
+                # note: the <node> variable contains a random identifier
+
+                # allow updating to successors
+                if repo[node].node() in foreground:
+                    # get the max revision for the given foreground set
+                    unfil = [repo.unfiltered()[n].rev() for n in foreground]
+                    node = repo[max(unfil)].node()
+                    pa = p1
+
         overwrite = force and not branchmerge
 
         p2 = repo[node]
         if pa is None:
             pa = p1.ancestor(p2)
@@ -724,23 +740,23 @@ 
                 if wc.sub(s).dirty():
                     raise util.Abort(_("uncommitted changes in "
                                        "subrepository '%s'") % s)
 
         elif not overwrite:
-            if p1 == p2: # no-op update
+            # no-op update
+            if (p1 == p2 and
+                not (foreground and foreground != set([p1.node()]))):
                 # call the hooks and exit early
                 repo.hook('preupdate', throw=True, parent1=xp2, parent2='')
                 repo.hook('update', parent1=xp2, parent2='', error=0)
                 return 0, 0, 0, 0
 
             if pa not in (p1, p2):  # nonlinear
                 dirty = wc.dirty(missing=True)
                 if dirty or onode is None:
-                    # Branching is a bit strange to ensure we do the minimal
-                    # amount of call to obsolete.background.
-                    foreground = obsolete.foreground(repo, [p1.node()])
-                    # note: the <node> variable contains a random identifier
+                    if foreground is None:
+                        foreground = obsolete.foreground(repo, [p1.node()])
                     if repo[node].node() in foreground:
                         pa = p1  # allow updating to successors
                     elif dirty:
                         msg = _("uncommitted changes")
                         if onode is None: