changeset 33843:d8d0ef5f5975

rebase: remove revprecursor and revpruned states (BC) Those states are no longer necessary for rebase to function properly. Remove them to make the code cleaner. Marked as BC because in a corner case where working parent is obsoleted, and is skipped for rebase, we no longer move working parent after rebase completes. That is better since if working parent is obsoleted, it should be the user moving working parent back there (after a rebase) explicitly, in that case, we shouldn't move working parent again. Differential Revision: https://phab.mercurial-scm.org/D24
author Jun Wu <quark@fb.com>
date Sat, 08 Jul 2017 20:38:34 -0700
parents 30573b3d2ebc
children 437e317d7913
files hgext/rebase.py tests/test-rebase-obsolete.t
diffstat 2 files changed, 12 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Sat Jul 08 20:14:33 2017 -0700
+++ b/hgext/rebase.py	Sat Jul 08 20:38:34 2017 -0700
@@ -62,10 +62,10 @@
 revtodo = -1
 nullmerge = -2
 revignored = -3
-# successor in rebase destination
-revprecursor = -4
-# plain prune (no successor)
-revpruned = -5
+
+# legacy revstates no longer needed in current code
+# -4: revprecursor, -5: revpruned
+legacystates = {'-4', '-5'}
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -231,8 +231,9 @@
                     activebookmark = l
                 else:
                     oldrev, newrev = l.split(':')
-                    if newrev in (str(nullmerge), str(revignored),
-                                  str(revprecursor), str(revpruned)):
+                    if newrev in legacystates:
+                        continue
+                    if newrev in (str(nullmerge), str(revignored)):
                         state[repo[oldrev].rev()] = int(newrev)
                     elif newrev == nullid:
                         state[repo[oldrev].rev()] = revtodo
@@ -308,9 +309,6 @@
             return abort(self.repo, self.originalwd, self.dest,
                          self.state, activebookmark=self.activebookmark)
 
-        obsrevs = (r for r, st in self.state.items() if st == revprecursor)
-        self._handleskippingobsolete(self.state.keys(), obsrevs, self.dest)
-
     def _preparenewrebase(self, dest, rebaseset):
         if dest is None:
             return _nothingtorebase()
@@ -445,10 +443,6 @@
                 ui.debug('ignoring null merge rebase of %s\n' % rev)
             elif self.state[rev] == revignored:
                 ui.status(_('not rebasing ignored %s\n') % desc)
-            elif self.state[rev] == revprecursor:
-                pass
-            elif self.state[rev] == revpruned:
-                pass
             else:
                 ui.status(_('already rebased %s as %s\n') %
                           (desc, repo[self.state[rev]]))
@@ -499,9 +493,7 @@
         # restore original working directory
         # (we do this before stripping)
         newwd = self.state.get(self.originalwd, self.originalwd)
-        if newwd == revprecursor:
-            newwd = self.obsoletenotrebased[self.originalwd]
-        elif newwd < 0:
+        if newwd < 0:
             # original directory is a parent of rebase set root or ignored
             newwd = self.originalwd
         if newwd not in [c.rev() for c in repo[None].parents()]:
@@ -1414,14 +1406,14 @@
         succ = obsoletenotrebased[r]
         if succ is None:
             msg = _('note: not rebasing %s, it has no successor\n') % desc
-            state[r] = revpruned
+            del state[r]
         else:
             destctx = unfi[succ]
             destdesc = '%d:%s "%s"' % (destctx.rev(), destctx,
                                        destctx.description().split('\n', 1)[0])
             msg = (_('note: not rebasing %s, already in destination as %s\n')
                    % (desc, destdesc))
-            state[r] = revprecursor
+            del state[r]
         repo.ui.status(msg)
     return originalwd, dest.rev(), state
 
--- a/tests/test-rebase-obsolete.t	Sat Jul 08 20:14:33 2017 -0700
+++ b/tests/test-rebase-obsolete.t	Sat Jul 08 20:38:34 2017 -0700
@@ -1152,10 +1152,10 @@
   2:1e9a3c00cbe9 b (no-eol)
   $ hg rebase -r 2 -d 3 --config experimental.stabilization.track-operation=1
   note: not rebasing 2:1e9a3c00cbe9 "b" (mybook), already in destination as 3:be1832deae9a "b"
-Check that working directory was updated to rev 3 although rev 2 was skipped
+Check that working directory was not updated to rev 3 because rev 2 was skipped
 during the rebase operation
   $ hg log -r .
-  3:be1832deae9a b (no-eol)
+  2:1e9a3c00cbe9 b (no-eol)
 
 Check that bookmark was not moved to rev 3 if rev 2 was skipped during the
 rebase operation. This makes sense because if rev 2 has a successor, the