git & svn externals - 最终解决方案了吗?

发布于 2024-10-11 16:16:08 字数 1646 浏览 8 评论 0原文

这是我目前用于 svn 项目的工作流程(我从不使用 svn 分支,有些项目也由其他人积极参与):

  • 在服务器上,执行初始的 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

输入 svn externals。我尝试了这里的每个脚本 已经但是他们都失败了。我的外部设置如下:

/path/to/x x
/path/to/y/z y/z
/path/to/a/b.file a/b.file

脚本执行诸如尝试在文件系统的根目录中创建 /path/to/xgit svn fetch /path/to/x 之类的操作代码>.此外,单个文件似乎会引起更多问题。 (子问题 1:这些脚本的 svn:externals 格式是什么?)

似乎并不难修改其中一个脚本来处理我的情况并正确复制我所追求的目录结构,但后来我'我留下了一个主要问题:如果我更改 x 和 y/z 目录中的文件,我看不到将其加入到单个 svn 提交中的方法,这就是我首先开始使用 git 的原因之一地方。

因此问题是:有没有一种方法可以复制上述工作流程,仅使用某个 svn 存储库的一部分,这样我就可以在根目录中执行 svn dcommit ?我更喜欢一个可以在 Linux 和 Windows 上运行的即用型解决方案。

编辑 我很快就破解了我找到的一个脚本,并使其复制了 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

子问题 2:是否无法通过 git svn 获取单个文件?

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):

  • 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 by git 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

Enter svn externals. I tried every script here already but all of them fail. My externals are setup like this:

/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?)

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.

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.

edit I 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:

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?

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

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

发布评论

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

评论(2

甜宝宝 2024-10-18 16:16:08

不幸的是,svn 的外部非常灵活。我遇到过许多将它们视为的脚本。,但<路径>也是允许的。所以我认为有些脚本在这方面已经被破坏了。

回答你的第二个子问题:不。 “git svn fetch”需要在 Subversion 存储库的子树上进行操作,但它需要是可以像分支一样对待的东西。唯一能很好地映射到该范例的是目录(例如 trunk/)。 FWIW、Bazaar 和 Mercurial 也在这里受到影响。归根结底,Subversion 只是一个版本化文件系统,而 Git 则拥有一流的分支概念。这是阻碍的不匹配之一。 :-(

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.

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. :-(

夜司空 2024-10-18 16:16:08

关于第二个子问题的另一个注释。
据我所知,到目前为止,Subversion 也不支持文件的 svn 外部,只支持文件夹。所以我猜属性中的此类条目将是无效的。不知道是否有任何工具可以处理这种情况。

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.

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