Boost logo

Boost :

Subject: Re: [boost] [git] Mercurial? easy merging in svn, how about git/hg?
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2012-03-29 05:41:22

Frank Birbacher wrote:

> [...] So we will need a more complex example, I
> think.
> using Subversion 1.7.4:
> # setup:
> cd /tmp
> svnadmin create testrepo
> svn mkdir file:///tmp/testrepo/{trunk,branches} -m "default dirs"
> svn co file:///tmp/testrepo/trunk workingcopy
> cd workingcopy
> # create branch:
> svn cp ^/trunk ^/branches/my-branch -m "branch"
> # edit branch:
> svn switch ^/branches/my-branch
> echo "new" > new.txt
> svn add new.txt
> svn ci -m "new file"
> # switch back to trunk and merge:
> svn switch ^/trunk
> svn merge ^/branches/my-branch
> # revise working copy before commit, or revert and try again
> # svn revert -R .
> svn ci -m "merged branch"
> svn switch ^/branches/my-branch
> echo "further" >> new.txt
> svn ci -m "added content"
> # merging:
> svn switch ^/trunk
> # optional inspection:
> # svn mergeinfo --show-revs=eligible ^/branches/my-branch
> svn merge ^/branches/my-branch
> # optional inspection:
> # svn pg svn:mergeinfo .
> svn ci -m "merged branch again"
> Running the above as a script takes some time:
> real 0m10.433s
> user 0m0.160s
> sys 0m0.253s

First I want to point out that such a mircobenchmark is probably not
very reliable, in part because this is a purely local repository.
That said, I think it's incredible that svn is taking ten seconds to
perform such trivial operations on such a tiny local test repository.
Perhaps you should repeat your measurement to make sure this wasn't
an outlier.

For the sake of completeness I've still written what I believe to be
the closest git equivalent, which you can find at the bottom of this
email. Again it takes the same number of commands but with a larger
fraction of them in the initial setup (suggesting that the real work
will ultimately take fewer commands in git), and again fewer
keystrokes per line on average. Time on an iMac from 2007:

real 0m0.319s
user 0m0.045s
sys 0m0.124s

This is fairly consistent over multiple runs.

> BTW, as I understand git: the working copy contains a hidden directory
> that stores all of the repository data. And the checkout will be
> placed at top-level. Is there a way to checkout multiple branches at
> the same time?

Yes, as Martin explained that can be done quite conveniently with a second working copy.



# setup:
# cd /tmp
mkdir testrepo
cd testrepo
git init
# creating standard branches (branches don't get created without content)
git co -b master
echo "old" > old.txt
git add old.txt
git ci -m "first commit"
git co -b develop

# create and switch to a branch:
git co -b branch
# edit branch:
echo "new" > new.txt
git add new.txt
git ci -m "new file"
# switch back to develop and merge+commit:
git co develop
git merge branch
# insert hypothetical conflict resolution here

git co branch
echo "further" >> new.txt
git ci -am "added content"
# switch and merge+commit:
git co develop
git merge branch
# inspection: git status, git log, etcetera

Boost list run by bdawes at, gregod at, cpdaniel at, john at