comparison hgext/mq.py @ 4243:815ad65cfca9

merge with crew-stable
author Thomas Arendsen Hein <thomas@intevation.de>
date Sun, 18 Mar 2007 20:44:58 +0100
parents 6cb5be6bd70f e1cdf5f6386e
children 1cc5fc1d0994
comparison
equal deleted inserted replaced
4237:da6b14877195 4243:815ad65cfca9
1144 if pushable: 1144 if pushable:
1145 unapplied.append((i, self.series[i])) 1145 unapplied.append((i, self.series[i]))
1146 self.explain_pushable(i) 1146 self.explain_pushable(i)
1147 return unapplied 1147 return unapplied
1148 1148
1149 def qseries(self, repo, missing=None, start=0, length=0, status=None, 1149 def qseries(self, repo, missing=None, start=0, length=None, status=None,
1150 summary=False): 1150 summary=False):
1151 def displayname(patchname): 1151 def displayname(patchname):
1152 if summary: 1152 if summary:
1153 msg = self.readheaders(patchname)[0] 1153 msg = self.readheaders(patchname)[0]
1154 msg = msg and ': ' + msg[0] or ': ' 1154 msg = msg and ': ' + msg[0] or ': '
1155 else: 1155 else:
1156 msg = '' 1156 msg = ''
1157 return '%s%s' % (patchname, msg) 1157 return '%s%s' % (patchname, msg)
1158 1158
1159 def pname(i):
1160 if status == 'A':
1161 return self.applied[i].name
1162 else:
1163 return self.series[i]
1164
1165 applied = dict.fromkeys([p.name for p in self.applied]) 1159 applied = dict.fromkeys([p.name for p in self.applied])
1166 if not length: 1160 if length is None:
1167 length = len(self.series) - start 1161 length = len(self.series) - start
1168 if not missing: 1162 if not missing:
1169 for i in xrange(start, start+length): 1163 for i in xrange(start, start+length):
1164 patch = self.series[i]
1165 if patch in applied:
1166 stat = 'A'
1167 elif self.pushable(i)[0]:
1168 stat = 'U'
1169 else:
1170 stat = 'G'
1170 pfx = '' 1171 pfx = ''
1171 patch = pname(i)
1172 if self.ui.verbose: 1172 if self.ui.verbose:
1173 if patch in applied:
1174 stat = 'A'
1175 elif self.pushable(i)[0]:
1176 stat = 'U'
1177 else:
1178 stat = 'G'
1179 pfx = '%d %s ' % (i, stat) 1173 pfx = '%d %s ' % (i, stat)
1174 elif status and status != stat:
1175 continue
1180 self.ui.write('%s%s\n' % (pfx, displayname(patch))) 1176 self.ui.write('%s%s\n' % (pfx, displayname(patch)))
1181 else: 1177 else:
1182 msng_list = [] 1178 msng_list = []
1183 for root, dirs, files in os.walk(self.path): 1179 for root, dirs, files in os.walk(self.path):
1184 d = root[len(self.path) + 1:] 1180 d = root[len(self.path) + 1:]
1185 for f in files: 1181 for f in files:
1186 fl = os.path.join(d, f) 1182 fl = os.path.join(d, f)
1187 if (fl not in self.series and 1183 if (fl not in self.series and
1188 fl not in (self.status_path, self.series_path) 1184 fl not in (self.status_path, self.series_path,
1185 self.guards_path)
1189 and not fl.startswith('.')): 1186 and not fl.startswith('.')):
1190 msng_list.append(fl) 1187 msng_list.append(fl)
1191 msng_list.sort() 1188 msng_list.sort()
1192 for x in msng_list: 1189 for x in msng_list:
1193 pfx = self.ui.verbose and ('D ') or '' 1190 pfx = self.ui.verbose and ('D ') or ''
1458 if patch: 1455 if patch:
1459 if patch not in q.series: 1456 if patch not in q.series:
1460 raise util.Abort(_("patch %s is not in series file") % patch) 1457 raise util.Abort(_("patch %s is not in series file") % patch)
1461 end = q.series.index(patch) + 1 1458 end = q.series.index(patch) + 1
1462 else: 1459 else:
1463 end = len(q.applied) 1460 end = q.series_end(True)
1464 if not end:
1465 return
1466
1467 return q.qseries(repo, length=end, status='A', summary=opts.get('summary')) 1461 return q.qseries(repo, length=end, status='A', summary=opts.get('summary'))
1468 1462
1469 def unapplied(ui, repo, patch=None, **opts): 1463 def unapplied(ui, repo, patch=None, **opts):
1470 """print the patches not yet applied""" 1464 """print the patches not yet applied"""
1471 q = repo.mq 1465 q = repo.mq
1472 if patch: 1466 if patch:
1473 if patch not in q.series: 1467 if patch not in q.series:
1474 raise util.Abort(_("patch %s is not in series file") % patch) 1468 raise util.Abort(_("patch %s is not in series file") % patch)
1475 start = q.series.index(patch) + 1 1469 start = q.series.index(patch) + 1
1476 else: 1470 else:
1477 start = q.series_end() 1471 start = q.series_end(True)
1478 q.qseries(repo, start=start, summary=opts.get('summary')) 1472 q.qseries(repo, start=start, status='U', summary=opts.get('summary'))
1479 1473
1480 def qimport(ui, repo, *filename, **opts): 1474 def qimport(ui, repo, *filename, **opts):
1481 """import a patch 1475 """import a patch
1482 1476
1483 The patch will have the same name as its source file unless you 1477 The patch will have the same name as its source file unless you
2160 ('k', 'keep', None, _('keep folded patch files')) 2154 ('k', 'keep', None, _('keep folded patch files'))
2161 ] + commands.commitopts, 2155 ] + commands.commitopts,
2162 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'), 2156 'hg qfold [-e] [-m <text>] [-l <file] PATCH...'),
2163 'qguard': (guard, [('l', 'list', None, _('list all patches and guards')), 2157 'qguard': (guard, [('l', 'list', None, _('list all patches and guards')),
2164 ('n', 'none', None, _('drop all guards'))], 2158 ('n', 'none', None, _('drop all guards'))],
2165 'hg qguard [PATCH] [+GUARD...] [-GUARD...]'), 2159 'hg qguard [PATCH] [+GUARD]... [-GUARD]...'),
2166 'qheader': (header, [], 2160 'qheader': (header, [],
2167 _('hg qheader [PATCH]')), 2161 _('hg qheader [PATCH]')),
2168 "^qimport": 2162 "^qimport":
2169 (qimport, 2163 (qimport,
2170 [('e', 'existing', None, 'import file in patch dir'), 2164 [('e', 'existing', None, 'import file in patch dir'),
2205 ('g', 'git', None, _('use git extended diff format')), 2199 ('g', 'git', None, _('use git extended diff format')),
2206 ('s', 'short', None, 'refresh only files already in the patch'), 2200 ('s', 'short', None, 'refresh only files already in the patch'),
2207 ('I', 'include', [], _('include names matching the given patterns')), 2201 ('I', 'include', [], _('include names matching the given patterns')),
2208 ('X', 'exclude', [], _('exclude names matching the given patterns')) 2202 ('X', 'exclude', [], _('exclude names matching the given patterns'))
2209 ] + commands.commitopts, 2203 ] + commands.commitopts,
2210 'hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] FILES...'), 2204 'hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'),
2211 'qrename|qmv': 2205 'qrename|qmv':
2212 (rename, [], 'hg qrename PATCH1 [PATCH2]'), 2206 (rename, [], 'hg qrename PATCH1 [PATCH2]'),
2213 "qrestore": 2207 "qrestore":
2214 (restore, 2208 (restore,
2215 [('d', 'delete', None, 'delete save entry'), 2209 [('d', 'delete', None, 'delete save entry'),
2226 [('n', 'none', None, _('disable all guards')), 2220 [('n', 'none', None, _('disable all guards')),
2227 ('s', 'series', None, _('list all guards in series file')), 2221 ('s', 'series', None, _('list all guards in series file')),
2228 ('', 'pop', None, 2222 ('', 'pop', None,
2229 _('pop to before first guarded applied patch')), 2223 _('pop to before first guarded applied patch')),
2230 ('', 'reapply', None, _('pop, then reapply patches'))], 2224 ('', 'reapply', None, _('pop, then reapply patches'))],
2231 'hg qselect [OPTION...] [GUARD...]'), 2225 'hg qselect [OPTION]... [GUARD]...'),
2232 "qseries": 2226 "qseries":
2233 (series, 2227 (series,
2234 [('m', 'missing', None, 'print patches not in series')] + seriesopts, 2228 [('m', 'missing', None, 'print patches not in series')] + seriesopts,
2235 'hg qseries [-ms]'), 2229 'hg qseries [-ms]'),
2236 "^strip": 2230 "^strip":