本文整理汇总了Python中mercurial.context.memfilectx函数的典型用法代码示例。如果您正苦于以下问题:Python memfilectx函数的具体用法?Python memfilectx怎么用?Python memfilectx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memfilectx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getfilectx
def getfilectx(repo, memctx, f):
of = files[f]
if 'deleted' in of:
if check_version(3, 2):
return None
else:
raise IOError
if 'ctx' in of:
if mode == 'hg':
ctx = of['ctx']
is_exec = ctx.isexec()
is_link = ctx.islink()
if check_version(3, 1):
return context.memfilectx(repo, f, ctx.data(),
is_link, is_exec)
else:
return context.memfilectx(f, ctx.data(),
is_link, is_exec)
else:
return of['ctx']
is_exec = of['mode'] == 'x'
is_link = of['mode'] == 'l'
rename = of.get('rename', None)
if check_version(3, 1):
return context.memfilectx(repo, f, of['data'],
is_link, is_exec, rename)
else:
return context.memfilectx(f, of['data'],
is_link, is_exec, rename)
开发者ID:felipec,项目名称:git,代码行数:29,代码来源:git-remote-hg.py
示例2: filectxfn
def filectxfn(_repo, memctx, path):
"""
Marks given path as added/changed/removed in a given _repo. This is
for internal mercurial commit function.
"""
# check if this path is removed
if path in (node.path for node in self.removed):
# Raising exception is a way to mark node for removal
raise IOError(errno.ENOENT, "%s is deleted" % path)
# check if this path is added
for node in self.added:
if node.path == path:
return memfilectx(
path=node.path,
data=node.content.encode("utf8"),
islink=False,
isexec=node.is_executable,
copied=False,
)
# or changed
for node in self.changed:
if node.path == path:
return memfilectx(
path=node.path,
data=node.content.encode("utf8"),
islink=False,
isexec=node.is_executable,
copied=False,
)
raise RepositoryError("Given path haven't been marked as added," "changed or removed (%s)" % path)
开发者ID:lukaszb,项目名称:vcs,代码行数:34,代码来源:hg.py
示例3: getfilectx
def getfilectx(repo, memctx, f):
if bfutil.is_standin(f):
# if the file isn't in the manifest then it was removed
# or renamed, raise IOError to indicate this
srcfname = bfutil.split_standin(f)
try:
fctx = ctx.filectx(srcfname)
except error.LookupError:
raise IOError()
renamed = fctx.renamed()
if renamed:
# standin is always a bfile because bfileness
# doesn't change after rename or copy
renamed = bfutil.standin(renamed[0])
return context.memfilectx(f, bfiletohash[srcfname], 'l' in fctx.flags(),
'x' in fctx.flags(), renamed)
else:
try:
fctx = ctx.filectx(f)
except error.LookupError:
raise IOError()
renamed = fctx.renamed()
if renamed:
renamed = renamed[0]
data = fctx.data()
if f == '.hgtags':
newdata = []
for line in data.splitlines():
id, name = line.split(' ', 1)
newdata.append('%s %s\n' % (node.hex(revmap[node.bin(id)]), name))
data = ''.join(newdata)
return context.memfilectx(f, data, 'l' in fctx.flags(),
'x' in fctx.flags(), renamed)
开发者ID:sergio,项目名称:dotfiles,代码行数:35,代码来源:bfcommands.py
示例4: makememfilectx
def makememfilectx(repo, path, data, islink, isexec, copied):
"""Return a memfilectx
Works around memfilectx() adding a repo argument between 3.0 and 3.1.
"""
from mercurial import context
try:
return context.memfilectx(repo, path, data, islink, isexec, copied)
except TypeError:
return context.memfilectx(path, data, islink, isexec, copied)
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:10,代码来源:compathacks.py
示例5: file_callback
def file_callback(repo, memctx, path):
if path == 'adding_file':
return context.memfilectx(path=path,
data='foo',
islink=False,
isexec=False,
copied=False)
elif path == 'adding_binary':
return context.memfilectx(path=path,
data='\0binary',
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
开发者ID:pnkfelix,项目名称:ConfigFiles,代码行数:14,代码来源:test_single_dir_clone.py
示例6: hgtagsfn
def hgtagsfn(repo, memctx, path):
assert path == '.hgtags'
return context.memfilectx(path=path,
data=tagdata,
islink=False,
isexec=False,
copied=False)
开发者ID:chaptastic,项目名称:config_files,代码行数:7,代码来源:svnmeta.py
示例7: getfilectx
def getfilectx(repo, memctx, f):
if lfutil.standin(f) in files:
# if the file isn't in the manifest then it was removed
# or renamed, raise IOError to indicate this
try:
fctx = ctx.filectx(lfutil.standin(f))
except error.LookupError:
return None
renamed = fctx.renamed()
if renamed:
renamed = lfutil.splitstandin(renamed[0])
hash = fctx.data().strip()
path = lfutil.findfile(rsrc, hash)
# If one file is missing, likely all files from this rev are
if path is None:
cachelfiles(ui, rsrc, ctx.node())
path = lfutil.findfile(rsrc, hash)
if path is None:
raise util.Abort(_("missing largefile '%s' from revision %s") % (f, node.hex(ctx.node())))
data = ""
fd = None
try:
fd = open(path, "rb")
data = fd.read()
finally:
if fd:
fd.close()
return context.memfilectx(repo, f, data, "l" in fctx.flags(), "x" in fctx.flags(), renamed)
else:
return _getnormalcontext(repo, ctx, f, revmap)
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:34,代码来源:lfcommands.py
示例8: filectxfn
def filectxfn(repo, memctx, path):
if path in files_data and files_data[path] is None:
raise IOError(errno.ENOENT, '%s is deleted' % path)
if path in binary_files or path in unknown_files:
pa = path
if branchpath:
pa = branchpath + '/' + path
data, mode = svn.get_file(pa, r.revnum)
isexe = 'x' in mode
islink = 'l' in mode
else:
isexe = exec_files.get(path, 'x' in parentctx.flags(path))
islink = link_files.get(path, 'l' in parentctx.flags(path))
data = ''
if path in files_data:
data = files_data[path]
if islink:
data = data[len('link '):]
elif path in parentctx:
data = parentctx[path].data()
copied = copies.get(path)
# TODO this branch feels like it should not be required,
# and this may actually imply a bug in getcopies
if copied not in parentctx.manifest():
copied = None
return context.memfilectx(path=path, data=data, islink=islink,
isexec=isexe, copied=copied)
开发者ID:TerminalSpirit,项目名称:dotfiles,代码行数:29,代码来源:stupid.py
示例9: getfilectx
def getfilectx(repo, memctx, f):
if lfutil.standin(f) in files:
# if the file isn't in the manifest then it was removed
# or renamed, raise IOError to indicate this
try:
fctx = ctx.filectx(lfutil.standin(f))
except error.LookupError:
raise IOError()
renamed = fctx.renamed()
if renamed:
renamed = lfutil.splitstandin(renamed[0])
hash = fctx.data().strip()
path = lfutil.findfile(rsrc, hash)
### TODO: What if the file is not cached?
data = ""
fd = None
try:
fd = open(path, "rb")
data = fd.read()
finally:
if fd:
fd.close()
return context.memfilectx(f, data, "l" in fctx.flags(), "x" in fctx.flags(), renamed)
else:
return _getnormalcontext(repo.ui, ctx, f, revmap)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:26,代码来源:lfcommands.py
示例10: getfilectx
def getfilectx(repo, memctx, f):
info = files.get(f)
if info != None:
# it's a file reported as modified from Git
delete, mode, sha = info
if delete:
raise IOError
if not sha: # indicates there's no git counterpart
e = ''
copied_path = None
if '.hgsubstate' == f:
data = util.serialize_hgsubstate(hgsubstate)
elif '.hgsub' == f:
data = util.serialize_hgsub(hgsub)
else:
data = self.git[sha].data
copied_path = hg_renames.get(f)
e = self.convert_git_int_mode(mode)
else:
# it's a converged file
fc = context.filectx(self.repo, f, changeid=memctx.p1().rev())
data = fc.data()
e = fc.flags()
copied_path = fc.renamed()
return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
开发者ID:escapewindow,项目名称:hg-git,代码行数:27,代码来源:git_handler.py
示例11: getfilectx
def getfilectx(repo, memctx, f):
v = files[f]
data, mode = source.getfile(f, v)
if f == '.hgtags':
data = self._rewritetags(source, revmap, data)
return context.memfilectx(f, data, 'l' in mode, 'x' in mode,
copies.get(f))
开发者ID:MezzLabs,项目名称:mercurial,代码行数:7,代码来源:hg.py
示例12: cb
def cb(repo, memctx, path):
if path == data:
return context.memfilectx(path=path,
data=data,
islink=False,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
开发者ID:bulwinkel,项目名称:dot-files,代码行数:8,代码来源:test_single_dir_clone.py
示例13: getfilectx
def getfilectx(repo, memctx, name):
fileid = files[name]
if fileid is None: # deleted file
raise IOError
data = self.getblob(fileid)
ctx = context.memfilectx(name, data, 'l' in modes,
'x' in modes, copies.get(name))
return ctx
开发者ID:Grahack,项目名称:git,代码行数:8,代码来源:hgimport.py
示例14: file_callback
def file_callback(repo, memctx, path):
if path == 'gamma':
return context.memfilectx(path=path,
data='foo',
islink=True,
isexec=False,
copied=False)
raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
开发者ID:bulwinkel,项目名称:dot-files,代码行数:8,代码来源:test_push_command.py
示例15: file_callback
def file_callback(repo, memctx, path):
return context.memfilectx(
path=path,
data=items[path],
islink=False,
isexec=False,
copied=False,
)
开发者ID:acdha,项目名称:django-versions,代码行数:8,代码来源:base.py
示例16: filectxfn
def filectxfn(repo, ctx, path):
if path in headmf:
fctx = last[path]
flags = fctx.flags()
mctx = context.memfilectx(
fctx.path(), fctx.data(), islink="l" in flags, isexec="x" in flags, copied=copied.get(path)
)
return mctx
raise IOError()
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:9,代码来源:histedit.py
示例17: filectxfn
def filectxfn(repo, memctx, path):
if path in externals:
if externals[path] is None:
raise IOError(errno.ENOENT, "no externals")
return context.memfilectx(path=path, data=externals[path], islink=False, isexec=False, copied=None)
for bad in bad_branch_paths[b]:
if path.startswith(bad):
raise IOError(errno.ENOENT, "Path %s is bad" % path)
return filectxfn2(repo, memctx, path)
开发者ID:avuori,项目名称:dotfiles,代码行数:9,代码来源:stupid.py
示例18: getfilectx
def getfilectx(repo, memctx, f):
if lfutil.standin(f) in files:
# if the file isn't in the manifest then it was removed
# or renamed, raise IOError to indicate this
try:
fctx = ctx.filectx(lfutil.standin(f))
except error.LookupError:
raise IOError()
renamed = fctx.renamed()
if renamed:
renamed = lfutil.splitstandin(renamed[0])
hash = fctx.data().strip()
path = lfutil.findfile(rsrc, hash)
### TODO: What if the file is not cached?
data = ''
fd = None
try:
fd = open(path, 'rb')
data = fd.read()
finally:
if fd:
fd.close()
return context.memfilectx(f, data, 'l' in fctx.flags(),
'x' in fctx.flags(), renamed)
else:
try:
fctx = ctx.filectx(f)
except error.LookupError:
raise IOError()
renamed = fctx.renamed()
if renamed:
renamed = renamed[0]
data = fctx.data()
if f == '.hgtags':
newdata = []
for line in data.splitlines():
id, name = line.split(' ', 1)
newdata.append('%s %s\n' % (node.hex(revmap[node.bin(id)]),
name))
data = ''.join(newdata)
return context.memfilectx(f, data, 'l' in fctx.flags(),
'x' in fctx.flags(), renamed)
开发者ID:mortonfox,项目名称:cr48,代码行数:43,代码来源:lfcommands.py
示例19: getfilectx
def getfilectx(repo, memctx, f):
delete, mode, sha = files[f]
if delete:
raise IOError
data = self.git[sha].data
copied_path = hg_renames.get(f)
e = self.convert_git_int_mode(mode)
return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
开发者ID:lloyd,项目名称:hg-git,代码行数:10,代码来源:git_handler.py
示例20: filectxfn
def filectxfn(repo, ctx, path):
if path in headmf:
fctx = head[path]
flags = fctx.flags()
mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
islink='l' in flags,
isexec='x' in flags,
copied=copied.get(path))
return mctx
return None
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:10,代码来源:common.py
注:本文中的mercurial.context.memfilectx函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论