本文整理汇总了Python中svn.fs.check_path函数的典型用法代码示例。如果您正苦于以下问题:Python check_path函数的具体用法?Python check_path怎么用?Python check_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, path, rev, repos, pool=None, parent=None):
self.path = path
self.repos = repos
self.fs_ptr = repos.fs_ptr
self.scope = repos.scope
self._scoped_svn_path = _to_svn(self.scope, path)
self.pool = Pool(pool)
self._requested_rev = rev
pool = self.pool()
if parent and parent._requested_rev == self._requested_rev:
self.root = parent.root
else:
self.root = fs.revision_root(self.fs_ptr, rev, self.pool())
node_type = fs.check_path(self.root, self._scoped_svn_path, pool)
if not node_type in _kindmap:
raise Exception('No such node')
if _kindmap[node_type] == 'F':
self.isdir = False
self.isfile = True
elif _kindmap[node_type] == 'D':
self.isdir = True
self.isfile = False
cr = fs.node_created_rev(self.root, self._scoped_svn_path, pool)
cp = fs.node_created_path(self.root, self._scoped_svn_path, pool)
if _is_path_within_scope(self.scope, cp):
self.created_rev = cr
self.created_path = _path_within_scope(self.scope, _from_svn(cp))
else:
self.created_rev, self.created_path = rev, path
self.rev = self.created_rev
示例2: has_node
def has_node(self, path, rev=None, pool=None):
if not pool:
pool = self.pool
rev = self.normalize_rev(rev)
rev_root = fs.revision_root(self.fs_ptr, rev, pool())
node_type = fs.check_path(rev_root, _to_svn(self.scope, path), pool())
return node_type in _kindmap
示例3: __init__
def __init__(self, path, rev, authz, scope, fs_ptr):
self.authz = authz
self.scope = scope
if scope != '/':
self.scoped_path = scope + path
else:
self.scoped_path = path
self.fs_ptr = fs_ptr
self._requested_rev = rev
self.root = fs.revision_root(fs_ptr, rev)
node_type = fs.check_path(self.root, self.scoped_path)
if not node_type in _kindmap:
raise TracError, "No node at %s in revision %s" % (path, rev)
self.created_rev = fs.node_created_rev(self.root, self.scoped_path)
self.created_path = fs.node_created_path(self.root, self.scoped_path)
# Note: 'created_path' differs from 'path' if the last change was a copy,
# and furthermore, 'path' might not exist at 'create_rev'.
# The only guarantees are:
# * this node exists at (path,rev)
# * the node existed at (created_path,created_rev)
# TODO: check node id
self.rev = self.created_rev
Node.__init__(self, path, self.rev, _kindmap[node_type])
示例4: putfile
def putfile(fname, rpath, uname="", commitmsg=""):
rpath = core.svn_path_canonicalize(rpath)
repos_ptr = repos.open(rpath)
fsob = repos.fs(repos_ptr)
# open a transaction against HEAD
rev = fs.youngest_rev(fsob)
txn = repos.fs_begin_txn_for_commit(repos_ptr, rev, uname, commitmsg)
root = fs.txn_root(txn)
rev_root = fs.revision_root(fsob, rev)
kind = fs.check_path(root, fname)
if kind == core.svn_node_none:
print("file '%s' does not exist, creating..." % fname)
fs.make_file(root, fname)
elif kind == core.svn_node_dir:
print("File '%s' is a dir." % fname)
return
else:
print("Updating file '%s'" % fname)
handler, baton = fs.apply_textdelta(root, fname, None, None)
### it would be nice to get an svn_stream_t. for now, just load in the
### whole file and shove it into the FS.
delta.svn_txdelta_send_string(open(fname, 'rb').read(),
handler, baton)
newrev = repos.fs_commit_txn(repos_ptr, txn)
print("revision: %s" % newrev)
示例5: _history
def _history(self, path, start, end, pool):
"""`path` is a unicode path in the scope.
Generator yielding `(path, rev)` pairs, where `path` is an `unicode`
object. Must start with `(path, created rev)`.
(wraps ``fs.node_history``)
"""
path_utf8 = _to_svn(pool(), self.scope, path)
if start < end:
start, end = end, start
if (start, end) == (1, 0): # only happens for empty repos
return
root = fs.revision_root(self.fs_ptr, start, pool())
# fs.node_history leaks when path doesn't exist (#6588)
if fs.check_path(root, path_utf8, pool()) == core.svn_node_none:
return
tmp1 = Pool(pool)
tmp2 = Pool(pool)
history_ptr = fs.node_history(root, path_utf8, tmp1())
cross_copies = 1
while history_ptr:
history_ptr = fs.history_prev(history_ptr, cross_copies, tmp2())
tmp1.clear()
tmp1, tmp2 = tmp2, tmp1
if history_ptr:
path_utf8, rev = fs.history_location(history_ptr, tmp2())
tmp2.clear()
if rev < end:
break
path = _from_svn(path_utf8)
yield path, rev
del tmp1
del tmp2
示例6: __init__
def __init__(self, path, rev, repos, pool=None, parent_root=None):
self.fs_ptr = repos.fs_ptr
self.scope = repos.scope
self.pool = Pool(pool)
pool = self.pool()
self._scoped_path_utf8 = _to_svn(pool, self.scope, path)
if parent_root:
self.root = parent_root
else:
self.root = fs.revision_root(self.fs_ptr, rev, pool)
node_type = fs.check_path(self.root, self._scoped_path_utf8, pool)
if not node_type in _kindmap:
raise NoSuchNode(path, rev)
cp_utf8 = fs.node_created_path(self.root, self._scoped_path_utf8, pool)
cp = _from_svn(cp_utf8)
cr = fs.node_created_rev(self.root, self._scoped_path_utf8, pool)
# Note: `cp` differs from `path` if the last change was a copy,
# In that case, `path` doesn't even exist at `cr`.
# The only guarantees are:
# * this node exists at (path,rev)
# * the node existed at (created_path,created_rev)
# Also, `cp` might well be out of the scope of the repository,
# in this case, we _don't_ use the ''create'' information.
if _is_path_within_scope(self.scope, cp):
self.created_rev = cr
self.created_path = _path_within_scope(self.scope, cp)
else:
self.created_rev, self.created_path = rev, path
# TODO: check node id
Node.__init__(self, repos, path, rev, _kindmap[node_type])
示例7: write
def write(self, data, uname='', commitmsg='',istext=False):
txn = repos.fs_begin_txn_for_commit(self._repo.repos_ptr, self.revno, uname, commitmsg)
r = None
try:
txn_root = fs.txn_root(txn)
kind = fs.check_path(txn_root, self.path)
if kind == core.svn_node_none:
if not _create_file(txn_root, self.path):
raise 'attempt to create file, but file creation error: %s'%path
pass
elif kind == core.svn_node_dir:
raise 'attempt to create file, but directory already exists: %s'%self.path
if istext:
fs.change_node_prop(txn_root, self.path, 'svn:eol-style', 'native')
pass
handler, baton = fs.apply_textdelta(txn_root, self.path, None, None)
delta.svn_txdelta_send_string(data, handler, baton)
r = repos.fs_commit_txn(self._repo.repos_ptr, txn)
except Exception, a:
fs.abort_txn(txn)
raise
示例8: blame
def blame(path, filename, rev=None):
annotresult = {}
path = core.svn_path_canonicalize(path)
repos_ptr = repos.open(path)
fsob = repos.fs(repos_ptr)
if rev is None:
rev = fs.youngest_rev(fsob)
filedata = ''
for i in range(0, rev+1):
root = fs.revision_root(fsob, i)
if fs.check_path(root, filename) != core.svn_node_none:
first = i
break
print("First revision is %d" % first)
print("Last revision is %d" % rev)
for i in range(first, rev+1):
previousroot = root
root = fs.revision_root(fsob, i)
if i != first:
if not fs.contents_changed(root, filename, previousroot, filename):
continue
file = fs.file_contents(root, filename)
previousdata = filedata
filedata = ''
while True:
data = core.svn_stream_read(file, CHUNK_SIZE)
if not data:
break
filedata = filedata + data
print("Current revision is %d" % i)
diffresult = difflib.ndiff(previousdata.splitlines(1),
filedata.splitlines(1))
# print ''.join(diffresult)
k = 0
for j in diffresult:
if j[0] == ' ':
if k in annotresult:
k = k + 1
continue
else:
annotresult[k] = (i, j[2:])
k = k + 1
continue
elif j[0] == '?':
continue
annotresult[k] = (i, j[2:])
if j[0] != '-':
k = k + 1
# print ''.join(diffresult)
# print annotresult
for x in range(len(annotresult.keys())):
sys.stdout.write("Line %d (r%d):%s" % (x,
annotresult[x][0],
annotresult[x][1]))
示例9: get_changes
def get_changes(self, old_path, old_rev, new_path, new_rev,
ignore_ancestry=0):
old_node = new_node = None
old_rev = self.normalize_rev(old_rev)
new_rev = self.normalize_rev(new_rev)
if self.has_node(old_path, old_rev):
old_node = self.get_node(old_path, old_rev)
else:
raise NoSuchNode(old_path, old_rev, 'The Base for Diff is invalid')
if self.has_node(new_path, new_rev):
new_node = self.get_node(new_path, new_rev)
else:
raise NoSuchNode(new_path, new_rev, 'The Target for Diff is invalid')
if new_node.kind != old_node.kind:
raise TracError('Diff mismatch: Base is a %s (%s in revision %s) '
'and Target is a %s (%s in revision %s).' \
% (old_node.kind, old_path, old_rev,
new_node.kind, new_path, new_rev))
subpool = Pool(self.pool)
if new_node.isdir:
editor = DiffChangeEditor()
e_ptr, e_baton = delta.make_editor(editor, subpool())
old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
def authz_cb(root, path, pool): return 1
text_deltas = 0 # as this is anyway re-done in Diff.py...
entry_props = 0 # "... typically used only for working copy updates"
repos.svn_repos_dir_delta(old_root,
_to_svn(self.scope + old_path), '',
new_root,
_to_svn(self.scope + new_path),
e_ptr, e_baton, authz_cb,
text_deltas,
1, # directory
entry_props,
ignore_ancestry,
subpool())
for path, kind, change in editor.deltas:
path = _from_svn(path)
old_node = new_node = None
if change != Changeset.ADD:
old_node = self.get_node(posixpath.join(old_path, path),
old_rev)
if change != Changeset.DELETE:
new_node = self.get_node(posixpath.join(new_path, path),
new_rev)
else:
kind = _kindmap[fs.check_path(old_root,
_to_svn(self.scope,
old_node.path),
subpool())]
yield (old_node, new_node, kind, change)
else:
old_root = fs.revision_root(self.fs_ptr, old_rev, subpool())
new_root = fs.revision_root(self.fs_ptr, new_rev, subpool())
if fs.contents_changed(old_root, _to_svn(self.scope, old_path),
new_root, _to_svn(self.scope, new_path),
subpool()):
yield (old_node, new_node, Node.FILE, Changeset.EDIT)
示例10: _create_dirs
def _create_dirs(txn_root, cpath):
if not cpath:
return True
kind = fs.check_path(txn_root,cpath)
if kind == core.svn_node_dir:
return True
elif kind == core.svn_node_file:
return False
for dpath,p in misc.iterdir(cpath):
dpath = _c(dpath)
kind = fs.check_path(txn_root, dpath)
if kind == core.svn_node_none:
fs.make_dir(txn_root, dpath)
continue
pass
return True
示例11: has_node
def has_node(self, path, rev=None, pool=None):
"""Check if `path` exists at `rev` (or latest if unspecified)"""
if not pool:
pool = self.pool
rev = self.normalize_rev(rev)
rev_root = fs.revision_root(self.fs_ptr, rev, pool())
node_type = fs.check_path(rev_root, _to_svn(pool(), self.scope, path),
pool())
return node_type in _kindmap
示例12: do_ls
def do_ls(self, arg):
"""list the contents of the current directory or provided path"""
parent = self.path
if not len(arg):
# no arg -- show a listing for the current directory.
entries = fs.dir_entries(self.root, self.path)
else:
# arg? show a listing of that path.
newpath = self._parse_path(arg)
kind = fs.check_path(self.root, newpath)
if kind == core.svn_node_dir:
parent = newpath
entries = fs.dir_entries(self.root, parent)
elif kind == core.svn_node_file:
parts = self._path_to_parts(newpath)
name = parts.pop(-1)
parent = self._parts_to_path(parts)
print(parent + ':' + name)
tmpentries = fs.dir_entries(self.root, parent)
if not tmpentries.get(name, None):
return
entries = {}
entries[name] = tmpentries[name]
else:
print("Path '%s' not found." % newpath)
return
keys = sorted(entries.keys())
print(" REV AUTHOR NODE-REV-ID SIZE DATE NAME")
print("----------------------------------------------------------------------------")
for entry in keys:
fullpath = parent + '/' + entry
size = ''
is_dir = fs.is_dir(self.root, fullpath)
if is_dir:
name = entry + '/'
else:
size = str(fs.file_length(self.root, fullpath))
name = entry
node_id = fs.unparse_id(entries[entry].id)
created_rev = fs.node_created_rev(self.root, fullpath)
author = fs.revision_prop(self.fs_ptr, created_rev,
core.SVN_PROP_REVISION_AUTHOR)
if not author:
author = ""
date = fs.revision_prop(self.fs_ptr, created_rev,
core.SVN_PROP_REVISION_DATE)
if not date:
date = ""
else:
date = self._format_date(date)
print("%6s %8s %12s %8s %12s %s" % (created_rev, author[:8],
node_id, size, date, name))
示例13: itemtype
def itemtype(self, path_parts, rev):
rev = self._getrev(rev)
basepath = self._getpath(path_parts)
kind = fs.check_path(self._getroot(rev), basepath, self.scratch_pool)
self._scratch_clear()
if kind == core.svn_node_dir:
return vclib.DIR
if kind == core.svn_node_file:
return vclib.FILE
raise vclib.ItemNotFound(path_parts)
示例14: do_cd
def do_cd(self, arg):
"""change directory"""
newpath = self._parse_path(arg)
# make sure that path actually exists in the filesystem as a directory
kind = fs.check_path(self.root, newpath)
if kind != core.svn_node_dir:
print("Path '%s' is not a valid filesystem directory." % newpath)
return
self.path = newpath
示例15: _gettype
def _gettype(self, path, rev):
# Similar to itemtype(), but without the authz check. Returns
# None for missing paths.
try:
kind = fs.check_path(self._getroot(rev), path)
except:
return None
if kind == core.svn_node_dir:
return vclib.DIR
if kind == core.svn_node_file:
return vclib.FILE
return None