Patchwork [10,of,17] rebase: avoid redundant repo[rev].rev() - just keep working in rev space

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 30, 2014, 7:08 p.m.
Message ID <478b02a4bca67c04dac9.1417374517@localhost.localdomain>
Download mbox | patch
Permalink /patch/6914/
State Superseded
Commit ffef6d503ab2b6c732ae6c786066b6ac9f6e858d
Headers show

Comments

Mads Kiilerich - Nov. 30, 2014, 7:08 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1417374421 -3600
#      Sun Nov 30 20:07:01 2014 +0100
# Node ID 478b02a4bca67c04dac9254cd5784280773dfaec
# Parent  8767105e12d87ea8e37803d6c7b792be66771e6d
rebase: avoid redundant repo[rev].rev() - just keep working in rev space
Pierre-Yves David - Dec. 1, 2014, 7:29 a.m.
On 11/30/2014 11:08 AM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1417374421 -3600
> #      Sun Nov 30 20:07:01 2014 +0100
> # Node ID 478b02a4bca67c04dac9254cd5784280773dfaec
> # Parent  8767105e12d87ea8e37803d6c7b792be66771e6d
> rebase: avoid redundant repo[rev].rev() - just keep working in rev space

Patch 9 and 10 sound yumi but does not apply without the previous ones.

I've not looked past the first 10 patches.
Mads Kiilerich - Dec. 1, 2014, 1:29 p.m.
On 12/01/2014 08:29 AM, Pierre-Yves David wrote:
> On 11/30/2014 11:08 AM, Mads Kiilerich wrote:
>> # HG changeset patch
>> # User Mads Kiilerich <madski@unity3d.com>
>> # Date 1417374421 -3600
>> #      Sun Nov 30 20:07:01 2014 +0100
>> # Node ID 478b02a4bca67c04dac9254cd5784280773dfaec
>> # Parent  8767105e12d87ea8e37803d6c7b792be66771e6d
>> rebase: avoid redundant repo[rev].rev() - just keep working in rev space
>
> Patch 9 and 10 sound yumi but does not apply without the previous ones.
>
> I've not looked past the first 10 patches.

Well ... you asked for them in the context of 
http://bz.selenic.com/show_bug.cgi?id=4076 .

/Mads

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -398,7 +398,7 @@  def rebase(ui, repo, **opts):
                     finally:
                         ui.setconfig('ui', 'forcemerge', '', 'rebase')
                 if not collapsef:
-                    merging = repo[p2].rev() != nullrev
+                    merging = p2 != nullrev
                     editform = cmdutil.mergeeditform(merging, 'rebase')
                     editor = cmdutil.getcommiteditor(editform=editform, **opts)
                     newnode = concludenode(repo, rev, p1, p2, extrafn=extrafn,
@@ -560,20 +560,20 @@  def rebasenode(repo, rev, p1, state, col
     'Rebase a single revision'
     # Merge phase
     # Update to target and merge it with local
-    if repo['.'].rev() != repo[p1].rev():
-        repo.ui.debug(" update to %d:%s\n" % (repo[p1].rev(), repo[p1]))
+    if repo['.'].rev() != p1:
+        repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1]))
         merge.update(repo, p1, False, True, False)
     else:
         repo.ui.debug(" already in target\n")
     repo.dirstate.write()
-    repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
-    if repo[rev].rev() == repo[min(state)].rev():
+    repo.ui.debug(" merge against %d:%s\n" % (rev, repo[rev]))
+    if rev == min(state):
         # Case (1) initial changeset of a non-detaching rebase.
         # Let the merge mechanism find the base itself.
         base = None
     elif not repo[rev].p2():
         # Case (2) detaching the node with a single parent, use this parent
-        base = repo[rev].p1().node()
+        base = repo[rev].p1().rev()
     else:
         # In case of merge, we need to pick the right parent as merge base.
         #
@@ -600,8 +600,8 @@  def rebasenode(repo, rev, p1, state, col
         # Which does not represent anything sensible and creates a lot of
         # conflicts.
         for p in repo[rev].parents():
-            if state.get(p.rev()) == repo[p1].rev():
-                base = p.node()
+            if state.get(p.rev()) == p1:
+                base = p.rev()
                 break
         else: # fallback when base not found
             base = None
@@ -610,7 +610,7 @@  def rebasenode(repo, rev, p1, state, col
             raise AssertionError('no base found to rebase on '
                                  '(rebasenode called wrong)')
     if base is not None:
-        repo.ui.debug("   detach base %d:%s\n" % (repo[base].rev(), repo[base]))
+        repo.ui.debug("   detach base %d:%s\n" % (base, repo[base]))
     # When collapsing in-place, the parent is the common ancestor, we
     # have to allow merging with it.
     stats = merge.update(repo, rev, True, True, False, base, collapse,
@@ -853,7 +853,7 @@  def abort(repo, originalwd, target, stat
     if cleanup:
         # Update away from the rebase if necessary
         if inrebase(repo, originalwd, state):
-            merge.update(repo, repo[originalwd].rev(), False, True, False)
+            merge.update(repo, originalwd, False, True, False)
 
         # Strip from the first rebased revision
         rebased = filter(lambda x: x > nullrev and x != target, state.values())