comparison hgext/mq.py @ 10824:18def0d5692d

qseries: make use of output labeling
author Brodie Rao <brodie@bitheap.org>
date Fri, 02 Apr 2010 15:22:14 -0500
parents 581d5e3095ef
children 717c35d55fb3
comparison
equal deleted inserted replaced
10823:581d5e3095ef 10824:18def0d5692d
1414 self.explain_pushable(i) 1414 self.explain_pushable(i)
1415 return unapplied 1415 return unapplied
1416 1416
1417 def qseries(self, repo, missing=None, start=0, length=None, status=None, 1417 def qseries(self, repo, missing=None, start=0, length=None, status=None,
1418 summary=False): 1418 summary=False):
1419 def displayname(pfx, patchname): 1419 def displayname(pfx, patchname, state):
1420 if summary: 1420 if summary:
1421 ph = patchheader(self.join(patchname), self.plainmode) 1421 ph = patchheader(self.join(patchname), self.plainmode)
1422 msg = ph.message and ph.message[0] or '' 1422 msg = ph.message and ph.message[0] or ''
1423 if self.ui.interactive(): 1423 if self.ui.interactive():
1424 width = util.termwidth() - len(pfx) - len(patchname) - 2 1424 width = util.termwidth() - len(pfx) - len(patchname) - 2
1427 else: 1427 else:
1428 msg = '' 1428 msg = ''
1429 msg = "%s%s: %s" % (pfx, patchname, msg) 1429 msg = "%s%s: %s" % (pfx, patchname, msg)
1430 else: 1430 else:
1431 msg = pfx + patchname 1431 msg = pfx + patchname
1432 self.ui.write(msg + '\n') 1432 self.ui.write(msg + '\n', label='qseries.' + state)
1433 1433
1434 applied = set([p.name for p in self.applied]) 1434 applied = set([p.name for p in self.applied])
1435 if length is None: 1435 if length is None:
1436 length = len(self.series) - start 1436 length = len(self.series) - start
1437 if not missing: 1437 if not missing:
1438 if self.ui.verbose: 1438 if self.ui.verbose:
1439 idxwidth = len(str(start + length - 1)) 1439 idxwidth = len(str(start + length - 1))
1440 for i in xrange(start, start + length): 1440 for i in xrange(start, start + length):
1441 patch = self.series[i] 1441 patch = self.series[i]
1442 if patch in applied: 1442 if patch in applied:
1443 stat = 'A' 1443 char, state = 'A', 'applied'
1444 elif self.pushable(i)[0]: 1444 elif self.pushable(i)[0]:
1445 stat = 'U' 1445 char, state = 'U', 'unapplied'
1446 else: 1446 else:
1447 stat = 'G' 1447 char, state = 'G', 'guarded'
1448 pfx = '' 1448 pfx = ''
1449 if self.ui.verbose: 1449 if self.ui.verbose:
1450 pfx = '%*d %s ' % (idxwidth, i, stat) 1450 pfx = '%*d %s ' % (idxwidth, i, char)
1451 elif status and status != stat: 1451 elif status and status != char:
1452 continue 1452 continue
1453 displayname(pfx, patch) 1453 displayname(pfx, patch, state)
1454 else: 1454 else:
1455 msng_list = [] 1455 msng_list = []
1456 for root, dirs, files in os.walk(self.path): 1456 for root, dirs, files in os.walk(self.path):
1457 d = root[len(self.path) + 1:] 1457 d = root[len(self.path) + 1:]
1458 for f in files: 1458 for f in files:
1462 self.guards_path) 1462 self.guards_path)
1463 and not fl.startswith('.')): 1463 and not fl.startswith('.')):
1464 msng_list.append(fl) 1464 msng_list.append(fl)
1465 for x in sorted(msng_list): 1465 for x in sorted(msng_list):
1466 pfx = self.ui.verbose and ('D ') or '' 1466 pfx = self.ui.verbose and ('D ') or ''
1467 displayname(pfx, x) 1467 displayname(pfx, x, 'missing')
1468 1468
1469 def issaveline(self, l): 1469 def issaveline(self, l):
1470 if l.name == '.hg.patches.save.line': 1470 if l.name == '.hg.patches.save.line':
1471 return True 1471 return True
1472 1472