##// END OF EJS Templates
New self-explanatory command qrename.
Brendan Cully -
r2750:8c814c1a default
parent child Browse files
Show More
@@ -1411,6 +1411,56 b' def pop(ui, repo, patch=None, **opts):'
1411 1411 q.save_dirty()
1412 1412 return 0
1413 1413
1414 def rename(ui, repo, patch, name=None, **opts):
1415 """rename a patch
1416
1417 With one argument, renames the current patch to PATCH1.
1418 With two arguments, renames PATCH1 to PATCH2."""
1419
1420 q = repo.mq
1421
1422 if not name:
1423 name = patch
1424 patch = None
1425
1426 if name in q.series:
1427 raise util.Abort(_('A patch named %s already exists in the series file') % name)
1428
1429 absdest = os.path.join(q.path, name)
1430 if os.path.exists(absdest):
1431 raise util.Abort(_('%s already exists') % absdest)
1432
1433 if patch:
1434 patch = q.lookup(patch)
1435 else:
1436 if not q.applied:
1437 ui.write(_('No patches applied\n'))
1438 return
1439 patch = q.lookup('qtip')
1440
1441 if ui.verbose:
1442 ui.write('Renaming %s to %s\n' % (patch, name))
1443 i = q.find_series(patch)
1444 q.full_series[i] = name
1445 q.read_series(q.full_series)
1446 q.series_dirty = 1
1447
1448 info = q.isapplied(patch)
1449 if info:
1450 q.applied[info[0]] = info[1] + ':' + name
1451 q.applied_dirty = 1
1452
1453 util.rename(os.path.join(q.path, patch), absdest)
1454 r = q.qrepo()
1455 if r:
1456 wlock = r.wlock()
1457 if r.dirstate.state(name) == 'r':
1458 r.undelete([name], wlock)
1459 r.copy(patch, name, wlock)
1460 r.remove([patch], False, wlock)
1461
1462 q.save_dirty()
1463
1414 1464 def restore(ui, repo, rev, **opts):
1415 1465 """restore the queue state saved by a rev"""
1416 1466 rev = repo.lookup(rev)
@@ -1552,6 +1602,8 b' cmdtable = {'
1552 1602 ('l', 'logfile', '', _('change commit message with <file> content')),
1553 1603 ('s', 'short', None, 'short refresh')],
1554 1604 'hg qrefresh [-e] [-m TEXT] [-l FILE] [-s]'),
1605 'qrename':
1606 (rename, [], 'hg qrename PATCH1 [PATCH2]'),
1555 1607 "qrestore":
1556 1608 (restore,
1557 1609 [('d', 'delete', None, 'delete save entry'),
@@ -39,6 +39,7 b' list of commands (use "hg help -v mq" to'
39 39 qprev print the name of the previous patch
40 40 qpush push the next patch onto the stack
41 41 qrefresh update the current patch
42 qrename rename a patch
42 43 qrestore restore the queue state saved by a rev
43 44 qsave save current queue state
44 45 qseries print the entire series file
General Comments 0
You need to be logged in to leave comments. Login now