Patchwork [3,of,3] rebase: use 'revdone' fake revision for already rebased nodes

login
register
mail settings
Submitter via Mercurial-devel
Date May 4, 2017, 8:20 p.m.
Message ID <461bddf60a770513d89d.1493929212@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20434/
State Accepted
Headers show

Comments

via Mercurial-devel - May 4, 2017, 8:20 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1493928262 25200
#      Thu May 04 13:04:22 2017 -0700
# Node ID 461bddf60a770513d89d225785d53f8b84e856b9
# Parent  2765672140ea50f5587be486b25af10509a3d35b
rebase: use 'revdone' fake revision for already rebased nodes

This is just an alternative implementation of the previous patch. Let
me know if you prefer this and I'll resend.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -65,6 +65,8 @@ 
 revprecursor = -4
 # plain prune (no successor)
 revpruned = -5
+# does not need to be rebased because it's already on top of destination
+revdone = -6
 revskipped = (revignored, revprecursor, revpruned)
 
 cmdtable = {}
@@ -384,7 +386,7 @@ 
             names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
             if names:
                 desc += ' (%s)' % ' '.join(names)
-            if self.state[rev] == rev:
+            if self.state[rev] == revdone:
                 ui.status(_('already rebased %s\n') % desc)
             elif self.state[rev] == revtodo:
                 pos += 1
@@ -973,6 +975,8 @@ 
     elif p1n in state:
         if state[p1n] == nullmerge:
             p1 = target
+        elif state[p1n] == revdone:
+            p1 = p1n
         elif state[p1n] in revskipped:
             p1 = nearestrebased(repo, p1n, state)
             if p1 is None:
@@ -996,6 +1000,8 @@ 
                 if p2 is None:
                     # no ancestors rebased yet, detach
                     p2 = target
+            elif state[p2n] == revdone:
+                p2 = p2n
             else:
                 p2 = state[p2n]
         else: # p2n external
@@ -1263,9 +1269,7 @@ 
             else:
                 samebranch = root.branch() == dest.branch()
             if not collapse and samebranch and root in dest.children():
-                # mark the revision as done by setting its new revision
-                # equal to its old (current) revisions
-                state[root.rev()] = root.rev()
+                state[root.rev()] = revdone
                 repo.ui.debug('source is a child of destination\n')
                 continue
 
@@ -1317,8 +1321,8 @@ 
     for rev in sorted(state):
         parents = [p for p in repo.changelog.parentrevs(rev) if p != nullrev]
         # if all parents of this revision are done, then so is this revision
-        if parents and all((state.get(p) == p for p in parents)):
-            state[rev] = rev
+        if parents and all((state.get(p) == revdone for p in parents)):
+            state[rev] = revdone
     for r in detachset:
         if r not in state:
             state[r] = nullmerge
@@ -1346,7 +1350,7 @@ 
     if obsolete.isenabled(repo, obsolete.createmarkersopt):
         markers = []
         for rev, newrev in sorted(state.items()):
-            if newrev >= 0 and newrev != rev:
+            if newrev >= 0 and newrev != revdone:
                 if rev in skipped:
                     succs = ()
                 elif collapsedas is not None:
@@ -1358,7 +1362,7 @@ 
             obsolete.createmarkers(repo, markers)
     else:
         rebased = [rev for rev in state
-                   if state[rev] > nullmerge and state[rev] != rev]
+                   if state[rev] > nullmerge and state[rev] != revdone]
         if rebased:
             stripped = []
             for root in repo.set('roots(%ld)', rebased):