When you pass wdir() to the -r flag, it catches the
WdirUnsupported error and fall back to and alternate path
Details
- Reviewers
 - None
 - Group Reviewers
 hg-reviewers - Commits
 - rHG16f93a3b8b05: grep: enable passing wdir as a revision
 
Diff Detail
- Repository
 - rHG Mercurial
 - Lint
 Lint Skipped - Unit
 Unit Tests Skipped 
Event Timeline
- 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 = Truecols = [ ('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() ?
+ if ctx.rev() is None :
+ rev = scmutil.intrev(ctx)
Moved this to top and queued, thanks.