本文整理汇总了Python中mercurial.util.pconvert函数的典型用法代码示例。如果您正苦于以下问题:Python pconvert函数的具体用法?Python pconvert怎么用?Python pconvert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pconvert函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: refresh
def refresh(self):
if self.lastrefresh + self.refreshinterval > time.time():
return
if self.baseui:
u = self.baseui.copy()
else:
u = ui.ui()
u.setconfig('ui', 'report_untrusted', 'off', 'hgwebdir')
u.setconfig('ui', 'nontty', 'true', 'hgwebdir')
# displaying bundling progress bar while serving feels wrong and may
# break some wsgi implementations.
u.setconfig('progress', 'disable', 'true', 'hgweb')
if not isinstance(self.conf, (dict, list, tuple)):
map = {'paths': 'hgweb-paths'}
if not os.path.exists(self.conf):
raise util.Abort(_('config file %s not found!') % self.conf)
u.readconfig(self.conf, remap=map, trust=True)
paths = []
for name, ignored in u.configitems('hgweb-paths'):
for path in u.configlist('hgweb-paths', name):
paths.append((name, path))
elif isinstance(self.conf, (list, tuple)):
paths = self.conf
elif isinstance(self.conf, dict):
paths = self.conf.items()
repos = findrepos(paths)
for prefix, root in u.configitems('collections'):
prefix = util.pconvert(prefix)
for path in scmutil.walkrepos(root, followsym=True):
repo = os.path.normpath(path)
name = util.pconvert(repo)
if name.startswith(prefix):
name = name[len(prefix):]
repos.append((name.lstrip('/'), repo))
self.repos = repos
self.ui = u
encoding.encoding = self.ui.config('web', 'encoding',
encoding.encoding)
self.style = self.ui.config('web', 'style', 'paper')
self.templatepath = self.ui.config('web', 'templates', None)
self.stripecount = self.ui.config('web', 'stripes', 1)
if self.stripecount:
self.stripecount = int(self.stripecount)
self._baseurl = self.ui.config('web', 'baseurl')
prefix = self.ui.config('web', 'prefix', '')
if prefix.startswith('/'):
prefix = prefix[1:]
if prefix.endswith('/'):
prefix = prefix[:-1]
self.prefix = prefix
self.lastrefresh = time.time()
开发者ID:pierfort123,项目名称:mercurial,代码行数:55,代码来源:hgwebdir_mod.py
示例2: parsedefinitions
def parsedefinitions(ui, repo, svnroot, exts):
"""Return (targetdir, revision, source) tuples. Fail if nested
targetdirs are detected. source is an svn project URL.
"""
defs = []
for base in sorted(exts):
for line in exts[base]:
try:
path, rev, source, pegrev = parsedefinition(line)
except BadDefinition:
ui.warn(_('ignoring invalid external definition: %r' % line))
continue
if re_scheme.search(source):
pass
elif source.startswith('^/'):
source = svnroot + source[1:]
else:
ui.warn(_('ignoring unsupported non-fully qualified external: %r' % source))
continue
wpath = hgutil.pconvert(os.path.join(base, path))
wpath = hgutil.canonpath(repo.root, '', wpath)
defs.append((wpath, rev, source, pegrev))
# Check target dirs are not nested
defs.sort()
for i, d in enumerate(defs):
for d2 in defs[i+1:]:
if d2[0].startswith(d[0] + '/'):
raise hgutil.Abort(_('external directories cannot nest:\n%s\n%s')
% (d[0], d2[0]))
return defs
开发者ID:chaptastic,项目名称:config_files,代码行数:30,代码来源:svnexternals.py
示例3: snapshot_node
def snapshot_node(ui, repo, files, node, tmproot):
"""
snapshot files as of some revision
(adapted from Extdiff extension)
"""
mf = repo.changectx(node).manifest()
dirname = os.path.basename(repo.root)
if dirname == "":
dirname = "root"
dirname = "%s.%s" % (dirname, short(node))
base = os.path.join(tmproot, dirname)
try:
os.mkdir(base)
except:
pass
ui.note(_("making snapshot of %d files from rev %s\n") % (len(files), short(node)))
for fn in files:
if not fn in mf:
# skipping new file after a merge ?
continue
wfn = util.pconvert(fn)
ui.note(" %s\n" % wfn)
dest = os.path.join(base, wfn)
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
os.makedirs(destdir)
data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
open(dest, "wb").write(data)
return dirname
开发者ID:tdjordan,项目名称:tortoisegit,代码行数:29,代码来源:gdialog.py
示例4: parsedefinitions
def parsedefinitions(ui, repo, svnroot, exts):
"""Return (targetdir, revision, source) tuples. Fail if nested
targetdirs are detected. source is an svn project URL.
"""
defs = []
for base in sorted(exts):
for line in exts[base]:
if not line.strip() or line.lstrip().startswith('#'):
# Ignore comments and blank lines
continue
try:
path, rev, source, pegrev, norevline = parsedefinition(line)
except BadDefinition:
ui.warn(_('ignoring invalid external definition: %r\n' % line))
continue
source = resolvesource(ui, svnroot, source)
if source is None:
continue
wpath = hgutil.pconvert(os.path.join(base, path))
wpath = hgutil.canonpath(repo.root, '', wpath)
defs.append((wpath, rev, source, pegrev, norevline, base))
# Check target dirs are not nested
defs.sort()
for i, d in enumerate(defs):
for d2 in defs[i+1:]:
if d2[0].startswith(d[0] + '/'):
raise hgutil.Abort(_('external directories cannot nest:\n%s\n%s')
% (d[0], d2[0]))
return defs
开发者ID:pnkfelix,项目名称:ConfigFiles,代码行数:29,代码来源:svnexternals.py
示例5: function
def function(tree, srcpath, opts):
if snapfile:
opts['rev'] = tree.revs
else:
destpath = relpath(os.path.abspath(os.curdir), tree.root)
rpath = util.pconvert(relpath(toproot, tree.root))
if not srcpath:
srcpath = forest.top().getpath(source)
if srcpath:
srcpath = '/'.join((srcpath, rpath))
else:
ui.warn(_("warning: %s\n") %
_("repository %s not found") % source[0])
try:
tree.getrepo(ui)
except RepoError:
# Need to clone
quiet = ui.quiet
try:
ui.quiet = True # Hack to shut up qclone's ui.status()
qclone(ui=ui,
source=srcpath, sroot=source,
dest=destpath, rpath=rpath,
opts=opts)
except util.Abort, err:
ui.warn(_("skipped: %s\n") % err)
ui.quiet = quiet
return
开发者ID:kiorky,项目名称:cryptelium-overlay,代码行数:28,代码来源:forest.py
示例6: snapshot_wdir
def snapshot_wdir(ui, repo, files, tmproot):
'''snapshot files from working directory.
if not using snapshot, -I/-X does not work and recursive diff
in tools like kdiff3 and meld displays too many files.'''
repo_root = repo.root
dirname = os.path.basename(repo_root)
if dirname == "":
dirname = "root"
base = os.path.join(tmproot, dirname)
os.mkdir(base)
ui.note(_('making snapshot of %d files from working dir\n') %
(len(files)))
fns_and_mtime = []
for fn in files:
wfn = util.pconvert(fn)
ui.note(' %s\n' % wfn)
dest = os.path.join(base, wfn)
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
os.makedirs(destdir)
fp = open(dest, 'wb')
for chunk in util.filechunkiter(repo.wopener(wfn)):
fp.write(chunk)
fp.close()
fns_and_mtime.append((dest, os.path.join(repo_root, fn),
os.path.getmtime(dest)))
return dirname, fns_and_mtime
开发者ID:c0ns0le,项目名称:cygwin,代码行数:34,代码来源:extdiff.py
示例7: _hgwebdir_refresh
def _hgwebdir_refresh(self):
if self.lastrefresh + self.refreshinterval > time.time():
return
_hgwebdir_refresh_parent(self)
for prefix, root in self.ui.configitems('collections'):
prefix = util.pconvert(prefix)
for path in walkrepos(root, followsym=True):
repo = hg.repository(self.ui, path)
for npath in repo.nested:
npath = os.path.normpath(os.path.join(path, npath))
name = util.pconvert(npath)
if name.startswith(prefix):
name = name[len(prefix):]
repo = (name.lstrip('/'), npath)
if repo not in self.repos:
self.repos.append(repo)
self.lastrefresh = time.time()
开发者ID:tygerlord,项目名称:hgnested,代码行数:17,代码来源:__init__.py
示例8: seed
def seed(ui, snapshot=None, source='default', **opts):
"""populate a forest according to a snapshot file.
Populate an empty local forest according to a snapshot file.
Given a snapshot file, clone any non-existant directory from the
provided path-alias. This defaults to cloning from the 'default'
path.
Unless the --tip option is set, this command will clone the
revision specified in the snapshot file.
Look at the help text for the clone command for more information.
"""
snapfile = snapshot or opts['snapfile']
if not snapfile:
raise cmdutil.ParseError("fseed", _("invalid arguments"))
forest = Forest(snapfile=snapfile)
tip = opts['tip']
dest = opts['root']
if not dest:
dest = os.curdir
forest.trees.remove(forest.top())
dest = os.path.normpath(dest)
for tree in forest.trees:
srcpath = tree.getpath([source])
if not srcpath:
ui.status("[%s]\n" % util.pconvert(tree.root))
ui.warn(_("skipped: path alias %s not defined\n") % source)
ui.status("\n")
continue
srcpath = urltopath(srcpath)
if tree.root == ".":
destpath = dest
else:
destpath = os.path.join(dest, tree.root)
opts['rev'] = tree.revs
try:
qclone(ui=ui,
source=srcpath, sroot=None,
dest=destpath, rpath=util.pconvert(tree.root),
opts=opts)
except util.Abort, err:
ui.warn(_("skipped: %s\n") % err)
ui.status("\n")
开发者ID:kiorky,项目名称:cryptelium-overlay,代码行数:46,代码来源:forest.py
示例9: splitstandin
def splitstandin(filename):
# Split on / because that's what dirstate always uses, even on Windows.
# Change local separator to / first just in case we are passed filenames
# from an external source (like the command line).
bits = util.pconvert(filename).split('/', 1)
if len(bits) == 2 and bits[0] == shortname:
return bits[1]
else:
return None
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:9,代码来源:lfutil.py
示例10: refresh
def refresh(self):
if self.lastrefresh + self.refreshinterval > time.time():
return
if self.baseui:
u = self.baseui.copy()
else:
u = ui.ui()
u.setconfig('ui', 'report_untrusted', 'off')
u.setconfig('ui', 'interactive', 'off')
if not isinstance(self.conf, (dict, list, tuple)):
map = {'paths': 'hgweb-paths'}
if not os.path.exists(self.conf):
raise util.Abort(_('config file %s not found!') % self.conf)
u.readconfig(self.conf, remap=map, trust=True)
paths = u.configitems('hgweb-paths')
elif isinstance(self.conf, (list, tuple)):
paths = self.conf
elif isinstance(self.conf, dict):
paths = self.conf.items()
repos = findrepos(paths)
for prefix, root in u.configitems('collections'):
prefix = util.pconvert(prefix)
for path in util.walkrepos(root, followsym=True):
repo = os.path.normpath(path)
name = util.pconvert(repo)
if name.startswith(prefix):
name = name[len(prefix):]
repos.append((name.lstrip('/'), repo))
self.repos = repos
self.ui = u
encoding.encoding = self.ui.config('web', 'encoding',
encoding.encoding)
self.style = self.ui.config('web', 'style', 'paper')
self.templatepath = self.ui.config('web', 'templates', None)
self.stripecount = self.ui.config('web', 'stripes', 1)
if self.stripecount:
self.stripecount = int(self.stripecount)
self._baseurl = self.ui.config('web', 'baseurl')
self.lastrefresh = time.time()
开发者ID:MezzLabs,项目名称:mercurial,代码行数:43,代码来源:hgwebdir_mod.py
示例11: shortreponame
def shortreponame(ui):
name = ui.config('web', 'name')
if not name:
return
src = ui.configsource('web', 'name') # path:line
if '/.hg/hgrc:' not in util.pconvert(src):
# global web.name will set the same name to all repositories
ui.debug('ignoring global web.name defined at %s\n' % src)
return
return name
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:10,代码来源:hglib.py
示例12: addrepocontentstotree
def addrepocontentstotree(roote, ctx, toproot=''):
subpaths = ctx.substate.keys()
for path in subpaths:
if not 'S' in self._statusfilter:
break
e = roote
pathelements = hglib.tounicode(path).split('/')
for p in pathelements[:-1]:
if not p in e:
e.addchild(p)
e = e[p]
p = pathelements[-1]
if not p in e:
e.addchild(p)
e = e[p]
e.setstatus('S')
# If the subrepo exists in the working directory
# and it is a mercurial subrepo,
# add the files that it contains to the tree as well, according
# to the status filter
abspath = os.path.join(ctx._repo.root, path)
if os.path.isdir(abspath):
# Add subrepo files to the tree
substate = ctx.substate[path]
# Add the subrepo info to the _subinfo dictionary:
# The value is the subrepo context, while the key is
# the path of the subrepo relative to the topmost repo
if toproot:
# Note that we cannot use os.path.join() because we
# need path items to be separated by "/"
toprelpath = '/'.join([toproot, path])
else:
toprelpath = path
toprelpath = util.pconvert(toprelpath)
self._subinfo[toprelpath] = \
{'substate': substate, 'ctx': None}
srev = substate[1]
sub = ctx.sub(path)
if srev and isinstance(sub, hgsubrepo):
srepo = sub._repo
if srev in srepo:
sctx = srepo[srev]
self._subinfo[toprelpath]['ctx'] = sctx
# Add the subrepo contents to the tree
e = addrepocontentstotree(e, sctx, toprelpath)
# Add regular files to the tree
status, uncleanpaths, files = getctxtreeinfo(ctx)
addfilestotree(roote, files, status, uncleanpaths)
return roote
开发者ID:velorientc,项目名称:git_test7,代码行数:55,代码来源:manifestmodel.py
示例13: _ignore_file
def _ignore_file(self, stat, file):
ignore = open(self.repo.wjoin('.hgignore'), 'a')
try:
try:
ignore.write('glob:' + util.pconvert(file) + '\n')
except IOError:
Prompt('Ignore Failed', 'Could not update .hgignore', self).run()
finally:
ignore.close()
self.reload_status()
return True
开发者ID:tdjordan,项目名称:tortoisegit,代码行数:11,代码来源:status.py
示例14: standin
def standin(filename):
'''Return the repo-relative path to the standin for the specified big
file.'''
# Notes:
# 1) Most callers want an absolute path, but _createstandin() needs
# it repo-relative so lfadd() can pass it to repoadd(). So leave
# it up to the caller to use repo.wjoin() to get an absolute path.
# 2) Join with '/' because that's what dirstate always uses, even on
# Windows. Change existing separator to '/' first in case we are
# passed filenames from an external source (like the command line).
return shortname + '/' + util.pconvert(filename)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:11,代码来源:lfutil.py
示例15: standin
def standin(filename):
'''Return the repo-relative path to the standin for the specified big
file.'''
# Notes:
# 1) Some callers want an absolute path, but for instance addlargefiles
# needs it repo-relative so it can be passed to repo[None].add(). So
# leave it up to the caller to use repo.wjoin() to get an absolute path.
# 2) Join with '/' because that's what dirstate always uses, even on
# Windows. Change existing separator to '/' first in case we are
# passed filenames from an external source (like the command line).
return shortnameslash + util.pconvert(filename)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:11,代码来源:lfutil.py
示例16: urlrepos
def urlrepos(prefix, roothead, paths):
"""yield url paths and filesystem paths from a list of repo paths
>>> list(urlrepos('hg', '/opt', ['/opt/r', '/opt/r/r', '/opt']))
[('hg/r', '/opt/r'), ('hg/r/r', '/opt/r/r'), ('hg', '/opt')]
>>> list(urlrepos('', '/opt', ['/opt/r', '/opt/r/r', '/opt']))
[('r', '/opt/r'), ('r/r', '/opt/r/r'), ('', '/opt')]
"""
for path in paths:
path = os.path.normpath(path)
yield (prefix + '/' +
util.pconvert(path[len(roothead):]).lstrip('/')).strip('/'), path
开发者ID:MezzLabs,项目名称:mercurial,代码行数:12,代码来源:hgwebdir_mod.py
示例17: webroot
def webroot(root):
"""strip leading prefix of repo root and turn into
url-safe path."""
count = int(self.ui.config("bugzilla", "strip", 0))
root = util.pconvert(root)
while count > 0:
c = root.find("/")
if c == -1:
break
root = root[c + 1 :]
count -= 1
return root
开发者ID:Rokko11,项目名称:idea-community,代码行数:12,代码来源:bugzilla.py
示例18: webroot
def webroot(root):
'''strip leading prefix of repo root and turn into
url-safe path.'''
count = int(self.ui.config('bugzilla', 'strip', 0))
root = util.pconvert(root)
while count > 0:
c = root.find('/')
if c == -1:
break
root = root[c+1:]
count -= 1
return root
开发者ID:Nurb432,项目名称:plan9front,代码行数:12,代码来源:bugzilla.py
示例19: strip
def strip(self, path):
'''strip leading slashes from local path, turn into web-safe path.'''
path = util.pconvert(path)
count = self.stripcount
while count > 0:
c = path.find('/')
if c == -1:
break
path = path[c+1:]
count -= 1
return path
开发者ID:carlgao,项目名称:lenga,代码行数:12,代码来源:notify.py
示例20: fileData
def fileData(self, index):
"""Returns the displayable file data at the given index"""
repo = self._repoagent.rawRepo()
if not index.isValid():
return filedata.createNullData(repo)
path, status, mst, upath, ext, sz = self.rows[index.row()]
wfile = util.pconvert(path)
ctx = repo[None]
pctx = self._pctx and self._pctx.p1() or ctx.p1()
if status == 'S':
return filedata.createSubrepoData(ctx, pctx, wfile)
else:
return filedata.createFileData(ctx, pctx, wfile, status, None, mst)
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:13,代码来源:status.py
注:本文中的mercurial.util.pconvert函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论