##// END OF EJS Templates
mq: rename read_series as parse_series, make simpler and faster
Vadim Gelfer -
r2767:60683ab1 default
parent child Browse files
Show More
@@ -57,7 +57,7 b' class queue:'
57
57
58 if os.path.exists(os.path.join(self.path, self.series_path)):
58 if os.path.exists(os.path.join(self.path, self.series_path)):
59 self.full_series = self.opener(self.series_path).read().splitlines()
59 self.full_series = self.opener(self.series_path).read().splitlines()
60 self.read_series(self.full_series)
60 self.parse_series()
61
61
62 if os.path.exists(os.path.join(self.path, self.status_path)):
62 if os.path.exists(os.path.join(self.path, self.status_path)):
63 self.applied = self.opener(self.status_path).read().splitlines()
63 self.applied = self.opener(self.status_path).read().splitlines()
@@ -75,18 +75,12 b' class queue:'
75 index += 1
75 index += 1
76 return None
76 return None
77
77
78 def read_series(self, list):
78 def parse_series(self):
79 def matcher(list):
80 pre = re.compile("(\s*)([^#]+)")
81 for l in list:
82 m = pre.match(l)
83 if m:
84 s = m.group(2)
85 s = s.rstrip()
86 if len(s) > 0:
87 yield s
88 self.series = []
79 self.series = []
89 self.series = [ x for x in matcher(list) ]
80 for l in self.full_series:
81 s = l.split('#', 1)[0].strip()
82 if s:
83 self.series.append(s)
90
84
91 def save_dirty(self):
85 def save_dirty(self):
92 if self.applied_dirty:
86 if self.applied_dirty:
@@ -397,7 +391,7 b' class queue:'
397 os.unlink(os.path.join(self.path, patch))
391 os.unlink(os.path.join(self.path, patch))
398 i = self.find_series(patch)
392 i = self.find_series(patch)
399 del self.full_series[i]
393 del self.full_series[i]
400 self.read_series(self.full_series)
394 self.parse_series()
401 self.series_dirty = 1
395 self.series_dirty = 1
402
396
403 def check_toppatch(self, repo):
397 def check_toppatch(self, repo):
@@ -435,7 +429,7 b' class queue:'
435 raise util.Abort(_("repo commit failed"))
429 raise util.Abort(_("repo commit failed"))
436 self.full_series[insert:insert] = [patch]
430 self.full_series[insert:insert] = [patch]
437 self.applied.append(revlog.hex(n) + ":" + patch)
431 self.applied.append(revlog.hex(n) + ":" + patch)
438 self.read_series(self.full_series)
432 self.parse_series()
439 self.series_dirty = 1
433 self.series_dirty = 1
440 self.applied_dirty = 1
434 self.applied_dirty = 1
441 p = self.opener(patch, "w")
435 p = self.opener(patch, "w")
@@ -1012,7 +1006,7 b' class queue:'
1012 self.ui.warn("restoring status: %s\n" % lines[0])
1006 self.ui.warn("restoring status: %s\n" % lines[0])
1013 self.full_series = series
1007 self.full_series = series
1014 self.applied = applied
1008 self.applied = applied
1015 self.read_series(self.full_series)
1009 self.parse_series()
1016 self.series_dirty = 1
1010 self.series_dirty = 1
1017 self.applied_dirty = 1
1011 self.applied_dirty = 1
1018 heads = repo.changelog.heads()
1012 heads = repo.changelog.heads()
@@ -1159,7 +1153,7 b' class queue:'
1159 % patch)
1153 % patch)
1160 index = self.full_series_end() + i
1154 index = self.full_series_end() + i
1161 self.full_series[index:index] = [patch]
1155 self.full_series[index:index] = [patch]
1162 self.read_series(self.full_series)
1156 self.parse_series()
1163 self.ui.warn("adding %s to series file\n" % patch)
1157 self.ui.warn("adding %s to series file\n" % patch)
1164 i += 1
1158 i += 1
1165 added.append(patch)
1159 added.append(patch)
@@ -1487,7 +1481,7 b' def rename(ui, repo, patch, name=None, *'
1487 ui.write('Renaming %s to %s\n' % (patch, name))
1481 ui.write('Renaming %s to %s\n' % (patch, name))
1488 i = q.find_series(patch)
1482 i = q.find_series(patch)
1489 q.full_series[i] = name
1483 q.full_series[i] = name
1490 q.read_series(q.full_series)
1484 q.parse_series()
1491 q.series_dirty = 1
1485 q.series_dirty = 1
1492
1486
1493 info = q.isapplied(patch)
1487 info = q.isapplied(patch)
General Comments 0
You need to be logged in to leave comments. Login now