开发者

how do i know if my working copy is out of sync

We keep a image of current release code in some local directory and for building the code we use the code in this directory. In the build script, I need a way to figure out if the code in image directory in sync with the current release branch in repository. If it开发者_如何学JAVA is so, I will do a svn update from within script. Can the revision numbers be somehow used to detect the out of sync condition? If so how?

Vadiraj


svn status -u

adds working revision and server out-of-date information.

If you don't have non-versioned files in the directory then it's up to date only if the status command returns nothing. Otherwise * means it's not up to date, ? means non-versioned, M - modified, etc.

In other words it's up to date if and only if the following returns 0:

svn status -u | grep -E -c "^\s+[^\?]"


Fast and direct way:

repoVersion="$(svn status -u --depth empty <myWCdir> | awk '{print $NF}')"
wcVersion="$(svn info --show-item revision <myWCdir>)"

Then you can just compare those two numbers, as in:

if [[ $repoVersion -eq $wcVersion ]]; then
    echo "<myWCdir> is up to date"
else
    echo "<myWCdir> is out of date"
fi

Note: Plain svn status -u is way overkill. SVN bumps the rev# of a dir if any contents change (at any depth).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜