changeset 27065:93bcc73df8d5

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 14 Nov 2015 17:44:01 -0800
parents a29db426c5ba
children 6f1f8e88f036
files mercurial/cmdutil.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Nov 21 19:21:01 2015 -0800
+++ b/mercurial/cmdutil.py	Sat Nov 14 17:44:01 2015 -0800
@@ -1301,16 +1301,17 @@
                               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 @@
             # 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: