本文整理汇总了Python中mercurial.util.normpath函数的典型用法代码示例。如果您正苦于以下问题:Python normpath函数的具体用法?Python normpath怎么用?Python normpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normpath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: to_relative_path
def to_relative_path(self, fullpath): # unicode or QString
if not fullpath:
return
fullpath = util.normpath(unicode(fullpath))
pathprefix = util.normpath(hglib.tounicode(self.repo.root)) + '/'
if not os.path.normcase(fullpath).startswith(os.path.normcase(pathprefix)):
return
return fullpath[len(pathprefix):]
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:8,代码来源:rename.py
示例2: lockany
def lockany(self):
wfile = QFileDialog.getOpenFileName(
self, _('Open a (nonmergable) file you wish to be locked'),
self.repo.root, _FILE_FILTER)
wfile = util.normpath(unicode(wfile))
pathprefix = util.normpath(hglib.tounicode(self.repo.root)) + '/'
if not os.path.normcase(wfile).startswith(os.path.normcase(pathprefix)):
self.showMessage.emit(_('File was not within current repository'))
wfile = wfile[len(pathprefix):]
self.showMessage.emit(_('Locking %s') % wfile)
self.lockrun(['lock', wfile])
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:13,代码来源:locktool.py
示例3: _normalizeEntryPaths
def _normalizeEntryPaths(self, entry):
"""
Normalize the name and old_name of an entry.
This implementation uses ``mercurial.util.normpath()``, since
at this level hg is expecting UNIX style pathnames, with
forward slash"/" as separator, also under insane operating systems.
"""
from mercurial.util import normpath
entry.name = normpath(self.repository.encode(entry.name))
if entry.old_name:
entry.old_name = normpath(self.repository.encode(entry.old_name))
开发者ID:lelit,项目名称:tailor,代码行数:14,代码来源:hg.py
示例4: _cwdlist
def _cwdlist(repo):
""" List the contents in the current directory. Annotate
the files in the sparse profile.
"""
ctx = repo['.']
mf = ctx.manifest()
cwd = util.normpath(os.getcwd())
# Get the root of the repo so that we remove the content of
# the root from the current working directory
root = repo.root
if cwd.startswith(root):
cwd = cwd[len(root):]
else:
raise error.Abort(_("the current working directory should begin " +
"with the root %s") % root)
cwd = cwd.strip("/")
sparsematch = repo.sparsematch(ctx.rev())
checkedoutentries = set()
allentries = set()
cwdlength = len(cwd) + 1
for filepath in mf:
if filepath.startswith(cwd):
tail = filepath[cwdlength:] if cwdlength > 1 else filepath
entryname = tail.split('/', 1)[0]
allentries.add(entryname)
if sparsematch(filepath):
checkedoutentries.add(entryname)
ui = repo.ui
for entry in sorted(allentries):
marker = ' ' if entry in checkedoutentries else '-'
ui.status("%s %s\n" % (marker, entry))
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:35,代码来源:sparse.py
示例5: keyfunc
def keyfunc(x):
l = hglib.fromunicode(x.rootpath())
try:
return hgsuborder.index(util.normpath(l))
except ValueError:
# If an item is not found, place it at the top
return 0
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:7,代码来源:reporegistry.py
示例6: addRepo
def addRepo(self, group, root, row=-1):
grp = group
if grp == None:
grp = self.allreposIndex()
rgi = grp.internalPointer()
if row < 0:
row = rgi.childCount()
# make sure all paths are properly normalized
root = os.path.normpath(root)
# Check whether the repo that we are adding is a subrepo
# This check could be expensive, particularly for network repositories
# Thus, only perform this check on network repos if the showNetworkSubrepos
# flag is set
itemIsSubrepo = False
if self.showNetworkSubrepos \
or not paths.netdrive_status(root):
outerrepopath = paths.find_root(os.path.dirname(root))
if outerrepopath:
# Check whether repo we are adding is a subrepo of
# its containing (outer) repo
# This check is currently quite imperfect, since it
# only checks the current repo revision
outerrepo = hg.repository(ui.ui(), path=outerrepopath)
relroot = util.normpath(root[len(outerrepopath)+1:])
if relroot in outerrepo['.'].substate:
itemIsSubrepo = True
self.beginInsertRows(grp, row, row)
if itemIsSubrepo:
ri = SubrepoItem(root)
else:
ri = RepoItem(root)
rgi.insertChild(row, ri)
if not self.showSubrepos \
or (not self.showNetworkSubrepos and paths.netdrive_status(root)):
self.endInsertRows()
return
invalidRepoList = ri.appendSubrepos()
self.endInsertRows()
if invalidRepoList:
if invalidRepoList[0] == root:
qtlib.WarningMsgBox(_('Could not get subrepository list'),
_('It was not possible to get the subrepository list for '
'the repository in:<br><br><i>%s</i>') % root)
else:
qtlib.WarningMsgBox(_('Could not open some subrepositories'),
_('It was not possible to fully load the subrepository '
'list for the repository in:<br><br><i>%s</i><br><br>'
'The following subrepositories may be missing, broken or '
'on an inconsistent state and cannot be accessed:'
'<br><br><i>%s</i>') %
(root, "<br>".join(invalidRepoList)))
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:58,代码来源:repotreemodel.py
示例7: init_data
def init_data(self, pats):
"""calculate initial values for widgets"""
fname = ''
target = ''
root = self.repo.root
cwd = os.getcwd()
try:
fname = scmutil.canonpath(root, cwd, pats[0])
target = scmutil.canonpath(root, cwd, pats[1])
except:
pass
os.chdir(root)
fname = hglib.tounicode(util.normpath(fname))
if target:
target = hglib.tounicode(util.normpath(target))
else:
target = fname
return (fname, target)
开发者ID:velorientc,项目名称:git_test7,代码行数:18,代码来源:rename.py
示例8: geturl
def geturl(path):
try:
return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
except SubversionException:
pass
if os.path.isdir(path):
path = os.path.normpath(os.path.abspath(path))
if os.name == 'nt':
path = '/' + util.normpath(path)
return 'file://%s' % path
return path
开发者ID:carlgao,项目名称:lenga,代码行数:11,代码来源:subversion.py
示例9: _renamePathname
def _renamePathname(self, oldname, newname):
"""Rename an entry"""
from os.path import join, isdir, normpath
self.log.info('Renaming %r to %r...', oldname, newname)
# Check both names, because maybe we are operating in
# disjunct dirs, and the target may be renamed to a
# temporary name
if (isdir(join(self.repository.basedir, normpath(oldname)))
or isdir(join(self.repository.basedir, normpath(newname)))):
# Given lack of support for directories in current HG,
# loop over all files under the old directory and
# do a copy on them.
for f in self._walk(oldname):
oldpath = join(oldname, f)
self._hgCommand('copy', oldpath, join(newname, f))
self._hgCommand('remove', oldpath, unlink=True)
else:
self._hgCommand('copy', oldname, newname)
self._hgCommand('remove', oldname, unlink=True)
开发者ID:lelit,项目名称:tailor,代码行数:21,代码来源:hg.py
示例10: __init__
def __init__(self, ui, path):
if svn is None:
raise MissingTool(_('Could not load Subversion python bindings'))
converter_sink.__init__(self, ui, path)
commandline.__init__(self, ui, 'svn')
self.delete = []
self.setexec = []
self.delexec = []
self.copies = []
self.wc = None
self.cwd = os.getcwd()
path = os.path.realpath(path)
created = False
if os.path.isfile(os.path.join(path, '.svn', 'entries')):
self.wc = path
self.run0('update')
else:
wcpath = os.path.join(os.getcwd(), os.path.basename(path) + '-wc')
if os.path.isdir(os.path.dirname(path)):
if not os.path.exists(os.path.join(path, 'db', 'fs-type')):
ui.status(_('initializing svn repository %r\n') %
os.path.basename(path))
commandline(ui, 'svnadmin').run0('create', path)
created = path
path = util.normpath(path)
if not path.startswith('/'):
path = '/' + path
path = 'file://' + path
ui.status(_('initializing svn working copy %r\n')
% os.path.basename(wcpath))
self.run0('checkout', path, wcpath)
self.wc = wcpath
self.opener = util.opener(self.wc)
self.wopener = util.opener(self.wc)
self.childmap = mapfile(ui, self.join('hg-childmap'))
self.is_exec = util.checkexec(self.wc) and util.is_exec or None
if created:
hook = os.path.join(created, 'hooks', 'pre-revprop-change')
fp = open(hook, 'w')
fp.write(pre_revprop_change)
fp.close()
util.set_flags(hook, False, True)
xport = transport.SvnRaTransport(url=geturl(path))
self.uuid = svn.ra.get_uuid(xport.ra)
开发者ID:MezzLabs,项目名称:mercurial,代码行数:52,代码来源:subversion.py
示例11: __init__
def __init__(self, ui, path):
checktool('svn', debname='subversion')
checktool('svnadmin', debname='subversion')
converter_sink.__init__(self, ui, path)
commandline.__init__(self, ui, 'svn')
self.delete = []
self.setexec = []
self.delexec = []
self.copies = []
self.wc = None
self.cwd = os.getcwd()
created = False
if os.path.isfile(os.path.join(path, '.svn', 'entries')):
self.wc = os.path.realpath(path)
self.run0('update')
else:
if not re.search(r'^(file|http|https|svn|svn\+ssh)\://', path):
path = os.path.realpath(path)
if os.path.isdir(os.path.dirname(path)):
if not os.path.exists(os.path.join(path, 'db', 'fs-type')):
ui.status(_('initializing svn repository %r\n') %
os.path.basename(path))
commandline(ui, 'svnadmin').run0('create', path)
created = path
path = util.normpath(path)
if not path.startswith('/'):
path = '/' + path
path = 'file://' + path
wcpath = os.path.join(os.getcwd(), os.path.basename(path) + '-wc')
ui.status(_('initializing svn working copy %r\n')
% os.path.basename(wcpath))
self.run0('checkout', path, wcpath)
self.wc = wcpath
self.opener = scmutil.opener(self.wc)
self.wopener = scmutil.opener(self.wc)
self.childmap = mapfile(ui, self.join('hg-childmap'))
self.is_exec = util.checkexec(self.wc) and util.isexec or None
if created:
hook = os.path.join(created, 'hooks', 'pre-revprop-change')
fp = open(hook, 'w')
fp.write(pre_revprop_change)
fp.close()
util.setflags(hook, False, True)
output = self.run0('info')
self.uuid = self.uuid_re.search(output).group(1).strip()
开发者ID:sitano,项目名称:hgext,代码行数:51,代码来源:subversion.py
示例12: appendSubrepos
def appendSubrepos(self, repo=None):
self._sharedpath = ''
invalidRepoList = []
try:
sri = None
if repo is None:
if not os.path.exists(self._root):
self._valid = False
return [hglib.fromunicode(self._root)]
elif (not os.path.exists(os.path.join(self._root, '.hgsub'))
and not os.path.exists(
os.path.join(self._root, '.hg', 'sharedpath'))):
return [] # skip repo creation, which is expensive
repo = hg.repository(ui.ui(), hglib.fromunicode(self._root))
if repo.sharedpath != repo.path:
self._sharedpath = hglib.tounicode(repo.sharedpath)
wctx = repo['.']
sortkey = lambda x: os.path.basename(util.normpath(repo.wjoin(x)))
for subpath in sorted(wctx.substate, key=sortkey):
sri = None
abssubpath = repo.wjoin(subpath)
subtype = wctx.substate[subpath][2]
sriIsValid = os.path.isdir(abssubpath)
sri = _newSubrepoItem(hglib.tounicode(abssubpath),
repotype=subtype)
sri._valid = sriIsValid
self.appendChild(sri)
if not sriIsValid:
self._valid = False
sri._valid = False
invalidRepoList.append(repo.wjoin(subpath))
return invalidRepoList
if subtype == 'hg':
# Only recurse into mercurial subrepos
sctx = wctx.sub(subpath)
invalidSubrepoList = sri.appendSubrepos(sctx._repo)
if invalidSubrepoList:
self._valid = False
invalidRepoList += invalidSubrepoList
except (EnvironmentError, error.RepoError, util.Abort), e:
# Add the repo to the list of repos/subrepos
# that could not be open
self._valid = False
if sri:
sri._valid = False
invalidRepoList.append(abssubpath)
invalidRepoList.append(hglib.fromunicode(self._root))
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:50,代码来源:repotreeitem.py
示例13: geturl
def geturl(path):
try:
return svn.client.url_from_path(svn.core.svn_path_canonicalize(path))
except SubversionException:
pass
if os.path.isdir(path):
path = os.path.normpath(os.path.abspath(path))
if os.name == 'nt':
path = '/' + util.normpath(path)
# Module URL is later compared with the repository URL returned
# by svn API, which is UTF-8.
path = encoding.tolocal(path)
return 'file://%s' % urllib.quote(path)
return path
开发者ID:iluxa-c0m,项目名称:mercurial-crew-tonfa,代码行数:14,代码来源:subversion.py
示例14: _renamePathname
def _renamePathname(self, oldname, newname):
"""Rename an entry"""
from os.path import join, isdir, normpath
repo = self._getRepo()
self.log.info('Renaming %r to %r...', oldname, newname)
if isdir(join(self.repository.basedir, normpath(newname))):
# Given lack of support for directories in current HG,
# loop over all files under the old directory and
# do a copy on them.
for f in self._walk(oldname):
oldpath = join(oldname, f)
repo.copy(oldpath, join(newname, f))
repo.remove([oldpath], unlink=True)
else:
repo.copy(oldname, newname)
repo.remove([oldname], unlink=True)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:19,代码来源:hg.py
示例15: sortbyhgsub
def sortbyhgsub(self):
ip = self.selitem.internalPointer()
repo = hg.repository(ui.ui(), ip.rootpath())
ctx = repo['.']
wfile = '.hgsub'
if wfile not in ctx:
return self.sortbypath()
data = ctx[wfile].data().strip()
data = data.split('\n')
getsubpath = lambda x: x.split('=')[0].strip()
abspath = lambda x: util.normpath(repo.wjoin(x))
hgsuborder = [abspath(getsubpath(x)) for x in data]
def keyfunc(x):
try:
return hgsuborder.index(util.normpath(x.rootpath()))
except:
# If an item is not found, place it at the top
return 0
self.tview.model().sortchilds(ip.childs, keyfunc)
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:19,代码来源:reporegistry.py
示例16: sortbyhgsub
def sortbyhgsub(self):
model = self.tview.model()
index = self.tview.currentIndex()
ip = index.internalPointer()
repo = hg.repository(ui.ui(), hglib.fromunicode(model.repoRoot(index)))
ctx = repo['.']
wfile = '.hgsub'
if wfile not in ctx:
return self.sortbypath()
data = ctx[wfile].data().strip()
data = data.split('\n')
getsubpath = lambda x: x.split('=')[0].strip()
abspath = lambda x: util.normpath(repo.wjoin(x))
hgsuborder = [abspath(getsubpath(x)) for x in data]
def keyfunc(x):
l = hglib.fromunicode(x.rootpath())
try:
return hgsuborder.index(util.normpath(l))
except ValueError:
# If an item is not found, place it at the top
return 0
self.tview.model().sortchilds(ip.childs, keyfunc)
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:22,代码来源:reporegistry.py
示例17: write
def write(self, fd, oldstyle=False):
"""Writes a snapshot file to a file descriptor."""
counter = 1
for tree in self.trees:
fd.write("[tree%s]\n" % counter)
root = relpath(self.top().root, tree.root)
if root == os.curdir:
root = '.'
root = util.normpath(root)
fd.write("root = %s\n" % root)
if tree.revs:
fd.write("revision = %s\n" % tree.revs[0])
else:
fd.write("revision = None\n")
if not oldstyle:
for name, path in tree.paths.items():
fd.write("path.%s = %s\n" % (name, path))
else:
fd.write("\n[tree%s.paths]\n" % counter)
for name, path in tree.paths.items():
fd.write("%s = %s\n" % (name, path))
fd.write("\n")
counter += 1
开发者ID:kiorky,项目名称:cryptelium-overlay,代码行数:23,代码来源:forest.py
示例18: len
oldlog = []
break
ui.note(_('cache has %d log entries\n') % len(oldlog))
except Exception, e:
ui.note(_('error reading cache: %r\n') % e)
if oldlog:
date = oldlog[-1].date # last commit date as a (time,tz) tuple
date = util.datestr(date, '%Y/%m/%d %H:%M:%S %1%2')
# build the CVS commandline
cmd = ['cvs', '-q']
if root:
cmd.append('-d%s' % root)
p = util.normpath(getrepopath(root))
if not p.endswith('/'):
p += '/'
if prefix:
# looks like normpath replaces "" by "."
prefix = p + util.normpath(prefix)
else:
prefix = p
cmd.append(['log', 'rlog'][rlog])
if date:
# no space between option and date string
cmd.append('-d>%s' % date)
cmd.append(directory)
# state machine begins here
tags = {} # dictionary of revisions on current file with their tags
开发者ID:codeskyblue,项目名称:gobuild-1,代码行数:31,代码来源:cvsps.py
示例19: createlog
#.........这里部分代码省略.........
# :pserver:[email protected]:/path
# and
# /pserver/user/server/path
# are mapped to different cache file names.
cachefile = root.split(":") + [directory, "cache"]
cachefile = ['-'.join(re.findall(r'\w+', s)) for s in cachefile if s]
cachefile = os.path.join(cachedir,
'.'.join([s for s in cachefile if s]))
if cache == 'update':
try:
ui.note(_('reading cvs log cache %s\n') % cachefile)
oldlog = pickle.load(open(cachefile))
for e in oldlog:
if not (util.safehasattr(e, 'branchpoints') and
util.safehasattr(e, 'commitid') and
util.safehasattr(e, 'mergepoint')):
ui.status(_('ignoring old cache\n'))
oldlog = []
break
ui.note(_('cache has %d log entries\n') % len(oldlog))
except Exception as e:
ui.note(_('error reading cache: %r\n') % e)
if oldlog:
date = oldlog[-1].date # last commit date as a (time,tz) tuple
date = util.datestr(date, '%Y/%m/%d %H:%M:%S %1%2')
# build the CVS commandline
cmd = ['cvs', '-q']
if root:
cmd.append('-d%s' % root)
p = util.normpath(getrepopath(root))
if not p.endswith('/'):
p += '/'
if prefix:
# looks like normpath replaces "" by "."
prefix = p + util.normpath(prefix)
else:
prefix = p
cmd.append(['log', 'rlog'][rlog])
if date:
# no space between option and date string
cmd.append('-d>%s' % date)
cmd.append(directory)
# state machine begins here
tags = {} # dictionary of revisions on current file with their tags
branchmap = {} # mapping between branch names and revision numbers
rcsmap = {}
state = 0
store = False # set when a new record can be appended
cmd = [util.shellquote(arg) for arg in cmd]
ui.note(_("running %s\n") % (' '.join(cmd)))
ui.debug("prefix=%r directory=%r root=%r\n" % (prefix, directory, root))
pfp = util.popen(' '.join(cmd))
peek = pfp.readline()
while True:
line = peek
if line == '':
break
peek = pfp.readline()
if line.endswith('\n'):
开发者ID:Distrotech,项目名称:mercurial,代码行数:67,代码来源:cvsps.py
示例20: appendSubrepos
def appendSubrepos(self, repo=None):
invalidRepoList = []
# Mercurial repos are the only ones that can have subrepos
if self.repotype() == 'hg':
try:
sri = None
if repo is None:
if not os.path.exists(self._root):
self._valid = False
return [self._root]
elif not os.path.exists(os.path.join(self._root, '.hgsub')):
return [] # skip repo creation, which is expensive
repo = hg.repository(ui.ui(), self._root)
wctx = repo['.']
sortkey = lambda x: os.path.basename(util.normpath(repo.wjoin(x)))
for subpath in sorted(wctx.substate, key=sortkey):
sri = None
abssubpath = repo.wjoin(subpath)
subtype = wctx.substate[subpath][2]
sriIsValid = os.path.isdir(abssubpath)
sri = SubrepoItem(abssubpath, subtype=subtype)
sri._valid = sriIsValid
self.appendChild(sri)
if not sriIsValid:
self._valid = False
sri._valid = False
invalidRepoList.append(repo.wjoin(subpath))
return invalidRepoList
continue
if subtype == 'hg':
# Only recurse into mercurial subrepos
sctx = wctx.sub(subpath)
invalidSubrepoList = sri.appendSubrepos(sctx._repo)
if invalidSubrepoList:
self._valid = False
invalidRepoList += invalidSubrepoList
except (EnvironmentError, error.RepoError, util.Abort), e:
# Add the repo to the list of repos/subrepos
# that could not be open
self._valid = False
if sri:
sri._valid = False
invalidRepoList.append(abssubpath)
invalidRepoList.append(self._root)
except Exception, e:
# If any other sort of exception happens, show the corresponding
# error message, but do not crash!
# Note that we _also_ will mark the offending repos as invalid
# It is unfortunate that Python 2.4, which we target does not
# support combined try/except/finally clauses, forcing us
# to duplicate some code here
self._valid = False
if sri:
sri._valid = False
invalidRepoList.append(abssubpath)
invalidRepoList.append(self._root)
# Show a warning message indicating that there was an error
if repo:
rootpath = repo.root
else:
rootpath = self._root
warningMessage = (_('An exception happened while loading the ' \
'subrepos of:<br><br>"%s"<br><br>') + \
_('The exception error message was:<br><br>%s<br><br>') +\
_('Click OK to continue or Abort to exit.')) \
% (rootpath, e.message)
res = qtlib.WarningMsgBox(_('Error loading subrepos'),
warningMessage,
buttons = QMessageBox.Ok | QMessageBox.Abort)
# Let the user abort so that he gets the full exception info
if res == QMessageBox.Abort:
raise
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:77,代码来源:repotreeitem.py
注:本文中的mercurial.util.normpath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论