Mercurial > hg
comparison hgext/mq.py @ 4239:417c2068cb92
Simplified qseries and hg qapplied to fix some bugs caused by optimization:
- hg qapplied -v now works consistendly to hg qunapplied -v, i.e. showing
guarded (or unapplied because they were guarded during hg qpush) patches.
- hg qapplied <patchname> now works again
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sun, 18 Mar 2007 12:20:15 +0100 |
parents | ce6c364ebb2a |
children | 7c59ade0f0d6 |
comparison
equal
deleted
inserted
replaced
4238:ce6c364ebb2a | 4239:417c2068cb92 |
---|---|
1109 if pushable: | 1109 if pushable: |
1110 unapplied.append((i, self.series[i])) | 1110 unapplied.append((i, self.series[i])) |
1111 self.explain_pushable(i) | 1111 self.explain_pushable(i) |
1112 return unapplied | 1112 return unapplied |
1113 | 1113 |
1114 def qseries(self, repo, missing=None, start=0, length=0, status=None, | 1114 def qseries(self, repo, missing=None, start=0, length=None, status=None, |
1115 summary=False): | 1115 summary=False): |
1116 def displayname(patchname): | 1116 def displayname(patchname): |
1117 if summary: | 1117 if summary: |
1118 msg = self.readheaders(patchname)[0] | 1118 msg = self.readheaders(patchname)[0] |
1119 msg = msg and ': ' + msg[0] or ': ' | 1119 msg = msg and ': ' + msg[0] or ': ' |
1120 else: | 1120 else: |
1121 msg = '' | 1121 msg = '' |
1122 return '%s%s' % (patchname, msg) | 1122 return '%s%s' % (patchname, msg) |
1123 | 1123 |
1124 def pname(i): | |
1125 if status == 'A': | |
1126 return self.applied[i].name | |
1127 else: | |
1128 return self.series[i] | |
1129 | |
1130 applied = dict.fromkeys([p.name for p in self.applied]) | 1124 applied = dict.fromkeys([p.name for p in self.applied]) |
1131 if not length: | 1125 if length is None: |
1132 length = len(self.series) - start | 1126 length = len(self.series) - start |
1133 if not missing: | 1127 if not missing: |
1134 for i in xrange(start, start+length): | 1128 for i in xrange(start, start+length): |
1129 patch = self.series[i] | |
1130 if patch in applied: | |
1131 stat = 'A' | |
1132 elif self.pushable(i)[0]: | |
1133 stat = 'U' | |
1134 else: | |
1135 stat = 'G' | |
1135 pfx = '' | 1136 pfx = '' |
1136 patch = pname(i) | |
1137 if self.ui.verbose: | 1137 if self.ui.verbose: |
1138 if patch in applied: | |
1139 stat = 'A' | |
1140 elif self.pushable(i)[0]: | |
1141 stat = 'U' | |
1142 else: | |
1143 stat = 'G' | |
1144 pfx = '%d %s ' % (i, stat) | 1138 pfx = '%d %s ' % (i, stat) |
1145 elif status == 'U' and not self.pushable(i)[0]: | 1139 elif status and status != stat: |
1146 continue | 1140 continue |
1147 self.ui.write('%s%s\n' % (pfx, displayname(patch))) | 1141 self.ui.write('%s%s\n' % (pfx, displayname(patch))) |
1148 else: | 1142 else: |
1149 msng_list = [] | 1143 msng_list = [] |
1150 for root, dirs, files in os.walk(self.path): | 1144 for root, dirs, files in os.walk(self.path): |
1424 if patch: | 1418 if patch: |
1425 if patch not in q.series: | 1419 if patch not in q.series: |
1426 raise util.Abort(_("patch %s is not in series file") % patch) | 1420 raise util.Abort(_("patch %s is not in series file") % patch) |
1427 end = q.series.index(patch) + 1 | 1421 end = q.series.index(patch) + 1 |
1428 else: | 1422 else: |
1429 end = len(q.applied) | 1423 end = q.series_end(True) |
1430 if not end: | |
1431 return | |
1432 | |
1433 return q.qseries(repo, length=end, status='A', summary=opts.get('summary')) | 1424 return q.qseries(repo, length=end, status='A', summary=opts.get('summary')) |
1434 | 1425 |
1435 def unapplied(ui, repo, patch=None, **opts): | 1426 def unapplied(ui, repo, patch=None, **opts): |
1436 """print the patches not yet applied""" | 1427 """print the patches not yet applied""" |
1437 q = repo.mq | 1428 q = repo.mq |