def main(pool, repos_dir, txn): # Construct a ChangeCollector to fetch our changes. fs_ptr = repos.svn_repos_fs(repos.svn_repos_open(repos_dir, pool)) root = fs.txn_root(fs.open_txn(fs_ptr, txn, pool), pool) cc = repos.ChangeCollector(fs_ptr, root, pool) # Call the transaction property validator. Might as well get the # cheap checks outta the way first. retval = test_props(cc.get_root_props()) if retval: return retval # Generate the path-based changes list. e_ptr, e_baton = delta.make_editor(cc, pool) repos.svn_repos_replay(root, e_ptr, e_baton, pool) # Call the path change validator. changes = cc.get_changes() paths = changes.keys() paths.sort(lambda a, b: core.svn_path_compare_paths(a, b)) for path in paths: change = changes[path] retval = test_path_change(path, change) if retval: return retval return 0
def _get_changed_paths(fsroot): """Return a 3-tuple: found_readable, found_unreadable, changed_paths.""" editor = repos.ChangeCollector(self.fs_ptr, fsroot) e_ptr, e_baton = delta.make_editor(editor) repos.svn_repos_replay(fsroot, e_ptr, e_baton) changedpaths = {} changes = editor.get_changes() # Copy the Subversion changes into a new hash, checking # authorization and converting them into ChangedPath objects. found_readable = found_unreadable = 0 for path in changes.keys(): spath = _to_str(path) change = changes[path] if change.path: change.path = _cleanup_path(change.path) if change.base_path: change.base_path = _cleanup_path(change.base_path) is_copy = 0 action = { repos.CHANGE_ACTION_ADD: vclib.ADDED, repos.CHANGE_ACTION_DELETE: vclib.DELETED, repos.CHANGE_ACTION_REPLACE: vclib.REPLACED, }.get(change.action, vclib.MODIFIED) if ((action == vclib.ADDED or action == vclib.REPLACED) and change.base_path and change.base_rev): is_copy = 1 pathtype = _kind2type(change.item_kind) parts = _path_parts(spath) if vclib.check_path_access(self, parts, pathtype, rev): if is_copy and change.base_path and (change.base_path != path): parts = _path_parts(_to_str(change.base_path)) if not vclib.check_path_access(self, parts, pathtype, change.base_rev): is_copy = 0 change.base_path = None change.base_rev = None found_unreadable = 1 if change.base_path: base_path = _to_str(change.base_path) else: base_path = None changedpaths[spath] = SVNChangedPath( spath, rev, pathtype, base_path, change.base_rev, action, is_copy, change.text_changed, change.prop_changes, ) found_readable = 1 else: found_unreadable = 1 return found_readable, found_unreadable, list( changedpaths.values())
def get_revision_info(svnrepos, rev): fsroot = svnrepos._getroot(rev) # Get the changes for the revision cps = ChangedPathSet() editor = repos.ChangeCollector(svnrepos.fs_ptr, fsroot, svnrepos.pool, cps.add_change) e_ptr, e_baton = delta.make_editor(editor, svnrepos.pool) repos.svn_repos_replay(fsroot, e_ptr, e_baton, svnrepos.pool) # Now get the revision property info. Would use # editor.get_root_props(), but something is broken there... datestr, author, msg = _fs_rev_props(svnrepos.fs_ptr, rev, svnrepos.pool) date = _datestr_to_date(datestr, svnrepos.pool) return date, author, msg, cps.get_changes()
def _get_changed_paths(fsroot): """Return a 3-tuple: found_readable, found_unreadable, changed_paths.""" editor = repos.ChangeCollector(self.fs_ptr, fsroot) e_ptr, e_baton = delta.make_editor(editor) repos.svn_repos_replay(fsroot, e_ptr, e_baton) changedpaths = {} changes = editor.get_changes() # Copy the Subversion changes into a new hash, checking # authorization and converting them into ChangedPath objects. found_readable = found_unreadable = 0 for path in changes.keys(): change = changes[path] if change.path: change.path = _cleanup_path(change.path) if change.base_path: change.base_path = _cleanup_path(change.base_path) is_copy = 0 if not hasattr(change, 'action'): # new to subversion 1.4.0 action = vclib.MODIFIED if not change.path: action = vclib.DELETED elif change.added: action = vclib.ADDED replace_check_path = path if change.base_path and change.base_rev: replace_check_path = change.base_path if changedpaths.has_key(replace_check_path) \ and changedpaths[replace_check_path].action == vclib.DELETED: action = vclib.REPLACED else: if change.action == repos.CHANGE_ACTION_ADD: action = vclib.ADDED elif change.action == repos.CHANGE_ACTION_DELETE: action = vclib.DELETED elif change.action == repos.CHANGE_ACTION_REPLACE: action = vclib.REPLACED else: action = vclib.MODIFIED if (action == vclib.ADDED or action == vclib.REPLACED) \ and change.base_path \ and change.base_rev: is_copy = 1 if change.item_kind == core.svn_node_dir: pathtype = vclib.DIR elif change.item_kind == core.svn_node_file: pathtype = vclib.FILE else: pathtype = None parts = _path_parts(path) if vclib.check_path_access(self, parts, pathtype, rev): if is_copy and change.base_path and (change.base_path != path): parts = _path_parts(change.base_path) if not vclib.check_path_access(self, parts, pathtype, change.base_rev): is_copy = 0 change.base_path = None change.base_rev = None found_unreadable = 1 changedpaths[path] = SVNChangedPath( path, rev, pathtype, change.base_path, change.base_rev, action, is_copy, change.text_changed, change.prop_changes) found_readable = 1 else: found_unreadable = 1 return found_readable, found_unreadable, changedpaths.values()