Proposed Patch to hgignore
Peter Arrenbrecht
peter.arrenbrecht at gmail.com
Fri Mar 7 01:30:47 CST 2008
Thanks. In light of the rest of the discussion that surfaced, I think
it wasn't much use anymore. Sorry about that.
-peo
On Fri, Mar 7, 2008 at 1:11 AM, Jakob Krainz <pistazienfresser at web.de> wrote:
> On Thu 2008-03-06 23:08:44 +0100, Peter Arrenbrecht wrote:
> > Could you inline that patch so it's easier to look at and, if
> > necessary, comment?
>
> yes, of course.
>
> oh, and i am sorry, but the patch i appended previously wasn't gzipped but
> plain text, so the filename is not correct. i can resend it if necessary.
>
>
>
> diff -r 0068809347d7 -r 3032962e4897 mercurial/ignore.py
> --- a/mercurial/ignore.py Fri Feb 29 14:48:21 2008 -0800
> +++ b/mercurial/ignore.py Sat Mar 01 23:36:37 2008 +0100
> @@ -46,9 +46,11 @@ def ignore(root, files, warn):
>
> syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'}
> pats = {}
> + patneg = {}
> for f in files:
> try:
> pats[f] = []
> + patneg[f] = []
> fp = open(f)
> syntax = 'relre:'
> for line in _parselines(fp):
> @@ -59,6 +61,11 @@ def ignore(root, files, warn):
> except KeyError:
> warn(_("%s: ignoring invalid syntax '%s'\n") % (f, s))
> continue
> + if line.startswith('!'):
> + negate = True
> + line = line[1:]
> + else:
> + negate = False
> pat = syntax + line
> for s, rels in syntaxes.items():
> if line.startswith(rels):
> @@ -68,6 +75,7 @@ def ignore(root, files, warn):
> pat = rels + line[len(s)+1:]
> break
> pats[f].append(pat)
> + patneg[f].append(negate)
> except IOError, inst:
> if f != files[0]:
> warn(_("skipping unreadable ignore file '%s': %s\n") %
> @@ -75,12 +83,23 @@ def ignore(root, files, warn):
>
> allpats = []
> [allpats.extend(patlist) for patlist in pats.values()]
> + allpatnegate = []
> + [allpatnegate.extend(neglist) for neglist in patneg.values()]
> if not allpats:
> return util.never
>
> + pinc = []
> + pexc = []
> +
> + for i in xrange(len(allpats)):
> + if(allpatnegate[i]):
> + pexc.append(allpats[i])
> + else:
> + pinc.append(allpats[i])
> +
> try:
> files, ignorefunc, anypats = (
> - util.matcher(root, inc=allpats, src='.hgignore'))
> + util.matcher(root, inc=pinc, exc=pexc, src='.hgignore'))
> except util.Abort:
> # Re-raise an exception where the src is the right file
> for f, patlist in pats.items():
>
More information about the Mercurial-devel
mailing list