Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 26433:3ad41638b4b4
changeset_printer: move _meaningful_parentrevs() to scmutil
It will be used by templatekw.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Sep 2015 12:29:09 +0900 |
parents | 0486c16ce621 |
children | 882b170ae616 |
comparison
equal
deleted
inserted
replaced
26432:39577d4520ab | 26433:3ad41638b4b4 |
---|---|
1193 label='log.%s' % ns.colorname) | 1193 label='log.%s' % ns.colorname) |
1194 if self.ui.debugflag: | 1194 if self.ui.debugflag: |
1195 # i18n: column positioning for "hg log" | 1195 # i18n: column positioning for "hg log" |
1196 self.ui.write(_("phase: %s\n") % ctx.phasestr(), | 1196 self.ui.write(_("phase: %s\n") % ctx.phasestr(), |
1197 label='log.phase') | 1197 label='log.phase') |
1198 for pctx in self._meaningful_parentrevs(ctx): | 1198 for pctx in scmutil.meaningfulparents(self.repo, ctx): |
1199 label = 'log.parent changeset.%s' % pctx.phasestr() | 1199 label = 'log.parent changeset.%s' % pctx.phasestr() |
1200 # i18n: column positioning for "hg log" | 1200 # i18n: column positioning for "hg log" |
1201 self.ui.write(_("parent: %d:%s\n") | 1201 self.ui.write(_("parent: %d:%s\n") |
1202 % (pctx.rev(), hexfunc(pctx.node())), | 1202 % (pctx.rev(), hexfunc(pctx.node())), |
1203 label=label) | 1203 label=label) |
1277 self.ui.write("\n") | 1277 self.ui.write("\n") |
1278 diffordiffstat(self.ui, self.repo, diffopts, prev, node, | 1278 diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
1279 match=matchfn, stat=False) | 1279 match=matchfn, stat=False) |
1280 self.ui.write("\n") | 1280 self.ui.write("\n") |
1281 | 1281 |
1282 def _meaningful_parentrevs(self, ctx): | |
1283 """Return list of meaningful (or all if debug) parentrevs for rev. | |
1284 | |
1285 For merges (two non-nullrev revisions) both parents are meaningful. | |
1286 Otherwise the first parent revision is considered meaningful if it | |
1287 is not the preceding revision. | |
1288 """ | |
1289 parents = ctx.parents() | |
1290 if len(parents) > 1: | |
1291 return parents | |
1292 if self.ui.debugflag: | |
1293 return [parents[0], self.repo['null']] | |
1294 if parents[0].rev() >= scmutil.intrev(ctx.rev()) - 1: | |
1295 return [] | |
1296 return parents | |
1297 | |
1298 class jsonchangeset(changeset_printer): | 1282 class jsonchangeset(changeset_printer): |
1299 '''format changeset information.''' | 1283 '''format changeset information.''' |
1300 | 1284 |
1301 def __init__(self, ui, repo, matchfn, diffopts, buffered): | 1285 def __init__(self, ui, repo, matchfn, diffopts, buffered): |
1302 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) | 1286 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) |
1454 def showparents(**args): | 1438 def showparents(**args): |
1455 ctx = args['ctx'] | 1439 ctx = args['ctx'] |
1456 parents = [[('rev', p.rev()), | 1440 parents = [[('rev', p.rev()), |
1457 ('node', p.hex()), | 1441 ('node', p.hex()), |
1458 ('phase', p.phasestr())] | 1442 ('phase', p.phasestr())] |
1459 for p in self._meaningful_parentrevs(ctx)] | 1443 for p in scmutil.meaningfulparents(self.repo, ctx)] |
1460 return showlist('parent', parents, **args) | 1444 return showlist('parent', parents, **args) |
1461 | 1445 |
1462 props = props.copy() | 1446 props = props.copy() |
1463 props.update(templatekw.keywords) | 1447 props.update(templatekw.keywords) |
1464 props['parents'] = showparents | 1448 props['parents'] = showparents |