# HG changeset patch # User Alexis S. L. Carvalho # Date 1174015377 10800 # Node ID 24c22a3f2ef86ad759d28bc3c826ca8d28927b87 # Parent c52b7176af9452c4d80940efa222c94e0c8303c8 pass repo.root to util.pathto() in preparation for the next patch diff -r c52b7176af94 -r 24c22a3f2ef8 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Fri Mar 16 00:22:55 2007 -0300 +++ b/mercurial/cmdutil.py Fri Mar 16 00:22:57 2007 -0300 @@ -145,7 +145,7 @@ exact = dict.fromkeys(files) for src, fn in repo.walk(node=node, files=files, match=matchfn, badmatch=badmatch): - yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact + yield src, fn, util.pathto(repo.root, repo.getcwd(), fn), fn in exact def findrenames(repo, added=None, removed=None, threshold=0.5): if added is None or removed is None: diff -r c52b7176af94 -r 24c22a3f2ef8 mercurial/commands.py --- a/mercurial/commands.py Fri Mar 16 00:22:55 2007 -0300 +++ b/mercurial/commands.py Fri Mar 16 00:22:57 2007 -0300 @@ -487,7 +487,7 @@ # target: ossep def copy(origsrc, abssrc, relsrc, target, exact): abstarget = util.canonpath(repo.root, cwd, target) - reltarget = util.pathto(cwd, abstarget) + reltarget = util.pathto(repo.root, cwd, abstarget) prevsrc = targets.get(abstarget) if prevsrc is not None: ui.warn(_('%s: not overwriting - %s collides with %s\n') % @@ -2418,11 +2418,12 @@ format = "%s %%s%s" % (char, end) for f in changes: - ui.write(format % util.pathto(cwd, f)) + ui.write(format % util.pathto(repo.root, cwd, f)) if ((all or opts.get('copies')) and not opts.get('no_status')): copied = repo.dirstate.copied(f) if copied: - ui.write(' %s%s' % (util.pathto(cwd, copied), end)) + ui.write(' %s%s' % (util.pathto(repo.root, cwd, copied), + end)) def tag(ui, repo, name, rev_=None, **opts): """add a tag for the current or given revision diff -r c52b7176af94 -r 24c22a3f2ef8 mercurial/dirstate.py --- a/mercurial/dirstate.py Fri Mar 16 00:22:55 2007 -0300 +++ b/mercurial/dirstate.py Fri Mar 16 00:22:57 2007 -0300 @@ -363,7 +363,7 @@ elif stat.S_ISSOCK(st.st_mode): kind = _('socket') elif stat.S_ISDIR(st.st_mode): kind = _('directory') self.ui.warn(_('%s: unsupported file type (type is %s)\n') % ( - util.pathto(self.getcwd(), f), + util.pathto(self.root, self.getcwd(), f), kind)) return False @@ -466,7 +466,7 @@ if not found: if inst.errno != errno.ENOENT or not badmatch: self.ui.warn('%s: %s\n' % ( - util.pathto(self.getcwd(), ff), + util.pathto(self.root, self.getcwd(), ff), inst.strerror)) elif badmatch and badmatch(ff) and imatch(nf): yield 'b', ff, None diff -r c52b7176af94 -r 24c22a3f2ef8 mercurial/localrepo.py --- a/mercurial/localrepo.py Fri Mar 16 00:22:55 2007 -0300 +++ b/mercurial/localrepo.py Fri Mar 16 00:22:57 2007 -0300 @@ -853,7 +853,7 @@ yield 'b', fn else: self.ui.warn(_('%s: No such file in rev %s\n') % ( - util.pathto(self.getcwd(), fn), short(node))) + util.pathto(self.root, self.getcwd(), fn), short(node))) else: for src, fn in self.dirstate.walk(files, match, badmatch=badmatch): yield src, fn diff -r c52b7176af94 -r 24c22a3f2ef8 mercurial/patch.py --- a/mercurial/patch.py Fri Mar 16 00:22:55 2007 -0300 +++ b/mercurial/patch.py Fri Mar 16 00:22:57 2007 -0300 @@ -353,7 +353,7 @@ cfiles = patches.keys() cwd = repo.getcwd() if cwd: - cfiles = [util.pathto(cwd, f) for f in patches.keys()] + cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()] for f in patches: ctype, gp = patches[f] if ctype == 'RENAME': diff -r c52b7176af94 -r 24c22a3f2ef8 mercurial/util.py --- a/mercurial/util.py Fri Mar 16 00:22:55 2007 -0300 +++ b/mercurial/util.py Fri Mar 16 00:22:57 2007 -0300 @@ -314,11 +314,16 @@ _globchars = {'[': 1, '{': 1, '*': 1, '?': 1} -def pathto(n1, n2): +def pathto(root, n1, n2): '''return the relative path from one place to another. + root should use os.sep to separate directories n1 should use os.sep to separate directories n2 should use "/" to separate directories returns an os.sep-separated path. + + If n1 is a relative path, it's assumed it's + relative to root. + n2 should always be relative to root. ''' if not n1: return localpath(n2) a, b = n1.split(os.sep), n2.split('/')