[PATCH] mq: avoid data loss upon qfold + qmv (issue3058)
Patrick Mezard
pmezard at gmail.com
Thu Oct 20 10:06:57 CDT 2011
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1319121811 -7200
# Branch stable
# Node ID 0c8afedaa8e2a5a90468c17fb16f3feb1f0ca2f2
# Parent 3eb1a90ea40941ad7a920daad665e27ffdb6f291
mq: avoid data loss upon qfold + qmv (issue3058)
When renaming a patch A as B where B was previously qfolded into A and
therefore marked as removed, a versioned MQ would first restore B before
marking it as a copy of A, thus losing A changes. The undelete() call is
probably a left-over, wctx.copy() explicitely handles the case where the
destination is removed.
Also note that status command represents "hg rm b; hg mv a b" as:
A b
a
R a
which explains the first hunk in test-mq-qrename.t.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2614,8 +2614,6 @@
r.dirstate.drop(patch)
r.dirstate.add(name)
else:
- if r.dirstate[name] == 'r':
- wctx.undelete([name])
wctx.copy(patch, name)
wctx.forget([patch])
finally:
diff --git a/tests/test-mq-qrename.t b/tests/test-mq-qrename.t
--- a/tests/test-mq-qrename.t
+++ b/tests/test-mq-qrename.t
@@ -76,8 +76,8 @@
$ hg qrename patchb patchc
$ hg qrename patcha patchb
$ hg st --mq
- M patchb
M series
+ A patchb
A patchc
R patcha
$ cd ..
@@ -94,3 +94,32 @@
nothing changed
[1]
$ cd ..
+
+Test renaming to a folded patch (issue3058)
+
+ $ hg init issue3058
+ $ cd issue3058
+ $ hg init --mq
+ $ echo a > a
+ $ hg add a
+ $ hg qnew adda
+ $ echo b >> a
+ $ hg qnew addb
+ $ hg qpop
+ popping addb
+ now at: adda
+ $ hg ci --mq -m "save mq"
+ $ hg qfold addb
+ $ hg qmv addb
+ $ cat .hg/patches/addb
+ # HG changeset patch
+ # Parent 0000000000000000000000000000000000000000
+
+ diff -r 000000000000 a
+ --- /dev/null * (glob)
+ +++ b/a * (glob)
+ @@ -0,0 +1,2 @@
+ +a
+ +b
+ $ cd ..
+
More information about the Mercurial-devel
mailing list