mq: make qimport -f work properly. Closes issue1255.
authorBrendan Cully <brendan@kublai.com>
Sat, 18 Oct 2008 17:29:45 -0700
changeset 7160 1b7b21b634f2
parent 7159 a634e0065295
child 7161 b420ef2c812b
mq: make qimport -f work properly. Closes issue1255. From Bernhard Leiner.
hgext/mq.py
tests/test-mq-qimport
tests/test-mq-qimport.out
--- a/hgext/mq.py	Sat Oct 18 16:53:44 2008 -0700
+++ b/hgext/mq.py	Sat Oct 18 17:29:45 2008 -0700
@@ -1511,9 +1511,11 @@
                 checkfile(patchname)
                 patchf = self.opener(patchname, "w")
                 patchf.write(text)
-            checkseries(patchname)
-            index = self.full_series_end() + i
-            self.full_series[index:index] = [patchname]
+            if not force:
+                checkseries(patchname)
+            if patchname not in self.series:
+                index = self.full_series_end() + i
+                self.full_series[index:index] = [patchname]
             self.parse_series()
             self.ui.warn("adding %s to series file\n" % patchname)
             i += 1
--- a/tests/test-mq-qimport	Sat Oct 18 16:53:44 2008 -0700
+++ b/tests/test-mq-qimport	Sat Oct 18 17:29:45 2008 -0700
@@ -36,6 +36,22 @@
 hg qimport file://$HGTMP/url.diff
 hg qun
 
+echo % import patch that already exists
+echo foo2 >> foo
+hg add foo
+hg diff > ../url.diff
+hg revert --no-backup foo
+rm foo
+hg qimport ../url.diff
+hg qpush
+cat foo
+hg qpop
+echo % qimport -f
+hg qimport -f ../url.diff
+hg qpush
+cat foo
+hg qpop
+
 echo % build diff with CRLF
 python ../writelines.py b 5 'a\n' 5 'a\r\n'
 hg ci -Am addb
--- a/tests/test-mq-qimport.out	Sat Oct 18 16:53:44 2008 -0700
+++ b/tests/test-mq-qimport.out	Sat Oct 18 17:29:45 2008 -0700
@@ -3,6 +3,18 @@
 % import URL
 adding url.diff to series file
 url.diff
+% import patch that already exists
+abort: patch "url.diff" already exists
+applying url.diff
+Now at: url.diff
+foo
+Patch queue now empty
+% qimport -f
+adding url.diff to series file
+applying url.diff
+Now at: url.diff
+foo2
+Patch queue now empty
 % build diff with CRLF
 adding b
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved