2018-07-06 20:32:46 +03:00
|
|
|
#require no-fsmonitor
|
2013-12-14 20:19:25 +04:00
|
|
|
$ python -c 'from mercurial.dirstate import rootcache' || exit 80
|
|
|
|
|
2013-11-27 18:27:59 +04:00
|
|
|
Load commonly used test logic
|
2018-01-09 17:08:01 +03:00
|
|
|
$ . "$TESTDIR/hggit/testutil"
|
2013-11-27 18:27:59 +04:00
|
|
|
|
|
|
|
$ hg init
|
|
|
|
|
2016-09-03 04:26:01 +03:00
|
|
|
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
|
|
|
|
|
2013-11-27 18:27:59 +04:00
|
|
|
$ 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
|
2018-07-06 20:32:46 +03:00
|
|
|
? foobar
|
2013-11-27 18:27:59 +04:00
|
|
|
|
2014-04-16 17:04:26 +04:00
|
|
|
$ 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
|
|
|
|
|
2013-11-27 18:27:59 +04:00
|
|
|
$ 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
|
2015-02-16 20:35:35 +03:00
|
|
|
|
|
|
|
$ hg add .gitignore
|
|
|
|
$ hg commit -m "add and commit .gitignore"
|
|
|
|
$ rm .gitignore
|
|
|
|
$ rm .hgignore
|
|
|
|
$ hg status
|
|
|
|
! .gitignore
|
|
|
|
? bar
|
|
|
|
? dir/.gitignore
|
|
|
|
? dir/bar
|
|
|
|
? foo
|
|
|
|
? foobar
|
gitdirstate: show pattern error in hgignore file as expected
Before this revision, invalid pattern in hgignore file causes
unintentional failure for UnboundLocalError of ignorefunc, if hggit is
used with Mercurial 3.5 or later.
In such case:
- checking source of invalid pattern at failure uses "pats" list for
hgignore files, but
- "pats" list is empty, if ignoremod is None (= Mercurial 3.5 or later)
- therefore, checking with matchmod.match() overlooks invalid pattern
Then, "return ignorefunc" is executed without assignment to
ignorefunc, and causes UnboundLocalError.
To show pattern error in hgignore file as expected even with Mercurial
3.5 or later, this revision puts '(FILE, ["include: FILE"])' tuples
into "pats" (to avoid code duplication, putting into allpats is
shared, too).
This makes checking source of invalid pattern at failure work as
expected for hgignore files.
Fixes #197
2017-08-04 20:13:11 +03:00
|
|
|
|
|
|
|
show pattern error in hgignore file as expected (issue197)
|
|
|
|
----------------------------------------------------------
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/invalidhgignore <<EOF
|
|
|
|
> # invalid syntax in regexp
|
|
|
|
> foo(
|
2018-08-03 06:18:50 +03:00
|
|
|
> syntax: re
|
gitdirstate: show pattern error in hgignore file as expected
Before this revision, invalid pattern in hgignore file causes
unintentional failure for UnboundLocalError of ignorefunc, if hggit is
used with Mercurial 3.5 or later.
In such case:
- checking source of invalid pattern at failure uses "pats" list for
hgignore files, but
- "pats" list is empty, if ignoremod is None (= Mercurial 3.5 or later)
- therefore, checking with matchmod.match() overlooks invalid pattern
Then, "return ignorefunc" is executed without assignment to
ignorefunc, and causes UnboundLocalError.
To show pattern error in hgignore file as expected even with Mercurial
3.5 or later, this revision puts '(FILE, ["include: FILE"])' tuples
into "pats" (to avoid code duplication, putting into allpats is
shared, too).
This makes checking source of invalid pattern at failure work as
expected for hgignore files.
Fixes #197
2017-08-04 20:13:11 +03:00
|
|
|
> 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]
|