svnant更新单个文件,跳过错误

时间:2018-06-05 13:11:23

标签: java svnant

我想将文件内容从我的本地文件夹更新为svn,请注意该文件存在于svn上。

首先我检查深度为空。  然后我在脚本上运行更新

<svn refid="svn.settings" logFile="${directory}/checkout_log.log">
        <checkout   url="${svn_path}" 
                    destpath="${full_path}"
                    revision="HEAD" depth="empty"
        />
        <update  recurse="false" revision="HEAD" dir="D:\Update\SVNCheckout\T\" file= "test.sql" />

        </svn>

然而在日志文件中它的说法

Skipped 'test.sql'
Summary of conflicts:
  Skipped paths: 1
<Update> finished.

好的,我知道存在冲突,但我怎么能svn resolve脚本

1 个答案:

答案 0 :(得分:0)

为了避免冲突,最好首先签出,然后修改签出的文件,然后尝试将其签入。如果失败,则删除所有临时文件并再次尝试。

整个过程如下(使用Ant Contrib作为普通Ant的扩展名):

<var name="finished" value="false" />
<for list="1,2,3,4,5,5,6,7,8,9,10" param="trynr">
  <sequential>
    <if>
      <equals arg1="${finished}" arg2="false" />
      <then>
        <echo message="#########################################" />
        <echo message="# trynr=@{trynr}" />
        <echo message="#########################################" />
        <trycatch property="errormsg" reference="exceptionObject">
          <try>
            <!-- Delete old checked out files -->
            <delete .../>
            <!-- Check out the file -->

            <!-- Modify the file -->

            <!-- Commit the file -->

            <var name="finished" value="true" />
          </try>
          <catch>
            <echo message="Update failed." />
            <echo message="Error message: ${errormsg}" />
            <if>
              <equals arg1="@{trynr}" arg2="10" />
              <then>
                <echo message="Giving up after @{trynr} attempts." />
                <fail message="Unable to update file. Giving up after @{trynr} attempts." />
              </then>
              <else>
                <echo message="Trying again in 2 seconds ..." />
                <sleep seconds="2"/>
              </else>
            </if>
          </catch>
        </trycatch>
      </then>
      <else />
    </if>
  </sequential>
</for>