comparison mercurial/cmdutil.py @ 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 080276d377d9
children c57ebef70f6f
comparison
equal deleted inserted replaced
27064:a29db426c5ba 27065:93bcc73df8d5
1299 self.ui.write(_("summary: %s\n") % 1299 self.ui.write(_("summary: %s\n") %
1300 description.splitlines()[0], 1300 description.splitlines()[0],
1301 label='log.summary') 1301 label='log.summary')
1302 self.ui.write("\n") 1302 self.ui.write("\n")
1303 1303
1304 self.showpatch(changenode, matchfn) 1304 self.showpatch(ctx, matchfn)
1305 1305
1306 def showpatch(self, node, matchfn): 1306 def showpatch(self, ctx, matchfn):
1307 if not matchfn: 1307 if not matchfn:
1308 matchfn = self.matchfn 1308 matchfn = self.matchfn
1309 if matchfn: 1309 if matchfn:
1310 stat = self.diffopts.get('stat') 1310 stat = self.diffopts.get('stat')
1311 diff = self.diffopts.get('patch') 1311 diff = self.diffopts.get('patch')
1312 diffopts = patch.diffallopts(self.ui, self.diffopts) 1312 diffopts = patch.diffallopts(self.ui, self.diffopts)
1313 prev = self.repo.changelog.parents(node)[0] 1313 node = ctx.node()
1314 prev = ctx.p1()
1314 if stat: 1315 if stat:
1315 diffordiffstat(self.ui, self.repo, diffopts, prev, node, 1316 diffordiffstat(self.ui, self.repo, diffopts, prev, node,
1316 match=matchfn, stat=True) 1317 match=matchfn, stat=True)
1317 if diff: 1318 if diff:
1318 if stat: 1319 if stat:
1490 self.ui.write(h) 1491 self.ui.write(h)
1491 1492
1492 # write changeset metadata, then patch if requested 1493 # write changeset metadata, then patch if requested
1493 key = self._parts['changeset'] 1494 key = self._parts['changeset']
1494 self.ui.write(templater.stringify(self.t(key, **props))) 1495 self.ui.write(templater.stringify(self.t(key, **props)))
1495 self.showpatch(ctx.node(), matchfn) 1496 self.showpatch(ctx, matchfn)
1496 1497
1497 if self._parts['footer']: 1498 if self._parts['footer']:
1498 if not self.footer: 1499 if not self.footer:
1499 self.footer = templater.stringify( 1500 self.footer = templater.stringify(
1500 self.t(self._parts['footer'], **props)) 1501 self.t(self._parts['footer'], **props))