diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2403,7 +2403,7 @@ def cat(ui, repo, ctx, matcher, prefix, file = matcher.files()[0] mf = repo.manifest mfnode = ctx.manifestnode() - if mf.find(mfnode, file)[0]: + if mfnode and mf.find(mfnode, file)[0]: write(file) return 0 diff --git a/tests/test-cat.t b/tests/test-cat.t --- a/tests/test-cat.t +++ b/tests/test-cat.t @@ -63,3 +63,8 @@ Test fileset tmp/h_45116003780e tmp/r_2 +Test working directory + + $ echo b-wdir > b + $ hg cat -r 'wdir()' b + b-wdir