| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- # From inside the SVN subdir you want to extract:
- set -euo pipefail
- DEST="${1:-trunk-git}"
- echo "Exporting SVN working copy to $DEST (versioned files only)..."
- rm -rf -- "$DEST"
- count=0
- start_ts="$(date +%s.%N)"
- if command -v script >/dev/null 2>&1; then
- # script(1) forces a pseudo-tty so svn flushes output immediately
- export_cmd=(script -q -c "svn export . \"$DEST\"" /dev/null)
- elif command -v stdbuf >/dev/null 2>&1; then
- export_cmd=(stdbuf -o0 -e0 svn export . "$DEST")
- else
- export_cmd=(svn export . "$DEST")
- fi
- # Keep awk unbuffered too
- if command -v stdbuf >/dev/null 2>&1; then
- awk_cmd=(stdbuf -o0 awk -v start="$start_ts")
- else
- awk_cmd=(awk -W interactive -v start="$start_ts")
- fi
- "${export_cmd[@]}" | "${awk_cmd[@]}" '
- function elapsed() {
- cmd = "date +%s.%N"
- cmd | getline now
- close(cmd)
- split(start, s, ".")
- split(now, n, ".")
- return (n[1]-s[1]) + (n[2]-s[2])/1e9
- }
- {
- count++
- if (count % 25 == 0) {
- t = elapsed()
- printf("[%.1fs] Exported %d items\n", t, count)
- fflush()
- }
- }
- END {
- t = elapsed()
- printf("[%.1fs] Exported %d items (done)\n", t, count)
- }
- '
- cd "$DEST"
- git init
- git config init.defaultBranch trunk || true
- git add -A
- git commit -m "Import SVN snapshot" || true
|