# HG changeset patch # User Gregory Szorc # Date 2015-11-15 01:44:01 # Node ID 93bcc73df8d56225ba1720a36865bfdec5dad088 # Parent a29db426c5ba2b975f590c1d62821625631081da cmdutil.changeset_printer: pass context into showpatch() Before, we passed the node then subsequently performed a lookup on repo.changelog. We already has the context available, so just pass it in. This does result in a small performance win. But I doubt it will show up anywhere because diff[stat] calculation will dwarf the time spent to create a changectx. Still, we should be creating fewer changectx out of principle. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1301,16 +1301,17 @@ class changeset_printer(object): label='log.summary') self.ui.write("\n") - self.showpatch(changenode, matchfn) - - def showpatch(self, node, matchfn): + self.showpatch(ctx, matchfn) + + def showpatch(self, ctx, matchfn): if not matchfn: matchfn = self.matchfn if matchfn: stat = self.diffopts.get('stat') diff = self.diffopts.get('patch') diffopts = patch.diffallopts(self.ui, self.diffopts) - prev = self.repo.changelog.parents(node)[0] + node = ctx.node() + prev = ctx.p1() if stat: diffordiffstat(self.ui, self.repo, diffopts, prev, node, match=matchfn, stat=True) @@ -1492,7 +1493,7 @@ class changeset_templater(changeset_prin # write changeset metadata, then patch if requested key = self._parts['changeset'] self.ui.write(templater.stringify(self.t(key, **props))) - self.showpatch(ctx.node(), matchfn) + self.showpatch(ctx, matchfn) if self._parts['footer']: if not self.footer: