1

How can I fix the svn:externals property on existing revisions if I have admin rights on the local copy of an (svnsync'd) repository?

Let me demonstrate the idea with a script which would be named something like fixup.sh and placed inside the local repository root path (same folder that contains conf/, db/, hooks/, etc):

#!/usr/bin/env bash
CURRBASENAME=$(dirname $(readlink -e $0))
svn propget -R svn:externals "file://$CURRBASENAME"|while read extrnls; do
    [[ -n "$extrnls" ]] || continue
    LOC=$(echo "$extrnls"|cut -f 1 -d ' ')
    NME=$(echo "$extrnls"|cut -f 3 -d ' ')
    REV=$(echo "$extrnls"|cut -f 4 -d ' ')
    [[ "${REV:0:2}" == "-r" ]] || REV=''
    [[ -z "$REV" ]] && EXT=$(echo "$extrnls"|cut -f 4 -d ' ')
    [[ -n "$REV" ]] && EXT=$(echo "$extrnls"|cut -f 5 -d ' ')
    LOCALIZED="^/${EXT##*/svn/}"

    svnmucc -n -m "Adjusting svn:externals $NAME to: $LOCALIZED $REV" propset svn:externals "$NME $REV $LOCALIZED" "$LOC"
done

Note that the script would not work with paths that contain spaces, unless escaped.

Unfortunately this kind of modification will create new revisions, which in turn will make it impossible to incrementally update the local repo from the original remote repo.

Preferably I would want to do this during the sync phase, e.g. by means of a hook. The "solution" presented here is more of a crutch than a solution, as it means that I would have to rewrite the history every time after syncing, effectively having to keep two separate copies: one modified and one "pristine" (well, besides the minor svnsync fixups).

NB: I'm working on the repo, not on a working copy. Also note that svn:externals is not a revprop!

Community
  • 1
  • 1
0xC0000022L
  • 20,597
  • 9
  • 86
  • 152

0 Answers0