sapling/tests/test-hggit-gitignore.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

165 lines
2.7 KiB
Perl

#require no-fsmonitor
$ python -c 'from edenscm.mercurial.dirstate import rootcache' || exit 80
Load commonly used test logic
$ . "$TESTDIR/hggit/testutil"
$ hg init
We should only read .gitignore files in a hg-git repo (i.e. one with .hg/git
directory) otherwise, a rogue .gitignore could slow down a hg-only repo
$ mkdir .hg/git
$ touch foo
$ touch foobar
$ touch bar
$ echo 'foo*' > .gitignore
$ hg status
? .gitignore
? bar
$ echo '*bar' > .gitignore
$ hg status
? .gitignore
? foo
$ mkdir dir
$ touch dir/foo
$ echo 'foo' > .gitignore
$ hg status
? .gitignore
? bar
? foobar
$ echo '/foo' > .gitignore
$ hg status
? .gitignore
? bar
? dir/foo
? foobar
$ rm .gitignore
$ echo 'foo' > dir/.gitignore
$ hg status
? bar
? dir/.gitignore
? foo
? foobar
$ touch dir/bar
$ echo 'bar' > .gitignore
$ hg status
? .gitignore
? dir/.gitignore
? foo
? foobar
$ echo '/bar' > .gitignore
$ hg status
? .gitignore
? dir/.gitignore
? dir/bar
? foo
? foobar
$ echo 'foo*' > .gitignore
$ echo '!*bar' >> .gitignore
$ hg status
? .gitignore
? bar
? dir/.gitignore
? dir/bar
? foobar
$ echo '.hg/' > .gitignore
$ hg status
? .gitignore
? bar
? dir/.gitignore
? dir/bar
? foo
? foobar
$ echo 'dir/.hg/' > .gitignore
$ hg status
? .gitignore
? bar
? dir/.gitignore
? dir/bar
? foo
? foobar
$ echo '.hg/foo' > .gitignore
$ hg status
? .gitignore
? bar
? dir/.gitignore
? dir/bar
? foo
? foobar
$ touch foo.hg
$ echo 'foo.hg' > .gitignore
$ hg status
? .gitignore
? bar
? dir/.gitignore
? dir/bar
? foo
? foobar
$ rm foo.hg
$ touch .hgignore
$ hg status
? .gitignore
? .hgignore
? bar
? dir/.gitignore
? dir/bar
? foo
? foobar
$ echo 'syntax: re' > .hgignore
$ echo 'foo.*$(?<!bar)' >> .hgignore
$ echo 'dir/foo' >> .hgignore
$ hg status
? .gitignore
? .hgignore
? bar
? dir/.gitignore
? dir/bar
? foobar
$ hg add .gitignore
$ hg commit -m "add and commit .gitignore"
$ rm .gitignore
$ rm .hgignore
$ hg status
! .gitignore
? bar
? dir/.gitignore
? dir/bar
? foo
? foobar
show pattern error in hgignore file as expected (issue197)
----------------------------------------------------------
$ cat > $TESTTMP/invalidhgignore <<EOF
> # invalid syntax in regexp
> foo(
> syntax: re
> EOF
$ hg status --config ui.ignore=$TESTTMP/invalidhgignore
abort: $TESTTMP/invalidhgignore: invalid pattern (relre): foo(
[255]
$ cat > .hgignore <<EOF
> # invalid syntax in regexp
> foo(
> EOF
$ hg status
abort: $TESTTMP/.hgignore: invalid pattern (relre): foo(
[255]