Mercurial > public > mercurial-scm > hg-stable
diff hgext/mq.py @ 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 | 30657909b2ba |
children | bbf544b5f2e9 |
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)