two git-svn changes to help work with chromium.org
cover two git-svn changes to help work with chromium.org
Google nicely mirrors the subversion chrome repository with git-svn. However, the git-svn mirror has only trunk. I wanted to add in a couple other branches to my clone of the git-svn mirror, but to do so I needed the ability to lie about the UUID since the publically accessible subversion repository has a different UUID than that which google is cloning from using git-svn.
In addition, google has a ton of branches in the subversion repository, and I only wanted a few. Hence this two-patch series. For posterity, here's what my .git/config looks like:
[remote "origin"]
url = git://git.chromium.org/chromium.git
fetch = +refs/heads/*:refs/remotes/origin/*
[svn-remote "svn"]
url = http://src.chromium.org/svn
fetch = trunk/src:refs/remotes/svn/trunk branches = branches/{249,302}/src:refs/remotes/svn/* rewriteRoot = svn://svn.chromium.org/chrome rewriteUUID = 0039d316-1c4b-4281-b951-d872f2087c98
Jay Soffian (2):
git-svn: allow UUID to be manually remapped via rewriteUUID
git-svn: allow subset of branches/tags to be specified in glob spec
Documentation/git-svn.txt | 31 +++++- git-svn.perl | 93 ++++++++++++----- t/t9153-git-svn-rewrite-uuid.sh | 25 +++++ t/t9153/svn.dump | 75 +++++++++++++ t/t9154-git-svn-fancy-glob.sh | 42 ++++++++ t/t9154/svn.dump | 222 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 460 insertions(+), 28 deletions(-) create mode 100755 t/t9153-git-svn-rewrite-uuid.sh create mode 100644 t/t9153/svn.dump create mode 100755 t/t9154-git-svn-fancy-glob.sh create mode 100644 t/t9154/svn.dump
PATCH 1/2 git-svn: allow UUID to be manually remapped via rewriteUUID
In certain situations it may be necessary to manually remap an svn repostitory UUID. For example:
o--- [git-svn clone]
/[origin svn repo]
\
o--- [svnsync clone]
Imagine that only "git-svn clone" and "svnsync clone" are made available to external users. Furthur, "git-svn clone" contains only trunk, and for reasons unknown, "svnsync clone" is missing the revision properties that normally provide the origin svn repo's UUID.
A git user who has cloned the "git-svn clone" repo now wishes to use git-svn to pull in the missing branches from the "synsync clone" repo. In order for git-svn to get the history correct for those branches, it needs to know the origin svn repo's UUID. Hence rewriteUUID.
--- Documentation/git-svn.txt | 15 ++++++-- git-svn.perl | 33 ++++++++++++++--- t/t9153-git-svn-rewrite-uuid.sh | 25 +++++++++++++ t/t9153/svn.dump | 75 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 8 deletions(-) create mode 100755 t/t9153-git-svn-rewrite-uuid.sh create mode 100644 t/t9153/svn.dump
Documentation/git-svn.txt +12 -3
@@ -62,6 +62,8 @@ COMMANDS Set the 'useSvnsyncProps' option in the [svn-remote] config. --rewrite-root=<URL>;; Set the 'rewriteRoot' option in the [svn-remote] config. +--rewrite-uuid=<UUID>;; + Set the 'rewriteUUID' option in the [svn-remote] config. --username=<USER>;; For transports that SVN handles authentication for (http, https, and plain svn), specify the username. For other
@@ -616,6 +618,12 @@ svn-remote.<name>.rewriteRoot:: the repository with a public http:// or svn:// URL in the metadata so users of it will see the public URL. +svn-remote.<name>.rewriteUUID:: + Similar to the useSvmProps option; this is for users who need + to remap the UUID manually. This may be useful in situations + where the original UUID is not available via either useSvmProps + or useSvnsyncProps. + svn.brokenSymlinkWorkaround:: This disables potentially expensive checks to workaround broken symlinks checked into SVN by broken clients. Set this
@@ -625,13 +633,14 @@ svn.brokenSymlinkWorkaround:: revision fetched. If unset, 'git svn' assumes this option to be "true". -Since the noMetadata, rewriteRoot, useSvnsyncProps and useSvmProps +Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and useSvmProps options all affect the metadata generated and used by 'git svn'; they *must* be set in the configuration file before any history is imported and these settings should never be changed once they are set. -Additionally, only one of these four options can be used per-svn-remote -section because they affect the 'git-svn-id:' metadata line. +Additionally, only one of these options can be used per svn-remote +section because they affect the 'git-svn-id:' metadata line, except +for rewriteRoot and rewriteUUID which can be used together. BASIC EXAMPLES
git-svn.perl +28 -5
@@ -115,6 +115,7 @@ my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared, 'use-svm-props' => sub { $icv{useSvmProps} = 1 }, 'use-svnsync-props' => sub { $icv{useSvnsyncProps} = 1 }, 'rewrite-root=s' => sub { $icv{rewriteRoot} = $_[1] }, + 'rewrite-uuid=s' => sub { $icv{rewriteUUID} = $_[1] }, %remote_opts ); my %cmt_opts = ( 'edit|e' => \$_edit, 'rmdir' => \$SVN::Git::Editor::_rmdir,
@@ -2189,6 +2190,10 @@ sub svnsync { die "Can't have both 'useSvnsyncProps' and 'rewriteRoot' ", "options set!\n"; } + if ($self->rewrite_uuid) { + die "Can't have both 'useSvnsyncProps' and 'rewriteUUID' ", + "options set!\n"; + } my $svnsync; # see if we have it in our config, first:
@@ -2470,6 +2475,20 @@ sub rewrite_root { $self->{-rewrite_root} = $rwr; } +sub rewrite_uuid { + my ($self) = @_; + return $self->{-rewrite_uuid} if exists $self->{-rewrite_uuid}; + my $k = "svn-remote.$self->{repo_id}.rewriteUUID"; + my $rwid = eval { command_oneline(qw/config --get/, $k) }; + if ($rwid) { + $rwid =~ s#/+$##; + if ($rwid !~ m#^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$#) { + die "$rwid is not a valid UUID (key: $k)\n"; + } + } + $self->{-rewrite_uuid} = $rwid; +} + sub metadata_url { my ($self) = @_; ($self->rewrite_root || $self->{url}) .
@@ -3253,6 +3272,10 @@ sub make_log_entry { die "Can't have both 'useSvmProps' and 'rewriteRoot' ", "options set!\n"; } + if ($self->rewrite_uuid) { + die "Can't have both 'useSvmProps' and 'rewriteUUID' ", + "options set!\n"; + } my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$}i; # we don't want "SVM: initializing mirror for junk" ... return undef if $r == 0;
@@ -3283,10 +3306,10 @@ sub make_log_entry { } else { my $url = $self->metadata_url; remove_username($url); - $log_entry{metadata} = "$url\@$rev " . - $self->ra->get_uuid; - $email ||= "$author\@" . $self->ra->get_uuid; - $commit_email ||= "$author\@" . $self->ra->get_uuid; + my $uuid = $self->rewrite_uuid || $self->ra->get_uuid; + $log_entry{metadata} = "$url\@$rev " . $uuid; + $email ||= "$author\@" . $uuid; + $commit_email ||= "$author\@" . $uuid; } $log_entry{name} = $name; $log_entry{email} = $email;
@@ -3368,7 +3391,7 @@ sub rebuild { '--'); my $metadata_url = $self->metadata_url; remove_username($metadata_url); - my $svn_uuid = $self->ra_uuid; + my $svn_uuid = $self->rewrite_uuid || $self->ra_uuid; my $c; while (<$log>) { if ( m{^commit ($::sha1)$} ) {
t/t9153-git-svn-rewrite-uuid.sh new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (c) 2010 Jay Soffian +# + +test_description='git svn --rewrite-uuid test' + +. ./lib-git-svn.sh + +uuid=6cc8ada4-5932-4b4a-8242-3534ed8a3232 + +test_expect_success 'load svn repo' " + svnadmin load -q '$rawsvnrepo' < '$TEST_DIRECTORY/t9153/svn.dump' && + git svn init --minimize-url --rewrite-uuid='$uuid' '$svnrepo' && + git svn fetch + " + +test_expect_success 'verify uuid' " + git cat-file commit refs/remotes/git-svn~0 | \ + grep '^${git_svn_id}: .*@2 $uuid$' && + git cat-file commit refs/remotes/git-svn~1 | \ + grep '^${git_svn_id}: .*@1 $uuid$' + " + +test_done
t/t9153/svn.dump new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
1.6.6.1.515.g288caf
PATCH 2/2 git-svn: allow subset of branches/tags to be specified in glob spec
In reply to Jay SoffianFor very large projects it is useful to be able to clone a subset of the upstream SVN repo's branches. Allow for this by letting the left-side of the branches and tags glob specs contain a brace-delineated comma-separated list of names. e.g.:
branches = branches/{red,green}/src:refs/remotes/branches/*
---
The only part of this I don't like is asking the user to manually edit .git/svn/.metadata, but I couldn't think of a clean way to invalidate the cached maxRev property. Further, if you know the starting point of your branches, it can speed things up quite a bit to just set maxRev to the appropriate value, esp for repos with a long history.
Documentation/git-svn.txt | 16 +++ git-svn.perl | 60 ++++++++---- t/t9154-git-svn-fancy-glob.sh | 42 ++++++++ t/t9154/svn.dump | 222 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 320 insertions(+), 20 deletions(-) create mode 100755 t/t9154-git-svn-fancy-glob.sh create mode 100644 t/t9154/svn.dump
Documentation/git-svn.txt +16 -0
@@ -825,6 +825,22 @@ independent path component (surrounded by '/' or EOL). This type of configuration is not automatically created by 'init' and should be manually entered with a text-editor or using 'git config'. +It is also possible to fetch a subset of branches or tags by using a +comma-separated list of names within braces. For example: + +------------------------------------------------------------------------ +[svn-remote "huge-project"] + url = http://server.org/svn + fetch = trunk/src:refs/remotes/trunk + branches = branches/{red,green}/src:refs/remotes/branches/* + tags = tags/{1.0,2.0}/src:refs/remotes/tags/* +------------------------------------------------------------------------ + +Note that git-svn keeps track of the highest revision in which a branch +or tag has appeared. If the subset of branches or tags is changed after +fetching, then .git/svn/.metadata must be manually edited to remove (or +reset) branches-maxRev and/or tags-maxRev as appropriate. + SEE ALSO -------- linkgit:git-rebase[1]
git-svn.perl +40 -20
83 lines not on this page · raw message
t/t9154-git-svn-fancy-glob.sh new file +42 -0
42 lines not on this page · raw message
t/t9154/svn.dump new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
1.6.6.1.515.g288caf
Quoted 5 lines · Jay Soffian
Google nicely mirrors the subversion chrome repository with git-svn. However, the git-svn mirror has only trunk. I wanted to add in a couple other branches to my clone of the git-svn mirror, but to do so I needed the ability to lie about the UUID since the publically accessible subversion repository has a different UUID than that which google is cloning from using git-svn.
Thanks Jay, pushed out to git://git.bogomips.org/git-svn
along with a few other changes I've been forgetting about:
Quoted 3 lines
Jay Soffian (2):
git-svn: allow UUID to be manually remapped via rewriteUUID
git-svn: allow subset of branches/tags to be specified in glob spec
Andrew Myrick (3):
git-svn: ignore changeless commits when checking for a cherry-pick
git-svn: handle merge-base failures
git-svn: update svn mergeinfo test suite
Igor Mironov (4):
git-svn: fix mismatched src/dst errors for branch/tag
git-svn: respect commiturl option for branch/tag
git-svn: add --username/commit-url options for branch/tag
git-svn: document --username/commit-url for branch/tag
Signature · 1 line
Eric Wong
Thanks, pulled.