[Assorted-commits] SF.net SVN: assorted:[1065] sandbox/trunk/src/git/gitsvn.bash
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-11-06 22:12:05
|
Revision: 1065 http://assorted.svn.sourceforge.net/assorted/?rev=1065&view=rev Author: yangzhang Date: 2008-11-06 22:12:00 +0000 (Thu, 06 Nov 2008) Log Message: ----------- cleaned and extended the test suite Modified Paths: -------------- sandbox/trunk/src/git/gitsvn.bash Modified: sandbox/trunk/src/git/gitsvn.bash =================================================================== --- sandbox/trunk/src/git/gitsvn.bash 2008-11-06 19:56:45 UTC (rev 1064) +++ sandbox/trunk/src/git/gitsvn.bash 2008-11-06 22:12:00 UTC (rev 1065) @@ -3,8 +3,10 @@ # Demo of how git svn and cloning that would work. Run this with e.g.: # ./gitsvn.bash /tmp/test -set -o errexit -o nounset +set -o errexit -o nounset -o xtrace +shownormal=false showfailure=false shownofailure=true + fail=false if $fail then rebase= @@ -16,204 +18,141 @@ mkdir -p $basedir cd $basedir +munge() { + local i=$1 dir=$2 + sed -i s/line$i\$/Line$i/ $dir/myfile +} + +svnci() { + local i=$1 + munge $i svn + svn ci -q -m "munge line$i in svn" svn/ +} + +gitci() { + local i=$1 + munge $i gitsvn + (cd gitsvn; git commit -q -a -m "munge line$i in git") +} + +cloci() { + local i=$1 + munge $i gitsvn2 + (cd gitsvn2; git commit -q -a -m "munge line$i in clo") +} + +svn2git() { + (cd gitsvn; git svn -q rebase) +} + +clo2git() { + (cd gitsvn; git pull $rebase -q file://$basedir/gitsvn2) +} + +gitst() { + if false + then (cd gitsvn; git log --pretty='format:%h... %ar by %an: %s') + fi +} + +clost() { + if false + then (cd gitsvn; git log --pretty='format:%h... %ar by %an: %s') + fi +} + # set up an svn repo mkdir svnrepo svnadmin create svnrepo # add something to the repo svn co -q file://$basedir/svnrepo svn -echo -e 'line1\nline2\nline3\nline4' > svn/myfile +seq 90 | xargs -I_ echo line_ > svn/myfile svn add -q svn/myfile svn ci -q -m 'added myfile' svn/ -# git clone it -# s +# clone the svn repo and commit there git svn -q clone file://$basedir/svnrepo gitsvn +gitci 30 -# make some more changes to svn and mirror those to gitsvn -# s--s -echo -e 'line5\nline6\nline7\nline8' >> svn/myfile -svn ci -q -m 'added more lines' svn/ -(cd gitsvn; git svn -q rebase) +# clone the git repo and commit there +git clone -q file://$basedir/gitsvn gitsvn2 +cloci 60 -# make concurrent changes to both svn and git -# s--s--s -# `-g -# ==> -# s--s--s -# `-g -sed -i s/line1/Line1/ svn/myfile -sed -i s/line5/Line5/ gitsvn/myfile -svn ci -q -m 'munge line1' svn/ -(cd gitsvn; git commit -a -m 'munge line5'; git svn -q rebase) -# clone the git repo elsewhere and commit something there -# s--s--s -# `-g -# `-G -git clone -q file://$basedir/gitsvn gitsvn2 -sed -i s/line8/Line8/ gitsvn2/myfile -(cd gitsvn2; git commit -q -a -m 'munge line8') -# make concurrent change to svn, and original git repo -# s--s--s--s -# `-g--g -# `-G -# ==> -# s--s--s--s -# `-g--g -# `-g -# `-G -sed -i s/line2/Line2/ svn/myfile -svn ci -q -m 'munge line2' svn/ -(cd gitsvn; git svn -q rebase) +if $shownormal ; then -# make another concurrent change to svn, then pull (merge) gitsvn2 changes into -# the original git repo, then update gitsvn from svn -# s--s--s--s--s -# `-g--g -# `-g -# `-G -# ==> -# s--s--s--s--s -# `-g--g--g -# `-g -# `-G-------' -# ==> -# CONFLICT -sed -i s/line3/Line3/ svn/myfile -svn ci -q -m 'munge line3' svn/ -# XXX problem here -( - cd gitsvn - git pull $rebase -q file://$basedir/gitsvn2 - git svn -q rebase || git diff -) + # commit to svn then pull to git + svnci 1 + svn2git + gitst -# Output: + # make another concurrent change to svn, then pull (merge) gitsvn2 changes into + # the original git repo, then update gitsvn from svn + svnci 3 + clo2git + gitst + svn2git + gitst + + # make any number of changes at any site before pulling in + + svnci 10 + svnci 12 + svnci 14 + + gitci 40 + gitci 42 + gitci 44 + + cloci 70 + cloci 72 + cloci 74 + + # either direction works + clo2git + svn2git + +fi + +# everything above was "commutative" + +if $showfailure ; then + + # these work + svnci 10 + gitci 11 + svnci 12 + gitci 13 + svnci 14 + gitci 15 + svn2git + +fi + +if $shownofailure ; then + + gitci 10 + cloci 11 + gitci 12 + cloci 13 + gitci 14 + cloci 15 + clo2git + +fi + +# What's actually happening? # -# $ bash -x ./gitsvn.bash /tmp/t4 -# + set -o errexit -o nounset -# + fail=false -# + false -# + rebase=--rebase -# + basedir=/tmp/t4 -# + mkdir -p /tmp/t4 -# + cd /tmp/t4 -# + mkdir svnrepo -# + svnadmin create svnrepo -# + svn co -q file:///tmp/t4/svnrepo svn -# + echo -e 'line1\nline2\nline3\nline4' -# + svn add -q svn/myfile -# + svn ci -q -m 'added myfile' svn/ -# + git svn -q clone file:///tmp/t4/svnrepo gitsvn -# Initialized empty Git repository in .git/ -# r1 = f39dddf518003f497e89b08c7d9ce03cb0834a5e (git-svn) -# Checked out HEAD: -# file:///tmp/t4/svnrepo r1 -# + echo -e 'line5\nline6\nline7\nline8' -# + svn ci -q -m 'added more lines' svn/ -# + cd gitsvn -# + git svn -q rebase -# r2 = 4eb6330c853563989930ebac27165fd613dca81b (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at 4eb6330... added more lines -# Fast-forwarded master to refs/remotes/git-svn. -# + sed -i s/line1/Line1/ svn/myfile -# + sed -i s/line5/Line5/ gitsvn/myfile -# + svn ci -q -m 'munge line1' svn/ -# + cd gitsvn -# + git commit -a -m 'munge line5' -# Created commit 1da2513: munge line5 -# 1 files changed, 1 insertions(+), 1 deletions(-) -# + git svn -q rebase -# r3 = 89c2629a7bc6e67e90e28e143b32ae0cf9c82d3a (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at 89c2629... munge line1 -# Applying munge line5 -# + git clone -q file:///tmp/t4/gitsvn gitsvn2 -# remote: Counting objects: 12, done. -# remote: Compressing objects: 100% (4/4), done. -# remote: Total 12 (delta 1), reused 0 (delta 0) -# + sed -i s/line8/Line8/ gitsvn2/myfile -# + cd gitsvn2 -# + git commit -q -a -m 'munge line8' -# + sed -i s/line2/Line2/ svn/myfile -# + svn ci -q -m 'munge line2' svn/ -# + cd gitsvn -# + git svn -q rebase -# r4 = 3073ef827c94d15a1f4b6c1187ba97cac5128241 (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at 3073ef8... munge line2 -# Applying munge line5 -# error: patch failed: myfile:2 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# + sed -i s/line3/Line3/ svn/myfile -# + svn ci -q -m 'munge line3' svn/ -# + cd gitsvn -# + git pull --rebase -q file:///tmp/t4/gitsvn2 -# remote: Counting objects: 8, done. -# remote: Compressing objects: 100% (2/2), done. -# remote: Total 6 (delta 0), reused 3 (delta 0) -# Unpacking objects: 100% (6/6), done. -# First, rewinding head to replay your work on top of it... -# HEAD is now at 9cfe5a5... munge line8 -# Applying munge line2 -# error: patch failed: myfile:1 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# Applying munge line5 -# error: patch failed: myfile:2 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# No changes -- Patch already applied. -# + git svn -q rebase -# r5 = aafbc408b0567d24e25eb96a940b69a5c20bd9cc (git-svn) -# First, rewinding head to replay your work on top of it... -# HEAD is now at aafbc40... munge line3 -# Applying munge line5 -# error: patch failed: myfile:2 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# Applying munge line8 -# Applying munge line2 -# error: patch failed: myfile:1 -# error: myfile: patch does not apply -# Using index info to reconstruct a base tree... -# Falling back to patching base and 3-way merge... -# Auto-merged myfile -# CONFLICT (content): Merge conflict in myfile -# Failed to merge in the changes. -# Patch failed at 0003. -# -# When you have resolved this problem run "git rebase --continue". -# If you would prefer to skip this patch, instead run "git rebase --skip". -# To restore the original branch and stop rebasing run "git rebase --abort". -# -# rebase refs/remotes/git-svn: command returned error: 1 -# -# + git diff -# diff --cc myfile -# index 2560a81,3813bf9..0000000 -# --- a/myfile -# +++ b/myfile -# @@@ -1,6 -1,6 +1,10 @@@ -# Line1 -# Line2 -# ++<<<<<<< HEAD:myfile -# +Line3 -# ++======= -# + line3 -# ++>>>>>>> munge line2:myfile -# line4 -# Line5 -# line6 +# When you do a git pull --rebase, it puts all your local changes after the +# remote changes. +# +# So when you do git svn rebase, changes from the main git repo and its clone +# come after the svn changes. +# +# And when you do git pull --rebase from the clone, changes from the main git +# repo and svn come after the clone changes. +# +# Rebasing in general requires your changes to be "portable" (not sure if +# "commutative" is accurate) so that changes can be moved around/reordered. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |