Patchwork rebase: make sure merge state is cleaned up for no-op rebases

login
register
mail settings
Submitter Jeremy Fitzhardinge
Date May 16, 2017, 6:34 p.m.
Message ID <bc016ab47131203f8f4f.1494959669@jsgf-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/20643/
State Superseded
Headers show

Comments

Jeremy Fitzhardinge - May 16, 2017, 6:34 p.m.
# HG changeset patch
# User Jeremy Fitzhardinge <jsgf@fb.com>
# Date 1494892737 25200
#      Mon May 15 16:58:57 2017 -0700
# Node ID bc016ab47131203f8f4f332e4f16fdf7899bbc80
# Parent  cb26d4cdd0f71423edde7451daf49f6f30bb385b
rebase: make sure merge state is cleaned up for no-op rebases

If a rebase ends up doing a no-op commit, make sure the merge state is still cleaned up.

Fix for bug 5494.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -418,6 +418,11 @@ 
                                            editor=editor,
                                            keepbranches=self.keepbranchesf,
                                            date=self.date)
+                    if newnode is None:
+                        # If it ended up being a no-op commit, then the normal
+                        # merge state clean-up path doesn't happen, so do it here.
+                        # Fix bug #5494
+                        mergemod.mergestate.clean(repo)
                 else:
                     # Skip commit if we are collapsing
                     repo.dirstate.beginparentchange()
diff --git a/tests/test-rebase-emptycleanup.t b/tests/test-rebase-emptycleanup.t
new file mode 100644
--- /dev/null
+++ b/tests/test-rebase-emptycleanup.t
@@ -0,0 +1,34 @@ 
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > rebase=
+  > EOF
+  $ hg init repo
+  $ cd repo
+  $ echo a >> a
+  $ hg commit -qAm base
+  $ echo b >> a
+  $ hg commit -qm b
+  $ hg up .^
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo c >> a
+  $ hg commit -qm c
+  $ hg rebase -s 1 -d 2 --noninteractive
+  rebasing 1:fdaca8533b86 "b"
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  unresolved conflicts (see hg resolve, then hg rebase --continue)
+  [1]
+  $ echo a > a
+  $ echo c >> a
+  $ hg resolve --mark a
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg rebase --continue
+  rebasing 1:fdaca8533b86 "b"
+  note: rebase of 1:fdaca8533b86 created no changes to commit
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/fdaca8533b86-7fd70513-backup.hg (glob)
+  $ hg resolve --list
+  $ ls .hg/merge
+  ls: .hg/merge: No such file or directory
+  [1]
+