##// END OF EJS Templates
mq: refactor makepatchname into class method
Mads Kiilerich -
r27918:c7cd551f stable
parent child Browse files
Show More
@@ -396,19 +396,6 b' def newcommit(repo, phase, *args, **kwar'
396 class AbortNoCleanup(error.Abort):
396 class AbortNoCleanup(error.Abort):
397 pass
397 pass
398
398
399 def makepatchname(existing, title, fallbackname):
400 """Return a suitable filename for title, adding a suffix to make
401 it unique in the existing list"""
402 namebase = re.sub('[\s\W_]+', '_', title.lower()).strip('_')
403 if not namebase:
404 namebase = fallbackname
405 name = namebase
406 i = 0
407 while name in existing:
408 i += 1
409 name = '%s__%s' % (namebase, i)
410 return name
411
412 class queue(object):
399 class queue(object):
413 def __init__(self, ui, baseui, path, patchdir=None):
400 def __init__(self, ui, baseui, path, patchdir=None):
414 self.basepath = path
401 self.basepath = path
@@ -1126,6 +1113,19 b' class queue(object):'
1126 else:
1113 else:
1127 raise error.Abort(_('patch "%s" already exists') % name)
1114 raise error.Abort(_('patch "%s" already exists') % name)
1128
1115
1116 def makepatchname(self, title, fallbackname):
1117 """Return a suitable filename for title, adding a suffix to make
1118 it unique in the existing list"""
1119 namebase = re.sub('[\s\W_]+', '_', title.lower()).strip('_')
1120 if not namebase:
1121 namebase = fallbackname
1122 name = namebase
1123 i = 0
1124 while name in self.fullseries:
1125 i += 1
1126 name = '%s__%s' % (namebase, i)
1127 return name
1128
1129 def checkkeepchanges(self, keepchanges, force):
1129 def checkkeepchanges(self, keepchanges, force):
1130 if force and keepchanges:
1130 if force and keepchanges:
1131 raise error.Abort(_('cannot use both --force and --keep-changes'))
1131 raise error.Abort(_('cannot use both --force and --keep-changes'))
@@ -2097,7 +2097,7 b' class queue(object):'
2097 lastparent = p1
2097 lastparent = p1
2098
2098
2099 if not patchname:
2099 if not patchname:
2100 patchname = makepatchname(self.fullseries,
2100 patchname = self.makepatchname(
2101 repo[r].description().split('\n', 1)[0],
2101 repo[r].description().split('\n', 1)[0],
2102 '%d.diff' % r)
2102 '%d.diff' % r)
2103 checkseries(patchname)
2103 checkseries(patchname)
General Comments 0
You need to be logged in to leave comments. Login now