Exemple #1
0
def handle_dir(path, current_parent, load_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:
    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):
      files.append(f)
      
  # 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 = {}
    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 = {}
    new_dir_node = SVNTreeNode(os.path.basename(d), None, None, dprops)
    handle_dir(d, new_dir_node, load_props, ignore_svn)
    current_parent.add_child(new_dir_node)
Exemple #2
0
def handle_dir(path, current_parent, load_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:
        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):
            files.append(f)

    # 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 = {}
        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 = {}
        new_dir_node = SVNTreeNode(os.path.basename(d), None, None, dprops)
        handle_dir(d, new_dir_node, load_props, ignore_svn)
        current_parent.add_child(new_dir_node)
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
def lock_admin_dir(wc_dir):
    "Lock a SVN administrative directory"

    path = os.path.join(wc_dir, main.get_admin_name(), 'lock')
    main.file_append(path, "stop looking!")
Exemple #6
0
    # deposit contents in the very last node.
    node = root_node
    while 1:
        if node.children is None:
            node.contents = contents
            node.props = props
            node.atts = atts
            break
        node = node.children[0]

    return root_node


# a regexp machine for matching the name of the administrative dir.
admin_dir = main.get_admin_name()
rm = re.compile("^" + admin_dir + "/" + "|/" + admin_dir + "/" + "|/" +
                admin_dir + "$" + "|^/" + admin_dir + "/" + "|^" + admin_dir +
                "$")


# 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."

    # 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 = {}
Exemple #7
0
def lock_admin_dir(wc_dir):
  "Lock a SVN administrative directory"

  path = os.path.join(wc_dir, main.get_admin_name(), 'lock')
  main.file_append(path, "stop looking!")