lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Converting a proprietary svn repository to git


From: Greg Chicares
Subject: Re: [lmi] Converting a proprietary svn repository to git
Date: Wed, 2 Mar 2016 16:31:52 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0

On 2016-03-02 14:10, Vadim Zeitlin wrote:
> On Tue, 1 Mar 2016 16:17:17 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> 
> -------------------------------------8<-------------------------------------
> GC> #!/bin/bash
> GC> 
> GC> # migrate a particular svn repository to git
> ...
> GC> # create a transitional git clone of the svn repository
> GC> # [GNU/Linux: 2 min; msw-xp: 41 min]
> GC> git svn clone \
> GC>   file:///tmp/migration/repository \
> GC>   --authors-file=/tmp/migration/authors.txt \
> GC>   --prefix="origin/" --no-metadata --trunk=/ ./transitional
> 
>  This normally ought to create HEAD pointing to master (you can run "git
> symbolic-ref HEAD" or, if you're feeling particularly real-programmerishly[*],
> just "cat .git/HEAD" to check this).

Seems correct there:

/tmp/migration/transitional[0]$git symbolic-ref HEAD
refs/heads/master
/tmp/migration/transitional[0]$cat .git/HEAD
ref: refs/heads/master

> GC> # create new bare repository
> GC> mkdir blessed
> GC> pushd blessed
> GC> git init --bare ./proprietary
> GC> pushd proprietary
> GC> git symbolic-ref HEAD refs/heads/trunk
> GC> git rev-parse HEAD
> GC> popd
> GC> popd
> 
>  This seems to be the part which creates problems later. Why do you do
> this? AFAICS you should simply delete the last two git commands entirely,
> just "git init" is all you need.

I was slavishly following a five-year-old tutorial:
  http://john.albin.net/git/convert-subversion-to-git
which prescribed those commands. Perhaps they were needed in 2010.

Removing that, and the rest of the stuff that looked strange to you
today, produces success.

>  Of course, all these remarks don't mean that you must redo the clone
> because, even if you took a rather long and winding road to get to it, the
> end result is still exactly the same. I'm only mentioning it in case you
> plan to do other svn-to-git migrations in the future or just need to know
> why did you need this "-b master" at the end.

Okay, but I do prefer to redo it, and the whole thing takes only 2:11.26 .
Now I have a simpler, solid script [0] I can refer to in future, and a
cleanly-migrated repository that seems less likely to contain latent errors.

It's also important for me to see that git can be used in a comprehensible
way, without all those esoteric incantations; thanks for showing me the clear
path. To think that I was just three simple commands away from success!

> [*] https://xkcd.com/378/

He doesn't mention 'sed -i'. Someday I really must study 'vi', which
I've heard is at least as powerful.

---------

[0] "a simpler, solid script":

#!/bin/bash

# migrate a particular svn repository to git

set -v

# edit the next line to set insurer's domain
export CompanyDomain="REDACTED.com"
[ "REDACTED.com" != "$CompanyDomain" ] || { echo "YOU WERE SUPPOSED TO 
CUSTOMIZE THAT"; exit 8; }

# make sure the svn tarball is in /tmp
[ -f "/tmp/repository-20160212T2239Z.tar.bz2" ] || { echo "SVN TARBALL NOT 
FOUND"; exit 9; }

uname -a
git --version
svn --version |head -1

# do everything in a fresh subdir of /tmp just to see if it all works
rm -rf /tmp/migration
mkdir --parents /tmp/migration
cd /tmp/migration

# unpack svn tarball and verify it
tar -xjvf /tmp/repository-20160212T2239Z.tar.bz2
svnadmin verify repository

# check out an svn working copy...
mkdir --parents svn_working_copy
pushd svn_working_copy
svn checkout \
  file:///tmp/migration/repository
popd

# ...for the sole purpose of extracting authors
pushd svn_working_copy/repository
svn log --xml \
  | grep author | sort -u \
  | sed -e "s/^[^>]*>\([^<]*\)<[^<]*$/\1 = \1 <address@hidden>/" \
  >/tmp/migration/authors.txt
popd

# create a transitional git clone of the svn repository
# [GNU/Linux: 2 min; msw-xp: 41 min]
git svn clone \
  file:///tmp/migration/repository \
  --authors-file=/tmp/migration/authors.txt \
  --prefix="origin/" --no-metadata --trunk=/ ./transitional

# create new bare repository
mkdir blessed
pushd blessed
git init --bare ./proprietary
popd

# push to bare repository
pushd /tmp/migration/transitional
git push --all /tmp/migration/blessed/proprietary/
popd

# clone from bare repository
mkdir --parents migrated
pushd migrated
git clone file:///tmp/migration/blessed/proprietary
popd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]