SVN:仅签出/导出目录结构

发布于 2024-07-13 02:38:01 字数 65 浏览 5 评论 0原文

有没有办法执行 SVN 签出(或导出),这将仅获取目录结构; 也就是说没有文件?

Is there a way to perform a SVN checkout (or export), which would fetch only the directory structure; that is to say, no files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

娇纵 2024-07-20 02:38:02

您可以在 checkout 命令中指定 --non-recursive ,可能会帮助您获得所需的结果。

You can specify --non-recursive to the checkout command, might help you to get what you want.

抚笙 2024-07-20 02:38:02

的contrib工具中有一个 python 脚本subversion,它使用空文件创建目录结构。
有了一点 Python 知识,跳过创建文件应该不难。

There is a python script in the contrib tools of subversion, which creates the directory structure with empty files.
With a little bit of python knowledge, it should not be to hard to skip creating the files at all.

儭儭莪哋寶赑 2024-07-20 02:38:02

SVN 本身无法做到这一点,但如果您只想导出目录结构,请尝试 svn ls -R --xml 获取目录结构的 XML 列表,然后手动重新创建它。

SVN can't do that per se, but if you just want to export directory structure, try svn ls -R --xml to get XML listing of the directory structure and then recreate it by hand.

时光倒影 2024-07-20 02:38:02

仅签出目录结构的用途是无法排除一个或多个目录被签出的部分解决方法。 假设与检查完整源代码相比,仅检查目录树的成本可以忽略不计。 签出版本化目录结构后,我可以使用 Subversion 的更新和 sparse目录 有选择地选择哪些目录树应包含文件。

A use for checking out just the directory structure is a partial workaround for not being able to exclude one or more directories from being checked out. It is assumed that the cost of just checking out the directory tree is negligible in comparison to checking out the full source. With a versioned directory structure checked out I could then use Subversion's update and sparse directories to selectively pick what directory trees should have files.

£噩梦荏苒 2024-07-20 02:38:02

这工作得很好

svn ls | xargs svn up -N

然后如果你想完全检查这些目录中的一些,请进入它们并使用

svn ls | xargs svn up

This works perfectly

svn ls | xargs svn up -N

And then if you want to get few of those directories fully checked out, go inside them and use

svn ls | xargs svn up
行雁书 2024-07-20 02:38:02

只是想补充一下,如果您需要在服务器端执行此操作(即不首先检查存储库),则相当于 svn ls 相当于 svnlook tree --full-paths >。
我必须创建 50GB 存储库文件夹结构的副本,并使用我在此处找到的提示来完成此操作,而无需创建整个内容的工作副本。

我的代码是:

svnlook tree /path/to/repo --full-paths | grep“/$”| grep -v“^/$”| xargs -I {} mkdir -p "{}"

grep -v "^/$" 因为输出包含单个 / (即文件系统根文件夹),而我没有'不想乱搞这个。

Just wanted to add, if you need to do this server-side (i.e. not checking out the repository first), the equivalent to svn ls is svnlook tree --full-paths.
I had to create a copy of a 50GB repo's folder structure and used the hints I found here to do it without having to create a working copy of the whole thing.

My code was:

svnlook tree /path/to/repo --full-paths | grep "/$" | grep -v "^/$" | xargs -I {} mkdir -p "{}"

The grep -v "^/$" because the output contained a single / (i.e. file system root folder) and I didn't want to mess around with that.

最近可好 2024-07-20 02:38:02

在 Windows 上,使用 TortoiseSVN 您可以执行 Checkout -> 结账深度:仅此一项。
这样你就可以获得单个文件夹/文件。 您可以通过这种方式重建您的结构(使用 repobrowser)。
有点麻烦,但如果你的目录结构不太复杂的话也是可行的。
我更喜欢这个而不是通过慢速网络检查数千个小文件(几千兆字节)......

on windows and with TortoiseSVN you can do Checkout -> checkout depth: only this item.
this way you can get single folders/files. you could rebuild your structure this way (using the repobrowser).
a bit cumbersome, but doable if your directory structure is not too complicated.
i preferred this over checking out thousands of small files (several gigabytes) over slow network ...

美羊羊 2024-07-20 02:38:02

我的 DotNet (LINQ) 方法是:

首先,运行 svn list 命令。 并将输出推送到 .xml 文件。

"svn.exe" list "https://myserver.com:8443/svn/DotNet/src/v40Base/v40/" --recursive --username %USERNAME% --xml >>myfile.xml

然后针对 .xml 文件运行一些 LINQ 代码。

    private static void FindSVNDirectories()
    {

        string fileName = @"C:\temp\myfile.xml";

        XDocument xDoc = XDocument.Load(fileName);

        //XNamespace ns = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
        string ns = string.Empty;

        //List of directories
        var list1 = from list in xDoc.Descendants(ns + "list")
                    from item in list.Elements(ns + "entry")
                    where item.Attribute("kind").Value=="dir"
                    select new
                       {
                           mykind = item.Attribute("kind").Value,
                           myname = (item.Element(ns + "name").Value)
                       };

        StringBuilder sb = new StringBuilder();
        foreach (var v in list1)
        {
            sb.Append(v.ToString() + System.Environment.NewLine );
        }

        Console.WriteLine(sb.ToString());


    }

My DotNet (LINQ) way to do this:

First, run the svn list command. And push the output to an .xml file.

"svn.exe" list "https://myserver.com:8443/svn/DotNet/src/v40Base/v40/" --recursive --username %USERNAME% --xml >>myfile.xml

And then run some LINQ code against the .xml file.

    private static void FindSVNDirectories()
    {

        string fileName = @"C:\temp\myfile.xml";

        XDocument xDoc = XDocument.Load(fileName);

        //XNamespace ns = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003");
        string ns = string.Empty;

        //List of directories
        var list1 = from list in xDoc.Descendants(ns + "list")
                    from item in list.Elements(ns + "entry")
                    where item.Attribute("kind").Value=="dir"
                    select new
                       {
                           mykind = item.Attribute("kind").Value,
                           myname = (item.Element(ns + "name").Value)
                       };

        StringBuilder sb = new StringBuilder();
        foreach (var v in list1)
        {
            sb.Append(v.ToString() + System.Environment.NewLine );
        }

        Console.WriteLine(sb.ToString());


    }
狼亦尘 2024-07-20 02:38:02

您可以使用此脚本,它将 svn 列出存储库并在目录中创建结构。

用法: perl checkout-struct.pl repos destdir

repos 不能是你的 repos 的根目录,它也可以是一个目录。

无法创建包含强调字符(àéîùç...)的目录,但可以很好地处理空格。 对于那些有时间的人来说,我认为这是一个编码问题。

checkout-struct.pl:

#!perl

my @dirs;
my $repos = shift;
my $dest = shift;

@dirs = grep { /\/$/ && /^[^\.]/ } `svn list -R $repos`;

foreach(@dirs) {
    s/\/$//;
    chomp;
    mkdir("$dest/$_") or warn $!." trying to create $dest/$_";
}

You may use this script which will svn list the repos and create the structure in a directory.

usage: perl checkout-structure.pl repos destdir

repos must not be the root of your repos, it can also precise a directory.

Fails to create dirs containing accentuated caracters (àéîùç...), but works fine with spaces. For these who have time for that, I think it's an encoding problem.

checkout-structure.pl:

#!perl

my @dirs;
my $repos = shift;
my $dest = shift;

@dirs = grep { /\/$/ && /^[^\.]/ } `svn list -R $repos`;

foreach(@dirs) {
    s/\/$//;
    chomp;
    mkdir("$dest/$_") or warn $!." trying to create $dest/$_";
}
悲喜皆因你 2024-07-20 02:38:02

简单看一下svn help co,我看不出有什么办法可以做到这一点。 我之前为从下载的库的新版本(即供应商分支)更新存储库所做的事情是删除不是 .svn 文件夹的所有内容:

#!/bin/sh
find ./ -type f | grep -v .svn | xargs rm -f

如果您试图避免检查,那么这不是特别有效这些文件首先被输出,但它应该有相同的结果。

I can't see that there is a way to do it from a brief look at svn help co. Something I've done before for updating a repository from a new version of a downloaded library (i.e. a vendor branch) is to delete everything which isn't an .svn folder:

#!/bin/sh
find ./ -type f | grep -v .svn | xargs rm -f

It's not particularly efficient if you were trying to avoid having to check those files out in the first place, but it should have the same result.

与君绝 2024-07-20 02:38:02

没有办法做到这一点,事实上这是一件有点奇怪的事情,所以现在我很好奇!

这可能不相关,但您可以通过添加 svn:ignore 相关目录上的属性。 这对于防止提交生成的工件(例如文档或缓存文件)特别有用。

There's no way to do this, and in fact it's a slightly odd thing to want to do, so now I'm curious!

This may not be relevant, but you can prevent the files being comitted in the first place by adding an svn:ignore property on the relevant directories. This is particularly useful to prevent generated artifacts such as documentation or cache files being comitted.

久隐师 2024-07-20 02:38:01
svn ls -R {svnrepo} | grep "/$" | xargs -n 1 mkdir -p

导出,而不是结账。

[更新]

结帐时:

env REPO={repo} sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth=empty $REPO'

对于太大的东西来说,这将非常慢。

svn ls -R {svnrepo} | grep "/$" | xargs -n 1 mkdir -p

Export, not a checkout.

[Updated]

With checkout:

env REPO={repo} sh -c 'svn ls -R $REPO | grep "/\$" | xargs -n 1 svn co --depth=empty $REPO'

This will be pretty slow for anything too large.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文