svn 移动目录以重新组织存储库

发布于 2024-12-08 00:49:25 字数 1422 浏览 0 评论 0原文

我有一个 svn 存储库,其中包含这样的主目录:

/apples/
/bananas/
/pears/

在我的工作副本中,这些实际上是更大树的子目录...

/food/fruit/apples
/food/fruit/bananas
/food/fruit/pears
/food/veggies/asparagus
/food/veggies/broccoli

我想重新组织我的存储库,以便 /food/ 实际上是存储库的根目录..但是我的工作副本是一个实时服务器,所以我需要非常小心不要破坏任何东西,哪怕是一分钟。它也是一棵非常大的树,因此回滚错误可能会导致明显的停机时间。

如果这只是在存储库中移动文件夹,我想我会知道如何将 svn move 与存储库参数一起使用(我认为这仍然是步骤#1?)...但我不确定如何将更改应用到工作副本,然后添加父文件夹,同时不搞乱现有工作文件。

我的答案:感谢 AH

1)确保存储库是最新的,然后在存储库中移动分支。这可以通过在存储库本身上使用 svn move 命令或通过工作副本上的操作来完成。这不会影响实时工作副本(暂时不要svn update!)。这是最简单的部分。

2) svn switch 将分支切换到新位置。在这个例子中,而 Fruit 以前是存储库的根:

svn switch https://host/svn/fruit /food/fruit

我以前对 svn switch 不太了解,但这并不太棘手。这会更改所有 .svn 元数据,但不会影响实际文件。

3)这是棘手的部分。您需要快速连续地执行这些步骤,以尽量减少停机时间(它们都非常快):

mv /food/fruit /food/fruit-temp
svn co --depth immediates https://host/svn/ /food/
rm -rf /food/fruit
mv /food/fruit-temp /food/fruit
svn update --set-depth infinity /food/

这里发生的情况是,使用 --深度立即执行 进行结账,为 /food/ 的内容创建元数据并创建 /fruit/ 子目录但不创建其内容(我们需要使用rm -rf这样我们就可以删除fruit内的.svn文件夹,但仅此而已那里)。然后我们只需将真实内容交换回去,父项和子项现在就缝合在一起了。 mv 完成后,我们就恢复在线状态。 set-depth infinity 将工作副本的范围扩展到您所期望的范围。最后我们可以svn add孩子的兄弟姐妹(例如蔬菜)。

I have a svn repo containing main directories like this:

/apples/
/bananas/
/pears/

In my working copy, those are actually subdirectories of a much bigger tree...

/food/fruit/apples
/food/fruit/bananas
/food/fruit/pears
/food/veggies/asparagus
/food/veggies/broccoli

I would like to reorganize my repo so that /food/ is in fact the root of the repo... but my working copy is a live server, so I need to be very careful not to break anything, even for a minute. It's also a really large tree, so rolling back a mistake could potentially create a noticeable downtime.

If this were just moving folders within the repo, I think I'd know how to use svn move with repo arguments (and I assume that is still step #1?)... but I'm not sure how to apply the change to the working copy, then add the parent folders, while not screwing up the existing working files.

MY ANSWER: thanks to A.H.

1) Make sure the repo is up-to-date and then move the branch within the repo. This can be done using svn move commands on the repo itself or through actions on a working copy. This does not affect the live working copy (don't svn update yet!). This is the easy part.

2) svn switch the branch to the new location. In this example, whereas fruit was previously the root of the repo:

svn switch https://host/svn/fruit /food/fruit

I didn't know much about svn switch previously, but this wasn't too tricky. This changes all the .svn metadata, but does not affect actual files.

3) Here's the tricky part. You need to take these steps in rapid succession for minimal downtime (they're each very fast):

mv /food/fruit /food/fruit-temp
svn co --depth immediates https://host/svn/ /food/
rm -rf /food/fruit
mv /food/fruit-temp /food/fruit
svn update --set-depth infinity /food/

What's happening here is that the checkout with --depth immediates creates the metadata for the contents of /food/ and creates the /fruit/ subdir but not its contents (we need to use rm -rf so we can get rid of the .svn folder inside fruit, but that's all that's there). Then we just swap the real content back in, and the parent and child are now stitched together. Once the mv is done, we're back online. The set-depth infinity extends the scope of the working copy to what you'd expect. Finally we can svn add the child's siblings (eg- veggies).

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

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

发布评论

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

评论(2

神爱温柔 2024-12-15 00:49:25

我的第一个建议是从一个尚未上线的新工作副本开始。在该工作副本(WC)中,您可以毫无危险地进行尝试。这就是工作复制的真正含义;-)

另一个提示:使用第二个工作副本逐步将现有结构重新排列为您想要的结构。一切就绪后,签入。请记住,必须使用 svn 命令完成重新排列。

然后使用另一个工作副本来检查您上次签入是否确实执行了您缩进的操作。

然后,您可以使用正常的 mv 命令更新实时工作副本或上次 WC 与实时站点的简单切换。

一步一步:

svn co $URL new-wc
cd new-wc
svn mkdir food
svn mkdir food/fruit
svn mv apples food/fruit
svn mv bananas food/fruit
svn mv pears food/fruit
svn ci

现在检查一个新的 WC 来验证 - 实时 WC 仍然没有变化!

cd ..
svn co $URL verify-wc
# take time and verify

现在在文件系统中切换实时 WC 和验证 WC - 如果它们位于同一文件系统上,速度会很快!

mv live-wc live-wc-old
mv verify-wc/food/fruit live-wc

现在现场厕所已经修好了。 ast 块的替代方案可以是:

cd live-wc
svn switch $URL/food/fruit

这应该不会耗时 - 但请先使用备份副本检查这一点:-)

My first tip is to do start with a fresh working copy which is NOT live. In that working copy (WC) you can try out things without any danger. Thats what working and copy really means ;-)

Another tip: Use the second working copy to rearrange the existing structure step by step into the structure you want. After everything is in place, check in. Please keep in mind that rearrangements must be done using the svn commands.

Then use another working copy to check, that your last checkin did indeed what you indented.

Then you can update your live working copy OR simple switch that last WC with the live site using the normal mv command.

Step by step:

svn co $URL new-wc
cd new-wc
svn mkdir food
svn mkdir food/fruit
svn mv apples food/fruit
svn mv bananas food/fruit
svn mv pears food/fruit
svn ci

Now checkout a fresh WC to verifiy - the live WC is still unchanged!

cd ..
svn co $URL verify-wc
# take time and verify

Now switch the live WC and the verify WC in the filesystem - this is fast if they are on the same filesystem!

mv live-wc live-wc-old
mv verify-wc/food/fruit live-wc

Now the live WC is fixed. An alternative for the ast block can be:

cd live-wc
svn switch $URL/food/fruit

This should do nothing time consuming - but please check this with a backup copy first :-)

不再见 2024-12-15 00:49:25

我会构建一个替代品,然后在实时工作副本上使用 svn switch 来切换到它。

1) svn 将整个工作目录复制到新工作目录

2) 在新工作副本中创建父文件夹

3) svn 将文件从副本中当前的相对位置复制或移动到预期位置。

4) 当您对新工作副本的设置非常满意时,提交它

5) 现在,在您的实时版本中,使用 svn switch 重新定位到新工作目录

由于 SVN 删除现有文件,您的服务器将暂时进行一些重组并签出新文件。但它会和 svn switch 命令一样快。

I would build a replacement and then use svn switch on your live working copy to switch to it.

1) svn copy your entire working directory to a new working directory

2) Create the parent folders in your new working copy

3) svn copy or move files from their current relative location in the copy to the intended locations.

4) When you are perfectly happy with the setup of the new working copy, commit it

5) Now, in your live version, use svn switch to retarget to the new working directory

Momentarily your server will suffer some reorganization as SVN removes the existing files and checkouts the new files. But it will be as fast as the svn switch command can make it.

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