hgext/mq.py
changeset 2698 c1123e83c8e2
parent 2697 6c540dd14c38
child 2699 f8bcaf5696d5
equal deleted inserted replaced
2697:6c540dd14c38 2698:c1123e83c8e2
   416                 raise util.Abort(_("Local changes found, refresh first"))
   416                 raise util.Abort(_("Local changes found, refresh first"))
   417             else:
   417             else:
   418                 commitfiles = c + a + r
   418                 commitfiles = c + a + r
   419         self.check_toppatch(repo)
   419         self.check_toppatch(repo)
   420         wlock = repo.wlock()
   420         wlock = repo.wlock()
   421         insert = self.series_end()
   421         insert = self.full_series_end()
   422         if msg:
   422         if msg:
   423             n = repo.commit(commitfiles, "[mq]: %s" % msg, force=True,
   423             n = repo.commit(commitfiles, "[mq]: %s" % msg, force=True,
   424                             wlock=wlock)
   424                             wlock=wlock)
   425         else:
   425         else:
   426             n = repo.commit(commitfiles,
   426             n = repo.commit(commitfiles,
  1043             self.ui.warn("repo commit failed\n")
  1043             self.ui.warn("repo commit failed\n")
  1044             return 1
  1044             return 1
  1045         self.applied.append(revlog.hex(n) + ":" + '.hg.patches.save.line')
  1045         self.applied.append(revlog.hex(n) + ":" + '.hg.patches.save.line')
  1046         self.applied_dirty = 1
  1046         self.applied_dirty = 1
  1047 
  1047 
       
  1048     def full_series_end(self):
       
  1049         if len(self.applied) > 0:
       
  1050             (top, p) = self.applied[-1].split(':')
       
  1051             end = self.find_series(p)
       
  1052             if end == None:
       
  1053                 return len(self.full_series)
       
  1054             return end + 1
       
  1055         return 0
       
  1056 
  1048     def series_end(self):
  1057     def series_end(self):
  1049         end = 0
  1058         end = 0
  1050         if len(self.applied) > 0:
  1059         if len(self.applied) > 0:
  1051             (top, p) = self.applied[-1].split(':')
  1060             (top, p) = self.applied[-1].split(':')
  1052             try:
  1061             try:
  1130                 patchf = self.opener(patch, "w")
  1139                 patchf = self.opener(patch, "w")
  1131                 patchf.write(text)
  1140                 patchf.write(text)
  1132             if patch in self.series:
  1141             if patch in self.series:
  1133                 self.ui.warn("patch %s is already in the series file\n" % patch)
  1142                 self.ui.warn("patch %s is already in the series file\n" % patch)
  1134                 sys.exit(1)
  1143                 sys.exit(1)
  1135             index = self.series_end() + i
  1144             index = self.full_series_end() + i
  1136             self.full_series[index:index] = [patch]
  1145             self.full_series[index:index] = [patch]
  1137             self.read_series(self.full_series)
  1146             self.read_series(self.full_series)
  1138             self.ui.warn("adding %s to series file\n" % patch)
  1147             self.ui.warn("adding %s to series file\n" % patch)
  1139             i += 1
  1148             i += 1
  1140             added.append(patch)
  1149             added.append(patch)