remote-svn-alpha updates
cover remote-svn-alpha updates
Most notable for this series is adding some tests for remote-svn-alpha helper and not (over)writing refs/heads/master.
The helper is able to import whole svn repository root as the only remote branch. But it doesn't reuse any previously imported data, i.e. each time whole history is imported. Also it can't yet push, and can't configure svn username other than Guest and password other than empty.
Works both in git clone and git remote add & git fetch scenarios.
$ git clone -b master svn-alpha::http://some.org/svnrepo "-b master" tells to use remote branch master as a local HEAD to be checked out. This is necessary because the helper can't tell git that HEAD is a "symlink" to refs/heads/master and even can't tell it's sha1 (lists it as "? HEAD") before actually importing. $ git remote add svn svn-alpha::http://some.org/svnrepo $ git fetch svn
Known bugs are:
1) absolutely empty (no r1) svn repo import fails
2) git clone needs either --bare, -n or -b master
The patch base is svn-fe-pu at git://repo.or.cz/git/jrn.git
also a commit 7153183171de77d084a4c24ef19d23d6313ded2a can be used as an earlier patch base.
For the last two commits some new svn-fe options[1] are required.
Whole git-remote-svn-alpha and a test script are cited at the bottom of this letter as a quick reference for those who don't track svn-fe-pu.
[1] http://thread.gmane.org/gmane.comp.version-control.git/176578
Dmitry Ivankov (5):
svn-fe: use svnrdump --quiet in remote-svn-alpha
svn-fe: allow svnadmin instead of svnrdump in svn helper
svn-fe: add a test for remote-svn-alpha
svn-fe: use svn-fe --no-progress in remote-svn-alpha
svn-fe: use proper refspec in remote-svn-alpha
contrib/svn-fe/git-remote-svn-alpha | 42 ++++- contrib/svn-fe/t/.gitignore | 3 + contrib/svn-fe/t/t9010-remote-svn-alpha.sh | 238 ++++++++++++++++++++++++++++ 3 files changed, 274 insertions(+), 9 deletions(-) create mode 100644 contrib/svn-fe/t/.gitignore create mode 100755 contrib/svn-fe/t/t9010-remote-svn-alpha.sh
Signature · 1 line
1.7.3.4
contrib/svn-fe/git-remote-svn-alpha new file +79 -0
@@ -0,0 +1,79 @@ +#!/bin/bash +set -o pipefail +set -e + +die () { + printf >&2 'fatal: %s\n' "$*" + exit 128 +} + +usage () { + printf >&2 'usage: %s\n' "$*" + exit 129 +} + +try_svnrdump () { + command -v svnrdump >/dev/null && + echo "svnrdump dump --non-interactive --username=Guest --password= \ + --quiet --incremental" || + true +} + +svnadmin_wrap () { + path=${1##file://} && + test "z$path" != "z$1" && + svnadmin dump --incremental --deltas --quiet "$path" "$2" +} + +try_svnadmin () { + command -v svnadmin >/dev/null && + echo svnadmin_wrap || + true +} + +SVNDUMP="" +SVNDUMP=${SVNDUMP:-`try_svnrdump`} +SVNDUMP=${SVNDUMP:-`try_svnadmin`} + +do_import () { + revs=$1 url=$2 dst=$3 + (eval "$SVNDUMP \"$url\" -r\"$revs\"" | svn-fe --ref="$dst" --no-progress) 3<&0 || die "FAILURE" + exec 1>&- +} + +test "${2+set}" || +usage 'git remote-svn-alpha <repository> <URL> < commandlist' +repo=$1 +url=$2 +need_import="" +remote_ref="refs/heads/master" +private_ref="refs/svn-alpha/$repo/SVNHEAD" + +while read -r cmd args +do + case $cmd in + capabilities) + echo import + echo "refspec HEAD:$private_ref" + echo "refspec $remote_ref:$private_ref" + echo + ;; + list) + echo "? HEAD" + echo "? $remote_ref" + echo + ;; + import) + test "$args" = "HEAD" || test "$args" = "$remote_ref" || + die "remote-svn-alpha: unsupported import ref argument: $args" + need_import="yes" + ;; + '') + test "$need_import" = "yes" || exit 0 + do_import 0:HEAD "$url" "$private_ref" + need_import="" + ;; + *) + die "remote-svn-alpha: unsupported command: $cmd $args" + esac +done
contrib/svn-fe/t/t9010-remote-svn-alpha.sh new file +238 -0
238 lines not on this page · raw message
PATCH 1/5 svn-fe: use svnrdump --quiet in remote-svn-alpha
svnrdump by default shows "Dumped revision #n" lines on stderr. svn-fe does it too on each imported revision, so pass --quiet to svnrdump. Once process indication is really needed it will be custom formatted in either svn-fe or remote-svn-alpha.
--- contrib/svn-fe/git-remote-svn-alpha | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
contrib/svn-fe/git-remote-svn-alpha +1 -1
@@ -15,7 +15,7 @@ usage () { do_import () { revs=$1 url=$2 (svnrdump dump --non-interactive --username=Guest --password= \ - -r"$revs" "$url" | svn-fe) 3<&0 || die "FAILURE" + -r"$revs" "$url" --quiet | svn-fe) 3<&0 || die "FAILURE" exec 1>&- }
Signature · 1 line
1.7.3.4
PATCH 2/5 svn-fe: allow svnadmin instead of svnrdump in svn helper
In reply to Dmitry Ivankovsvnrdump produces the same stream as svnadmin dump. svnrdump is able to do it via any svn remote protocol while svnadmin needs access to the repository filesystem and can't produce subdirectory dumps. But svnrdump is a newer tool and may be unavailable on some systems.
Try to use svnadmin dump for file:// repository urls if there is no svnrdump in the PATH. First of all this is to be used in tests, where the repository is indeed local most of the time.
--- contrib/svn-fe/git-remote-svn-alpha | 26 ++++++++++++++++++++++++-- 1 files changed, 24 insertions(+), 2 deletions(-)
contrib/svn-fe/git-remote-svn-alpha +24 -2
@@ -12,10 +12,32 @@ usage () { exit 129 } +try_svnrdump () { + command -v svnrdump >/dev/null && + echo "svnrdump dump --non-interactive --username=Guest --password= \ + --quiet --incremental" || + true +} + +svnadmin_wrap () { + path=${1##file://} && + test "z$path" != "z$1" && + svnadmin dump --incremental --deltas --quiet "$path" "$2" +} + +try_svnadmin () { + command -v svnadmin >/dev/null && + echo svnadmin_wrap || + true +} + +SVNDUMP="" +SVNDUMP=${SVNDUMP:-`try_svnrdump`} +SVNDUMP=${SVNDUMP:-`try_svnadmin`} + do_import () { revs=$1 url=$2 - (svnrdump dump --non-interactive --username=Guest --password= \ - -r"$revs" "$url" --quiet | svn-fe) 3<&0 || die "FAILURE" + (eval "$SVNDUMP \"$url\" -r\"$revs\"" | svn-fe) 3<&0 || die "FAILURE" exec 1>&- }
Signature · 1 line
1.7.3.4
PATCH 3/5 svn-fe: add a test for remote-svn-alpha
In reply to Dmitry IvankovThe test creates a few svn repositories from fixed dumps using svnadmin. Currently it checks for crashes on first time import mostly.
--- contrib/svn-fe/t/.gitignore | 3 + contrib/svn-fe/t/t9010-remote-svn-alpha.sh | 229 ++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 0 deletions(-) create mode 100644 contrib/svn-fe/t/.gitignore create mode 100755 contrib/svn-fe/t/t9010-remote-svn-alpha.sh
contrib/svn-fe/t/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +/trash directory* +/test-results +/.prove
contrib/svn-fe/t/t9010-remote-svn-alpha.sh new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH 4/5 svn-fe: use svn-fe --no-progress in remote-svn-alpha
In reply to Dmitry Ivankovsvn-fe by default produces a progress line for each imported revision. For large repos it stresses the terminal and a user, possibly scrolls away error messages.
Just disable progress lines for now.
--- contrib/svn-fe/git-remote-svn-alpha | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
contrib/svn-fe/git-remote-svn-alpha +1 -1
@@ -37,7 +37,7 @@ SVNDUMP=${SVNDUMP:-`try_svnadmin`} do_import () { revs=$1 url=$2 - (eval "$SVNDUMP \"$url\" -r\"$revs\"" | svn-fe) 3<&0 || die "FAILURE" + (eval "$SVNDUMP \"$url\" -r\"$revs\"" | svn-fe --no-progress) 3<&0 || die "FAILURE" exec 1>&- }
Signature · 1 line
1.7.3.4
PATCH 5/5 svn-fe: use proper refspec in remote-svn-alpha
In reply to Dmitry IvankovCreate a per repository name private refs namespace as suggested by the remote helpers documentation. This allows to have several svn remotes at the same time. And also this way we don't overwrite the local branch master.
The refpec is:
HEAD:refs/svn-alpha/$reponame/SVNHEAD refs/heads/master:refs/svn-alpha/$reponame/SVNHEAD
--- contrib/svn-fe/git-remote-svn-alpha | 18 ++++++++++-------- contrib/svn-fe/t/t9010-remote-svn-alpha.sh | 9 +++++++++ 2 files changed, 19 insertions(+), 8 deletions(-)
contrib/svn-fe/git-remote-svn-alpha +10 -8
@@ -36,8 +36,8 @@ SVNDUMP=${SVNDUMP:-`try_svnrdump`} SVNDUMP=${SVNDUMP:-`try_svnadmin`} do_import () { - revs=$1 url=$2 - (eval "$SVNDUMP \"$url\" -r\"$revs\"" | svn-fe --no-progress) 3<&0 || die "FAILURE" + revs=$1 url=$2 dst=$3 + (eval "$SVNDUMP \"$url\" -r\"$revs\"" | svn-fe --ref="$dst" --no-progress) 3<&0 || die "FAILURE" exec 1>&- }
@@ -46,29 +46,31 @@ usage 'git remote-svn-alpha <repository> <URL> < commandlist' repo=$1 url=$2 need_import="" +remote_ref="refs/heads/master" +private_ref="refs/svn-alpha/$repo/SVNHEAD" while read -r cmd args do case $cmd in capabilities) echo import - echo "refspec HEAD:refs/heads/master" - echo "refspec refs/heads/master:refs/heads/master" + echo "refspec HEAD:$private_ref" + echo "refspec $remote_ref:$private_ref" echo ;; list) - echo '? HEAD' - echo '? refs/heads/master' + echo "? HEAD" + echo "? $remote_ref" echo ;; import) - test "$args" = "HEAD" || test "$args" = "refs/heads/master" || + test "$args" = "HEAD" || test "$args" = "$remote_ref" || die "remote-svn-alpha: unsupported import ref argument: $args" need_import="yes" ;; '') test "$need_import" = "yes" || exit 0 - do_import 0:HEAD "$url" + do_import 0:HEAD "$url" "$private_ref" need_import="" ;; *)
contrib/svn-fe/t/t9010-remote-svn-alpha.sh +9 -0
@@ -226,4 +226,13 @@ test_expect_success SMALL_SVN 'fetch each rev of SMALL separately' ' test_cmp ref7_2 ref_2 ' +test_expect_success TINY_SVN 'fetch TINY does not write to refs/heads/master' ' + reinit_git && + url=$(svnurl tiny.svn) && + git remote add svn "$url" && + git fetch svn && + git show-ref --verify refs/remotes/svn/master && + test_must_fail git show-ref --verify refs/heads/master +' + test_done
Signature · 1 line
1.7.3.4
Re: [PATCH 2/5] svn-fe: allow svnadmin instead of svnrdump in svn helper
In reply to Dmitry IvankovHi,
Quoted 8 lines · Dmitry Ivankov
svnrdump produces the same stream as svnadmin dump. svnrdump is able to do it via any svn remote protocol while svnadmin needs access to the repository filesystem and can't produce subdirectory dumps. But svnrdump is a newer tool and may be unavailable on some systems.
Try to use svnadmin dump for file:// repository urls if there is no svnrdump in the PATH. First of all this is to be used in tests, where the repository is indeed local most of the time.
svnrdump's output is not identical to svnadmin's output. You'd perhaps want to document the differences, and the impact they might have?
Quoted 8 lines
contrib/svn-fe/git-remote-svn-alpha +0
-0@@ -12,10 +12,32 @@ usage () {exit 129
}
contrib/svn-fe/git-remote-svn-alpha usage () { · line 20
Quoted 6 lines
contrib/svn-fe/git-remote-svn-alpha +6
-0+try_svnrdump () { + command -v svnrdump >/dev/null && + echo "svnrdump dump --non-interactive --username=Guest --password= \ + --quiet --incremental" || + true +}
I saw this '--username', '--password' in other patches too. I'm probably missing context, but I'm curious to know why this is required and what you're planning to do to fix it in the future.
Thanks.
-- Ram
Re: [PATCH 2/5] svn-fe: allow svnadmin instead of svnrdump in svn helper
Quoted 8 lines · Ramkumar Ramachandra
Hi,
Quoted 5 lines · Dmitry Ivankov
svnrdump produces the same stream as svnadmin dump. svnrdump is able to do it via any svn remote protocol while svnadmin needs access to the repository filesystem and can't produce subdirectory dumps. But svnrdump is a newer tool and may be unavailable on some systems.
Quoted 7 lines
Quoted 3 lines
Try to use svnadmin dump for file:// repository urls if there is no svnrdump in the PATH. First of all this is to be used in tests, where the repository is indeed local most of the time.
svnrdump's output is not identical to svnadmin's output. You'd perhaps want to document the differences, and the impact they might have?
Hm, I don't see much differences.
Data format is the same SVN-fs-dump-format-version: 3. In my case I observe following differences:
- svnadmin writes sha1 checksums along with md5 ones
- hashtable dumps can have different elements dump order
- svnrdump sets Prop-delta: true for empty props
- text deltas can be encoded differently (does it affect svn:ann?) My svnadmin is version 1.6.16 (r1073529)
svnrdump is from r1135490
Anything else I'm missing in a simple dump of a repository root?
Quoted 9 lines
Quoted 9 lines
contrib/svn-fe/git-remote-svn-alpha +0
-0@@ -12,10 +12,32 @@ usage () {exit 129
}
Quoted 10 lines
contrib/svn-fe/git-remote-svn-alpha usage () { · line 20
Quoted 6 lines
contrib/svn-fe/git-remote-svn-alpha +6
-0+try_svnrdump () { + command -v svnrdump >/dev/null && + echo "svnrdump dump --non-interactive --username=Guest --password= \ + --quiet --incremental" || + true +}I saw this '--username', '--password' in other patches too. I'm probably missing context, but I'm curious to know why this is required and what you're planning to do to fix it in the future.
For repos with no read restrictions this isn't necessary, like those in the test script supplied.
It's a placeholder for quick local patch if anyone wants to test a repo with permissions.
In future it should be allowed to configure credentials in corresponding remote section of git.config and
pass all these options to helpers. Using ~/.subversion/ configuration is a valid option too.
Quoted 5 lines
Thanks.
-- Ram
Re: [PATCH 2/5] svn-fe: allow svnadmin instead of svnrdump in svn helper
Hi again,
Quoted 14 lines · Dmitry Ivankov
Quoted 3 lines · Ramkumar Ramachandra
svnrdump's output is not identical to svnadmin's output. You'd perhaps want to document the differences, and the impact they might have?
Hm, I don't see much differences.
Data format is the same SVN-fs-dump-format-version: 3. In my case I observe following differences:
- svnadmin writes sha1 checksums along with md5 ones
- hashtable dumps can have different elements dump order
- svnrdump sets Prop-delta: true for empty props
- text deltas can be encoded differently (does it affect svn:ann?) My svnadmin is version 1.6.16 (r1073529)
svnrdump is from r1135490
Quoted 1 line
Anything else I'm missing in a simple dump of a repository root?
Yes, those are the differences. Both of us know this, but an new reader might naively assume that they are exactly the same -- that's why I suggested that you document the fact somewhere. Once you've documented it, it's clear that these subtle differences have no impact on how svn-fe deals with the streams.
Quoted 11 lines
Quoted 3 lines
I saw this '--username', '--password' in other patches too. I'm probably missing context, but I'm curious to know why this is required and what you're planning to do to fix it in the future.
For repos with no read restrictions this isn't necessary, like those in the test script supplied.
It's a placeholder for quick local patch if anyone wants to test a repo with permissions.
In future it should be allowed to configure credentials in corresponding remote section of git.config and
pass all these options to helpers. Using ~/.subversion/ configuration is a valid option too.
I see. However, I think you should just have one dedicated test for testing credentials -- once that passes, you don't need to complicate the other tests with information about credentials. Try to test only one aspect in each test; the report summarizing failed tests will make more sense then.
Thanks.
-- Ram
Re: [PATCH 2/5] svn-fe: allow svnadmin instead of svnrdump in svn helper
Quoted 12 lines · Ramkumar Ramachandra
Quoted 10 lines · Dmitry Ivankov
Hm, I don't see much differences.
Data format is the same SVN-fs-dump-format-version: 3. In my case I observe following differences:
- svnadmin writes sha1 checksums along with md5 ones
- hashtable dumps can have different elements dump order
- svnrdump sets Prop-delta: true for empty props
- text deltas can be encoded differently (does it affect svn:ann?) My svnadmin is version 1.6.16 (r1073529)
svnrdump is from r1135490
Quoted 3 lines
Quoted 1 line
Anything else I'm missing in a simple dump of a repository root?
Yes, those are the differences.
Are the differences documented somewhere (e.g., the svnbook)?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I saw this '--username', '--password' in other patches too. I'm probably missing context, but I'm curious to know why this is required and what you're planning to do to fix it in the future.
[...]
Quoted 2 lines
Quoted 2 lines
It's a placeholder for quick local patch if anyone wants to test a repo with permissions.
I suspect it snuck in from tests with the cvs2svn repository. :)
Do you know another small repository that's entertaining to test with?
Quoted 2 lines
Quoted 2 lines
In future it should be allowed to configure credentials in corresponding remote section of git.config
Yep, something along those lines sounds sensible. In the short term, I think there's been some talk of a configuration option to override the svnrdump command; that could be used to pass credentials.
Inspired by the old HTTP convention, I tried
svn log http://Guest:@cvs2svn.tigris.org/svn/cvs2svn
and
svn log http://Guest:[email protected]/svn/cvs2svn
but alas, neither works.
Re: [PATCH 4/5] svn-fe: use svn-fe --no-progress in remote-svn-alpha
In reply to Dmitry IvankovHi again,
Quoted 10 lines · Dmitry Ivankov
svn-fe by default produces a progress line for each imported revision. For large repos it stresses the terminal and a user, possibly scrolls away error messages.
Just disable progress lines for now.
Signed-off-by Dmitry Ivankov <[email protected]>---
contrib/svn-fe/git-remote-svn-alpha | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)
Perhaps squash this into the patch that introduces --[no]-progress in svn-fe?
-- Ram
Re: [PATCH 4/5] svn-fe: use svn-fe --no-progress in remote-svn-alpha
Quoted 10 lines · Ramkumar Ramachandra
Quoted 6 lines · Dmitry Ivankov
Just disable progress lines for now.
Signed-off-by Dmitry Ivankov <[email protected]>---
contrib/svn-fe/git-remote-svn-alpha | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)Perhaps squash this into the patch that introduces --[no]-progress in svn-fe?
Since git-remote-svn-alpha is a slushy codebase and svn-fe is a little more stable, it seems best to keep patches to the two separate for now. Even so, mentioning remote-svn's needs can still be a useful way to make svn-fe changes easier to understand (which is what I think you are getting at here); thanks for the hint.