Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/mq.py @ 3085:dc784839516d
mq: add qdelete --forget option
This removes an applied patch from the series and status files without
popping it. It is useful when an mq patch has been applied upstream.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 14 Sep 2006 15:35:55 +0200 |
parents | fd1479e30aaf |
children | 7fa3d38a99b6 |
comparison
equal
deleted
inserted
replaced
3084:fd1479e30aaf | 3085:dc784839516d |
---|---|
481 err = 1 | 481 err = 1 |
482 break | 482 break |
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]: |
507 del self.full_series[i] | 518 del self.full_series[i] |
508 self.parse_series() | 519 self.parse_series() |
1304 qrepo.add(added) | 1315 qrepo.add(added) |
1305 | 1316 |
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 |
1316 def applied(ui, repo, patch=None, **opts): | 1332 def applied(ui, repo, patch=None, **opts): |
1317 """print the patches already applied""" | 1333 """print the patches already applied""" |
1915 [('I', 'include', [], _('include names matching the given patterns')), | 1931 [('I', 'include', [], _('include names matching the given patterns')), |
1916 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 1932 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
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')), |
1925 ('k', 'keep', None, _('keep folded patch files')), | 1942 ('k', 'keep', None, _('keep folded patch files')), |
1926 ('m', 'message', '', _('set patch header to <text>')), | 1943 ('m', 'message', '', _('set patch header to <text>')), |