How to skip initial revisions in svnsync sync (to

2019-05-29 04:53发布

问题:

I want to sync/copy a single project out of a moderate large SVN repo using the (usual) sequence

  svnadmin create %mirror%
  rem make insecure dummy hook
  echo rem dummy > %mirror%\hooks\pre-revprop-change.bat
  svnsync init %mirror_url% http://svn/original/...
  svnsync sync %mirror_url%

This works but takes long time, see related question. In fact I do not need any revisions prior to e.g. r=17830. And the real problem is that the original repo seems to be corrupt before this revision and I can't convert it to hg, so I try to workaround ...

Question: Is there a way to fake the newly created repo (after 4th line) so it "believes" it has revision 17830 already and continues with newer ones. (Maybe some propset magic?) There are no changes in the project/folder before that revision.

回答1:

svnsync will copy revisions based on value in the 'current' file (of the destination repo), and the entry in the svnsync revprop 0 file that says which is the last revision copied. Initialise svnsync, then fudge both of these numbers to your desired revision and it should work as you want.



回答2:

This is possible.

You need to create dummy rev files in the folders \db\revprops\0 and \db\revs\0 so that you don't get the error there is no revision 17830.



回答3:

The SVN mailing list has an answer to that topic; see http://svn.haxx.se/dev/archive-2010-02/0114.shtml



回答4:

From my experiments based and helped by the answers, I believe this is not possible.



回答5:

Try this, (just figured this out)

1) check out a working copy of the repository you are syncing to

2a) generate a patch with svn diff -rcurrent:next from the source repository (so current is the current revision, and next is the next one that is broken) however, most of the I found svn diff still works

2b) or, add a dummy file to the repository you are syncing to and tag it (so you can check in something)

3) do a svn ci -m 'syncfix' which will bump the repository you are syncing to

4) after this, svnsync sync will continue most of the time

5) sometimes it will complain the HEAD is one revision in the future. To fix this go to /db/revprops/0 edit the 0 file, chmod +w 0 bump the revision,

....

svn:sync-last-merged-rev
V 4
8499 <--- this one, add one to it so 8500 in this example 
END

6) after this, svnsync sync will continue

7) below is a script I just made to get over the bumps, the end result will probably not be perfect but it will get most of the stuff in. then you can fix the end result by exporting into it from the HEAD of the repository you are syncing from.

set -x

SYNC_REPO=/repo/reelbox.org-sync

SRC_WD=/src/Multimedia/Reelbox/reelbox.org
SYNC_WD=/src/Multimedia/Reelbox/reelbox.org-sync

bumpRevision()
{
   SYNC_REPO_FILE=$SYNC_REPO/db/revprops/0/0

   cd $SYNC_WD
   svn update

   CUR_REV=`svn update | awk '{print $3}' | sed s/\.$//`

   echo $CUR_REV

   NEXT_REV=`expr $CUR_REV + 1`

   echo $NEXT_REV

   cd $SRC_WD

   echo svn diff -r$CUR_REV:$NEXT_REV, >>SYNCLOG
   svn diff -r$CUR_REV:$NEXT_REV 2>>SYNCLOG >$SYNC_WD/patch.in
   echo >>SYNCLOG

   LOG=`svn log -r$NEXT_REV`

   cd $SYNC_WD
   patch -p0 < patch.in

   RESULT=`svn diff`

   echo $LOG
   echo $RESULT

   if [ -n "$RESULT" ]; then
      echo patched
      svn ci -m "syncfix:$LOG"
  else
     echo not patched
     if [ ! -f FIXFILE ]; then
        echo $NEXT_REV > FIXFILE
         svn add FIXFILE
     else
        echo $NEXT_REV >> FIXFILE
     fi

     svn ci -m "syncfix:nothing patched:$LOG"
  fi
}

doSync()
{
   svnsync sync file://$SYNC_REPO

   STATUS=$?

   if [ $STATUS == 1 ]; then
      ECODE=`svnsync sync file://$SYNC_REPO 2>&1 | awk '{print $2}' | sed s/:$//`
      echo $ECODE
      case $ECODE in
         E000022)
           exit 1
         ;;
     esac
   fi

   return $STATUS
 }

 # bumpRevision

doSync
while [ $? == 1 ]; do
   bumpRevision   
   doSync
done

Ondrej Popp