Submitter | Katsunori FUJIWARA |
---|---|
Date | Dec. 23, 2015, 1:33 p.m. |
Message ID | <7aa93dad8092b571fb5a.1450877591@feefifofum> |
Download | mbox | patch |
Permalink | /patch/12291/ |
State | Accepted |
Delegated to: | Yuya Nishihara |
Headers | show |
Comments
On Wed, 23 Dec 2015 22:33:11 +0900, FUJIWARA Katsunori wrote: > # HG changeset patch > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp> > # Date 1450877332 -32400 > # Wed Dec 23 22:28:52 2015 +0900 > # Branch stable > # Node ID 7aa93dad8092b571fb5ab0b3e3509a0320546b64 > # Parent e47841c8343d06b91637c84866bf1469b835b1f7 > mq: use fallback patch name if no alpha-numeric byte in the summary line I've added (issue5025). > diff --git a/hgext/mq.py b/hgext/mq.py > --- a/hgext/mq.py > +++ b/hgext/mq.py > @@ -395,10 +395,12 @@ def newcommit(repo, phase, *args, **kwar > class AbortNoCleanup(error.Abort): > pass > > -def makepatchname(existing, title): > +def makepatchname(existing, title, fallbackname): > """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('_') > + if not namebase: > + namebase = fallbackname > name = namebase > i = 0 > while name in existing: > @@ -2101,7 +2103,8 @@ class queue(object): > > if not patchname: > patchname = makepatchname(self.fullseries, > - repo[r].description().split('\n', 1)[0]) > + repo[r].description().split('\n', 1)[0], > + '%d.diff' % r) Looks good as it was '%d.diff' before 143b52fce68e. Pushed to the clowncopter, thanks.
Patch
diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -395,10 +395,12 @@ def newcommit(repo, phase, *args, **kwar class AbortNoCleanup(error.Abort): pass -def makepatchname(existing, title): +def makepatchname(existing, title, fallbackname): """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('_') + if not namebase: + namebase = fallbackname name = namebase i = 0 while name in existing: @@ -2101,7 +2103,8 @@ class queue(object): if not patchname: patchname = makepatchname(self.fullseries, - repo[r].description().split('\n', 1)[0]) + repo[r].description().split('\n', 1)[0], + '%d.diff' % r) checkseries(patchname) self.checkpatchname(patchname, force) self.fullseries.insert(0, patchname) 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 @@ -290,3 +290,26 @@ check qimport phase: $ cd .. $ killdaemons.py + +check patch name generation for non-alpha-numeric summary line + + $ cd repo + + $ hg qpop -a -q + patch queue now empty + $ hg qseries -v + 0 U imported_patch_b_diff + 1 U 0 + 2 U this-name-is-better + 3 U url.diff + + $ echo bb >> b + $ hg commit -m '==++--==' + + $ hg qimport -r tip + $ hg qseries -v + 0 A 1.diff + 1 U imported_patch_b_diff + 2 U 0 + 3 U this-name-is-better + 4 U url.diff