1113 if self.ui.debugflag: |
1113 if self.ui.debugflag: |
1114 hexfunc = hex |
1114 hexfunc = hex |
1115 else: |
1115 else: |
1116 hexfunc = short |
1116 hexfunc = short |
1117 |
1117 |
1118 parents = [self.repo[p] |
|
1119 for p in self._meaningful_parentrevs(log, rev)] |
|
1120 |
|
1121 # i18n: column positioning for "hg log" |
1118 # i18n: column positioning for "hg log" |
1122 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), |
1119 self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), |
1123 label='log.changeset changeset.%s' % ctx.phasestr()) |
1120 label='log.changeset changeset.%s' % ctx.phasestr()) |
1124 |
1121 |
1125 # branches are shown first before any other names due to backwards |
1122 # branches are shown first before any other names due to backwards |
1143 label='log.%s' % ns.colorname) |
1140 label='log.%s' % ns.colorname) |
1144 if self.ui.debugflag: |
1141 if self.ui.debugflag: |
1145 # i18n: column positioning for "hg log" |
1142 # i18n: column positioning for "hg log" |
1146 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()), |
1143 self.ui.write(_("phase: %s\n") % _(ctx.phasestr()), |
1147 label='log.phase') |
1144 label='log.phase') |
1148 for pctx in parents: |
1145 for pctx in self._meaningful_parentrevs(ctx): |
1149 label = 'log.parent changeset.%s' % pctx.phasestr() |
1146 label = 'log.parent changeset.%s' % pctx.phasestr() |
1150 # i18n: column positioning for "hg log" |
1147 # i18n: column positioning for "hg log" |
1151 self.ui.write(_("parent: %d:%s\n") |
1148 self.ui.write(_("parent: %d:%s\n") |
1152 % (pctx.rev(), hexfunc(pctx.node())), |
1149 % (pctx.rev(), hexfunc(pctx.node())), |
1153 label=label) |
1150 label=label) |
1227 self.ui.write("\n") |
1224 self.ui.write("\n") |
1228 diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
1225 diffordiffstat(self.ui, self.repo, diffopts, prev, node, |
1229 match=matchfn, stat=False) |
1226 match=matchfn, stat=False) |
1230 self.ui.write("\n") |
1227 self.ui.write("\n") |
1231 |
1228 |
1232 def _meaningful_parentrevs(self, log, rev): |
1229 def _meaningful_parentrevs(self, ctx): |
1233 """Return list of meaningful (or all if debug) parentrevs for rev. |
1230 """Return list of meaningful (or all if debug) parentrevs for rev. |
1234 |
1231 |
1235 For merges (two non-nullrev revisions) both parents are meaningful. |
1232 For merges (two non-nullrev revisions) both parents are meaningful. |
1236 Otherwise the first parent revision is considered meaningful if it |
1233 Otherwise the first parent revision is considered meaningful if it |
1237 is not the preceding revision. |
1234 is not the preceding revision. |
1238 """ |
1235 """ |
1239 parents = log.parentrevs(rev) |
1236 parents = ctx.parents() |
1240 if not self.ui.debugflag and parents[1] == nullrev: |
1237 if len(parents) > 1: |
1241 if parents[0] >= rev - 1: |
1238 return parents |
1242 parents = [] |
1239 if self.ui.debugflag: |
1243 else: |
1240 return [parents[0], self.repo['null']] |
1244 parents = [parents[0]] |
1241 if parents[0].rev() >= ctx.rev() - 1: |
|
1242 return [] |
1245 return parents |
1243 return parents |
1246 |
1244 |
1247 class jsonchangeset(changeset_printer): |
1245 class jsonchangeset(changeset_printer): |
1248 '''format changeset information.''' |
1246 '''format changeset information.''' |
1249 |
1247 |
1352 cache=defaulttempl) |
1350 cache=defaulttempl) |
1353 if tmpl: |
1351 if tmpl: |
1354 self.t.cache['changeset'] = tmpl |
1352 self.t.cache['changeset'] = tmpl |
1355 |
1353 |
1356 self.cache = {} |
1354 self.cache = {} |
1357 |
|
1358 def _meaningful_parentrevs(self, ctx): |
|
1359 """Return list of meaningful (or all if debug) parentrevs for rev. |
|
1360 """ |
|
1361 parents = ctx.parents() |
|
1362 if len(parents) > 1: |
|
1363 return parents |
|
1364 if self.ui.debugflag: |
|
1365 return [parents[0], self.repo['null']] |
|
1366 if parents[0].rev() >= ctx.rev() - 1: |
|
1367 return [] |
|
1368 return parents |
|
1369 |
1355 |
1370 def _show(self, ctx, copies, matchfn, props): |
1356 def _show(self, ctx, copies, matchfn, props): |
1371 '''show a single changeset or file revision''' |
1357 '''show a single changeset or file revision''' |
1372 |
1358 |
1373 showlist = templatekw.showlist |
1359 showlist = templatekw.showlist |