Patchwork [1,of,1,stable] update: remove .hg/graftstate on clean (issue3970)

login
register
mail settings
Submitter Siddharth Agarwal
Date June 29, 2013, 1:26 a.m.
Message ID <9b8c82497c9fd777733a.1372469210@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1760/
State Accepted
Commit 0af993732f669d20545f5495da146e1ef445e708
Headers show

Comments

Siddharth Agarwal - June 29, 2013, 1:26 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1372463911 25200
#      Fri Jun 28 16:58:31 2013 -0700
# Node ID 9b8c82497c9fd777733ad06d99b2b7743817cac1
# Parent  d4f8d94edf49ca1d6ef80ef1fbba056544830946
update: remove .hg/graftstate on clean (issue3970)

e078ea9b4ce4 introduced a check for interrupted grafts while committing. This
exposed a bug where hg update --clean didn't remove that file.
Matt Mackall - June 29, 2013, 6:52 p.m.
On Fri, 2013-06-28 at 18:26 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1372463911 25200
> #      Fri Jun 28 16:58:31 2013 -0700
> # Node ID 9b8c82497c9fd777733ad06d99b2b7743817cac1
> # Parent  d4f8d94edf49ca1d6ef80ef1fbba056544830946
> update: remove .hg/graftstate on clean (issue3970)

Queued for stable, thanks.

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -471,6 +471,7 @@ 
 def clean(repo, node, show_stats=True):
     """forcibly switch the working directory to node, clobbering changes"""
     stats = updaterepo(repo, node, True)
+    util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
     if show_stats:
         _showstats(repo, stats)
     return stats[3] > 0
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -181,6 +181,32 @@ 
   (use "hg graft -c" to continue graft)
   [255]
 
+Abort the graft and try committing:
+
+  $ hg up -C .
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo c >> e
+  $ hg ci -mtest
+
+  $ hg strip . --config extensions.mq=
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
+
+Graft again:
+
+  $ hg graft 1 5 4 3 'merge()' 2
+  skipping ungraftable merge revision 6
+  skipping already grafted revision 2
+  skipping already grafted revision 1
+  skipping already grafted revision 5
+  grafting revision 4
+  merging e
+  warning: conflicts during merge.
+  merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
+  abort: unresolved conflicts, can't continue
+  (use hg resolve and hg graft --continue)
+  [255]
+
 Continue without resolve should fail:
 
   $ hg graft -c