Mercurial > hg
view tests/test-arbitraryfilectx.t @ 40923:3ed77780f4a6
wireprotov2: send linknodes to emitfilerevisions()
Previously, linknodes were calculated within emitfilerevisions() by
using filectx.introrev(), which would always use the linkrev/linknode
as recorded by storage. This is wrong for cases where the receiver
doesn't have the changeset the linknode refers to.
This commit changes the logic for linknode emission so the mapping
of filenode to linknode is computed by the caller and passed into
emitfilerevisions().
As part of the change, linknodes for "filesdata" in the
haveparents=False case are now correct: the existing code performed a
manifest walk and it was trivial to plug in the correct linknode.
However, behavior for the haveparents=True case is still wrong
because it relies on filtering linkrevs against the outgoing set in
order to determine what to send. This will be fixed in a subsequent
commit.
The change test test-wireproto-exchangev2-shallow.t is a bit wonky.
The test repo has 6 revisions. The changed test is performing a shallow
clone with depth=1. So, only file data for revision 5 is present
locally. So, the new behavior of associating the linknode with
revision 5 for every file revision seems correct. Of course, when
backfilling old revisions, we'll want to update the linknode. But
this problem requires wire protocol support and we'll cross that
bridge later.
Differential Revision: https://phab.mercurial-scm.org/D5405
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 10 Dec 2018 18:04:12 +0000 |
parents | 9954d0e2ad00 |
children | 5361f9ed8a30 |
line wrap: on
line source
Setup: $ cat > eval.py <<EOF > from __future__ import absolute_import > import filecmp > from mercurial import commands, context, pycompat, registrar > cmdtable = {} > command = registrar.command(cmdtable) > @command(b'eval', [], b'hg eval CMD') > def eval_(ui, repo, *cmds, **opts): > cmd = b" ".join(cmds) > res = pycompat.bytestr(eval(cmd, globals(), locals())) > ui.warn(b"%s" % res) > EOF $ echo "[extensions]" >> $HGRCPATH $ echo "eval=`pwd`/eval.py" >> $HGRCPATH Arbitraryfilectx.cmp does not follow symlinks: $ mkdir case1 $ cd case1 $ hg init #if symlink $ 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" #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 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): $ hg eval "context.arbitraryfilectx('A', repo).cmp(repo[None]['real_A'])" True (no-eol) $ hg eval "not filecmp.cmp('A', 'real_A')" True (no-eol) These files are identical and should return False (same): $ hg eval "context.arbitraryfilectx('A', repo).cmp(repo[None]['A'])" False (no-eol) $ hg eval "context.arbitraryfilectx('A', repo).cmp(repo[None]['B'])" False (no-eol) $ hg eval "not filecmp.cmp('A', 'B')" 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. $ hg eval "context.arbitraryfilectx('real_A', repo).cmp(repo[None]['sym_A'])" 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. #if symlink $ hg eval "not filecmp.cmp('real_A', 'sym_A')" True (no-eol) #else $ hg eval "not filecmp.cmp('real_A', 'sym_A')" False (no-eol) #endif