504 err = 1 |
504 err = 1 |
505 break |
505 break |
506 tr.close() |
506 tr.close() |
507 return (err, n) |
507 return (err, n) |
508 |
508 |
509 def delete(self, repo, patch, force=False): |
509 def delete(self, repo, patch, keep=False): |
510 patch = self.lookup(patch, strict=True) |
510 patch = self.lookup(patch, strict=True) |
511 info = self.isapplied(patch) |
511 info = self.isapplied(patch) |
512 if info: |
512 if info: |
513 raise util.Abort(_("cannot delete applied patch %s") % patch) |
513 raise util.Abort(_("cannot delete applied patch %s") % patch) |
514 if patch not in self.series: |
514 if patch not in self.series: |
515 raise util.Abort(_("patch %s not in series file") % patch) |
515 raise util.Abort(_("patch %s not in series file") % patch) |
516 if force: |
516 if not keep: |
517 r = self.qrepo() |
517 r = self.qrepo() |
518 if r: |
518 if r: |
519 r.remove([patch], True) |
519 r.remove([patch], True) |
520 else: |
520 else: |
521 os.unlink(self.join(patch)) |
521 os.unlink(self.join(patch)) |
1302 |
1302 |
1303 def delete(ui, repo, patch, **opts): |
1303 def delete(ui, repo, patch, **opts): |
1304 """remove a patch from the series file |
1304 """remove a patch from the series file |
1305 |
1305 |
1306 The patch must not be applied. |
1306 The patch must not be applied. |
1307 With -f, deletes the patch file as well as the series entry.""" |
1307 With -k, the patch file is preserved in the patch directory.""" |
1308 q = repo.mq |
1308 q = repo.mq |
1309 q.delete(repo, patch, force=opts.get('force')) |
1309 q.delete(repo, patch, keep=opts.get('keep')) |
1310 q.save_dirty() |
1310 q.save_dirty() |
1311 return 0 |
1311 return 0 |
1312 |
1312 |
1313 def applied(ui, repo, patch=None, **opts): |
1313 def applied(ui, repo, patch=None, **opts): |
1314 """print the patches already applied""" |
1314 """print the patches already applied""" |
1462 |
1462 |
1463 Patches must not yet be applied. Each patch will be successively |
1463 Patches must not yet be applied. Each patch will be successively |
1464 applied to the current patch in the order given. If all the |
1464 applied to the current patch in the order given. If all the |
1465 patches apply successfully, the current patch will be refreshed |
1465 patches apply successfully, the current patch will be refreshed |
1466 with the new cumulative patch, and the folded patches will |
1466 with the new cumulative patch, and the folded patches will |
1467 be deleted. With -f/--force, the folded patch files will |
1467 be deleted. With -k/--keep, the folded patch files will not |
1468 be removed afterwards. |
1468 be removed afterwards. |
1469 |
1469 |
1470 The header for each folded patch will be concatenated with |
1470 The header for each folded patch will be concatenated with |
1471 the current patch header, separated by a line of '* * *'.""" |
1471 the current patch header, separated by a line of '* * *'.""" |
1472 |
1472 |
1512 message = ui.edit(message, user or ui.username()) |
1512 message = ui.edit(message, user or ui.username()) |
1513 |
1513 |
1514 q.refresh(repo, msg=message) |
1514 q.refresh(repo, msg=message) |
1515 |
1515 |
1516 for patch in patches: |
1516 for patch in patches: |
1517 q.delete(repo, patch, force=opts['force']) |
1517 q.delete(repo, patch, keep=opts['keep']) |
1518 |
1518 |
1519 q.save_dirty() |
1519 q.save_dirty() |
1520 |
1520 |
1521 def guard(ui, repo, *args, **opts): |
1521 def guard(ui, repo, *args, **opts): |
1522 '''set or print guards for a patch |
1522 '''set or print guards for a patch |
1901 "qcommit|qci": |
1901 "qcommit|qci": |
1902 (commit, |
1902 (commit, |
1903 commands.table["^commit|ci"][1], |
1903 commands.table["^commit|ci"][1], |
1904 'hg qcommit [OPTION]... [FILE]...'), |
1904 'hg qcommit [OPTION]... [FILE]...'), |
1905 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), |
1905 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), |
1906 "qdelete": |
1906 "qdelete|qremove|qrm": |
1907 (delete, |
1907 (delete, |
1908 [('f', 'force', None, _('delete patch file'))], |
1908 [('k', 'keep', None, _('keep patch file'))], |
1909 'hg qdelete [-f] PATCH'), |
1909 'hg qdelete [-k] PATCH'), |
1910 'qfold': |
1910 'qfold': |
1911 (fold, |
1911 (fold, |
1912 [('e', 'edit', None, _('edit patch header')), |
1912 [('e', 'edit', None, _('edit patch header')), |
1913 ('f', 'force', None, _('delete folded patch files')), |
1913 ('k', 'keep', None, _('keep folded patch files')), |
1914 ('m', 'message', '', _('set patch header to <text>')), |
1914 ('m', 'message', '', _('set patch header to <text>')), |
1915 ('l', 'logfile', '', _('set patch header to contents of <file>'))], |
1915 ('l', 'logfile', '', _('set patch header to contents of <file>'))], |
1916 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'), |
1916 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'), |
1917 'qguard': (guard, [('l', 'list', None, _('list all patches and guards')), |
1917 'qguard': (guard, [('l', 'list', None, _('list all patches and guards')), |
1918 ('n', 'none', None, _('drop all guards'))], |
1918 ('n', 'none', None, _('drop all guards'))], |