[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r35538 - in trunk/subversion/tests/cmdline: . svntest

From: David Glasser <glasser_at_davidglasser.net>
Date: Wed, 28 Jan 2009 21:21:42 -0800

Note that this probably will fail on Windows and will need a
path_local_style or something.

--dave

On Wed, Jan 28, 2009 at 9:14 PM, David Glasser <glasser_at_davidglasser.net> wrote:
> Author: glasser
> Date: Wed Jan 28 21:14:55 2009
> New Revision: 35538
>
> Log:
> Speed up test suite by running 'svn proplist' only once per wc tree instead of
> once per file in it. (Yeah, there's an extra tree walk, but that should just
> make the second tree walk come from cache.)
>
> * subversion/tests/cmdline/svntest/tree.py
> (get_nodes_which_might_have_props): New.
> (get_props): Take a list of paths and return a hash of prop hashes.
> (handle_dir): Change load_props arg to props hash. Look in hash instead of
> calling get_props.
> (build_tree_from_wc): Adjust.
>
> * subversion/tests/cmdline/autoprop_tests.py
> (check_proplist): Adjust.
>
> Modified:
> trunk/subversion/tests/cmdline/autoprop_tests.py
> trunk/subversion/tests/cmdline/svntest/tree.py
>
> Modified: trunk/subversion/tests/cmdline/autoprop_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/autoprop_tests.py?pathrev=35538&r1=35537&r2=35538
> ==============================================================================
> --- trunk/subversion/tests/cmdline/autoprop_tests.py Wed Jan 28 17:52:12 2009 (r35537)
> +++ trunk/subversion/tests/cmdline/autoprop_tests.py Wed Jan 28 21:14:55 2009 (r35538)
> @@ -33,7 +33,7 @@ Item = svntest.wc.StateItem
> def check_proplist(path, exp_out):
> """Verify that property list on PATH has a value of EXP_OUT"""
>
> - props = svntest.tree.get_props(path)
> + props = svntest.tree.get_props([path])[path]
> if props != exp_out:
> print("Expected properties: %s" % exp_out)
> print("Actual properties: %s" % props)
>
> Modified: trunk/subversion/tests/cmdline/svntest/tree.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/tree.py?pathrev=35538&r1=35537&r2=35538
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/tree.py Wed Jan 28 17:52:12 2009 (r35537)
> +++ trunk/subversion/tests/cmdline/svntest/tree.py Wed Jan 28 21:14:55 2009 (r35538)
> @@ -390,44 +390,61 @@ def create_from_path(path, contents=None
> return root_node
>
>
> -# helper for handle_dir(), which is a helper for build_tree_from_wc()
> -def get_props(path):
> - """Return a hash of props for PATH, using the svn client. Convert each
> - embedded end-of-line to a single LF character."""
> +def get_nodes_which_might_have_props(wc_path):
> + dot_svn = main.get_admin_name()
> + def walker(output, dirname, names):
> + names[:] = [n for n in names if n != dot_svn]
> + output.extend([os.path.join(dirname, n) for n in names])
> + nodes = [wc_path]
> + os.path.walk(wc_path, walker, nodes)
> + return nodes
> +
> +# helper for build_tree_from_wc()
> +def get_props(paths):
> + """Return a hash of hashes of props for PATHS, using the svn client. Convert
> + each embedded end-of-line to a single LF character."""
>
> # It's not kosher to look inside .svn/ and try to read the internal
> # property storage format. Instead, we use 'svn proplist'. After
> # all, this is the only way the user can retrieve them, so we're
> # respecting the black-box paradigm.
>
> - props = {}
> - exit_code, output, errput = main.run_svn(1, "proplist", path, "--verbose")
> + files = {}
> + filename = None
> + exit_code, output, errput = main.run_svn(1, "proplist", "--verbose", *paths)
> +
> + properties_on_re = re.compile("^Properties on '(.+)':$")
>
> # Parse the output
> for line in output:
> line = line.rstrip('\r\n') # ignore stdout's EOL sequence
>
> - if line.startswith('Properties on '):
> - continue
> + match = properties_on_re.match(line)
> + if match:
> + filename = match.group(1)
>
> elif line.startswith(' '):
> - # It's (part of) the value
> - props[name] += line[4:] + '\n' # strip the indentation
> + # It's (part of) the value (strip the indentation)
> + if filename is None:
> + raise "Missing 'Properties on' line: '"+line+"'"
> + files.setdefault(filename, {})[name] += line[4:] + '\n'
>
> elif line.startswith(' '):
> # It's the name
> name = line[2:] # strip the indentation
> - props[name] = ''
> + if filename is None:
> + raise "Missing 'Properties on' line: '"+line+"'"
> + files.setdefault(filename, {})[name] = ''
>
> else:
> raise "Malformed line from proplist: '"+line+"'"
>
> # Strip, from each property value, the final new-line that we added
> - for name in props:
> - props[name] = props[name][:-1]
> -
> - return props
> + for filename in files:
> + for name in files[filename]:
> + files[filename][name] = files[filename][name][:-1]
>
> + return files
>
> # helper for handle_dir(), which helps build_tree_from_wc()
> def get_text(path):
> @@ -442,9 +459,8 @@ def get_text(path):
> fp.close()
> return contents
>
> -
> # main recursive helper for build_tree_from_wc()
> -def handle_dir(path, current_parent, load_props, ignore_svn):
> +def handle_dir(path, current_parent, props, ignore_svn):
>
> # get a list of all the files
> all_files = os.listdir(path)
> @@ -453,7 +469,8 @@ def handle_dir(path, current_parent, loa
>
> # put dirs and files in their own lists, and remove SVN dirs
> for f in all_files:
> - f = os.path.join(path, f)
> + if path != '.': # 'svn pl -v' strips leading './'
> + f = os.path.join(path, f)
> if (os.path.isdir(f) and os.path.basename(f) != main.get_admin_name()):
> dirs.append(f)
> elif os.path.isfile(f):
> @@ -462,22 +479,16 @@ def handle_dir(path, current_parent, loa
> # add each file as a child of CURRENT_PARENT
> for f in files:
> fcontents = get_text(f)
> - if load_props:
> - fprops = get_props(f)
> - else:
> - fprops = {}
> + fprops = props.get(f, {})
> current_parent.add_child(SVNTreeNode(os.path.basename(f), None,
> fcontents, fprops))
>
> # for each subdir, create a node, walk its tree, add it as a child
> for d in dirs:
> - if load_props:
> - dprops = get_props(d)
> - else:
> - dprops = {}
> + dprops = props.get(d, {})
> new_dir_node = SVNTreeNode(os.path.basename(d), None, None, dprops)
> current_parent.add_child(new_dir_node)
> - handle_dir(d, new_dir_node, load_props, ignore_svn)
> + handle_dir(d, new_dir_node, props, ignore_svn)
>
> def get_child(node, name):
> """If SVNTreeNode NODE contains a child named NAME, return child;
> @@ -893,15 +904,18 @@ def build_tree_from_wc(wc_path, load_pro
>
> root = SVNTreeNode(root_node_name, None)
>
> - # if necessary, store the root dir's props in a new child node '.'.
> + props = {}
> + wc_path = os.path.normpath(wc_path)
> if load_props:
> - props = get_props(wc_path)
> - if props:
> - root_dir_node = SVNTreeNode(os.path.basename('.'), None, None, props)
> + nodes = get_nodes_which_might_have_props(wc_path)
> + props = get_props(nodes)
> + if props.has_key(wc_path):
> + root_dir_node = SVNTreeNode(os.path.basename('.'), None, None,
> + props[wc_path])
> root.add_child(root_dir_node)
>
> # Walk the tree recursively
> - handle_dir(os.path.normpath(wc_path), root, load_props, ignore_svn)
> + handle_dir(wc_path, root, props, ignore_svn)
>
> return root
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1066742
>

-- 
glasser_at_davidglasser.net | langtonlabs.org | flickr.com/photos/glasser/
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1066769
Received on 2009-01-29 06:21:59 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.