SVN:稀疏更新以仅创建中继
SVN: Sparse update to create only trunks
我查看了几种解决方案,只检查 svn t运行ks。按照红皮书,我们有一个传统的 svn 设置,即
/
|-- /branches
|-- /tags
`-- /trunk
|-- foo
`-- bar
问题是我们有 100 个项目,都是 Maven 模块。每个项目都遵循上面的结构。
我想转到我们的 repo 的根目录并检查每个项目,这样我的结构类似于:
A/
`-- /trunk
|-- foo
`-- bar
B/
`-- /trunk
|-- foo
`-- bar
C/
`-- /trunk
|-- foo
`-- bar
... etc...
我已经使用 TortoiseSVN 并使用更新到修订版的选项 -> 选择项目并取消选择所有标签和分支来实现此目的。
这给出了以下输出样式:
Sparse update tags, depth 'Exclude'
C:\svnrepo\A\tags
Sparse update branches, depth 'Exclude'
C:\svnrepo\A\branches
Sparse update trunk, depth 'Fully recursive'
C:\svnrepo\A\trunk
我想做的是不必单击所有这些标签和分支复选框。 TortoiseSVN 有办法实现吗?有没有人有一个脚本可以 运行 on windows 和 运行 适当的命令行从每个项目中排除每个标签和分支?我看过这里,但没有多大意义:
http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html
好吧,没有 PC,但是 Windows 沐浴脚本应该是这样的:
svn co --depth=immediates %REPO% projects
cd projects
for /D %%d in (*) do svn up --set-depth=infinity %%d/trunk
我没有你的确切设置,所以我不能说这是否有效,或者你必须先 cd 进入 %%d
,然后执行 svn --set-depth=infinity trunk
然后cd ..
进入下一个项目。但是,这会让您了解如何将 Windows 批处理脚本与 svn
命令行客户端结合使用,以完成您无法通过 GUI 客户端轻松完成的操作。
当然,问题在于您为什么要查看每个项目(其中的 100 个),除非您实际上正在处理所有数百个项目。这可能需要非常非常长的时间来处理。当你真正开始一个特定的项目工作时,它已经过时了。
你最好使用稀疏签出来签出每个项目(可能还有主干),然后当你真正需要处理一个项目时,对项目的 `svn up --set-depth=infinity中继目录。也许这样的事情可能会更好:
svn co --depth=immediates %REPO% projects
cd projects
for /D %%d in (*) do svn up --set-depth=empty %%d/trunk
然后,您可以在实际处理项目时svn update --set-depth=infinity
。
回答我自己的问题。作为一名 Java 开发者,我的 shell 技能不是一流的,所以最终决定加入 Java。
使用不是那么快的 SVNKIT,我能够创建这个方法。我将所有内容都保存在一个方法中,以便 post 在这里,希望它能帮助其他人,如果不是解决方案的话,至少可以作为一个指针。它是针对 Java 7.
构建的
...
public void doRootCheckout(Path workingCopyDirectory) throws SVNException, IOException {
// Following advice from:
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
// USERNAME/PASSWORD are the svn username and passwords.
// Clearly you will need to use your own!
svnOperationFactory.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager(USERNAME, PASSWORD.toCharArray());
try {
final SvnCheckout checkout = svnOperationFactory.createCheckout();
checkout.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory.toFile()));
// repoUrl is the url of your SVN repository and in this
// example is a UTF-8 string, e.g. http://my.repo.com/java
SVNURL url = SVNURL.parseURIEncoded(repoUrl);
checkout.setSource(SvnTarget.fromURL(url));
checkout.setAllowUnversionedObstructions(false);
// Our local clients are fixed at the 1.7 svn format so had to set this here
checkout.setTargetWorkingCopyFormat(ISVNWCDb.WC_FORMAT_17);
// This solution is somewhat inefficient as it first
// checks out all the code from the root of the repoUrl
// including all tags and branches.
// This can take a long time...
checkout.setDepth(SVNDepth.INFINITY);
checkout.run();
// When the full checkout is completed we
// need to iterate through all the directories
// and exclude all tags and branches...
// This also can take a long time...
Files.walkFileTree(workingCopyDirectory, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
if (dir.endsWith("tags") || dir.endsWith("branches")) {
System.out.println("Excluding: " + dir.toAbsolutePath().toString());
SvnUpdate svnUpdate = svnOperationFactory.createUpdate();
svnUpdate.setDepth(SVNDepth.EXCLUDE);
svnUpdate.setDepthIsSticky(true);
svnUpdate.setSingleTarget(SvnTarget.fromFile(dir.toFile()));
try {
svnUpdate.run();
} catch (SVNException e) {
e.printStackTrace();
}
}
return FileVisitResult.CONTINUE;
}
});
} finally {
svnOperationFactory.dispose();
}
}
...
我查看了几种解决方案,只检查 svn t运行ks。按照红皮书,我们有一个传统的 svn 设置,即
/
|-- /branches
|-- /tags
`-- /trunk
|-- foo
`-- bar
问题是我们有 100 个项目,都是 Maven 模块。每个项目都遵循上面的结构。
我想转到我们的 repo 的根目录并检查每个项目,这样我的结构类似于:
A/
`-- /trunk
|-- foo
`-- bar
B/
`-- /trunk
|-- foo
`-- bar
C/
`-- /trunk
|-- foo
`-- bar
... etc...
我已经使用 TortoiseSVN 并使用更新到修订版的选项 -> 选择项目并取消选择所有标签和分支来实现此目的。
这给出了以下输出样式:
Sparse update tags, depth 'Exclude'
C:\svnrepo\A\tags
Sparse update branches, depth 'Exclude'
C:\svnrepo\A\branches
Sparse update trunk, depth 'Fully recursive'
C:\svnrepo\A\trunk
我想做的是不必单击所有这些标签和分支复选框。 TortoiseSVN 有办法实现吗?有没有人有一个脚本可以 运行 on windows 和 运行 适当的命令行从每个项目中排除每个标签和分支?我看过这里,但没有多大意义:
http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html
好吧,没有 PC,但是 Windows 沐浴脚本应该是这样的:
svn co --depth=immediates %REPO% projects
cd projects
for /D %%d in (*) do svn up --set-depth=infinity %%d/trunk
我没有你的确切设置,所以我不能说这是否有效,或者你必须先 cd 进入 %%d
,然后执行 svn --set-depth=infinity trunk
然后cd ..
进入下一个项目。但是,这会让您了解如何将 Windows 批处理脚本与 svn
命令行客户端结合使用,以完成您无法通过 GUI 客户端轻松完成的操作。
当然,问题在于您为什么要查看每个项目(其中的 100 个),除非您实际上正在处理所有数百个项目。这可能需要非常非常长的时间来处理。当你真正开始一个特定的项目工作时,它已经过时了。
你最好使用稀疏签出来签出每个项目(可能还有主干),然后当你真正需要处理一个项目时,对项目的 `svn up --set-depth=infinity中继目录。也许这样的事情可能会更好:
svn co --depth=immediates %REPO% projects
cd projects
for /D %%d in (*) do svn up --set-depth=empty %%d/trunk
然后,您可以在实际处理项目时svn update --set-depth=infinity
。
回答我自己的问题。作为一名 Java 开发者,我的 shell 技能不是一流的,所以最终决定加入 Java。
使用不是那么快的 SVNKIT,我能够创建这个方法。我将所有内容都保存在一个方法中,以便 post 在这里,希望它能帮助其他人,如果不是解决方案的话,至少可以作为一个指针。它是针对 Java 7.
构建的...
public void doRootCheckout(Path workingCopyDirectory) throws SVNException, IOException {
// Following advice from:
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
// USERNAME/PASSWORD are the svn username and passwords.
// Clearly you will need to use your own!
svnOperationFactory.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager(USERNAME, PASSWORD.toCharArray());
try {
final SvnCheckout checkout = svnOperationFactory.createCheckout();
checkout.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory.toFile()));
// repoUrl is the url of your SVN repository and in this
// example is a UTF-8 string, e.g. http://my.repo.com/java
SVNURL url = SVNURL.parseURIEncoded(repoUrl);
checkout.setSource(SvnTarget.fromURL(url));
checkout.setAllowUnversionedObstructions(false);
// Our local clients are fixed at the 1.7 svn format so had to set this here
checkout.setTargetWorkingCopyFormat(ISVNWCDb.WC_FORMAT_17);
// This solution is somewhat inefficient as it first
// checks out all the code from the root of the repoUrl
// including all tags and branches.
// This can take a long time...
checkout.setDepth(SVNDepth.INFINITY);
checkout.run();
// When the full checkout is completed we
// need to iterate through all the directories
// and exclude all tags and branches...
// This also can take a long time...
Files.walkFileTree(workingCopyDirectory, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
if (dir.endsWith("tags") || dir.endsWith("branches")) {
System.out.println("Excluding: " + dir.toAbsolutePath().toString());
SvnUpdate svnUpdate = svnOperationFactory.createUpdate();
svnUpdate.setDepth(SVNDepth.EXCLUDE);
svnUpdate.setDepthIsSticky(true);
svnUpdate.setSingleTarget(SvnTarget.fromFile(dir.toFile()));
try {
svnUpdate.run();
} catch (SVNException e) {
e.printStackTrace();
}
}
return FileVisitResult.CONTINUE;
}
});
} finally {
svnOperationFactory.dispose();
}
}
...