# HG changeset patch # User Vadim Gelfer # Date 1136245696 28800 # Node ID 84e9b3484ff6ea7d25cbaa1f26cc40afdbc258fd # Parent c50bddfbc812f541b17fae79cf6501e492efe5c3 if hgignore contains errors, print message that is not confusing. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -68,7 +68,8 @@ class dirstate(object): try: syntax = syntaxes[s] except KeyError: - self.ui.warn(_("ignoring invalid syntax '%s'\n") % s) + self.ui.warn(_(".hgignore: ignoring invalid " + "syntax '%s'\n") % s) continue pat = syntax + line for s in syntaxes.values(): @@ -88,7 +89,8 @@ class dirstate(object): ignore = self.hgignore() if ignore: files, self.ignorefunc, anypats = util.matcher(self.root, - inc=ignore) + inc=ignore, + src='.hgignore') else: self.ignorefunc = util.never return self.ignorefunc(fn) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -191,17 +191,17 @@ def canonpath(root, cwd, myname): else: raise Abort('%s not under root' % myname) -def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''): - return _matcher(canonroot, cwd, names, inc, exc, head, 'glob') +def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None): + return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src) -def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head=''): +def cmdmatcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None): if os.name == 'nt': dflt_pat = 'glob' else: dflt_pat = 'relpath' - return _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat) + return _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src) -def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat): +def _matcher(canonroot, cwd, names, inc, exc, head, dflt_pat, src): """build a function to match a set of file patterns arguments: @@ -262,7 +262,8 @@ def _matcher(canonroot, cwd, names, inc, pat = '(?:%s)' % regex(k, p, tail) matches.append(re.compile(pat).match) except re.error: - raise Abort("invalid pattern: %s:%s" % (k, p)) + if src: raise Abort("%s: invalid pattern: %s:%s" % (src, k, p)) + else: raise Abort("invalid pattern: %s:%s" % (k, p)) def buildfn(text): for m in matches: