##// END OF EJS Templates
mq: add qdelete --forget option...
Brendan Cully -
r3088:dc784839 default
parent child Browse files
Show More
@@ -0,0 +1,35 b''
1 #!/bin/sh
2
3 echo "[extensions]" >> $HGRCPATH
4 echo "mq=" >> $HGRCPATH
5
6 hg init a
7 cd a
8
9 echo 'base' > base
10 hg ci -Ambase -d '1 0'
11
12 hg qnew a
13 hg qnew b
14 hg qnew c
15
16 hg qdel c
17 hg qpop
18 hg qdel c
19 hg qseries
20 ls .hg/patches
21 hg qpop
22 hg qdel -k b
23 ls .hg/patches
24 hg qdel -f a
25 hg qapplied
26 hg log --template '{rev} {desc}\n'
27
28 hg qnew d
29 hg qnew e
30 hg qnew f
31
32 hg qdel -f e
33 hg qdel -f d e
34 hg qapplied
35 hg log --template '{rev} {desc}\n'
@@ -0,0 +1,23 b''
1 adding base
2 abort: cannot delete applied patch c
3 Now at: b
4 a
5 b
6 a
7 b
8 series
9 status
10 Now at: a
11 a
12 b
13 series
14 status
15 1 New patch: a
16 0 base
17 abort: patch e not at base
18 f
19 4 New patch: f
20 3 New patch: e
21 2 New patch: d
22 1 New patch: a
23 0 base
@@ -483,24 +483,35 b' class queue:'
483 tr.close()
483 tr.close()
484 return (err, n)
484 return (err, n)
485
485
486 def delete(self, repo, patches, keep=False):
486 def delete(self, repo, patches, opts):
487 realpatches = []
487 realpatches = []
488 appliedbase = 0
489 forget = opts.get('forget')
488 for patch in patches:
490 for patch in patches:
489 patch = self.lookup(patch, strict=True)
491 patch = self.lookup(patch, strict=True)
490 info = self.isapplied(patch)
492 info = self.isapplied(patch)
491 if info:
493 if info and not forget:
492 raise util.Abort(_("cannot delete applied patch %s") % patch)
494 raise util.Abort(_("cannot delete applied patch %s") % patch)
493 if patch not in self.series:
495 if patch not in self.series:
494 raise util.Abort(_("patch %s not in series file") % patch)
496 raise util.Abort(_("patch %s not in series file") % patch)
497 if forget:
498 if not info:
499 raise util.Abort(_("cannot forget unapplied patch %s") % patch)
500 if info[0] != appliedbase:
501 raise util.Abort(_("patch %s not at base") % patch)
502 appliedbase += 1
495 realpatches.append(patch)
503 realpatches.append(patch)
496
504
497 if not keep:
505 if not opts.get('keep'):
498 r = self.qrepo()
506 r = self.qrepo()
499 if r:
507 if r:
500 r.remove(realpatches, True)
508 r.remove(realpatches, True)
501 else:
509 else:
502 os.unlink(self.join(patch))
510 os.unlink(self.join(patch))
503
511
512 if forget:
513 del self.applied[:appliedbase]
514 self.applied_dirty = 1
504 indices = [self.find_series(p) for p in realpatches]
515 indices = [self.find_series(p) for p in realpatches]
505 indices.sort()
516 indices.sort()
506 for i in indices[-1::-1]:
517 for i in indices[-1::-1]:
@@ -1306,10 +1317,15 b' class queue:'
1306 def delete(ui, repo, patch, *patches, **opts):
1317 def delete(ui, repo, patch, *patches, **opts):
1307 """remove patches from queue
1318 """remove patches from queue
1308
1319
1309 The patches must not be applied.
1320 With --forget, mq will stop managing the named patches. The
1310 With -k, the patch files are preserved in the patch directory."""
1321 patches must be applied and at the base of the stack. This option
1322 is useful when the patches have been applied upstream.
1323
1324 Otherwise, the patches must not be applied.
1325
1326 With --keep, the patch files are preserved in the patch directory."""
1311 q = repo.mq
1327 q = repo.mq
1312 q.delete(repo, (patch,) + patches, keep=opts.get('keep'))
1328 q.delete(repo, (patch,) + patches, opts)
1313 q.save_dirty()
1329 q.save_dirty()
1314 return 0
1330 return 0
1315
1331
@@ -1917,8 +1933,9 b' cmdtable = {'
1917 'hg qdiff [-I] [-X] [FILE]...'),
1933 'hg qdiff [-I] [-X] [FILE]...'),
1918 "qdelete|qremove|qrm":
1934 "qdelete|qremove|qrm":
1919 (delete,
1935 (delete,
1920 [('k', 'keep', None, _('keep patch file'))],
1936 [('f', 'forget', None, _('stop managing an applied patch')),
1921 'hg qdelete [-k] PATCH'),
1937 ('k', 'keep', None, _('keep patch file'))],
1938 'hg qdelete [-f] [-k] PATCH'),
1922 'qfold':
1939 'qfold':
1923 (fold,
1940 (fold,
1924 [('e', 'edit', None, _('edit patch header')),
1941 [('e', 'edit', None, _('edit patch header')),
General Comments 0
You need to be logged in to leave comments. Login now