hgext/mq.py
changeset 8527 f9a80054dd3c
parent 8525 b169ba60eebe
child 8624 2b3dec0ef3ae
equal deleted inserted replaced
8526:f78eadbb5769 8527:f9a80054dd3c
   428         ctx = repo[rev]
   428         ctx = repo[rev]
   429         ret = hg.merge(repo, rev)
   429         ret = hg.merge(repo, rev)
   430         if ret:
   430         if ret:
   431             raise util.Abort(_("update returned %d") % ret)
   431             raise util.Abort(_("update returned %d") % ret)
   432         n = repo.commit(None, ctx.description(), ctx.user(), force=1)
   432         n = repo.commit(None, ctx.description(), ctx.user(), force=1)
   433         if n == None:
   433         if n is None:
   434             raise util.Abort(_("repo commit failed"))
   434             raise util.Abort(_("repo commit failed"))
   435         try:
   435         try:
   436             ph = mergeq.readheaders(patch)
   436             ph = mergeq.readheaders(patch)
   437         except:
   437         except:
   438             raise util.Abort(_("unable to read %s") % patch)
   438             raise util.Abort(_("unable to read %s") % patch)
   601             files = patch.updatedir(self.ui, repo, files)
   601             files = patch.updatedir(self.ui, repo, files)
   602             match = cmdutil.matchfiles(repo, files or [])
   602             match = cmdutil.matchfiles(repo, files or [])
   603             n = repo.commit(files, message, ph.user, ph.date, match=match,
   603             n = repo.commit(files, message, ph.user, ph.date, match=match,
   604                             force=True)
   604                             force=True)
   605 
   605 
   606             if n == None:
   606             if n is None:
   607                 raise util.Abort(_("repo commit failed"))
   607                 raise util.Abort(_("repo commit failed"))
   608 
   608 
   609             if update_status:
   609             if update_status:
   610                 self.applied.append(statusentry(hex(n), patchname))
   610                 self.applied.append(statusentry(hex(n), patchname))
   611 
   611 
   765 
   765 
   766                 if hasattr(msg, '__call__'):
   766                 if hasattr(msg, '__call__'):
   767                     msg = msg()
   767                     msg = msg()
   768                 commitmsg = msg and msg or ("[mq]: %s" % patchfn)
   768                 commitmsg = msg and msg or ("[mq]: %s" % patchfn)
   769                 n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
   769                 n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True)
   770                 if n == None:
   770                 if n is None:
   771                     raise util.Abort(_("repo commit failed"))
   771                     raise util.Abort(_("repo commit failed"))
   772                 try:
   772                 try:
   773                     self.full_series[insert:insert] = [patchfn]
   773                     self.full_series[insert:insert] = [patchfn]
   774                     self.applied.append(statusentry(hex(n), patchfn))
   774                     self.applied.append(statusentry(hex(n), patchfn))
   775                     self.parse_series()
   775                     self.parse_series()
   858                     return self.series[self.series_end(True)-1]
   858                     return self.series[self.series_end(True)-1]
   859                 if s == 'qbase':
   859                 if s == 'qbase':
   860                     return self.series[0]
   860                     return self.series[0]
   861             return None
   861             return None
   862 
   862 
   863         if patch == None:
   863         if patch is None:
   864             return None
   864             return None
   865         if patch in self.series:
   865         if patch in self.series:
   866             return patch
   866             return patch
   867 
   867 
   868         if not os.path.isfile(self.join(patch)):
   868         if not os.path.isfile(self.join(patch)):
  1420                 file_ = se.name
  1420                 file_ = se.name
  1421                 if se.rev:
  1421                 if se.rev:
  1422                     applied.append(se)
  1422                     applied.append(se)
  1423                 else:
  1423                 else:
  1424                     series.append(file_)
  1424                     series.append(file_)
  1425         if datastart == None:
  1425         if datastart is None:
  1426             self.ui.warn(_("No saved patch data found\n"))
  1426             self.ui.warn(_("No saved patch data found\n"))
  1427             return 1
  1427             return 1
  1428         self.ui.warn(_("restoring status: %s\n") % lines[0])
  1428         self.ui.warn(_("restoring status: %s\n") % lines[0])
  1429         self.full_series = series
  1429         self.full_series = series
  1430         self.applied = applied
  1430         self.applied = applied
  1484 
  1484 
  1485     def full_series_end(self):
  1485     def full_series_end(self):
  1486         if len(self.applied) > 0:
  1486         if len(self.applied) > 0:
  1487             p = self.applied[-1].name
  1487             p = self.applied[-1].name
  1488             end = self.find_series(p)
  1488             end = self.find_series(p)
  1489             if end == None:
  1489             if end is None:
  1490                 return len(self.full_series)
  1490                 return len(self.full_series)
  1491             return end + 1
  1491             return end + 1
  1492         return 0
  1492         return 0
  1493 
  1493 
  1494     def series_end(self, all_patches=False):
  1494     def series_end(self, all_patches=False):
  2088     maxname = None
  2088     maxname = None
  2089     for f in names:
  2089     for f in names:
  2090         m = namere.match(f)
  2090         m = namere.match(f)
  2091         if m:
  2091         if m:
  2092             index = int(m.group(1))
  2092             index = int(m.group(1))
  2093             if maxindex == None or index > maxindex:
  2093             if maxindex is None or index > maxindex:
  2094                 maxindex = index
  2094                 maxindex = index
  2095                 maxname = f
  2095                 maxname = f
  2096     if maxname:
  2096     if maxname:
  2097         return (os.path.join(directory, maxname), maxindex)
  2097         return (os.path.join(directory, maxname), maxindex)
  2098     return (None, None)
  2098     return (None, None)