Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/tests/cmdline/svntest/wc.py view on Meta::CPAN
def svn_uri_quote(url):
# svn defines a different set of "safe" characters than Python does, so
# we need to avoid escaping them. see subr/path.c:uri_char_validity[]
return urllib.quote(url, "!$&'()*+,-./:=@_~")
# ------------
def open_wc_db(local_path):
"""Open the SQLite DB for the WC path LOCAL_PATH.
Return (DB object, WC root path, WC relpath of LOCAL_PATH)."""
dot_svn = svntest.main.get_admin_name()
root_path = local_path
relpath = ''
while True:
db_path = os.path.join(root_path, dot_svn, 'wc.db')
try:
db = svntest.sqlite3.connect(db_path)
break
except: pass
head, tail = os.path.split(root_path)
if head == root_path:
raise svntest.Failure("No DB for " + local_path)
root_path = head
relpath = os.path.join(tail, relpath).replace(os.path.sep, '/').rstrip('/')
return db, root_path, relpath
# ------------
def text_base_path(file_path):
"""Return the path to the text-base file for the versioned file
FILE_PATH."""
info = svntest.actions.run_and_parse_info(file_path)[0]
checksum = info['Checksum']
db, root_path, relpath = open_wc_db(file_path)
# Calculate single DB location
dot_svn = svntest.main.get_admin_name()
fn = os.path.join(root_path, dot_svn, 'pristine', checksum[0:2], checksum)
# For SVN_WC__VERSION < 29
if os.path.isfile(fn):
return fn
# For SVN_WC__VERSION >= 29
if os.path.isfile(fn + ".svn-base"):
return fn + ".svn-base"
raise svntest.Failure("No pristine text for " + relpath)
def sqlite_stmt(wc_root_path, stmt):
"""Execute STMT on the SQLite wc.db in WC_ROOT_PATH and return the
results."""
db = open_wc_db(wc_root_path)[0]
c = db.cursor()
c.execute(stmt)
return c.fetchall()
# ------------
### probably toss these at some point. or major rework. or something.
### just bootstrapping some changes for now.
#
def item_to_node(path, item):
tree = svntest.tree.build_generic_tree([item.as_node_tuple(path)])
while tree.children:
assert len(tree.children) == 1
tree = tree.children[0]
return tree
### yanked from tree.compare_trees()
def display_nodes(label, path, expected, actual):
'Display two nodes, expected and actual.'
expected = item_to_node(path, expected)
actual = item_to_node(path, actual)
o = StringIO()
o.write("=============================================================\n")
o.write("Expected '%s' and actual '%s' in %s tree are different!\n"
% (expected.name, actual.name, label))
o.write("=============================================================\n")
o.write("EXPECTED NODE TO BE:\n")
o.write("=============================================================\n")
expected.pprint(o)
o.write("=============================================================\n")
o.write("ACTUAL NODE FOUND:\n")
o.write("=============================================================\n")
actual.pprint(o)
logger.warn(o.getvalue())
o.close()
### yanked from tree.py
def default_singleton_handler(description, path, item):
node = item_to_node(path, item)
logger.warn("Couldn't find node '%s' in %s tree" % (node.name, description))
o = StringIO()
node.pprint(o)
logger.warn(o.getvalue())
o.close()
raise svntest.tree.SVNTreeUnequal
( run in 1.529 second using v1.01-cache-2.11-cpan-ceb78f64989 )