hgext/mq.py
changeset 2890 790fd342b6c7
parent 2889 57b88b86a845
child 2907 b70740aefa4d
equal deleted inserted replaced
2889:57b88b86a845 2890:790fd342b6c7
   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, keep=False):
   509     def delete(self, repo, patches, keep=False):
   510         patch = self.lookup(patch, strict=True)
   510         realpatches = []
   511         info = self.isapplied(patch)
   511         for patch in patches:
   512         if info:
   512             patch = self.lookup(patch, strict=True)
   513             raise util.Abort(_("cannot delete applied patch %s") % patch)
   513             info = self.isapplied(patch)
   514         if patch not in self.series:
   514             if info:
   515             raise util.Abort(_("patch %s not in series file") % patch)
   515                 raise util.Abort(_("cannot delete applied patch %s") % patch)
       
   516             if patch not in self.series:
       
   517                 raise util.Abort(_("patch %s not in series file") % patch)
       
   518             realpatches.append(patch)
       
   519 
   516         if not keep:
   520         if not keep:
   517             r = self.qrepo()
   521             r = self.qrepo()
   518             if r:
   522             if r:
   519                 r.remove([patch], True)
   523                 r.remove(realpatches, True)
   520             else:
   524             else:
   521                 os.unlink(self.join(patch))
   525                 os.unlink(self.join(patch))
   522         i = self.find_series(patch)
   526 
   523         del self.full_series[i]
   527         indices = [self.find_series(p) for p in realpatches]
       
   528         indices.sort()
       
   529         for i in indices[-1::-1]:
       
   530             del self.full_series[i]
   524         self.parse_series()
   531         self.parse_series()
   525         self.series_dirty = 1
   532         self.series_dirty = 1
   526 
   533 
   527     def check_toppatch(self, repo):
   534     def check_toppatch(self, repo):
   528         if len(self.applied) > 0:
   535         if len(self.applied) > 0:
  1298         self.series_dirty = 1
  1305         self.series_dirty = 1
  1299         qrepo = self.qrepo()
  1306         qrepo = self.qrepo()
  1300         if qrepo:
  1307         if qrepo:
  1301             qrepo.add(added)
  1308             qrepo.add(added)
  1302 
  1309 
  1303 def delete(ui, repo, patch, **opts):
  1310 def delete(ui, repo, patch, *patches, **opts):
  1304     """remove a patch from the series file
  1311     """remove patches from queue
  1305 
  1312 
  1306     The patch must not be applied.
  1313     The patches must not be applied.
  1307     With -k, the patch file is preserved in the patch directory."""
  1314     With -k, the patch files are preserved in the patch directory."""
  1308     q = repo.mq
  1315     q = repo.mq
  1309     q.delete(repo, patch, keep=opts.get('keep'))
  1316     q.delete(repo, (patch,) + patches, keep=opts.get('keep'))
  1310     q.save_dirty()
  1317     q.save_dirty()
  1311     return 0
  1318     return 0
  1312 
  1319 
  1313 def applied(ui, repo, patch=None, **opts):
  1320 def applied(ui, repo, patch=None, **opts):
  1314     """print the patches already applied"""
  1321     """print the patches already applied"""