D2878: rebase: avoid defining two lists with the same contents

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Mar 16 05:36:50 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In abort(), there's "dstates" and "rebased" that are identical, which
  they seem to have been since https://phab.mercurial-scm.org/rHG0806823370d8baf6788bf771880a61193dcc6caf (rebase: properly calculate
  descendant set when aborting (issue3332), 2012-03-22). Let's
  de-duplicate. I don't know what "dstates" means, but "rebased" makes
  sense (it's the list of rebased revisions), so let's pick that.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1543,28 +1543,26 @@
     try:
         # If the first commits in the rebased set get skipped during the rebase,
         # their values within the state mapping will be the dest rev id. The
-        # dstates list must must not contain the dest rev (issue4896)
-        dstates = [s for r, s in state.items() if s >= 0 and s != destmap[r]]
-        immutable = [d for d in dstates if not repo[d].mutable()]
+        # rebased list must must not contain the dest rev (issue4896)
+        rebased = [s for r, s in state.items() if s >= 0 and s != destmap[r]]
+        immutable = [d for d in rebased if not repo[d].mutable()]
         cleanup = True
         if immutable:
             repo.ui.warn(_("warning: can't clean up public changesets %s\n")
                         % ', '.join(str(repo[r]) for r in immutable),
                         hint=_("see 'hg help phases' for details"))
             cleanup = False
 
         descendants = set()
-        if dstates:
-            descendants = set(repo.changelog.descendants(dstates))
-        if descendants - set(dstates):
+        if rebased:
+            descendants = set(repo.changelog.descendants(rebased))
+        if descendants - set(rebased):
             repo.ui.warn(_("warning: new changesets detected on destination "
                            "branch, can't strip\n"))
             cleanup = False
 
         if cleanup:
             shouldupdate = False
-            rebased = [s for r, s in state.items()
-                       if s >= 0 and s != destmap[r]]
             if rebased:
                 strippoints = [
                         c.node() for c in repo.set('roots(%ld)', rebased)]



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list