简体   繁体   English

如何在 Linux 上直观地比较由 SVN 版本的文件夹的两个修订版?

[英]How to visually compare two revisions of a folder versioned by SVN on Linux?

I can compare a current folder state to its latest revision using the following command:我可以使用以下命令将当前文件夹 state 与其最新版本进行比较:

meld .

meld shows a list of changed files. meld显示已更改文件的列表。 One can click on each file and see a diff.可以单击每个文件并查看差异。

Is it possible to compare a current folder state to its specific revision (not the latest one)?是否可以将当前文件夹 state 与其特定版本(不是最新版本)进行比较?

TortoiseSVN allows to compare arbitrary revisions, however it works on Windows only. TortoiseSVN 允许比较任意版本,但它仅适用于 Windows。 SmartSVN is proprietary. SmartSVN 是专有的。 SVN CLI is unusable for big changesets (CLI diff is fine for small commits, but it's very hard to use it for branch comparision with a lot of changes). SVN CLI 不适用于大的变更集(CLI diff 对于小提交很好,但是很难将它用于具有大量更改的分支比较)。

Maybe I could checkout the revision to compare into a separate folder and compare two folders using meld .也许我可以检查修订以比较到一个单独的文件夹并使用meld比较两个文件夹。 But I guess there should be a simpler approach.但我想应该有一个更简单的方法。

Preface前言

Question is offtopic here: as already mentioned in comment, it's question for Software Recommendations site问题在这里是题外话:正如评论中已经提到的,这是软件推荐网站的问题

Face

  1. Every versioned object with history in SVN can be referenced using PEG-revision for its history state每个版本的 object 在 SVN 中都有历史记录,可以使用PEG 修订版来引用其历史记录 state
  2. Folder in SVN-repo is object of versioning SVN-repo 中的文件夹是版本控制的 object
  3. In order to compare two folders, you have to have folder-diff tool (for your OS) and know (command-line) options for calling it为了比较两个文件夹,您必须拥有文件夹差异工具(适用于您的操作系统)并知道(命令行)调用它的选项

According to Slant's comparison :根据Slant 的比较

  • Meld can be used on Linux for folder-diffing Meld 可用于 Linux 进行文件夹差异
  • Best folder-diff tool is Beyond Compare最好的文件夹差异工具是 Beyond Compare

From points 1-3 above it follows that Meld can be used for your task in form从上面的第 1-3 点可以看出,Meld 可以用于您的任务

meld folder@REV1 folder@REV2

Folder comparision is usually required for code review or branch merging.代码审查或分支合并通常需要文件夹比较。 It seems that the simplest approach is as follows:似乎最简单的方法如下:

  1. Find last trunk revision merged to a current brach查找合并到当前分支的最后一个主干修订
  2. If the current branch was not merged from trunk, then find the branch creration revision如果当前分支未从主干合并,则查找分支创建修订
  3. Checkout trunk with a specified revision to some folder对某个文件夹具有指定修订的结帐主干
  4. Compare the trunk folder and the brach folder比较主干文件夹和分支文件夹

I didn't found any existing tools supporting it.我没有找到任何支持它的现有工具。 Here is a simple bash script:这是一个简单的 bash 脚本:

TRUNK_FOLDER=~/tmp/trunk-merge
LAST_TRUNK_MERGED_REV=$(svn mergeinfo --show-revs merged -R "^/trunk" | tail -n 1)
if [[ -z "$LAST_TRUNK_MERGED_REV" ]]; then
  LAST_TRUNK_MERGED_REV=$(svn log -r 1:HEAD --limit 1 --stop-on-copy -q | grep -oP "^r\K[0-9]+")
  echo "The branch was copied from trunk@$LAST_TRUNK_MERGED_REV"
else
  echo "The branch was last merged from trunk@$LAST_TRUNK_MERGED_REV"
fi
svn update -r $LAST_TRUNK_MERGED_REV "$TRUNK_FOLDER"
meld "$TRUNK_FOLDER" .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM