Patchwork D7727: rebase: make sure pruning does not confuse rebase (issue6180)

login
register
mail settings
Submitter phabricator
Date Dec. 27, 2019, 4:56 p.m.
Message ID <differential-rev-PHID-DREV-djgq5p6owc4n3akztbni-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44049/
State Superseded
Headers show

Comments

phabricator - Dec. 27, 2019, 4:56 p.m.
khanchi97 created this revision.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before this patch, if a user is rebasing a stack of commits and
  hit a conflict in between and decided to drop that commit (the commit
  which is being rebased but hit conflict) and pruned it, now what
  `hg rebase --continue` does is: skip that dropped commit and move
  on to rebase the next commit and gets confused here because wdir
  has two parents which is because while we skipped that dropped
  commit wdir had two parents and we didn't update that to one parent.
  
  Changes in test file demonstrate the fixed behavior.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: khanchi97, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 27, 2019, 5:04 p.m.
khanchi97 added a comment.
khanchi97 abandoned this revision.


  abandoing because I phabsent them in reverse order and it got messed up saying 'Graph cycle detected'

REPOSITORY
  rHG Mercurial

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

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

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

Patch

diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -478,14 +478,13 @@ 
   $ hg resolve -m
   (no more unresolved files)
   continue: hg rebase --continue
-XXX: it should have rebased revision 3 since it made changes unrelated to
-destination, so no reason to say "its destination already has all its changes"
   $ hg rebase -c
   note: not rebasing 2:06a50ac6b5ab "conflict in a", it has no successor
   rebasing 3:aea370672fd7 "add b" (tip)
-  note: not rebasing 3:aea370672fd7 "add b" (tip), its destination already has all its changes
   $ hg tglog
-  @  1:draft 'edit a'
+  @  4:draft 'add b'
+  |
+  o  1:draft 'edit a'
   |
   o  0:draft 'add a'
   
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -594,6 +594,10 @@ 
                 adjustdest(repo, rev, self.destmap, self.state, self.skipped)
             )
             self.state[rev] = dest
+            # since we are done, make sure wdir has one parent (issue6180)
+            if len(repo[None].parents()) == 2:
+                p1 = repo[None].p1().node()
+                repo.setparents(p1)
         elif self.state[rev] == revtodo:
             ui.status(_(b'rebasing %s\n') % desc)
             progressfn(ctx)