本文整理汇总了Python中svn.fs.revision_root函数的典型用法代码示例。如果您正苦于以下问题:Python revision_root函数的具体用法?Python revision_root怎么用?Python revision_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了revision_root函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(self, repo_path):
repo_path = core.svn_path_canonicalize(repo_path)
repos_ptr = repos.open(repo_path)
fs_ptr = repos.fs(repos_ptr)
rev = fs.youngest_rev(fs_ptr)
base_root = fs.revision_root(fs_ptr, 0)
root = fs.revision_root(fs_ptr, rev)
hist = fs.node_history(root, self.root)
while hist is not None:
hist = fs.history_prev(hist,0)
dummy,rev = fs.history_location(hist)
d = fs.revision_prop(fs_ptr, rev, core.SVN_PROP_REVISION_DATE)
author = fs.revision_prop(fs_ptr, rev, \
core.SVN_PROP_REVISION_AUTHOR)
if author == 'svnadmin':
continue
self.last_author = author
self.last_date = core.svn_time_from_cstring(d) / 1000000
self.last_rev = rev
def authz_cb(root, path, pool):
return 1
editor = SvnDumperEditor(self)
e_ptr, e_baton = delta.make_editor(editor)
repos.dir_delta(base_root, '', '', root, self.root, e_ptr, e_baton,
authz_cb, 0, 1, 0, 0)
break
示例2: _print_tree
def _print_tree(self, e_factory, base_rev=None, pass_root=0):
if base_rev is None:
# a specific base rev was not provided. use the transaction base,
# or the previous revision
if self.txn_ptr:
base_rev = fs.txn_base_revision(self.txn_ptr)
else:
base_rev = self.rev - 1
# get the current root
if self.txn_ptr:
root = fs.txn_root(self.txn_ptr)
else:
root = fs.revision_root(self.fs_ptr, self.rev)
# the base of the comparison
base_root = fs.revision_root(self.fs_ptr, base_rev)
if pass_root:
editor = e_factory(root, base_root)
else:
editor = e_factory()
# construct the editor for printing these things out
e_ptr, e_baton = delta.make_editor(editor)
# compute the delta, printing as we go
def authz_cb(root, path, pool):
return 1
repos.dir_delta(base_root, '', '', root, '',
e_ptr, e_baton, authz_cb, 0, 1, 0, 0)
示例3: inner
def inner(pool, path, rev):
repos_ptr = repos.svn_repos_open(path, pool)
fs_ptr = repos.svn_repos_fs(repos_ptr)
root = fs.revision_root(fs_ptr, rev, pool)
base_rev = rev - 1
# get all changes
editor = repos.RevisionChangeCollector(fs_ptr, rev, pool)
e_ptr, e_baton = delta.make_editor(editor, pool)
repos.svn_repos_replay(root, e_ptr, e_baton, pool)
changelist = editor.changes.items()
changelist.sort()
base_root = fs.revision_root(fs_ptr, base_rev, pool)
l = []
for filepath, change in changelist:
d = {'path': filepath, 'info': ''}
if change.path:
if change.added:
d['action'] = 'new'
else:
d['action'] = 'modify'
differ = fs.FileDiff(base_root, change.path, root, filepath,
pool, '-L \t(original) -L \t(new) -u'.split(' '))
d['info'] = differ.get_pipe().read()
else:
d['action'] = 'delete'
l.append(d)
return l
示例4: _print_tree
def _print_tree(self, e_factory, rootpath='', base_rev=None, pass_root=0):
# It no longer prints, it returns the editor made by e_factory which
# contains the tree in a list.
if base_rev is None:
# a specific base rev was not provided. use the transaction base,
# or the previous revision
if self.txn_ptr:
base_rev = fs.txn_base_revision(self.txn_ptr)
else:
base_rev = self.rev - 1
# get the current root
if self.txn_ptr:
root = fs.txn_root(self.txn_ptr, self.pool)
else:
root = fs.revision_root(self.fs_ptr, self.rev, self.pool)
# the base of the comparison
base_root = fs.revision_root(self.fs_ptr, base_rev, self.pool)
if pass_root:
editor = e_factory(root, base_root)
else:
editor = e_factory()
# construct the editor for printing these things out
e_ptr, e_baton = delta.make_editor(editor, self.pool)
# compute the delta, printing as we go
def authz_cb(root, path, pool):
return 1
repos.dir_delta(base_root, '', '', root, rootpath.encode('utf-8'),
e_ptr, e_baton, authz_cb, 0, 1, 0, 0, self.pool)
return editor
示例5: 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]))
示例6: 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)
示例7: test_unnamed_editor
def test_unnamed_editor(self):
"""Test editor object without reference from interpreter"""
# Check that the delta.Editor object has proper lifetime. Without
# increment of the refcount in make_baton, the object was destroyed
# immediately because the interpreter does not hold a reference to it.
this_root = fs.revision_root(self.fs, self.rev)
prev_root = fs.revision_root(self.fs, self.rev-1)
e_ptr, e_baton = delta.make_editor(ChangeReceiver(this_root, prev_root))
repos.dir_delta(prev_root, '', '', this_root, '', e_ptr, e_baton,
_authz_callback, 1, 1, 0, 0)
示例8: test_dir_delta
def test_dir_delta(self):
"""Test scope of dir_delta callbacks"""
# Run dir_delta
this_root = fs.revision_root(self.fs, self.rev)
prev_root = fs.revision_root(self.fs, self.rev-1)
editor = ChangeReceiver(this_root, prev_root)
e_ptr, e_baton = delta.make_editor(editor)
repos.dir_delta(prev_root, '', '', this_root, '', e_ptr, e_baton,
_authz_callback, 1, 1, 0, 0)
# Check results
self.assertEqual(editor.textdeltas[0].new_data, "This is a test.\n")
self.assertEqual(editor.textdeltas[1].new_data, "A test.\n")
self.assertEqual(len(editor.textdeltas),2)
示例9: add_history
def add_history(self, path, revision, pool):
# If filtering, only add the path and revision to the histories
# list if they were actually changed in this revision (where
# change means the path itself was changed, or one of its parents
# was copied). This is useful for omitting bubble-up directory
# changes.
if not self.oldest_rev:
self.oldest_rev = revision
else:
assert(revision < self.oldest_rev)
if not self.show_all_logs:
rev_root = fs.revision_root(self.fs_ptr, revision)
changed_paths = fs.paths_changed(rev_root)
paths = changed_paths.keys()
if path not in paths:
# Look for a copied parent
test_path = path
found = 0
while 1:
off = test_path.rfind('/')
if off < 0:
break
test_path = test_path[0:off]
if test_path in paths:
copyfrom_rev, copyfrom_path = fs.copied_from(rev_root, test_path)
if copyfrom_rev >= 0 and copyfrom_path:
found = 1
break
if not found:
return
self.histories.append([revision, _cleanup_path(path)])
if self.limit and len(self.histories) == self.limit:
raise core.SubversionException("", _SVN_ERR_CEASE_INVOCATION)
示例10: 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)
示例11: _get_root
def _get_root(self, rev):
try:
return self.roots[rev]
except KeyError:
pass
root = self.roots[rev] = _svnfs.revision_root(self.fs_ptr, rev)
return root
示例12: __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])
示例13: get_copy_ancestry
def get_copy_ancestry(self):
"""Retrieve the list of `(path,rev)` copy ancestors of this node.
Most recent ancestor first. Each ancestor `(path, rev)` corresponds
to the path and revision of the source at the time the copy or move
operation was performed.
"""
ancestors = []
previous = (self._scoped_path_utf8, self.rev, self.root)
while previous:
(previous_path, previous_rev, previous_root) = previous
previous = None
root_path = fs.closest_copy(previous_root, previous_path)
if root_path:
(root, path) = root_path
path = path.lstrip('/')
rev = fs.revision_root_revision(root)
relpath = None
if path != previous_path:
# `previous_path` is a subfolder of `path` and didn't
# change since `path` was copied
relpath = previous_path[len(path):].strip('/')
copied_from = fs.copied_from(root, path)
if copied_from:
(rev, path) = copied_from
path = path.lstrip('/')
root = fs.revision_root(self.fs_ptr, rev, self.pool())
if relpath:
path += '/' + relpath
ui_path = _path_within_scope(self.scope, _from_svn(path))
if ui_path:
ancestors.append((ui_path, rev))
previous = (path, rev, root)
return ancestors
示例14: __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
示例15: 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