Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
- Lint Skipped 
- Unit
- Unit Tests Skipped 
| Lint Skipped | 
| Unit Tests Skipped | 
| # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> | # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> | ||||
| # Copyright 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> | # Copyright 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> | ||||
| # | # | ||||
| # This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
| # GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
| from __future__ import absolute_import, print_function | from __future__ import absolute_import, print_function | ||||
| import posixpath | import posixpath | ||||
| from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
| from mercurial import ( | from mercurial import ( | ||||
| error, | error, | ||||
| pycompat, | |||||
| ) | ) | ||||
| from . import common | from . import common | ||||
| SKIPREV = common.SKIPREV | SKIPREV = common.SKIPREV | ||||
| def rpairs(path): | def rpairs(path): | ||||
| '''Yield tuples with path split at '/', starting with the full path. | '''Yield tuples with path split at '/', starting with the full path. | ||||
| No leading, trailing or double '/', please. | No leading, trailing or double '/', please. | ||||
| >>> for x in rpairs(b'foo/bar/baz'): print(x) | >>> for x in rpairs(b'foo/bar/baz'): print(x) | ||||
| if name in mapping: | if name in mapping: | ||||
| self.ui.warn(_('%s:%d: %r already in %s list\n') % | self.ui.warn(_('%s:%d: %r already in %s list\n') % | ||||
| (lex.infile, lex.lineno, name, listname)) | (lex.infile, lex.lineno, name, listname)) | ||||
| return 1 | return 1 | ||||
| if (name.startswith('/') or | if (name.startswith('/') or | ||||
| name.endswith('/') or | name.endswith('/') or | ||||
| '//' in name): | '//' in name): | ||||
| self.ui.warn(_('%s:%d: superfluous / in %s %r\n') % | self.ui.warn(_('%s:%d: superfluous / in %s %r\n') % | ||||
| (lex.infile, lex.lineno, listname, name)) | (lex.infile, lex.lineno, listname, | ||||
| pycompat.bytestr(name))) | |||||
| return 1 | return 1 | ||||
| return 0 | return 0 | ||||
| lex = common.shlexer( | lex = common.shlexer( | ||||
| filepath=path, wordchars='!@#$%^&*()-=+[]{}|;:,./<>?') | filepath=path, wordchars='!@#$%^&*()-=+[]{}|;:,./<>?') | ||||
| cmd = lex.get_token() | cmd = lex.get_token() | ||||
| while cmd: | while cmd: | ||||
| if cmd == 'include': | if cmd == 'include': | ||||
| name = normalize(lex.get_token()) | name = normalize(lex.get_token()) | ||||
| errs += check(name, self.exclude, 'exclude') | errs += check(name, self.exclude, 'exclude') | ||||
| self.include[name] = name | self.include[name] = name | ||||
| elif cmd == 'exclude': | elif cmd == 'exclude': | ||||
| name = normalize(lex.get_token()) | name = normalize(lex.get_token()) | ||||
| errs += check(name, self.include, 'include') | errs += check(name, self.include, 'include') | ||||
| errs += check(name, self.rename, 'rename') | errs += check(name, self.rename, 'rename') | ||||
| self.exclude[name] = name | self.exclude[name] = name | ||||
| elif cmd == 'rename': | elif cmd == 'rename': | ||||
| src = normalize(lex.get_token()) | src = normalize(lex.get_token()) | ||||
| dest = normalize(lex.get_token()) | dest = normalize(lex.get_token()) | ||||
| errs += check(src, self.exclude, 'exclude') | errs += check(src, self.exclude, 'exclude') | ||||
| self.rename[src] = dest | self.rename[src] = dest | ||||
| elif cmd == 'source': | elif cmd == 'source': | ||||
| errs += self.parse(normalize(lex.get_token())) | errs += self.parse(normalize(lex.get_token())) | ||||
| else: | else: | ||||
| self.ui.warn(_('%s:%d: unknown directive %r\n') % | self.ui.warn(_('%s:%d: unknown directive %r\n') % | ||||
| (lex.infile, lex.lineno, cmd)) | (lex.infile, lex.lineno, pycompat.bytestr(cmd))) | ||||
| errs += 1 | errs += 1 | ||||
| cmd = lex.get_token() | cmd = lex.get_token() | ||||
| return errs | return errs | ||||
| def lookup(self, name, mapping): | def lookup(self, name, mapping): | ||||
| name = normalize(name) | name = normalize(name) | ||||
| for pre, suf in rpairs(name): | for pre, suf in rpairs(name): | ||||
| try: | try: | ||||