##// END OF EJS Templates
mq: change qdel --forget to --rev; accept any revision symbol
Brendan Cully -
r3373:9851f46d default
parent child Browse files
Show More
@@ -488,22 +488,33 b' class queue:'
488 488
489 489 def delete(self, repo, patches, opts):
490 490 realpatches = []
491 appliedbase = 0
492 forget = opts.get('forget')
493 491 for patch in patches:
494 492 patch = self.lookup(patch, strict=True)
495 493 info = self.isapplied(patch)
496 if info and not forget:
494 if info:
497 495 raise util.Abort(_("cannot delete applied patch %s") % patch)
498 496 if patch not in self.series:
499 497 raise util.Abort(_("patch %s not in series file") % patch)
500 if forget:
501 if not info:
502 raise util.Abort(_("cannot forget unapplied patch %s") % patch)
503 if info[0] != appliedbase:
504 raise util.Abort(_("patch %s not at base") % patch)
498 realpatches.append(patch)
499
500 appliedbase = 0
501 if opts.get('rev'):
502 if not self.applied:
503 raise util.Abort(_('no patches applied'))
504 revs = [int(r) for r in cmdutil.revrange(ui, repo, opts['rev'])]
505 if len(revs) > 1 and revs[0] > revs[1]:
506 revs.reverse()
507 for rev in revs:
508 if appliedbase >= len(self.applied):
509 raise util.Abort(_("revision %d is not managed") % rev)
510
511 base = revlog.bin(self.applied[appliedbase].rev)
512 node = repo.changelog.node(rev)
513 if node != base:
514 raise util.Abort(_("cannot delete revision %d above "
515 "applied patches") % rev)
516 realpatches.append(self.applied[appliedbase].name)
505 517 appliedbase += 1
506 realpatches.append(patch)
507 518
508 519 if not opts.get('keep'):
509 520 r = self.qrepo()
@@ -512,7 +523,7 b' class queue:'
512 523 else:
513 524 os.unlink(self.join(patch))
514 525
515 if forget:
526 if appliedbase:
516 527 del self.applied[:appliedbase]
517 528 self.applied_dirty = 1
518 529 indices = [self.find_series(p) for p in realpatches]
@@ -1351,10 +1362,10 b' class queue:'
1351 1362 if qrepo:
1352 1363 qrepo.add(added)
1353 1364
1354 def delete(ui, repo, patch, *patches, **opts):
1365 def delete(ui, repo, *patches, **opts):
1355 1366 """remove patches from queue
1356 1367
1357 With --forget, mq will stop managing the named patches. The
1368 With --rev, mq will stop managing the named revisions. The
1358 1369 patches must be applied and at the base of the stack. This option
1359 1370 is useful when the patches have been applied upstream.
1360 1371
@@ -1362,7 +1373,7 b' def delete(ui, repo, patch, *patches, **'
1362 1373
1363 1374 With --keep, the patch files are preserved in the patch directory."""
1364 1375 q = repo.mq
1365 q.delete(repo, (patch,) + patches, opts)
1376 q.delete(repo, patches, opts)
1366 1377 q.save_dirty()
1367 1378 return 0
1368 1379
@@ -2018,9 +2029,9 b' cmdtable = {'
2018 2029 'hg qdiff [-I] [-X] [FILE]...'),
2019 2030 "qdelete|qremove|qrm":
2020 2031 (delete,
2021 [('f', 'forget', None, _('stop managing an applied patch')),
2022 ('k', 'keep', None, _('keep patch file'))],
2023 'hg qdelete [-f] [-k] PATCH'),
2032 [('k', 'keep', None, _('keep patch file')),
2033 ('r', 'rev', [], _('stop managing a revision'))],
2034 'hg qdelete [-k] [-r REV]... PATCH...'),
2024 2035 'qfold':
2025 2036 (fold,
2026 2037 [('e', 'edit', None, _('edit patch header')),
General Comments 0
You need to be logged in to leave comments. Login now