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

Re: svn commit: r36476 - trunk/subversion/tests/cmdline/svntest

From: Greg Stein <gstein_at_gmail.com>
Date: Wed, 11 Mar 2009 03:44:03 +0100

This borked a few tests... investigating...

On Wed, Mar 11, 2009 at 01:17, Greg Stein <gstein_at_gmail.com> wrote:
> Author: gstein
> Date: Tue Mar 10 17:17:21 2009
> New Revision: 36476
>
> Log:
> Convert one more tree builder function over to the State model.
>
> * subversion/tests/cmdline/svntest/wc.py:
>  (State.from_wc): new class method to build a State object from the files
>    found on-disk in a working copy.
>
> * subversion/tests/cmdline/svntest/tree.py:
>  (get_nodes_which_might_have_props): removed. obsolete.
>  (get_text): rewrite this stupid-ass little function.
>  (handle_dir): removed. obsolete.
>  (build_tree_from_wc): use State.from_wc() and then .old_tree() to create
>    the old-style tree description of the wc.
>
> Modified:
>   trunk/subversion/tests/cmdline/svntest/tree.py
>   trunk/subversion/tests/cmdline/svntest/wc.py
>
> Modified: trunk/subversion/tests/cmdline/svntest/tree.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/tree.py?pathrev=36476&r1=36475&r2=36476
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/tree.py      Tue Mar 10 16:14:52 2009        (r36475)
> +++ trunk/subversion/tests/cmdline/svntest/tree.py      Tue Mar 10 17:17:21 2009        (r36476)
> @@ -444,14 +444,6 @@ def create_from_path(path, contents=None
>   return root_node
>
>
> -def get_nodes_which_might_have_props(wc_path):
> -  dot_svn = svntest.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):
> @@ -505,7 +497,7 @@ def get_props(paths):
>
>   return files
>
> -# helper for handle_dir(), which helps build_tree_from_wc()
> +### ridiculous function. callers should do this one line themselves.
>  def get_text(path):
>   "Return a string with the textual contents of a file at PATH."
>
> @@ -513,42 +505,8 @@ def get_text(path):
>   if not os.path.isfile(path):
>     return None
>
> -  fp = open(path, 'r')
> -  contents = fp.read()
> -  fp.close()
> -  return contents
> -
> -# main recursive helper for build_tree_from_wc()
> -def handle_dir(path, current_parent, props, ignore_svn):
> -
> -  # get a list of all the files
> -  all_files = os.listdir(path)
> -  files = []
> -  dirs = []
> -
> -  # put dirs and files in their own lists, and remove SVN dirs
> -  for f in all_files:
> -    if path != '.':  # 'svn pl -v' strips leading './'
> -      f = os.path.join(path, f)
> -    if os.path.isdir(f) \
> -          and os.path.basename(f) != svntest.main.get_admin_name():
> -      dirs.append(f)
> -    elif os.path.isfile(f):
> -      files.append(f)
> -
> -  # add each file as a child of CURRENT_PARENT
> -  for f in files:
> -    fcontents = get_text(f)
> -    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:
> -    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, props, ignore_svn)
> +  return open(path, 'r').read()
> +
>
>  def get_child(node, name):
>   """If SVNTreeNode NODE contains a child named NAME, return child;
> @@ -836,21 +794,4 @@ def build_tree_from_wc(wc_path, load_pro
>     files.  If IGNORE_SVN is true, then exclude SVN admin dirs from the tree.
>     If LOAD_PROPS is true, the props will be added to the tree."""
>
> -    root = SVNTreeNode(root_node_name, None)
> -
> -    props = {}
> -    wc_path = os.path.normpath(wc_path)
> -    if load_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(wc_path, root, props, ignore_svn)
> -
> -    return root
> -
> -### End of file.
> +    return svntest.wc.State.from_wc(wc_path, load_props, ignore_svn).old_tree()
>
> Modified: trunk/subversion/tests/cmdline/svntest/wc.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/wc.py?pathrev=36476&r1=36475&r2=36476
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/wc.py        Tue Mar 10 16:14:52 2009        (r36475)
> +++ trunk/subversion/tests/cmdline/svntest/wc.py        Tue Mar 10 17:17:21 2009        (r36476)
> @@ -368,6 +368,53 @@ class State:
>
>     return cls('', desc)
>
> +  @classmethod
> +  def from_wc(cls, path, load_props=False, ignore_svn=True):
> +    """Create a State object from a working copy.
> +
> +    Walks the tree at PATH, building a State based on the actual files
> +    and directories found. If LOAD_PROPS is True, then the properties
> +    will be loaded for all nodes (Very Expensive!). If IGNORE_SVN is
> +    True, then the .svn subdirectories will be excluded from the State.
> +    """
> +
> +    desc = { }
> +    dot_svn = svntest.main.get_admin_name()
> +
> +    def path_to_key(p, l=len(path)+1):
> +      if p == path:
> +        return ''
> +      assert p.startswith(path + os.sep)
> +      return p[l:].replace(os.sep, '/')
> +
> +    def _walker(baton, dirname, names):
> +      parent = path_to_key(dirname)
> +      if parent:
> +        parent += '/'
> +      if ignore_svn and (dot_svn in names):
> +        names.remove(dot_svn)
> +      for name in names:
> +        node = os.path.join(dirname, name)
> +        if os.path.isfile(node):
> +          contents = open(node, 'r').read()
> +        else:
> +          contents = None
> +        desc['%s%s' % (parent, name)] = StateItem(contents=contents)
> +
> +    os.path.walk(path, _walker, None)
> +
> +    if load_props:
> +      paths = [os.path.join(path, p.replace('/', os.sep)) for p in desc.keys()]
> +      paths.append(path)
> +      all_props = svntest.tree.get_props(paths)
> +      for node, props in all_props.items():
> +        if node == path:
> +          desc['.'] = StateItem(props=props)
> +        else:
> +          desc[path_to_key(node)].props = props
> +
> +    return cls('', desc)
> +
>
>  class StateItem:
>   """Describes an individual item within a working copy.
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1305390
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1305959
Received on 2009-03-11 03:56:37 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.