--- a/hgext/mq.py Wed Sep 13 16:41:03 2006 -0700
+++ b/hgext/mq.py Thu Sep 14 15:35:55 2006 +0200
@@ -483,24 +483,35 @@
tr.close()
return (err, n)
- def delete(self, repo, patches, keep=False):
+ def delete(self, repo, patches, opts):
realpatches = []
+ appliedbase = 0
+ forget = opts.get('forget')
for patch in patches:
patch = self.lookup(patch, strict=True)
info = self.isapplied(patch)
- if info:
+ if info and not forget:
raise util.Abort(_("cannot delete applied patch %s") % patch)
if patch not in self.series:
raise util.Abort(_("patch %s not in series file") % patch)
+ if forget:
+ if not info:
+ raise util.Abort(_("cannot forget unapplied patch %s") % patch)
+ if info[0] != appliedbase:
+ raise util.Abort(_("patch %s not at base") % patch)
+ appliedbase += 1
realpatches.append(patch)
- if not keep:
+ if not opts.get('keep'):
r = self.qrepo()
if r:
r.remove(realpatches, True)
else:
os.unlink(self.join(patch))
+ if forget:
+ del self.applied[:appliedbase]
+ self.applied_dirty = 1
indices = [self.find_series(p) for p in realpatches]
indices.sort()
for i in indices[-1::-1]:
@@ -1306,10 +1317,15 @@
def delete(ui, repo, patch, *patches, **opts):
"""remove patches from queue
- The patches must not be applied.
- With -k, the patch files are preserved in the patch directory."""
+ With --forget, mq will stop managing the named patches. The
+ patches must be applied and at the base of the stack. This option
+ is useful when the patches have been applied upstream.
+
+ Otherwise, the patches must not be applied.
+
+ With --keep, the patch files are preserved in the patch directory."""
q = repo.mq
- q.delete(repo, (patch,) + patches, keep=opts.get('keep'))
+ q.delete(repo, (patch,) + patches, opts)
q.save_dirty()
return 0
@@ -1917,8 +1933,9 @@
'hg qdiff [-I] [-X] [FILE]...'),
"qdelete|qremove|qrm":
(delete,
- [('k', 'keep', None, _('keep patch file'))],
- 'hg qdelete [-k] PATCH'),
+ [('f', 'forget', None, _('stop managing an applied patch')),
+ ('k', 'keep', None, _('keep patch file'))],
+ 'hg qdelete [-f] [-k] PATCH'),
'qfold':
(fold,
[('e', 'edit', None, _('edit patch header')),