comparison mercurial/logcmdutil.py @ 36920:6ff6e1d6b5b8

templater: move stringify() to templateutil module As we have a util module, it doesn't make sense to import stringify() from templatefilters.py.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 08 Mar 2018 23:10:46 +0900
parents c6061cadb400
children 255f635c3204
comparison
equal deleted inserted replaced
36919:8fba319750c2 36920:6ff6e1d6b5b8
31 revsetlang, 31 revsetlang,
32 scmutil, 32 scmutil,
33 smartset, 33 smartset,
34 templatekw, 34 templatekw,
35 templater, 35 templater,
36 templateutil,
36 util, 37 util,
37 ) 38 )
38 from .utils import dateutil 39 from .utils import dateutil
39 40
40 def getlimit(opts): 41 def getlimit(opts):
447 partnames = [p for p in self._parts.keys() if p != tmplspec.ref] 448 partnames = [p for p in self._parts.keys() if p != tmplspec.ref]
448 m = formatter.templatepartsmap(tmplspec, self.t, partnames) 449 m = formatter.templatepartsmap(tmplspec, self.t, partnames)
449 self._parts.update(m) 450 self._parts.update(m)
450 451
451 if self._parts['docheader']: 452 if self._parts['docheader']:
452 self.ui.write(templater.stringify(self.t(self._parts['docheader']))) 453 self.ui.write(
454 templateutil.stringify(self.t(self._parts['docheader'])))
453 455
454 def close(self): 456 def close(self):
455 if self._parts['docfooter']: 457 if self._parts['docfooter']:
456 if not self.footer: 458 if not self.footer:
457 self.footer = "" 459 self.footer = ""
458 self.footer += templater.stringify(self.t(self._parts['docfooter'])) 460 self.footer += templateutil.stringify(
461 self.t(self._parts['docfooter']))
459 return super(changesettemplater, self).close() 462 return super(changesettemplater, self).close()
460 463
461 def _show(self, ctx, copies, props): 464 def _show(self, ctx, copies, props):
462 '''show a single changeset or file revision''' 465 '''show a single changeset or file revision'''
463 props = props.copy() 466 props = props.copy()
468 471
469 # write separator, which wouldn't work well with the header part below 472 # write separator, which wouldn't work well with the header part below
470 # since there's inherently a conflict between header (across items) and 473 # since there's inherently a conflict between header (across items) and
471 # separator (per item) 474 # separator (per item)
472 if self._parts['separator'] and index > 0: 475 if self._parts['separator'] and index > 0:
473 self.ui.write(templater.stringify(self.t(self._parts['separator']))) 476 self.ui.write(
477 templateutil.stringify(self.t(self._parts['separator'])))
474 478
475 # write header 479 # write header
476 if self._parts['header']: 480 if self._parts['header']:
477 h = templater.stringify(self.t(self._parts['header'], **props)) 481 h = templateutil.stringify(self.t(self._parts['header'], **props))
478 if self.buffered: 482 if self.buffered:
479 self.header[ctx.rev()] = h 483 self.header[ctx.rev()] = h
480 else: 484 else:
481 if self.lastheader != h: 485 if self.lastheader != h:
482 self.lastheader = h 486 self.lastheader = h
483 self.ui.write(h) 487 self.ui.write(h)
484 488
485 # write changeset metadata, then patch if requested 489 # write changeset metadata, then patch if requested
486 key = self._parts[self._tref] 490 key = self._parts[self._tref]
487 self.ui.write(templater.stringify(self.t(key, **props))) 491 self.ui.write(templateutil.stringify(self.t(key, **props)))
488 self._showpatch(ctx) 492 self._showpatch(ctx)
489 493
490 if self._parts['footer']: 494 if self._parts['footer']:
491 if not self.footer: 495 if not self.footer:
492 self.footer = templater.stringify( 496 self.footer = templateutil.stringify(
493 self.t(self._parts['footer'], **props)) 497 self.t(self._parts['footer'], **props))
494 498
495 def templatespec(tmpl, mapfile): 499 def templatespec(tmpl, mapfile):
496 if mapfile: 500 if mapfile:
497 return formatter.templatespec('changeset', tmpl, mapfile) 501 return formatter.templatespec('changeset', tmpl, mapfile)