[PATCH 1 of 2] rebase: remove sortedstate-related confusion

Kostia Balytskyi ikostia at fb.com
Thu Jul 14 06:21:07 EDT 2016


# HG changeset patch
# User Kostia Balytskyi <ikostia at fb.com>
# Date 1468491129 25200
#      Thu Jul 14 03:12:09 2016 -0700
# Node ID e4bd35636e3ff107e6e1847806d6243c30393b4b
# Parent  2beb390fcc108e887567d2f37ee69908d61f5ec2
rebase: remove sortedstate-related confusion

The following rebase implementation details are frustrating:
- storing a list of sorted revision numbers in a field named sortedstate
- having sortedstate be a field of the rebaseruntime class
- using sortedstate[-1] as opposed to a more intuitive max(self.state) to
  compute the latest revision in the state

This commit fixes those imperfections.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -335,10 +335,10 @@ class rebaseruntime(object):
         if self.activebookmark:
             bookmarks.deactivate(repo)
 
-        self.sortedstate = sorted(self.state)
-        total = len(self.sortedstate)
+        sortedrevs = sorted(self.state)
+        total = len(self.state)
         pos = 0
-        for rev in self.sortedstate:
+        for rev in sortedrevs:
             ctx = repo[rev]
             desc = '%d:%s "%s"' % (ctx.rev(), ctx,
                                    ctx.description().split('\n', 1)[0])
@@ -438,7 +438,7 @@ class rebaseruntime(object):
                         commitmsg += '\n* %s' % repo[rebased].description()
                 editopt = True
             editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
-            revtoreuse = self.sortedstate[-1]
+            revtoreuse = max(self.state)
             newnode = concludenode(repo, revtoreuse, p1, self.external,
                                    commitmsg=commitmsg,
                                    extrafn=_makeextrafn(self.extrafns),


More information about the Mercurial-devel mailing list