Patchwork [1,of,3,V2] rebase: use '>= 0' to know is a revision was rebased

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 4, 2014, 3:29 p.m.
Message ID <29392f55598d979e9aa3.1417706995@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7003/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 4, 2014, 3:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1417705382 28800
#      Thu Dec 04 07:03:02 2014 -0800
# Node ID 29392f55598d979e9aa32c1aba7ea8e8cab8ac76
# Parent  fc76f55705eb5884707c977ecb756aee7c794676
rebase: use '>= 0' to know is a revision was rebased

The fact that the state for "not yet rebased" is -1 is an implementation
details. So we change the comparisons to some semantically more correct.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -808,11 +808,11 @@  def inrebase(repo, originalwd, state):
 
     return False
 
 def abort(repo, originalwd, target, state):
     'Restore the repository to its original state'
-    dstates = [s for s in state.values() if s > nullrev]
+    dstates = [s for s in state.values() if s >= 0]
     immutable = [d for d in dstates if not repo[d].mutable()]
     cleanup = True
     if immutable:
         repo.ui.warn(_("warning: can't clean up immutable changesets %s\n")
                      % ', '.join(str(repo[r]) for r in immutable),
@@ -831,11 +831,11 @@  def abort(repo, originalwd, target, stat
         # Update away from the rebase if necessary
         if inrebase(repo, originalwd, state):
             merge.update(repo, repo[originalwd].rev(), False, True, False)
 
         # Strip from the first rebased revision
-        rebased = filter(lambda x: x > -1 and x != target, state.values())
+        rebased = filter(lambda x: x >= 0 and x != target, state.values())
         if rebased:
             strippoints = [c.node()  for c in repo.set('roots(%ld)', rebased)]
             # no backup of rebased cset versions needed
             repair.strip(repo.ui, repo, strippoints)
 
@@ -1010,11 +1010,11 @@  def summaryhook(ui, repo):
     except error.RepoLookupError:
         # i18n: column positioning for "hg summary"
         msg = _('rebase: (use "hg rebase --abort" to clear broken state)\n')
         ui.write(msg)
         return
-    numrebased = len([i for i in state.itervalues() if i != -1])
+    numrebased = len([i for i in state.itervalues() if i >= 0])
     # i18n: column positioning for "hg summary"
     ui.write(_('rebase: %s, %s (rebase --continue)\n') %
              (ui.label(_('%d rebased'), 'rebase.rebased') % numrebased,
               ui.label(_('%d remaining'), 'rebase.remaining') %
               (len(state) - numrebased)))