380 err = 1 |
380 err = 1 |
381 break |
381 break |
382 tr.close() |
382 tr.close() |
383 return (err, n) |
383 return (err, n) |
384 |
384 |
385 def delete(self, repo, patch): |
385 def delete(self, repo, patch, force=False): |
386 patch = self.lookup(patch, strict=True) |
386 patch = self.lookup(patch, strict=True) |
387 info = self.isapplied(patch) |
387 info = self.isapplied(patch) |
388 if info: |
388 if info: |
389 raise util.Abort(_("cannot delete applied patch %s") % patch) |
389 raise util.Abort(_("cannot delete applied patch %s") % patch) |
390 if patch not in self.series: |
390 if patch not in self.series: |
391 raise util.Abort(_("patch %s not in series file") % patch) |
391 raise util.Abort(_("patch %s not in series file") % patch) |
|
392 if force: |
|
393 r = self.qrepo() |
|
394 if r: |
|
395 r.remove([patch], True) |
|
396 else: |
|
397 os.unlink(os.path.join(self.path, patch)) |
392 i = self.find_series(patch) |
398 i = self.find_series(patch) |
393 del self.full_series[i] |
399 del self.full_series[i] |
394 self.read_series(self.full_series) |
400 self.read_series(self.full_series) |
395 self.series_dirty = 1 |
401 self.series_dirty = 1 |
396 |
402 |
1157 qrepo = self.qrepo() |
1163 qrepo = self.qrepo() |
1158 if qrepo: |
1164 if qrepo: |
1159 qrepo.add(added) |
1165 qrepo.add(added) |
1160 |
1166 |
1161 def delete(ui, repo, patch, **opts): |
1167 def delete(ui, repo, patch, **opts): |
1162 """remove a patch from the series file""" |
1168 """remove a patch from the series file |
|
1169 |
|
1170 The patch must not be applied. |
|
1171 With -f, deletes the patch file as well as the series entry.""" |
1163 q = repo.mq |
1172 q = repo.mq |
1164 q.delete(repo, patch) |
1173 q.delete(repo, patch, force=opts.get('force')) |
1165 q.save_dirty() |
1174 q.save_dirty() |
1166 return 0 |
1175 return 0 |
1167 |
1176 |
1168 def applied(ui, repo, patch=None, **opts): |
1177 def applied(ui, repo, patch=None, **opts): |
1169 """print the patches already applied""" |
1178 """print the patches already applied""" |
1557 "qcommit|qci": |
1566 "qcommit|qci": |
1558 (commit, |
1567 (commit, |
1559 commands.table["^commit|ci"][1], |
1568 commands.table["^commit|ci"][1], |
1560 'hg qcommit [OPTION]... [FILE]...'), |
1569 'hg qcommit [OPTION]... [FILE]...'), |
1561 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), |
1570 "^qdiff": (diff, [], 'hg qdiff [FILE]...'), |
1562 "qdelete": (delete, [], 'hg qdelete PATCH'), |
1571 "qdelete": |
|
1572 (delete, |
|
1573 [('f', 'force', None, _('delete patch file'))], |
|
1574 'hg qdelete [-f] PATCH'), |
1563 'qfold': (fold, [], 'hg qfold PATCH...'), |
1575 'qfold': (fold, [], 'hg qfold PATCH...'), |
1564 'qheader': (header, [], |
1576 'qheader': (header, [], |
1565 _('hg qheader [PATCH]')), |
1577 _('hg qheader [PATCH]')), |
1566 "^qimport": |
1578 "^qimport": |
1567 (qimport, |
1579 (qimport, |