Mercurial > hg-stable
changeset 26736:143b52fce68e
mq: generate patch names from first line of description
Avoid the pointless numeric rev.diff patch names.
Instead, do like mbox extension does and create meaningful patch names.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 10 Mar 2015 13:19:17 +0100 |
parents | ec74ea542201 |
children | a930d66a04af |
files | hgext/mq.py tests/test-mq-qdelete.t tests/test-mq-qimport.t tests/test-mq-subrepo.t tests/test-rebase-mq-skip.t tests/test-strip.t |
diffstat | 6 files changed, 55 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Thu Oct 15 21:36:47 2015 +0200 +++ b/hgext/mq.py Tue Mar 10 13:19:17 2015 +0100 @@ -395,6 +395,17 @@ 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 @@ 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)
--- a/tests/test-mq-qdelete.t Thu Oct 15 21:36:47 2015 +0200 +++ b/tests/test-mq-qdelete.t Tue Mar 10 13:19:17 2015 +0100 @@ -155,11 +155,11 @@ $ 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 @@ 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
--- a/tests/test-mq-qimport.t Thu Oct 15 21:36:47 2015 +0200 +++ b/tests/test-mq-qimport.t Tue Mar 10 13:19:17 2015 +0100 @@ -198,32 +198,32 @@ 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
--- a/tests/test-mq-subrepo.t Thu Oct 15 21:36:47 2015 +0200 +++ b/tests/test-mq-subrepo.t Tue Mar 10 13:19:17 2015 +0100 @@ -249,8 +249,8 @@ 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 @@ 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
--- a/tests/test-rebase-mq-skip.t Thu Oct 15 21:36:47 2015 +0200 +++ b/tests/test-rebase-mq-skip.t Tue Mar 10 13:19:17 2015 +0100 @@ -142,12 +142,12 @@ $ 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 @@ (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 |
--- a/tests/test-strip.t Thu Oct 15 21:36:47 2015 +0200 +++ b/tests/test-strip.t Tue Mar 10 13:19:17 2015 +0100 @@ -431,9 +431,9 @@ applied patches before strip $ hg qapplied - 2.diff - 3.diff - 4.diff + d + e + f stripping revision in queue @@ -444,7 +444,7 @@ applied patches after stripping rev in queue $ hg qapplied - 2.diff + d stripping ancestor of queue