# HG changeset patch # User Brendan Cully # Date 2008-10-19 00:29:45 # Node ID 1b7b21b634f263505735826c477a0fbd6318e565 # Parent a634e006529536f1a2da4368f61f8f95ac1de5f8 mq: make qimport -f work properly. Closes issue1255. From Bernhard Leiner. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1511,9 +1511,11 @@ class queue: 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 diff --git a/tests/test-mq-qimport b/tests/test-mq-qimport --- a/tests/test-mq-qimport +++ b/tests/test-mq-qimport @@ -36,6 +36,22 @@ rm foo 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 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 @@ -3,6 +3,18 @@ abort: unable to read non-existing-file % 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