mq qimport should not leave diffs that are not in series when it aborts

timeless timeless at gmail.com
Thu Dec 17 15:43:53 CST 2009


Currently 3.diff ends up in the .hg/patches/ directory which means a
second qimport fails, which is annoying, and if you have lots of files
in your mq directory, most of which are qpopped, it's not very safe to
just delete files randomly.

# HG changeset patch
# User timeless at mozdev.org
# Date 1261086126 -7200
# Node ID 5b4022b073578d42722ef2c246b81fdf11802cfb
# Parent  69ce7a10e593d28006790b8e264e2a89b8ad41f9
mq qimport should not leave diffs that are not in series when it aborts

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1615,6 +1615,7 @@ class queue(object):
             if git:
                 self.diffopts().git = True

+            nps = []
             for r in rev:
                 p1, p2 = repo.changelog.parentrevs(r)
                 n = repo.changelog.node(r)
@@ -1630,6 +1631,9 @@ class queue(object):
                 self.check_reserved_name(patchname)
                 checkseries(patchname)
                 checkfile(patchname)
+                nps.append((n, patchname))
+
+            for n, patchname in nps:
                 self.full_series.insert(0, patchname)

                 patchf = self.opener(patchname, "w")
diff --git a/tests/test-mq-qimport b/tests/test-mq-qimport
--- a/tests/test-mq-qimport
+++ b/tests/test-mq-qimport
@@ -108,3 +108,21 @@ hg up -C
 hg qimport --push another.diff
 hg qfin -a
 hg qimport -rtip -P
+
+echo % try to import across branches
+hg init import-bad-series
+cd import-bad-series
+touch a
+hg ci -Am adde
+echo 1 >> a
+hg ci -m 1
+hg up -r 0
+echo 2 >> a
+hg ci -m 2
+hg up -r 1
+echo 3 >> a
+hg ci -m 3
+hg qimport -r 1:3
+hg qimport -r 3
+hg qpop
+cd ..
diff --git a/tests/test-mq-qimport.out b/tests/test-mq-qimport.out
--- a/tests/test-mq-qimport.out
+++ b/tests/test-mq-qimport.out
@@ -52,3 +52,11 @@ applying another.diff
 now at: another.diff
 patch b.diff finalized without changeset message
 patch another.diff finalized without changeset message
+% try to import across branches
+adding a
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+abort: revision 2 is not the parent of 1
+popping 3.diff
+patch queue now empty


More information about the Mercurial-devel mailing list