Mercurial > hg
view contrib/simplemerge @ 43964:8f67735344ae
tests: convert the `root` arg of matchmod.match() to local path separators
This fixes tests that broke with 8b1a9ba375e5, complaining that "X not under
root /repo". The vast majority of real uses are to pass `repo.root`, which is
normalized by `wdirvfs.base` being set to the result of `os.path.realpath()`.
Failure to convert looks like this:
--- c:/Users/Matt/hg/tests/test-match.py.out
+++ c:/Users/Matt/hg/tests/test-match.py.err
@@ -0,0 +1,48 @@
+ERROR: testVisitchildrensetGlob (__main__.IncludeMatcherTests)
+
+Traceback (most recent call last):
+ File "c:\Users\Matt\hg\tests\test-match.py", line 180, in testVisitchildrensetGlob
+ m = matchmod.match(b'/repo', b'', include=[b'glob:dir/z*'])
+ File "c:\Users\Matt\hg\mercurial\match.py", line 271, in match
+ kindpats = normalize(include, b'glob', root, cwd, auditor, warn)
+ File "c:\Users\Matt\hg\mercurial\match.py", line 322, in _donormalize
+ pat = pathutil.canonpath(root, cwd, pat, auditor=auditor)
+ File "c:\Users\Matt\hg\mercurial\pathutil.py", line 251, in canonpath
+ _(b"%s not under root '%s'") % (myname, root), hint=hint
+Abort: dir/z* not under root '/repo'
+ERROR: testVisitdirGlob (__main__.IncludeMatcherTests)
Differential Revision: https://phab.mercurial-scm.org/D7724
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 26 Dec 2019 16:45:56 -0500 |
parents | 99e231afc29c |
children | 4c1b4805db57 |
line wrap: on
line source
#!/usr/bin/env python from __future__ import absolute_import import getopt import sys import hgdemandimport hgdemandimport.enable() from mercurial.i18n import _ from mercurial import ( context, error, fancyopts, pycompat, simplemerge, ui as uimod, ) from mercurial.utils import procutil, stringutil options = [ (b'L', b'label', [], _(b'labels to use on conflict markers')), (b'a', b'text', None, _(b'treat all files as text')), (b'p', b'print', None, _(b'print results instead of overwriting LOCAL')), (b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')), (b'h', b'help', None, _(b'display help and exit')), (b'q', b'quiet', None, _(b'suppress output')), ] usage = _( b'''simplemerge [OPTS] LOCAL BASE OTHER Simple three-way file merge utility with a minimal feature set. Apply to LOCAL the changes necessary to go from BASE to OTHER. By default, LOCAL is overwritten with the results of this operation. ''' ) class ParseError(Exception): """Exception raised on errors in parsing the command line.""" def showhelp(): pycompat.stdout.write(usage) pycompat.stdout.write(b'\noptions:\n') out_opts = [] for shortopt, longopt, default, desc in options: out_opts.append( ( b'%2s%s' % ( shortopt and b'-%s' % shortopt, longopt and b' --%s' % longopt, ), b'%s' % desc, ) ) opts_len = max([len(opt[0]) for opt in out_opts]) for first, second in out_opts: pycompat.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) try: for fp in (sys.stdin, pycompat.stdout, sys.stderr): procutil.setbinary(fp) opts = {} try: bargv = [a.encode('utf8') for a in sys.argv[1:]] args = fancyopts.fancyopts(bargv, options, opts) except getopt.GetoptError as e: raise ParseError(e) if opts[b'help']: showhelp() sys.exit(0) if len(args) != 3: raise ParseError(_(b'wrong number of arguments').decode('utf8')) local, base, other = args sys.exit( simplemerge.simplemerge( uimod.ui.load(), context.arbitraryfilectx(local), context.arbitraryfilectx(base), context.arbitraryfilectx(other), **pycompat.strkwargs(opts) ) ) except ParseError as e: e = stringutil.forcebytestr(e) pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) showhelp() sys.exit(1) except error.Abort as e: pycompat.stderr.write(b"abort: %s\n" % e) sys.exit(255) except KeyboardInterrupt: sys.exit(255)