如何使 svn diff 忽略某些文件?

发布于 2024-11-26 03:41:35 字数 339 浏览 2 评论 0原文

我有一个实时系统和一个测试系统。该软件使用SVN进行版本控制。实时版本是一个特定的 TRUNK 修订版。

现在我想创建测试系统中的文件与实时系统中的文件的差异。我可以在测试盒上执行此操作

# svn diff -r 12345

,其中 12345 是实时系统的修订版。这按预期工作,但是该项目也将其配置文件放在 SVN 下,并且自然地实时系统不会与测试系统共享配置,因此我需要排除它。

我对 svn 不太熟悉,看起来没有开关可以专门排除文件/目录。

我想知道是否需要编写一个脚本来首先检查更改的文件,过滤该列表,然后提供 svn diff 的路径。

I have a live and a test system. The software is using SVN for version control. The live version is a specific TRUNK revision.

Now I'd like to create a diff from the files in the test-system to the live system. I can do this with

# svn diff -r 12345

On the test box where 12345 is the revision of the live system. That works as intended, however the project has put it's config file under SVN as well and naturally the live system does not share the config with the test system so I need to exclude it.

I'm not that well with svn and it looks like that there is no switch to specifically exclude files/dirs.

I'm wondering if I need to write a script for the job checking for changed files first, filtering that list and then provide the PATHs to svn diff.

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

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

发布评论

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

评论(1

吃不饱 2024-12-03 03:41:36

,它能够列出自特定修订版以来的至少所有修改以及本地修改

$ ./svn-modified-since 10563

我创建了一个小 shell脚本

#!/bin/bash

LOCALBASE=$(svnversion -n|grep -oP "^\d+(?=M$)")

# echo "Local base revision: $LOCALBASE"

if [ ! $LOCALBASE ]
    then
        echo "Quit: No modifications in local copy found."
        exit
fi

TARGETBASE=$1

# echo "Target base revision: $TARGETBASE"

if [ ! $TARGETBASE ]
    then
        echo "Quit: No target base revision given."
        exit
fi

WORKPATH=$2

# files changed in working directory copy
FILES=`svn status $WORKPATH`

# files changed between working copy and foreign base revision
FILES="$FILES
`svn diff --summarize -r $TARGETBASE:$LOCALBASE $WORKPATH`"

: sort -u

示例输出:

M       common_functions.php
M       config.php
M       locale/fr/LC_MESSAGES/fr.mo
M       locale/fr/LC_MESSAGES/fr.po
M       common_functions.php
?       tmp/surrogates.php
...

我现在可以使用 grep 过滤该输出,并将文件名用作 xargs 的参数:

# ./svn-modified-since 10563 | grep -v "^\?" | grep -o "([^ ]+)$" | grep -v "config.php" | xargs svn diff --force -r 10563 > my.diff

要处理像 LC_MESSAGES 这样的二进制文件,我可以将其设置为使用替换 svn diff 命令:

svn diff --force --diff-cmd /usr/bin/diff -x "-au --binary" -r 10563

使用

patch -p0 -i my.diff 

I created a little shell script that's able to list at least all modifications since a specific revision plus the local modifications:

$ ./svn-modified-since 10563

Code:

#!/bin/bash

LOCALBASE=$(svnversion -n|grep -oP "^\d+(?=M$)")

# echo "Local base revision: $LOCALBASE"

if [ ! $LOCALBASE ]
    then
        echo "Quit: No modifications in local copy found."
        exit
fi

TARGETBASE=$1

# echo "Target base revision: $TARGETBASE"

if [ ! $TARGETBASE ]
    then
        echo "Quit: No target base revision given."
        exit
fi

WORKPATH=$2

# files changed in working directory copy
FILES=`svn status $WORKPATH`

# files changed between working copy and foreign base revision
FILES="$FILES
`svn diff --summarize -r $TARGETBASE:$LOCALBASE $WORKPATH`"

echo "$FILES" | sort -u

Example output:

M       common_functions.php
M       config.php
M       locale/fr/LC_MESSAGES/fr.mo
M       locale/fr/LC_MESSAGES/fr.po
M       common_functions.php
?       tmp/surrogates.php
...

I can now filter that output with grep and use the filenames as parameters with xargs:

# ./svn-modified-since 10563 | grep -v "^\?" | grep -o "([^ ]+)$" | grep -v "config.php" | xargs svn diff --force -r 10563 > my.diff

To handle binary files like the LC_MESSAGES, I could get it to work with replacing the svn diff command:

svn diff --force --diff-cmd /usr/bin/diff -x "-au --binary" -r 10563

With

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