--- a/hgext/graphlog.py Wed Apr 20 19:54:57 2011 +0200
+++ b/hgext/graphlog.py Wed Apr 20 21:41:41 2011 +0200
@@ -18,7 +18,7 @@
from mercurial.i18n import _
from mercurial.node import nullrev
from mercurial import cmdutil, commands, extensions
-from mercurial import hg, util, graphmod
+from mercurial import hg, scmutil, util, graphmod
ASCIIDATA = 'ASC'
@@ -250,7 +250,7 @@
return
if path:
- path = util.canonpath(repo.root, os.getcwd(), path)
+ path = scmutil.canonpath(repo.root, os.getcwd(), path)
if path: # could be reset in canonpath
revdag = graphmod.filerevs(repo, path, start, stop, limit)
else:
--- a/hgext/keyword.py Wed Apr 20 19:54:57 2011 +0200
+++ b/hgext/keyword.py Wed Apr 20 21:41:41 2011 +0200
@@ -83,6 +83,7 @@
from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
from mercurial import localrepo, match, patch, templatefilters, templater, util
+from mercurial import scmutil
from mercurial.hgweb import webcommands
from mercurial.i18n import _
import os, re, shutil, tempfile
@@ -619,8 +620,8 @@
expansion. '''
source = repo.dirstate.copied(dest)
if 'l' in wctx.flags(source):
- source = util.canonpath(repo.root, cwd,
- os.path.realpath(source))
+ source = scmutil.canonpath(repo.root, cwd,
+ os.path.realpath(source))
return kwt.match(source)
candidates = [f for f in repo.dirstate.copies() if
--- a/mercurial/cmdutil.py Wed Apr 20 19:54:57 2011 +0200
+++ b/mercurial/cmdutil.py Wed Apr 20 21:41:41 2011 +0200
@@ -429,7 +429,7 @@
# relsrc: ossep
# otarget: ossep
def copyfile(abssrc, relsrc, otarget, exact):
- abstarget = util.canonpath(repo.root, cwd, otarget)
+ abstarget = scmutil.canonpath(repo.root, cwd, otarget)
reltarget = repo.pathto(abstarget, cwd)
target = repo.wjoin(abstarget)
src = repo.wjoin(abssrc)
@@ -497,7 +497,7 @@
# return: function that takes hgsep and returns ossep
def targetpathfn(pat, dest, srcs):
if os.path.isdir(pat):
- abspfx = util.canonpath(repo.root, cwd, pat)
+ abspfx = scmutil.canonpath(repo.root, cwd, pat)
abspfx = util.localpath(abspfx)
if destdirexists:
striplen = len(os.path.split(abspfx)[0])
@@ -523,7 +523,7 @@
res = lambda p: os.path.join(dest,
os.path.basename(util.localpath(p)))
else:
- abspfx = util.canonpath(repo.root, cwd, pat)
+ abspfx = scmutil.canonpath(repo.root, cwd, pat)
if len(abspfx) < len(srcs[0][0]):
# A directory. Either the target path contains the last
# component of the source path or it does not.
--- a/mercurial/hgweb/webutil.py Wed Apr 20 19:54:57 2011 +0200
+++ b/mercurial/hgweb/webutil.py Wed Apr 20 21:41:41 2011 +0200
@@ -7,7 +7,7 @@
# GNU General Public License version 2 or any later version.
import os, copy
-from mercurial import match, patch, util, error, ui
+from mercurial import match, patch, scmutil, error, ui
from mercurial.node import hex, nullid
def up(p):
@@ -127,7 +127,7 @@
def cleanpath(repo, path):
path = path.lstrip('/')
- return util.canonpath(repo.root, '', path)
+ return scmutil.canonpath(repo.root, '', path)
def changectx(repo, req):
changeid = "tip"
--- a/mercurial/match.py Wed Apr 20 19:54:57 2011 +0200
+++ b/mercurial/match.py Wed Apr 20 21:41:41 2011 +0200
@@ -6,7 +6,7 @@
# GNU General Public License version 2 or any later version.
import re
-import util
+import scmutil, util
from i18n import _
class match(object):
@@ -269,7 +269,7 @@
pats = []
for kind, name in [_patsplit(p, default) for p in names]:
if kind in ('glob', 'relpath'):
- name = util.canonpath(root, cwd, name, auditor)
+ name = scmutil.canonpath(root, cwd, name, auditor)
elif kind in ('relglob', 'path'):
name = util.normpath(name)
elif kind in ('listfile', 'listfile0'):
--- a/mercurial/patch.py Wed Apr 20 19:54:57 2011 +0200
+++ b/mercurial/patch.py Wed Apr 20 21:41:41 2011 +0200
@@ -21,7 +21,8 @@
# helper functions
def copyfile(src, dst, basedir):
- abssrc, absdst = [util.canonpath(basedir, basedir, x) for x in [src, dst]]
+ abssrc, absdst = [scmutil.canonpath(basedir, basedir, x)
+ for x in [src, dst]]
if os.path.lexists(absdst):
raise util.Abort(_("cannot create %s: destination already exists") %
dst)
--- a/mercurial/scmutil.py Wed Apr 20 19:54:57 2011 +0200
+++ b/mercurial/scmutil.py Wed Apr 20 21:41:41 2011 +0200
@@ -120,3 +120,51 @@
f.write(src)
f.close()
self._fixfilemode(dst)
+
+def canonpath(root, cwd, myname, auditor=None):
+ '''return the canonical path of myname, given cwd and root'''
+ if util.endswithsep(root):
+ rootsep = root
+ else:
+ rootsep = root + os.sep
+ name = myname
+ if not os.path.isabs(name):
+ name = os.path.join(root, cwd, name)
+ name = os.path.normpath(name)
+ if auditor is None:
+ auditor = util.path_auditor(root)
+ if name != rootsep and name.startswith(rootsep):
+ name = name[len(rootsep):]
+ auditor(name)
+ return util.pconvert(name)
+ elif name == root:
+ return ''
+ else:
+ # Determine whether `name' is in the hierarchy at or beneath `root',
+ # by iterating name=dirname(name) until that causes no change (can't
+ # check name == '/', because that doesn't work on windows). For each
+ # `name', compare dev/inode numbers. If they match, the list `rel'
+ # holds the reversed list of components making up the relative file
+ # name we want.
+ root_st = os.stat(root)
+ rel = []
+ while True:
+ try:
+ name_st = os.stat(name)
+ except OSError:
+ break
+ if util.samestat(name_st, root_st):
+ if not rel:
+ # name was actually the same as root (maybe a symlink)
+ return ''
+ rel.reverse()
+ name = os.path.join(*rel)
+ auditor(name)
+ return util.pconvert(name)
+ dirname, basename = os.path.split(name)
+ rel.append(basename)
+ if dirname == name:
+ break
+ name = dirname
+
+ raise util.Abort('%s not under root' % myname)
--- a/mercurial/util.py Wed Apr 20 19:54:57 2011 +0200
+++ b/mercurial/util.py Wed Apr 20 21:41:41 2011 +0200
@@ -295,54 +295,6 @@
b.reverse()
return os.sep.join((['..'] * len(a)) + b) or '.'
-def canonpath(root, cwd, myname, auditor=None):
- """return the canonical path of myname, given cwd and root"""
- if endswithsep(root):
- rootsep = root
- else:
- rootsep = root + os.sep
- name = myname
- if not os.path.isabs(name):
- name = os.path.join(root, cwd, name)
- name = os.path.normpath(name)
- if auditor is None:
- auditor = path_auditor(root)
- if name != rootsep and name.startswith(rootsep):
- name = name[len(rootsep):]
- auditor(name)
- return pconvert(name)
- elif name == root:
- return ''
- else:
- # Determine whether `name' is in the hierarchy at or beneath `root',
- # by iterating name=dirname(name) until that causes no change (can't
- # check name == '/', because that doesn't work on windows). For each
- # `name', compare dev/inode numbers. If they match, the list `rel'
- # holds the reversed list of components making up the relative file
- # name we want.
- root_st = os.stat(root)
- rel = []
- while True:
- try:
- name_st = os.stat(name)
- except OSError:
- break
- if samestat(name_st, root_st):
- if not rel:
- # name was actually the same as root (maybe a symlink)
- return ''
- rel.reverse()
- name = os.path.join(*rel)
- auditor(name)
- return pconvert(name)
- dirname, basename = os.path.split(name)
- rel.append(basename)
- if dirname == name:
- break
- name = dirname
-
- raise Abort('%s not under root' % myname)
-
_hgexecutable = None
def main_is_frozen():