Skip to content
Snippets Groups Projects
Commit cf982a23 authored by Katsunori FUJIWARA's avatar Katsunori FUJIWARA
Browse files

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
parent c560ed4d
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment