Re: [Feature Request] Better Subversion integration

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Sam Granieri Jr <sjgdev@...>
Cc: Git Users List <git@...>
Date: Saturday, February 9, 2008 - 11:56 pm

On 2008.02.09 20:44:59 -0600, Sam Granieri Jr wrote:

SVN tags aren't like git tags. A "tag" in SVN is just another directory,
which you can modify at will. Yeah, I know, you _should_ not commit any
changes to SVN "tags", but shit happens. And once you modify the "tag"
in SVN, you would have to invalidate the git tag, and finding a commit
that matches the SVN state of things is probably way too expensive to be
practical. Maybe some --we-never-mess-up-svn-tag-alike-branches could
be added to allow git-svn to create teal git tags though? Dunno, I don't
care much. Shouldn't be too hard to find some shell magic to create
tags, if one wants them.


Didn't need to convert tags yet, but I have a small shell script that
does branching for me (see below). What it does, is to simply look at
the history and figure out the first commit that exists in SVN. Then it
invokes the svn program and creates a branch in SVN, starting at that
commit. Then you can just fetch that branch, rebase your work and commit
away. Writing a similar hack for tags shouldn't be too hard.

For example (assuming that you saved the script as git-svn-branch):
git checkout -b my_branch remotes/trunk
// work work work
.oO( Hm, maybe I should put that into a SVN branch for foobar reason )
git-svn-branch my_branch
git svn fetch
git rebase --onto remotes/my_branch remotes/trunk my_branch
git svn dcommit -n # This should now (pretend to) dcommit to my_branch

One thing it gets wrong (probably, never tried) is that it will take the
wrong starting point when you cherry-picked a commit from another SVN
branch and didn't remove the git-svn-id line. That is because it doesn't
make use of the .rev_map files and thus cannot figure out if the
git-svn-id line is actually valid.

IIRC git-svn should handle such cherry-picks gracefully, so
integrating that thing with git-svn would have some benefits, but I
don't speak any perl. Maybe someone else wants to take the job?

HTH
Björn


#!/bin/sh
if test "$1" = ''
then
	echo "Usage: git-svn-branch <branch_name>"
	exit 127
fi

CURRENT=$(git rev-list --first-parent --pretty=format:%b HEAD | grep -m1 -o 'git-svn-id: [^ ]*' | sed -e 's/git-svn-id: //')

SRC=${CURRENT%@*}
REV=${CURRENT#*@}
URL=$(git config --get svn-remote.svn.url)

URL=$(echo -n "$URL" | sed -e 's!//.*@!//!')
DST="$URL/$(git config --get svn-remote.svn.branches | grep -o '^[^:]*' | sed -e "s/\*/$1/")"

svn cp -r "$REV" "$SRC" "$DST" -m "Create branch $1"
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[Feature Request] Better Subversion integration, Sam Granieri Jr, (Sat Feb 9, 10:44 pm)
Re: [Feature Request] Better Subversion integration, Björn, (Sat Feb 9, 11:56 pm)
Re: [Feature Request] Better Subversion integration, Sebastian Harl, (Mon Feb 11, 4:47 am)
Re: [Feature Request] Better Subversion integration, Jan Hudec, (Fri Feb 15, 6:38 pm)
Re: [Feature Request] Better Subversion integration, Sam Granieri Jr, (Mon Feb 11, 12:55 pm)
Re: [Feature Request] Better Subversion integration, Sebastian Harl, (Mon Feb 11, 6:11 pm)
Re: [Feature Request] Better Subversion integration, Michael Haggerty, (Sun Feb 10, 12:52 pm)
Re: [Feature Request] Better Subversion integration, Michael Haggerty, (Sun Feb 10, 3:36 pm)