Mercurial > hg
comparison mercurial/templater.py @ 2191:c2e43535d4d1
make templater bit more flexible and efficient for external users.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Wed, 03 May 2006 14:35:17 -0700 |
parents | e3eba577a0ae |
children | f1986a61ccff |
comparison
equal
deleted
inserted
replaced
2190:b67fcd91dd1b | 2191:c2e43535d4d1 |
---|---|
266 fp.write('\n') | 266 fp.write('\n') |
267 return fp.getvalue() | 267 return fp.getvalue() |
268 | 268 |
269 common_filters = { | 269 common_filters = { |
270 "addbreaks": nl2br, | 270 "addbreaks": nl2br, |
271 "basename": os.path.basename, | |
271 "age": age, | 272 "age": age, |
272 "date": lambda x: util.datestr(x), | 273 "date": lambda x: util.datestr(x), |
273 "domain": domain, | 274 "domain": domain, |
274 "email": email, | 275 "email": email, |
275 "escape": lambda x: cgi.escape(x, True), | 276 "escape": lambda x: cgi.escape(x, True), |
334 dest.write(t) | 335 dest.write(t) |
335 | 336 |
336 def write_header(self, thing): | 337 def write_header(self, thing): |
337 self.write(thing, header=True) | 338 self.write(thing, header=True) |
338 | 339 |
339 def show(self, rev=0, changenode=None, brinfo=None): | 340 def show(self, rev=0, changenode=None, brinfo=None, changes=None, |
341 **props): | |
340 '''show a single changeset or file revision''' | 342 '''show a single changeset or file revision''' |
341 log = self.repo.changelog | 343 log = self.repo.changelog |
342 if changenode is None: | 344 if changenode is None: |
343 changenode = log.node(rev) | 345 changenode = log.node(rev) |
344 elif not rev: | 346 elif not rev: |
345 rev = log.rev(changenode) | 347 rev = log.rev(changenode) |
346 | 348 if changes is None: |
347 changes = log.read(changenode) | 349 changes = log.read(changenode) |
348 | 350 |
349 def showlist(name, values, plural=None, **args): | 351 def showlist(name, values, plural=None, **args): |
350 '''expand set of values. | 352 '''expand set of values. |
351 name is name of key in template map. | 353 name is name of key in template map. |
352 values is list of strings or dicts. | 354 values is list of strings or dicts. |
451 def showfiles(**args): | 453 def showfiles(**args): |
452 for x in showlist('file', changes[3], **args): yield x | 454 for x in showlist('file', changes[3], **args): yield x |
453 showadds = '' | 455 showadds = '' |
454 showdels = '' | 456 showdels = '' |
455 | 457 |
456 props = { | 458 defprops = { |
457 'author': changes[1], | 459 'author': changes[1], |
458 'branches': showbranches, | 460 'branches': showbranches, |
459 'date': changes[2], | 461 'date': changes[2], |
460 'desc': changes[4], | 462 'desc': changes[4], |
461 'file_adds': showadds, | 463 'file_adds': showadds, |
465 'node': hex(changenode), | 467 'node': hex(changenode), |
466 'parents': showparents, | 468 'parents': showparents, |
467 'rev': rev, | 469 'rev': rev, |
468 'tags': showtags, | 470 'tags': showtags, |
469 } | 471 } |
472 props = props.copy() | |
473 props.update(defprops) | |
470 | 474 |
471 try: | 475 try: |
472 if self.ui.debugflag and 'header_debug' in self.t: | 476 if self.ui.debugflag and 'header_debug' in self.t: |
473 key = 'header_debug' | 477 key = 'header_debug' |
474 elif self.ui.quiet and 'header_quiet' in self.t: | 478 elif self.ui.quiet and 'header_quiet' in self.t: |