##// END OF EJS Templates
cat: don't prefetch files unless the output requires it...
cat: don't prefetch files unless the output requires it It's a waste to cache lfs blobs when cat'ing the raw data at best, but a hassle debugging when the blob is missing. I'm not sure if there are other commands that have '{data}' for output, and if there's a general way to prefetch on that keyword. It's interesting that the verbose output seems to leak into the JSON output, but that seems like an existing bug.

File last commit:

r41365:5361f9ed default
r42678:561cd02c default
Show More
test-arbitraryfilectx.t
101 lines | 2.6 KiB | text/troff | Tads3Lexer
/ tests / test-arbitraryfilectx.t
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 Setup:
$ cat > eval.py <<EOF
> from __future__ import absolute_import
> import filecmp
Pulkit Goyal
py3: use pycompat.bytestr() intsead of str...
r37334 > from mercurial import commands, context, pycompat, registrar
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 > cmdtable = {}
> command = registrar.command(cmdtable)
Pulkit Goyal
py3: add missing b'' in test-arbitraryfilectx.t...
r36400 > @command(b'eval', [], b'hg eval CMD')
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 > def eval_(ui, repo, *cmds, **opts):
Pulkit Goyal
py3: add b'' prefixes to string literals in test files...
r35965 > cmd = b" ".join(cmds)
Pulkit Goyal
py3: use pycompat.bytestr() intsead of str...
r37334 > res = pycompat.bytestr(eval(cmd, globals(), locals()))
Pulkit Goyal
py3: add b'' prefixes to string literals in test files...
r35965 > ui.warn(b"%s" % res)
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 > EOF
$ echo "[extensions]" >> $HGRCPATH
$ echo "eval=`pwd`/eval.py" >> $HGRCPATH
Arbitraryfilectx.cmp does not follow symlinks:
$ mkdir case1
$ cd case1
$ hg init
Matt Harbison
test-arbitraryfilectx: stabilize for Windows...
r34937 #if symlink
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 $ printf "A" > real_A
$ printf "foo" > A
$ printf "foo" > B
$ ln -s A sym_A
$ hg add .
adding A
adding B
adding real_A
adding sym_A
$ hg commit -m "base"
Matt Harbison
test-arbitraryfilectx: stabilize for Windows...
r34937 #else
$ hg import -q --bypass - <<EOF
> # HG changeset patch
> # User test
> # Date 0 0
> base
>
> diff --git a/A b/A
> new file mode 100644
> --- /dev/null
> +++ b/A
> @@ -0,0 +1,1 @@
> +foo
> \ No newline at end of file
> diff --git a/B b/B
> new file mode 100644
> --- /dev/null
> +++ b/B
> @@ -0,0 +1,1 @@
> +foo
> \ No newline at end of file
> diff --git a/real_A b/real_A
> new file mode 100644
> --- /dev/null
> +++ b/real_A
> @@ -0,0 +1,1 @@
> +A
> \ No newline at end of file
> diff --git a/sym_A b/sym_A
> new file mode 120000
> --- /dev/null
> +++ b/sym_A
> @@ -0,0 +1,1 @@
> +A
> \ No newline at end of file
> EOF
$ hg up -q
#endif
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836
These files are different and should return True (different):
(Note that filecmp.cmp's return semantics are inverted from ours, so we invert
for simplicity):
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "context.arbitraryfilectx(b'A', repo).cmp(repo[None][b'real_A'])"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 True (no-eol)
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "not filecmp.cmp(b'A', b'real_A')"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 True (no-eol)
These files are identical and should return False (same):
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "context.arbitraryfilectx(b'A', repo).cmp(repo[None][b'A'])"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 False (no-eol)
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "context.arbitraryfilectx(b'A', repo).cmp(repo[None][b'B'])"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 False (no-eol)
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "not filecmp.cmp(b'A', b'B')"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 False (no-eol)
This comparison should also return False, since A and sym_A are substantially
the same in the eyes of ``filectx.cmp``, which looks at data only.
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "context.arbitraryfilectx(b'real_A', repo).cmp(repo[None][b'sym_A'])"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 False (no-eol)
A naive use of filecmp on those two would wrongly return True, since it follows
the symlink to "A", which has different contents.
Matt Harbison
test-arbitraryfilectx: stabilize for Windows...
r34937 #if symlink
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "not filecmp.cmp(b'real_A', b'sym_A')"
Phil Cohen
arbitraryfilecontext: skip the cmp fast path if any side is a symlink...
r34836 True (no-eol)
Matt Harbison
test-arbitraryfilectx: stabilize for Windows...
r34937 #else
Augie Fackler
py3: fix missing b prefixes in test-arbitraryfilectx.t...
r41365 $ hg eval "not filecmp.cmp(b'real_A', b'sym_A')"
Matt Harbison
test-arbitraryfilectx: stabilize for Windows...
r34937 False (no-eol)
#endif