你可以使用Subversion进行部分结账吗?
如果在trunk / trunk下有20个目录,并且每个目录只有3个目录,那么是否可以在trunk下面进行Subversion签出?
Subversion 1.5引入了稀疏的签出,这可能是你可能会觉得有用的。 从文档 :
… 稀疏的目录 (或浅层结账 )…允许您轻松检出一个工作副本或一个工作副本的一部分 – 比完整的recursion更浅,可以自由地将先前忽略的文件和子目录引入晚点。
事实上,感谢我在这里发表的评论,看起来像稀疏的目录是要走的路。 我相信下面应该做到这一点:
svn checkout --depth empty http://svnserver/trunk/proj svn update --set-depth infinity proj/foo svn update --set-depth infinity proj/bar svn update --set-depth infinity proj/baz
或者, – --depth immediates
而不是empty
检查文件和目录在trunk/proj
没有他们的内容。 这样你可以看到存储库中存在哪些目录。
正如@ zigdon的回答中所提到的,您也可以执行非recursion检出。 这是一个更老的和不太灵活的方式来达到类似的效果:
svn checkout --non-recursive http://svnserver/trunk/proj svn update trunk/foo svn update trunk/bar svn update trunk/baz
或者做一个非recursion结账的/ trunk,然后只需要手动更新你需要的3个目录。
我写了一个脚本来自动化复杂的稀疏检出。
#!/usr/bin/env python ''' This script makes a sparse checkout of an SVN tree in the current working directory. Given a list of paths in an SVN repository, it will: 1. Checkout the common root directory 2. Update with depth=empty for intermediate directories 3. Update with depth=infinity for the leaf directories ''' import os import getpass import pysvn __author__ = "Karl Ostmo" __date__ = "July 13, 2011" # ============================================================================= # XXX The os.path.commonprefix() function does not behave as expected! # See here: http://mail.python.org/pipermail/python-dev/2002-December/030947.html # and here: http://nedbatchelder.com/blog/201003/whats_the_point_of_ospathcommonprefix.html # and here (what ever happened?): http://bugs.python.org/issue400788 from itertools import takewhile def allnamesequal(name): return all(n==name[0] for n in name[1:]) def commonprefix(paths, sep='/'): bydirectorylevels = zip(*[p.split(sep) for p in paths]) return sep.join(x[0] for x in takewhile(allnamesequal, bydirectorylevels)) # ============================================================================= def getSvnClient(options): password = options.svn_password if not password: password = getpass.getpass('Enter SVN password for user "%s": ' % options.svn_username) client = pysvn.Client() client.callback_get_login = lambda realm, username, may_save: (True, options.svn_username, password, True) return client # ============================================================================= def sparse_update_with_feedback(client, new_update_path): revision_list = client.update(new_update_path, depth=pysvn.depth.empty) # ============================================================================= def sparse_checkout(options, client, repo_url, sparse_path, local_checkout_root): path_segments = sparse_path.split(os.sep) path_segments.reverse() # Update the middle path segments new_update_path = local_checkout_root while len(path_segments) > 1: path_segment = path_segments.pop() new_update_path = os.path.join(new_update_path, path_segment) sparse_update_with_feedback(client, new_update_path) if options.verbose: print "Added internal node:", path_segment # Update the leaf path segment, fully-recursive leaf_segment = path_segments.pop() new_update_path = os.path.join(new_update_path, leaf_segment) if options.verbose: print "Will now update with 'recursive':", new_update_path update_revision_list = client.update(new_update_path) if options.verbose: for revision in update_revision_list: print "- Finished updating %s to revision: %d" % (new_update_path, revision.number) # ============================================================================= def group_sparse_checkout(options, client, repo_url, sparse_path_list, local_checkout_root): if not sparse_path_list: print "Nothing to do!" return checkout_path = None if len(sparse_path_list) > 1: checkout_path = commonprefix(sparse_path_list) else: checkout_path = sparse_path_list[0].split(os.sep)[0] root_checkout_url = os.path.join(repo_url, checkout_path).replace("\\", "/") revision = client.checkout(root_checkout_url, local_checkout_root, depth=pysvn.depth.empty) checkout_path_segments = checkout_path.split(os.sep) for sparse_path in sparse_path_list: # Remove the leading path segments path_segments = sparse_path.split(os.sep) start_segment_index = 0 for i, segment in enumerate(checkout_path_segments): if segment == path_segments[i]: start_segment_index += 1 else: break pruned_path = os.sep.join(path_segments[start_segment_index:]) sparse_checkout(options, client, repo_url, pruned_path, local_checkout_root) # ============================================================================= if __name__ == "__main__": from optparse import OptionParser usage = """%prog [path2] [more paths...]""" default_repo_url = "http://svn.example.com/MyRepository" default_checkout_path = "sparse_trunk" parser = OptionParser(usage) parser.add_option("-r", "--repo_url", type="str", default=default_repo_url, dest="repo_url", help='Repository URL (default: "%s")' % default_repo_url) parser.add_option("-l", "--local_path", type="str", default=default_checkout_path, dest="local_path", help='Local checkout path (default: "%s")' % default_checkout_path) default_username = getpass.getuser() parser.add_option("-u", "--username", type="str", default=default_username, dest="svn_username", help='SVN login username (default: "%s")' % default_username) parser.add_option("-p", "--password", type="str", dest="svn_password", help="SVN login password") parser.add_option("-v", "--verbose", action="store_true", default=False, dest="verbose", help="Verbose output") (options, args) = parser.parse_args() client = getSvnClient(options) group_sparse_checkout( options, client, options.repo_url, map(os.path.relpath, args), options.local_path)
有点。 正如鲍比所说:
svn co file:///.../trunk/foo file:///.../trunk/bar file:///.../trunk/hum
会得到的文件夹,但你会从颠覆的angular度来分开的文件夹。 你将不得不单独提交和更新每个子文件夹。
我不相信你可以签出一个部分树,然后与部分树一起作为一个单一的实体。
没有任何特别有用的方式,不。 你可以检查子树(如鲍比·杰克的build议),但你失去了primefaces地更新/提交的能力; 要做到这一点,他们需要置于他们共同的父母之下,一旦你检查出共同的父母,你会下载该父母下的一切。 非recursion不是一个好的select,因为你想要更新和提交是recursion的。