diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -395,6 +395,17 @@ def newcommit(repo, phase, *args, **kwar class AbortNoCleanup(error.Abort): pass +def makepatchname(existing, title): + """Return a suitable filename for title, adding a suffix to make + it unique in the existing list""" + namebase = re.sub('[\s\W_]+', '_', title.lower()).strip('_') + name = namebase + i = 0 + while name in existing: + i += 1 + name = '%s__%s' % (namebase, i) + return name + class queue(object): def __init__(self, ui, baseui, path, patchdir=None): self.basepath = path @@ -2090,7 +2101,8 @@ class queue(object): lastparent = p1 if not patchname: - patchname = normname('%d.diff' % r) + patchname = makepatchname(self.fullseries, + repo[r].description().split('\n', 1)[0]) checkseries(patchname) self.checkpatchname(patchname, force) self.fullseries.insert(0, patchname) diff --git a/tests/test-mq-qdelete.t b/tests/test-mq-qdelete.t --- a/tests/test-mq-qdelete.t +++ b/tests/test-mq-qdelete.t @@ -155,11 +155,11 @@ qdel -k X && hg qimp -e X used to trigge $ hg init --mq $ hg qimport -r 3 $ hg qpop - popping 3.diff + popping imported_patch_pc patch queue now empty - $ hg qdel -k 3.diff - $ hg qimp -e 3.diff - adding 3.diff to series file + $ hg qdel -k imported_patch_pc + $ hg qimp -e imported_patch_pc + adding imported_patch_pc to series file $ hg qfinish -a no patches applied @@ -167,17 +167,17 @@ qdel -k X && hg qimp -e X used to trigge resilience to inconsistency: qfinish -a with applied patches not in series $ hg qser - 3.diff + imported_patch_pc $ hg qapplied $ hg qpush - applying 3.diff - patch 3.diff is empty - now at: 3.diff + applying imported_patch_pc + patch imported_patch_pc is empty + now at: imported_patch_pc $ echo next >> base $ hg qrefresh -d '1 0' $ echo > .hg/patches/series # remove 3.diff from series to confuse mq $ hg qfinish -a - revision 47dfa8501675 refers to unknown patches: 3.diff + revision 47dfa8501675 refers to unknown patches: imported_patch_pc more complex state 'both known and unknown patches diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t --- a/tests/test-mq-qimport.t +++ b/tests/test-mq-qimport.t @@ -198,32 +198,32 @@ try to import --push now at: appendbar.diff $ hg qfin -a patch b.diff finalized without changeset message - $ touch .hg/patches/2.diff + $ touch .hg/patches/append_foo $ hg qimport -r 'p1(.)::' - abort: patch "2.diff" already exists + abort: patch "append_foo" already exists [255] $ hg qapplied - 3.diff + append_bar $ hg qfin -a - $ rm .hg/patches/2.diff + $ rm .hg/patches/append_foo $ hg qimport -r 'p1(.)::' -P $ hg qpop -a - popping 3.diff - popping 2.diff + popping append_bar + popping append_foo patch queue now empty - $ hg qdel 3.diff - $ hg qdel -k 2.diff + $ hg qdel append_foo + $ hg qdel -k append_bar qimport -e - $ hg qimport -e 2.diff - adding 2.diff to series file - $ hg qdel -k 2.diff + $ hg qimport -e append_bar + adding append_bar to series file + $ hg qdel -k append_bar qimport -e --name newname oldexisitingpatch - $ hg qimport -e --name this-name-is-better 2.diff - renaming 2.diff to this-name-is-better + $ hg qimport -e --name this-name-is-better append_bar + renaming append_bar to this-name-is-better adding this-name-is-better to series file $ hg qser this-name-is-better diff --git a/tests/test-mq-subrepo.t b/tests/test-mq-subrepo.t --- a/tests/test-mq-subrepo.t +++ b/tests/test-mq-subrepo.t @@ -249,8 +249,8 @@ qpop reverting subrepo sub adding sub/a (glob) $ hg qpop - popping 1.diff - now at: 0.diff + popping 1 + now at: 0 $ hg status -AS C .hgsub C .hgsubstate @@ -268,11 +268,11 @@ qpush reverting subrepo sub adding sub/a (glob) $ hg qpush - applying 1.diff + applying 1 subrepository sub diverged (local revision: b2fdb12cd82b, remote revision: aa037b301eba) (M)erge, keep (l)ocal or keep (r)emote? m 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - now at: 1.diff + now at: 1 $ hg status -AS C .hgsub C .hgsubstate diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t --- a/tests/test-rebase-mq-skip.t +++ b/tests/test-rebase-mq-skip.t @@ -142,12 +142,12 @@ already has one local mq patch $ hg up -q qtip $ HGMERGE=internal:fail hg rebase - rebasing 1:b4bffa6e4776 "r1" (1.diff qbase) + rebasing 1:b4bffa6e4776 "r1" (qbase r1) note: rebase of 1:b4bffa6e4776 created no changes to commit - rebasing 2:c0fd129beb01 "r2" (2.diff) - rebasing 3:6ff5b8feed8e "r3" (3.diff) + rebasing 2:c0fd129beb01 "r2" (r2) + rebasing 3:6ff5b8feed8e "r3" (r3) note: rebase of 3:6ff5b8feed8e created no changes to commit - rebasing 4:094320fec554 "r4" (4.diff) + rebasing 4:094320fec554 "r4" (r4) unresolved conflicts (see hg resolve, then hg rebase --continue) [1] @@ -155,20 +155,20 @@ already has one local mq patch (no more unresolved files) $ hg rebase --continue - already rebased 1:b4bffa6e4776 "r1" (1.diff qbase) as 057f55ff8f44 - already rebased 2:c0fd129beb01 "r2" (2.diff) as 1660ab13ce9a - already rebased 3:6ff5b8feed8e "r3" (3.diff) as 1660ab13ce9a - rebasing 4:094320fec554 "r4" (4.diff) + already rebased 1:b4bffa6e4776 "r1" (qbase r1) as 057f55ff8f44 + already rebased 2:c0fd129beb01 "r2" (r2) as 1660ab13ce9a + already rebased 3:6ff5b8feed8e "r3" (r3) as 1660ab13ce9a + rebasing 4:094320fec554 "r4" (r4) note: rebase of 4:094320fec554 created no changes to commit - rebasing 5:681a378595ba "r5" (5.diff) - rebasing 6:512a1f24768b "r6" (6.diff qtip) + rebasing 5:681a378595ba "r5" (r5) + rebasing 6:512a1f24768b "r6" (qtip r6) note: rebase of 6:512a1f24768b created no changes to commit saved backup bundle to $TESTTMP/b/.hg/strip-backup/b4bffa6e4776-b9bfb84d-backup.hg (glob) $ hg tglog - @ 8: 'r5' tags: 5.diff qtip tip + @ 8: 'r5' tags: qtip r5 tip | - o 7: 'r2' tags: 2.diff qbase + o 7: 'r2' tags: qbase r2 | o 6: 'branch2-r6' tags: qparent | diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -431,9 +431,9 @@ strip of applied mq should cleanup statu applied patches before strip $ hg qapplied - 2.diff - 3.diff - 4.diff + d + e + f stripping revision in queue @@ -444,7 +444,7 @@ stripping revision in queue applied patches after stripping rev in queue $ hg qapplied - 2.diff + d stripping ancestor of queue