git & svn externals - 最终解决方案了吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4689090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git & svn externals - a final solution yet?
提问by stijn
this is the workflow I currently use for my svn projects (I never use svn branches, and some projects are actively worked on by other people as well):
这是我目前用于 svn 项目的工作流程(我从不使用 svn 分支,并且其他人也积极参与一些项目):
- on the server, do the inital
git svn fetch
which might take hours. Also create a 'build' branch. - on a development machine cloning is now fast:
git clone srv://project.git, git checkout build
followed bygit update-refs ..., git svn fetch
to restore the link to the svn repository - work, commit, work commit, ...
- to check if things are sane,
git push build
to the server and trigger a build in Hudson for that branch - to store work so that I can work on it from another machine, also push build branch
- when satisfied, join commits together in logical steps (eg one for each bug), commit to svn and reset everything like
git checkout master, git merge build, git svn dcommit, git push, git checkout build, git rebase master, git push build
- 在服务器上,执行
git svn fetch
可能需要数小时的初始化。还要创建一个“构建”分支。 - 在开发机器上克隆现在很快:
git clone srv://project.git, git checkout build
其次是git update-refs ..., git svn fetch
恢复到 svn 存储库的链接 - 工作,提交,工作提交,...
- 检查事情是否正常,
git push build
到服务器并在 Hudson 中为该分支触发构建 - 存储工作以便我可以在另一台机器上处理它,同时推送构建分支
- 当满意时,在逻辑步骤中加入提交(例如每个错误一个),提交到 svn 并重置所有内容,例如
git checkout master, git merge build, git svn dcommit, git push, git checkout build, git rebase master, git push build
Enter svn externals. I tried every script herealready but all of them fail. My externals are setup like this:
输入 svn externals。我已经在这里尝试了所有脚本,但都失败了。我的外部设置如下:
/path/to/x x
/path/to/y/z y/z
/path/to/a/b.file a/b.file
and the scripts do things like trying to create /path/to/x
in the root of the filesystem and git svn fetch /path/to/x
. Also the single files seem to cause more problems. (subquestion 1: what is the svn:externals format these scripts were written for then?)
并且脚本执行诸如尝试/path/to/x
在文件系统的根目录中创建和git svn fetch /path/to/x
. 此外,单个文件似乎会导致更多问题。(子问题 1:当时编写这些脚本的 svn:externals 格式是什么?)
It doesn't seem to hard modifying one of the scripts to handle my situation and replicate the directory structure I'm after correctly, but then I'm left with a major problem: if I change a file in both x and y/z directories, I don't see a way to join this into a single svn commit and that is one of the reasons I started using git in the first place.
似乎并不难修改其中一个脚本来处理我的情况并正确复制我所追求的目录结构,但是我遇到了一个主要问题:如果我同时更改 x 和 y/z 中的文件目录,我没有看到将其加入单个 svn 提交的方法,这就是我首先开始使用 git 的原因之一。
Hence the question: is there a way I can replicate the above workflow, using only parts of a certain svn repository, in such a way that I can do svn dcommit in the root? I'd prefer a ready-to-use solution that works both on linux and windows.
因此,问题是:有没有一种方法可以复制上述工作流程,仅使用某个 svn 存储库的一部分,这样我就可以在根目录中执行 svn dcommit?我更喜欢在 linux 和 windows 上都可以使用的即用型解决方案。
editI quickly hacked through one of the scripts I found and made it replicating the directory structure of the svn externals. I cannot clone single files though, here's output:
编辑我迅速破解了我找到的其中一个脚本,并使其复制了 svn 外部的目录结构。虽然我无法克隆单个文件,但输出如下:
git svn clone -r HEAD srv://svn/repo/path/to/projects.sln
Initialized empty Git repository in xxx/projects.sln/.git/
Invalid filesystem path syntax: REPORT request failed on '/svn/repo/!svn/vcc/default':
Cannot replace a directory from within at yyy/git/libexec/git-core/git-svn line 5114
subquestion 2: is it not possible fetching a single file through git svn?
子问题 2:通过 git svn 获取单个文件是不可能的吗?
采纳答案by John Szakmeister
Unfortunately, svn's externals are quite flexible. I've run across a number of scripts that treat them as <path> <url>, but <url> <path> is also allowed. So I think some of the scripts are just broken in that regard.
不幸的是,svn 的外部非常灵活。我遇到了许多将它们视为 <path> <url> 的脚本,但是 <url> <path> 也是允许的。所以我认为一些脚本在这方面被破坏了。
To answer your second subquestion: no. 'git svn fetch' needs to operate on a subtree of Subversion's repo, but it needs to be something it can treat like a branch. The only thing map well into that paradigm is a directory (trunk/, for example). FWIW, Bazaar and Mercurial suffer here too. At the end of the day, Subversion is just a versioned file system, whereas Git has a first class concept of a branch. This is one of those mismatches getting in the way. :-(
回答你的第二个子问题:不。'git svn fetch' 需要在 Subversion 的 repo 的子树上操作,但它需要可以像分支一样对待。唯一能很好地映射到该范式的是目录(例如,trunk/)。FWIW、Bazaar 和 Mercurial 也受到了影响。归根结底,Subversion 只是一个版本化的文件系统,而 Git 拥有一流的分支概念。这是阻碍的不匹配之一。:-(
回答by agross
Just a another note on the second subquestion. As far as I know subversion as of today also does not support svn externals for files, only folders. So I guess such entries in the properties would be invalid. Don't know if there is any tooling which handles this case.
只是关于第二个子问题的另一个注释。据我所知,到目前为止,subversion 也不支持文件的 svn externals,只支持文件夹。所以我猜这些属性中的条目将是无效的。不知道是否有任何工具可以处理这种情况。