D3673: grep: enables passing wdir as a revision in grep

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Thu May 31 08:44:15 EDT 2018


yuja added a comment.


  >   - a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2513,19 +2513,27 @@ @util.cachefunc def binary(): flog = getfile(fn)
  > - return stringutil.binary(flog.read(ctx.filenode(fn))) +            try: +                content = flog.read(ctx.filenode(fn)) +            except error.WdirUnsupported: +                content = ctx[fn].data()
  
  `ctx[fn].isbinary()` is preferred.
  
  > - fm.data(node=fm.hexfunc(ctx.node())) +            fm.data(node=fm.hexfunc(scmutil.binnode(ctx))) +            if ctx._rev is None :
  
  `ctx.rev()`
  
  > +                showrev = False
  >  +            else :
  >  +                showrev = True
  > 
  >   cols = [
  >       ('filename', fn, True),
  > 
  > - ('rev', rev, True), +                ('rev', rev, showrev),
  
  It's probably better to not disable the revision output since we'll need
  a revision number in machine-readable output such as JSON.
  
  We can use `scmutil.intrev(ctx)` instead. The output is a bit ugly for
  humans, but it's valid and we can fix it to be prettier later.
  
  > - copied = flog.renamed(fnode) +            try: +                copied = flog.renamed(fnode) +            except error.WdirUnsupported : +                copied = False
  
  `ctx[fn].renamed()` ?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3673

To: sangeet259, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list