Patchwork D7664: rebase: make rebase not crash if p1 == p2 != nullid

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2019, 11:58 p.m.
Message ID <differential-rev-PHID-DREV-mbrheralytpxlkv555z7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43831/
State Superseded
Headers show

Comments

phabricator - Dec. 13, 2019, 11:58 p.m.
spectral created this revision.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While this shouldn't happen normally, some historical bugs can have caused this
  kind of commit to exist. Instead of crashing and having it be unobvious how to
  recover, let's try to continue on. Without this, we get an error like
  "ValueError: min() arg is an empty sequence"

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: spectral, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 14, 2019, 12:03 a.m.
This revision is now accepted and ready to land.
martinvonz added a comment.
martinvonz accepted this revision.


  I think "historical" here means "before D7549 <https://phab.mercurial-scm.org/D7549>.

REPOSITORY
  rHG Mercurial

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7664/new/

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

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

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1791,7 +1791,7 @@ 
     # But our merge base candidates (D and E in above case) could still be
     # better than the default (ancestor(F, Z) == null). Therefore still
     # pick one (so choose p1 above).
-    if sum(1 for b in bases if b != nullrev) > 1:
+    if sum(1 for b in set(bases) if b != nullrev) > 1:
         unwanted = [None, None]  # unwanted[i]: unwanted revs if choose bases[i]
         for i, base in enumerate(bases):
             if base == nullrev: