[Reviewers] [Differential] [Request, 32 lines] D24: rebase: remove revprecursor and revpruned states (BC)

quark (Jun Wu) phabricator-noreply at mercurial-scm.org
Mon Jul 10 19:15:27 UTC 2017


quark created this revision.
Herald added a subscriber: reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D24

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

Index: tests/test-rebase-obsolete.t
===================================================================
--- tests/test-rebase-obsolete.t
+++ tests/test-rebase-obsolete.t
@@ -969,10 +969,10 @@
   2:1e9a3c00cbe9 b (no-eol)
   $ hg rebase -r 2 -d 3 --config experimental.evolution.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
Index: hgext/rebase.py
===================================================================
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -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]]))
@@ -494,9 +488,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()]:
@@ -1326,14 +1318,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
 


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: quark
Cc: reviewers


More information about the Reviewers mailing list