# HG changeset patch # User mpm@selenic.com # Date 1125124150 25200 # Node ID 8b7d63489db36ad40ddb8684f1f65d7bb6685afe # Parent 253072f39205fd7ad893612036caefb28c2ed87c Change canonpath to not know about repo objects Code in util should not have any knowledge about repo objects diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -30,7 +30,7 @@ def relpath(repo, args): return args def matchpats(repo, cwd, pats=[], opts={}, head=''): - return util.matcher(repo, cwd, pats or ['.'], opts.get('include'), + return util.matcher(repo.root, cwd, pats or ['.'], opts.get('include'), opts.get('exclude'), head) def makewalk(repo, pats, opts, head=''): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -85,20 +85,20 @@ def pathto(n1, n2): b.reverse() return os.sep.join((['..'] * len(a)) + b) -def canonpath(repo, cwd, myname): - rootsep = repo.root + os.sep +def canonpath(root, cwd, myname): + rootsep = root + os.sep name = myname if not name.startswith(os.sep): - name = os.path.join(repo.root, cwd, name) + name = os.path.join(root, cwd, name) name = os.path.normpath(name) if name.startswith(rootsep): return pconvert(name[len(rootsep):]) - elif name == repo.root: + elif name == root: return '' else: - raise Abort('%s not under repository root' % myname) + raise Abort('%s not under root' % myname) -def matcher(repo, cwd, names, inc, exc, head=''): +def matcher(canonroot, cwd, names, inc, exc, head=''): def patkind(name): for prefix in 're:', 'glob:', 'path:', 'relpath:': if name.startswith(prefix): return name.split(':', 1) @@ -135,7 +135,7 @@ def matcher(repo, cwd, names, inc, exc, roots = [] for kind, name in map(patkind, names): if kind in ('glob', 'relpath'): - name = canonpath(repo, cwd, name) + name = canonpath(canonroot, cwd, name) if name == '': kind, name = 'glob', '**' if kind in ('glob', 'path', 're'):