如何跨存储库迁移 svn:externals 属性中的所有 URL?

发布于 2024-07-07 21:09:16 字数 426 浏览 8 评论 0 原文

我们正在将 SVN 存储库从一台机器移动到另一台机器,随之而来的是新存储库的新域名。 问题是,在存储库中,有很多 svn:externals 对存储库中其他项目的引用。 例如,我们有projectA,它在 svn:externals 属性中具有:

external/libraryA svn://oldserver.net/repo/libraryA
external/libraryB svn://oldserver.net/repo/libraryB

...等等。 所有 URL 都引用该特定域名,因此可以轻松解析。 已经吸取了教训,我将把这些 URL 迁移到“svn://localhost/”,但我需要找到一种方法来遍历存储库历史记录并重写所有旧 URL,以便我们仍然可以查看这些项目的旧版本没有损坏的链接。

我该怎么做呢?

We are in the process of moving our SVN repositories from one machine to another one, and with it will come a new domain name for the new repo. The problem is, that within the repository, there are lots of svn:externals references to other projects within the repository. So for example, we have projectA, which has in the svn:externals properties:

external/libraryA svn://oldserver.net/repo/libraryA
external/libraryB svn://oldserver.net/repo/libraryB

...and so on. All of the URL's reference this particular domain name, so it can be easily parsed. Having already learned my lesson, I will migrate these URLs to be "svn://localhost/", but I need to find a way to go through the repository history and rewrite all of the old URLs, so that we can still check out older revisions of these projects without having broken links.

How would I go about doing this?

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

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

发布评论

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

评论(6

亢潮 2024-07-14 21:09:16

我会为此使用 SvnDumpTool 。 它正是您正在寻找的内容:

svndumptool transform-prop svn:externals "(\S*) (|-r ?\d* ?)http://oldserver.net(/\S*)" "\2\3 \1" source.dumpfile source-fixed-externals.dumpfile

这修复了 的每个外部subversion 1.5 格式,并使用相对 URL。

所以 svn:externals 就像:

external/libraryA svn://oldserver.net/repo/libraryA

变成:

 /repo/libraryA external/libraryA

使用服务器根相对 URL。

I'd use SvnDumpTool for this. It has exactly what you're looking for:

svndumptool transform-prop svn:externals "(\S*) (|-r ?\d* ?)http://oldserver.net(/\S*)" "\2\3 \1" source.dumpfile source-fixed-externals.dumpfile

This fixes up each external to the subversion 1.5 format, and uses relative URLs.

So svn:externals like:

external/libraryA svn://oldserver.net/repo/libraryA

become:

 /repo/libraryA external/libraryA

using server root relative URLs.

时光无声 2024-07-14 21:09:16

正如您所指出的,您仍然希望能够查看较旧的修订版本,唯一的解决方案实际上是“重写”整个历史记录(前面提到的解决方案 D)。

为此,您应该:

1) 使用 整个存储库的内容="noreferrer" title="svnadmin dump">svnadmin dump:

$ svnadmin dump /path/to/repos > original-dumpfile
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.

2) 编辑转储文件,更改 svn:externals URL。 这是最困难的部分:假设存储库也包含二进制数据,在纯文本编辑器中打开转储文件很可能会损坏转储文件。 我在使用所谓的“十六进制编辑器”方面有很好的经验,例如 免费十六进制编辑器 XVI32

3) 创建一个新存储库并将修改后的转储文件加载到其中:

$ svnadmin create newrepos
$ svnadmin load newrepos < modified-dumpfile

有关更多信息,您可能也对此链接感兴趣:
http://svnbook.red-bean.com/en/1.1/ch05s03.html

注意:Subversion 1.5 实际上在 svn:externals 属性中添加了对相对 URL 的支持,这可以准确地防止将来出现此类问题:
http://subversion.tigris.org/svn_1.5_releasenotes.html#externals

As you indicated that you still want to be able to check out older revisions, the only solution is really to "rewrite" the entire history (solution D mentioned earlier).

To do this, you should:

1) Dump the contents of the entire repository using svnadmin dump:

$ svnadmin dump /path/to/repos > original-dumpfile
* Dumped revision 0.
* Dumped revision 1.
* Dumped revision 2.
* Dumped revision 3.

2) Edit the dump file, to change the svn:externals URLs. This is the most difficult part: Assuming the repository contains binary data as well, opening the dump file in a plain text editor will most likely corrupt the dump file. I've had good experiences using a so-called "hex-editor", for instance the Freeware Hex Editor XVI32

3) Create a new repository and load the modified dumpfile into it:

$ svnadmin create newrepos
$ svnadmin load newrepos < modified-dumpfile

For more information, you might also be interested in this link:
http://svnbook.red-bean.com/en/1.1/ch05s03.html

NOTE: Subversion 1.5 actually added support for relative URLs in the svn:externals property, which can precisely prevent these sort of problems in the future:
http://subversion.tigris.org/svn_1.5_releasenotes.html#externals

窗影残 2024-07-14 21:09:16

我必须在 9 个用户和 4 个部署中重新定位 12 个工作副本。 这是一个简单的更改,用 IP 替换域,即 thing.domain.net -> 192.168.0.1

期望 svn relocate 的行为如所描述的那样(遍历嵌套外部)我编写了一个简单的 DOS 指令在每个位置运行:

for /D %G in (*)做 (
cd./%G
& svn 重新定位 http://thing.domain.net http://192.168.0.1
& cd ..)

这没有按预期工作,只是重新定位父 WC。

我的解决方案是编辑存储库本身(我使用 Tortoise Repo Browser)来更改外部的位置。 在此更改之后,只需更新重新定位的父级即可使所有内容保持一致。

让所有 Tortoise 用户清除他们的 URL 历史记录可能是个好主意,这样他们就不会无意中使用旧 URL 执行操作(它仍然存在于 DNS 查找中):

设置->保存的数据->URL历史记录->清除

I had to relocate 12 working copies across 9 users and 4 deployments. It was a simple change, replacing a domain with an IP, i.e. thing.domain.net -> 192.168.0.1

Expecting svn relocate to behave as described (traverse nested externals) I wrote a simple DOS instruction to run at each location:

for /D %G in (*) do (
cd ./%G
& svn relocate http://thing.domain.net http://192.168.0.1
& cd ..)

This didn't work as expected, only relocating the parent WC.

My solution was to edit the repositories themselves (I used Tortoise Repo Browser) to change the location of the externals. Following this change an update to the relocated parent was all that was required to bring everything into line.

It would probably be a good idea to get all the Tortoise users to clear their URL history so they don't inadvertently perform operations using the old URL (it still exists in the DNS lookup):

Settings->Saved Data->URL history->Clear

往事风中埋 2024-07-14 21:09:16

我使用 vi 编辑了转储文件,但必须使用“-b”开关以二进制模式进行编辑,这样任何可以解释为行结尾的字符都不会被转换。

例如 vi -b filename.dump

另外,我发现,如果您的 URL 长度发生变化,则也必须修改字符串长度。
例如,考虑如下所示的条目:

Node-path: trunk/src/include

Node-kind: dir

Node-action: change

Prop-content-length: 192

Content-length: 192

K13

svn:externals

V 156

MGL_ABC svn ://server_name/dir1/dir2

MGL_DEF svn://server_name/dir1/dir3

修改这些 URL 时,如果字符串长度发生变化,则还需要将“192”、“192”和“156”更改为匹配新的长度。
我发现很难计算绝对长度,但很容易找到差异。
例如,假设 URL 1 缩短了 3 个字符,URL 2 缩短了 4 个字符。 然后,您必须从这三个字符串长度数字中的每一个中减去“7”。

I edited my dump file with vi but I had to use the "-b" switch to edit in binary mode such that any characters that could be interpreted to be line endings did not get converted.

e.g. vi -b filename.dump

Also, I found that, if your URL length changes, there are string lengths that also had to be modified.
For example, consider an entry that looks like this:

Node-path: trunk/src/include

Node-kind: dir

Node-action: change

Prop-content-length: 192

Content-length: 192

K13

svn:externals

V 156

MGL_ABC svn://server_name/dir1/dir2

MGL_DEF svn://server_name/dir1/dir3

When you modify those URLs, if the length of the string changes, you need to also change the "192", "192" and "156" to match the new length.
I found it difficult to compute the absolute length but easy to find the differential.
For example, let's say URL 1 becomes shorter by 3 characters and URL 2 becomes shorter by 4 characters. Then, you would have to subract '7' from each of those three string length numbers.

海夕 2024-07-14 21:09:16

您可以:

a)检查旧版本,并更改​​主机文件以将旧名称指向新地址,然后进行 svn 更新。 如果 URL 路径也发生了变化……那么您也可以:

b) 花时间编写一个脚本,在当前(旧版本)工作副本中查找属性并更改那里的 URL,而不提交它们。 或者:

c) 记下您签入新属性值的修订版本,签出旧版本,然后将这些修订版本(仅影响属性)合并到您的工作副本中。

d) 或者,可能使用 svndump 转储存储库数据,字符串替换转储中的 URL,然后恢复它。我不会向您保证这甚至有效;-)

You could:

a) check out the old revision, and change your hosts-file to point the old name to the new address, then svn update. In case the URL-path also changed... well then you might as well:

b) take the time to write a script that find the properties in the current (old revision-) working copy and changes the URLs there, without committing them. OR:

c) make a note of the revision(-s) where you checked in the new property values, check out the old version, and simply do a merge those revisions (-that only affect the properties) into your working copy.

d) or, possibly, use svndump to dump the repository data, string-replace the URL in the dump, then restore it.. I would not give you any guarantee that that even works ;-)

冰魂雪魄 2024-07-14 21:09:16

我的所有外部文件都位于名为 flow 的目录中。 我用这个单行代码(bash shell)修复了外部的 URL:

for p in $(find -maxdepth 4 -name flow); do svn ps svn:externals "$(svn pg svn:externals $p/.. | perl -pe 's/^(\w+) svn\+ssh.*thing\.domain\.net(.*)/$2 $1/')" $p/..; done

All my externals were in directories named flow. I fixed the URLs in my externals with this one-liner (bash shell):

for p in $(find -maxdepth 4 -name flow); do svn ps svn:externals "$(svn pg svn:externals $p/.. | perl -pe 's/^(\w+) svn\+ssh.*thing\.domain\.net(.*)/$2 $1/')" $p/..; done
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文