comparison mercurial/logcmdutil.py @ 43102:829088e87032

log: populate keywords if specified in custom -Tjson(...) or -Tcbor(...) To make things simple, early return for ui.quiet is disabled if the formatter is templated and provides some datahint().
author Yuya Nishihara <yuya@tcha.org>
date Sun, 06 Oct 2019 14:58:41 -0400
parents 90b9a7e06c2c
children d783f945a701
comparison
equal deleted inserted replaced
43101:1d12ae5096d1 43102:829088e87032
438 fm = self._fm 438 fm = self._fm
439 fm.startitem() 439 fm.startitem()
440 fm.context(ctx=ctx) 440 fm.context(ctx=ctx)
441 fm.data(rev=scmutil.intrev(ctx), node=fm.hexfunc(scmutil.binnode(ctx))) 441 fm.data(rev=scmutil.intrev(ctx), node=fm.hexfunc(scmutil.binnode(ctx)))
442 442
443 if self.ui.quiet: 443 datahint = fm.datahint()
444 if self.ui.quiet and not datahint:
444 return 445 return
445 446
446 fm.data( 447 fm.data(
447 branch=ctx.branch(), 448 branch=ctx.branch(),
448 phase=ctx.phasestr(), 449 phase=ctx.phasestr(),
454 parents=fm.formatlist( 455 parents=fm.formatlist(
455 [fm.hexfunc(c.node()) for c in ctx.parents()], name=b'node' 456 [fm.hexfunc(c.node()) for c in ctx.parents()], name=b'node'
456 ), 457 ),
457 ) 458 )
458 459
459 if self.ui.debugflag: 460 if self.ui.debugflag or b'manifest' in datahint:
460 fm.data( 461 fm.data(manifest=fm.hexfunc(ctx.manifestnode() or wdirid))
461 manifest=fm.hexfunc(ctx.manifestnode() or wdirid), 462 if self.ui.debugflag or b'extra' in datahint:
462 extra=fm.formatdict(ctx.extra()), 463 fm.data(extra=fm.formatdict(ctx.extra()))
463 ) 464
464 465 if (
466 self.ui.debugflag
467 or b'modified' in datahint
468 or b'added' in datahint
469 or b'removed' in datahint
470 ):
465 files = ctx.p1().status(ctx) 471 files = ctx.p1().status(ctx)
466 fm.data( 472 fm.data(
467 modified=fm.formatlist(files[0], name=b'file'), 473 modified=fm.formatlist(files[0], name=b'file'),
468 added=fm.formatlist(files[1], name=b'file'), 474 added=fm.formatlist(files[1], name=b'file'),
469 removed=fm.formatlist(files[2], name=b'file'), 475 removed=fm.formatlist(files[2], name=b'file'),
470 ) 476 )
471 477
472 elif self.ui.verbose: 478 verbose = not self.ui.debugflag and self.ui.verbose
479 if verbose or b'files' in datahint:
473 fm.data(files=fm.formatlist(ctx.files(), name=b'file')) 480 fm.data(files=fm.formatlist(ctx.files(), name=b'file'))
474 if copies: 481 if verbose and copies or b'copies' in datahint:
475 fm.data( 482 fm.data(
476 copies=fm.formatdict(copies, key=b'name', value=b'source') 483 copies=fm.formatdict(copies or {}, key=b'name', value=b'source')
477 ) 484 )
478 485
479 if self._includestat: 486 if self._includestat or b'diffstat' in datahint:
480 self.ui.pushbuffer() 487 self.ui.pushbuffer()
481 self._differ.showdiff(self.ui, ctx, self._diffopts, stat=True) 488 self._differ.showdiff(self.ui, ctx, self._diffopts, stat=True)
482 fm.data(diffstat=self.ui.popbuffer()) 489 fm.data(diffstat=self.ui.popbuffer())
483 if self._includediff: 490 if self._includediff or b'diff' in datahint:
484 self.ui.pushbuffer() 491 self.ui.pushbuffer()
485 self._differ.showdiff(self.ui, ctx, self._diffopts, stat=False) 492 self._differ.showdiff(self.ui, ctx, self._diffopts, stat=False)
486 fm.data(diff=self.ui.popbuffer()) 493 fm.data(diff=self.ui.popbuffer())
487 494
488 495