comparison hgext/mq.py @ 2753:84218111e80f

Add -m, -l, -e options to qfold.
author Brendan Cully <brendan@kublai.com>
date Tue, 01 Aug 2006 15:24:11 -0700
parents 752b9475a700
children 19041b8cbc86
comparison
equal deleted inserted replaced
2748:752b9475a700 2753:84218111e80f
1294 """diff of the current patch""" 1294 """diff of the current patch"""
1295 # deep in the dirstate code, the walkhelper method wants a list, not a tuple 1295 # deep in the dirstate code, the walkhelper method wants a list, not a tuple
1296 repo.mq.diff(repo, list(files)) 1296 repo.mq.diff(repo, list(files))
1297 return 0 1297 return 0
1298 1298
1299 def fold(ui, repo, *files): 1299 def fold(ui, repo, *files, **opts):
1300 """fold the named patches into the current patch 1300 """fold the named patches into the current patch
1301 Patches must not yet be applied.""" 1301
1302 Patches must not yet be applied.
1303 The header for each folded patch will be concatenated with
1304 the current patch header, separated by a line of '* * *'."""
1305
1302 q = repo.mq 1306 q = repo.mq
1303 1307
1304 if not files: 1308 if not files:
1305 raise util.Abort(_('qfold requires at least one patch name')) 1309 raise util.Abort(_('qfold requires at least one patch name'))
1306 if not q.check_toppatch(repo): 1310 if not q.check_toppatch(repo):
1307 raise util.Abort(_('No patches applied\n')) 1311 raise util.Abort(_('No patches applied\n'))
1312
1313 message=commands.logmessage(**opts)
1314 if opts['edit']:
1315 if message:
1316 raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
1308 1317
1309 parent = q.lookup('qtip') 1318 parent = q.lookup('qtip')
1310 patches = [] 1319 patches = []
1311 messages = [] 1320 messages = []
1312 for f in files: 1321 for f in files:
1316 if q.isapplied(patch): 1325 if q.isapplied(patch):
1317 raise util.Abort(_('qfold cannot fold already applied patch %s') % patch) 1326 raise util.Abort(_('qfold cannot fold already applied patch %s') % patch)
1318 patches.append(patch) 1327 patches.append(patch)
1319 1328
1320 for patch in patches: 1329 for patch in patches:
1321 messages.append(q.readheaders(patch)[0]) 1330 if not message:
1331 messages.append(q.readheaders(patch)[0])
1322 pf = os.path.join(q.path, patch) 1332 pf = os.path.join(q.path, patch)
1323 (patchsuccess, files, fuzz) = q.patch(repo, pf) 1333 (patchsuccess, files, fuzz) = q.patch(repo, pf)
1324 if not patchsuccess: 1334 if not patchsuccess:
1325 raise util.Abort(_('Error folding patch %s') % patch) 1335 raise util.Abort(_('Error folding patch %s') % patch)
1326 1336
1327 message = q.readheaders(parent)[0] 1337 if not message:
1328 for msg in messages: 1338 message, comments, user = q.readheaders(parent)[0:3]
1329 message.append('* * *') 1339 for msg in messages:
1330 message.extend(msg) 1340 message.append('* * *')
1331 message = '\n'.join(message) 1341 message.extend(msg)
1342 message = '\n'.join(message)
1343
1344 if opts['edit']:
1345 message = ui.edit(message, user or ui.username())
1332 1346
1333 q.refresh(repo, msg=message) 1347 q.refresh(repo, msg=message)
1334 1348
1335 for patch in patches: 1349 for patch in patches:
1336 q.delete(repo, patch) 1350 q.delete(repo, patch)
1508 (commit, 1522 (commit,
1509 commands.table["^commit|ci"][1], 1523 commands.table["^commit|ci"][1],
1510 'hg qcommit [OPTION]... [FILE]...'), 1524 'hg qcommit [OPTION]... [FILE]...'),
1511 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), 1525 "^qdiff": (diff, [], 'hg qdiff [FILE]...'),
1512 "qdelete": (delete, [], 'hg qdelete PATCH'), 1526 "qdelete": (delete, [], 'hg qdelete PATCH'),
1513 'qfold': (fold, [], 'hg qfold PATCH...'), 1527 'qfold':
1528 (fold,
1529 [('e', 'edit', None, _('edit patch header')),
1530 ('m', 'message', '', _('set patch header to <text>')),
1531 ('l', 'logfile', '', _('set patch header to contents of <file>'))],
1532 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'),
1514 'qheader': (header, [], 1533 'qheader': (header, [],
1515 _('hg qheader [PATCH]')), 1534 _('hg qheader [PATCH]')),
1516 "^qimport": 1535 "^qimport":
1517 (qimport, 1536 (qimport,
1518 [('e', 'existing', None, 'import file in patch dir'), 1537 [('e', 'existing', None, 'import file in patch dir'),