##// 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 def delete(self, repo, patches, opts):
489 def delete(self, repo, patches, opts):
490 realpatches = []
490 realpatches = []
491 appliedbase = 0
492 forget = opts.get('forget')
493 for patch in patches:
491 for patch in patches:
494 patch = self.lookup(patch, strict=True)
492 patch = self.lookup(patch, strict=True)
495 info = self.isapplied(patch)
493 info = self.isapplied(patch)
496 if info and not forget:
494 if info:
497 raise util.Abort(_("cannot delete applied patch %s") % patch)
495 raise util.Abort(_("cannot delete applied patch %s") % patch)
498 if patch not in self.series:
496 if patch not in self.series:
499 raise util.Abort(_("patch %s not in series file") % patch)
497 raise util.Abort(_("patch %s not in series file") % patch)
500 if forget:
498 realpatches.append(patch)
501 if not info:
499
502 raise util.Abort(_("cannot forget unapplied patch %s") % patch)
500 appliedbase = 0
503 if info[0] != appliedbase:
501 if opts.get('rev'):
504 raise util.Abort(_("patch %s not at base") % patch)
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 appliedbase += 1
517 appliedbase += 1
506 realpatches.append(patch)
507
518
508 if not opts.get('keep'):
519 if not opts.get('keep'):
509 r = self.qrepo()
520 r = self.qrepo()
@@ -512,7 +523,7 b' class queue:'
512 else:
523 else:
513 os.unlink(self.join(patch))
524 os.unlink(self.join(patch))
514
525
515 if forget:
526 if appliedbase:
516 del self.applied[:appliedbase]
527 del self.applied[:appliedbase]
517 self.applied_dirty = 1
528 self.applied_dirty = 1
518 indices = [self.find_series(p) for p in realpatches]
529 indices = [self.find_series(p) for p in realpatches]
@@ -1351,10 +1362,10 b' class queue:'
1351 if qrepo:
1362 if qrepo:
1352 qrepo.add(added)
1363 qrepo.add(added)
1353
1364
1354 def delete(ui, repo, patch, *patches, **opts):
1365 def delete(ui, repo, *patches, **opts):
1355 """remove patches from queue
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 patches must be applied and at the base of the stack. This option
1369 patches must be applied and at the base of the stack. This option
1359 is useful when the patches have been applied upstream.
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 With --keep, the patch files are preserved in the patch directory."""
1374 With --keep, the patch files are preserved in the patch directory."""
1364 q = repo.mq
1375 q = repo.mq
1365 q.delete(repo, (patch,) + patches, opts)
1376 q.delete(repo, patches, opts)
1366 q.save_dirty()
1377 q.save_dirty()
1367 return 0
1378 return 0
1368
1379
@@ -2018,9 +2029,9 b' cmdtable = {'
2018 'hg qdiff [-I] [-X] [FILE]...'),
2029 'hg qdiff [-I] [-X] [FILE]...'),
2019 "qdelete|qremove|qrm":
2030 "qdelete|qremove|qrm":
2020 (delete,
2031 (delete,
2021 [('f', 'forget', None, _('stop managing an applied patch')),
2032 [('k', 'keep', None, _('keep patch file')),
2022 ('k', 'keep', None, _('keep patch file'))],
2033 ('r', 'rev', [], _('stop managing a revision'))],
2023 'hg qdelete [-f] [-k] PATCH'),
2034 'hg qdelete [-k] [-r REV]... PATCH...'),
2024 'qfold':
2035 'qfold':
2025 (fold,
2036 (fold,
2026 [('e', 'edit', None, _('edit patch header')),
2037 [('e', 'edit', None, _('edit patch header')),
General Comments 0
You need to be logged in to leave comments. Login now