sapling/tests/test-fb-hgext-treemanifest-fastmanifest.t
Jun Wu 9dc21f8d0b codemod: import from the edenscm package
Summary:
D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`.
That has nasty problems if both `import mercurial` and
`import edenscm.mercurial` are used, because Python would think `mercurial.foo`
and `edenscm.mercurial.foo` are different modules so code like
`try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)`
would fail to handle the `edenscm.mercurial` version. There are also some
module-level states (ex. `extensions._extensions`) that would cause trouble if
they have multiple versions in a single process.

Change imports to use the `edenscm` so ideally the `mercurial` is no longer
imported at all. Add checks in extensions.py to catch unexpected extensions
importing modules from the old (wrong) locations when running tests.

Reviewed By: phillco

Differential Revision: D13868981

fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
2019-01-29 17:25:32 -08:00

76 lines
2.0 KiB
Perl

# Integration tests between tree and fastmanifest
$ . "$TESTDIR/library.sh"
$ cat >> $TESTTMP/flatcheck.py <<EOF
> import sys, traceback
> from edenscm.mercurial import extensions, manifest
> def uisetup(ui):
> extensions.wrapfunction(manifest.manifestrevlog, 'revision', readmf)
> def readmf(orig, self, nodeorrev, **kwargs):
> if nodeorrev != -1:
> print >> sys.stderr, 'read flat manifest'
> stack = traceback.extract_stack()
> print >> sys.stderr, ''.join(traceback.format_list(stack[-3:-2]))
> return orig(self, nodeorrev, **kwargs)
> EOF
$ hg init master
$ cd master
$ echo a > a && hg ci -Aqm 'added a'
$ cd ..
$ hg clone -q ssh://user@dummy/master client
$ cd master
$ echo b > b && hg ci -Aqm 'added b'
$ echo c > c && hg ci -Aqm 'added c'
$ cd ..
$ cd client
$ cat >> .hg/hgrc <<EOF
> [extensions]
> fastmanifest=
> flatcheck=$TESTTMP/flatcheck.py
> treemanifest=
>
> [remotefilelog]
> usefastdatapack=True
> reponame=master
>
> [fastmanifest]
> usetree=True
> usecache=True
>
> [treemanifest]
> autocreatetrees=True
> demanddownload=False
> EOF
$ hg pull -q
read flat manifest
File "*fastmanifest/implementation.py", line *, in loadflat (glob)
data = self.revlog.revision(self._node)
# Test checking out from a fastmanifest to a treemanifest uses the treemanifest
$ hg up tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo d > d && hg ci -Aqm 'added d'
read flat manifest
File "*fastmanifest/implementation.py", line *, in add (glob)
p1text = origself.revision(p1)
$ hg debugcachemanifest -r .
read flat manifest
File "*fastmanifest/implementation.py", line *, in loadflat (glob)
data = self.revlog.revision(self._node)
$ hg diff -r tip -r 1 --stat
c | 1 -
d | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
$ hg diff -r 1 -r tip --stat
c | 1 +
d | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)