将 svn checkout 更新到特定日期(包括外部)

发布于 2024-10-03 10:30:19 字数 250 浏览 11 评论 0原文

我想对特定日期执行 svn 更新,可以使用 svn update -r {2010-10-17} 来执行此操作。不幸的是,当遇到外部时,它将在外部中进行更新,而不通过 -r {2010-10-17} 选项。这导致我们获得了基本代码的正确过去版本,但许多外部代码的最新(不需要的)版本。

如何更新到特定修订版或日期并通过外部正确递归?

(注意:我知道这里的错误可能是使用了没有指定明确修订的外部组件。)

I want to perform an svn update to a specific date, and I can do this with svn update -r {2010-10-17}. Unfortunately when this encounters an external it will do the update within the external without passing through the -r {2010-10-17} option. This results in us getting the correct past revision of the base code, but the latest (undesired) versions of many of the externals.

How can I update to a specific revision or date and have this recurse correctly through the externals?

(Note: I understand that the mistake here might have been to use externals with no explicit revisions specified.)

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

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

发布评论

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

评论(4

笛声青案梦长安 2024-10-10 10:30:19

我希望,任何人迟早都会将我的常识性逻辑(仅限于某些领域的目录类型外部)实现到 bash 和 cmd 脚本中,我们将对此重复得到“明确的答案” 你的基本任务

是:

  • svn up你的超级仓库到过去所需的点(更新到日期/并且没有时间/是,顺便说一句,不是最好的选择,但是 - 适用)
  • 获取路径列表到项目中的所有外部(因为外部定义可以存在于树中的任何位置),来自 WC-root svn propget svn:externals -R (-R 是为了检查整个树,而无需大量 < code>cd)
  • 对于 propget 输出中的每个字符串(格式如下 . - https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib lib ): cd 到字符串的最后一个字段 / 相对于第一个字段,这又是 root/ 的相对路径,并且 svn 直到同一点,就像对 superrepo 所做的那样: svn update -r {2010-10-17}

因此,您将拥有混合工作副本,但超级存储库和外部文件将处于“过去的某些修订”状态。

注意:

用于使用外部文件构建目录的本地路径的附加示例(嵌套 WC 确实)在更复杂的情况下。

对于

>svn propget svn:externals -R
tags\1.0.1 - -r 2 https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib@2 lib

trunk - https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib lib

我的 WC 中外部的最终路径将是(相对于 WC-root)

tags\1.0.1\lib
trunk\lib

I hope, anybody will implement my common-sense logic (limited to directory-type externals in some areas) into bash and cmd-script sooner or later and we'll get "definitive answer" to this repeating question

Your base task is:

  • svn up your super-repo to needed point in past (updating to date /and without time/ is, BTW, not a best choice, but - apllicable)
  • get list of paths to all externals in your project (because externals definitions can exist anywhere in tree), from WC-root svn propget svn:externals -R (-R in order to check the whole tree without a lot of cd)
  • for each string in propget output (with format like this . - https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib lib): cd to the last field of string /relative to the first field, which is, in turn, is relative path to root/ and svn up to the same point, as it was done for superrepo: svn update -r {2010-10-17}

As result you'll have Mixed Working Copy, but superrepo and externals will be in state "for some revision in the past"

Note:

Additional sample for constructing local path to directory with externals (nested WC really) on more complex case.

For

>svn propget svn:externals -R
tags\1.0.1 - -r 2 https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib@2 lib

trunk - https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib lib

finals paths to externals in my WC will be (relative to WC-root)

tags\1.0.1\lib
trunk\lib
悲念泪 2024-10-10 10:30:19

我添加这个答案是为了防止有人试图更新已签出的 subversion 存储库以将本地文件日期同步到存储库日期,我想这样做,这样我就可以进行 FS 时间戳比较。

我制作了这个 oneliner 来解决这个问题(但在使用它之前请阅读下面的行):

svn info --show-item last-changed-date -R | xargs -I{} -P1000 -n1 sh -c 'x="{}";设置-x; exec touch -d "${x%% *}" "${x#* }"'

注意: -P1000 指定 xargs 应同时运行 1000shtouch 副本来进行实际更新。根据系统负载,降低此值可能是明智的。在基于 i3 的微型英特尔 NUC 1000 进程上,事实证明它是完美的,使用 80-95% 的 CPU(100% 通常意味着 CPU 过载)。如果有疑问,请打开例如 htop 并使用不同的值进行测试 - 但仅运行几秒钟,因为它每次都需要从头开始运行。

对于 USB HDD 上大约 3GB 的小型 SVN 存储库,运行大约需要 5 分钟。

set +x 打开详细执行,我在执行 touch 之前执行此操作,以便您可以观看它的运行。如果您想要非详细执行,请删除该命令。

I'm adding this answer in case anyone's trying to update an already-checked-out subversion repository to sync the local file dates to the repo dates, which I wanted to do so I could do FS timestamp comparisons.

I made this oneliner to do the trick (but read the line below before using it):

svn info --show-item last-changed-date -R | xargs -I{} -P1000 -n1 sh -c 'x="{}"; set -x; exec touch -d "${x%% *}" "${x#* }"'

NOTE: The -P1000 specifies that xargs should run 1000 simultaneous copies of sh and touch to do the actual updating. Depending on system load it may be wise to lower this. On a tiny i3-based Intel NUC 1000 processes actually turned out to be perfect, using 80-95% CPU (100% generally means the CPU is overloaded). If in doubt, open eg htop and test with different values - but only run it for a few seconds, because it will need to run from the start each time.

For a small ~3GB SVN repo on a USB HDD, this took about 5 minutes to run.

The set +x turns on verbose execution, which I do just before executing touch so you can watch it run. If you want non-verbose execution, remove that command.

何以笙箫默 2024-10-10 10:30:19

我们仅包含其他项目中的整个目录:

  • mainprj/bin/subprj1
  • mainprj/bin/subprj2
  • mainprj/dat/subprj1
  • mainprj/ dat/subprj2
  • subprj1/bin # 包含在 mainprj/bin/subprj1 subprj1
  • /dat # 包含在 mainprj/ 中dat/subprj1
  • subprj2/bin # 包含在 mainprj/bin/subprj2
  • subprj2/dat # 包含在 mainprj/ 中dat/subprj2

具有此布局 svn propget svn:externals -R 返回

# cd mainprj
# svn propget svn:externals -R
bin - subprj1 svn+ssh://svnserver/svn/subprj1/trunk/bin
subprj2 svn+ssh://svnserver/svn/subprj2/trunk/bin

dat - subprj1 svn+ssh://svnserver/svn/subprj1/trunk/dat
subprj2 svn+ssh://svnserver/svn/subprj2/trunk/dat

,您可以更新到修复日期,如下所示:

svn propget svn:externals -R |\ 
   grep -vE '^
 | sed -e "s/^[^-]* - //" |\
   while read line; do \
      pushd ${line##*/}; \
         svn update -r {2019-04-26} ${line%% *}; \
      popd; \
   done

We include only whole dirs in other projects:

  • mainprj/bin/subprj1
  • mainprj/bin/subprj2
  • mainprj/dat/subprj1
  • mainprj/dat/subprj2
  • subprj1/bin # included in mainprj/bin/subprj1
  • subprj1/dat # included in mainprj/dat/subprj1
  • subprj2/bin # included in mainprj/bin/subprj2
  • subprj2/dat # included in mainprj/dat/subprj2

with this layout svn propget svn:externals -R returns

# cd mainprj
# svn propget svn:externals -R
bin - subprj1 svn+ssh://svnserver/svn/subprj1/trunk/bin
subprj2 svn+ssh://svnserver/svn/subprj2/trunk/bin

dat - subprj1 svn+ssh://svnserver/svn/subprj1/trunk/dat
subprj2 svn+ssh://svnserver/svn/subprj2/trunk/dat

and you can update to a fix date as follows:

svn propget svn:externals -R |\ 
   grep -vE '^
 | sed -e "s/^[^-]* - //" |\
   while read line; do \
      pushd ${line##*/}; \
         svn update -r {2019-04-26} ${line%% *}; \
      popd; \
   done
谜兔 2024-10-10 10:30:19

据我所知,如果不更改外部配置,就无法做到这一点。但是,更改外部配置会为每个人更改它,因此只需一次提交和更新即可完成。

As far as I've been able to work out, you can't do this without changing your externals config. But, changing the externals config changes it for everyone, so it's just a single commit and update and you're done.

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