t / t9151 / make-svnmerge-dumpon commit Merge branch 'cc/maint-bisect-paths' into maint (ce5044d)
   1#!/bin/sh
   2#
   3# this script sets up a Subversion repository for Makefile in the
   4# first ever git merge, as if it were done with svnmerge (SVN 1.5+)
   5#
   6
   7rm -rf foo.svn foo
   8set -e
   9
  10mkdir foo.svn
  11svnadmin create foo.svn
  12svn co file://`pwd`/foo.svn foo
  13
  14commit() {
  15    i=$(( $1 + 1 ))
  16    shift;
  17    svn commit -m "(r$i) $*" >/dev/null || exit 1
  18    echo $i
  19}
  20
  21say() {
  22    echo "\e[1m * $*\e[0m"
  23}
  24
  25i=0
  26cd foo
  27mkdir trunk
  28mkdir branches
  29mkdir tags
  30svn add trunk branches tags
  31i=$(commit $i "Setup trunk, branches, and tags")
  32
  33git cat-file blob 6683463e:Makefile > trunk/Makefile
  34svn add trunk/Makefile 
  35
  36say "Committing ANCESTOR"
  37i=$(commit $i "ancestor")
  38svn cp trunk branches/left
  39
  40say "Committing BRANCH POINT"
  41i=$(commit $i "make left branch")
  42svn cp trunk branches/right
  43
  44say "Committing other BRANCH POINT"
  45i=$(commit $i "make right branch")
  46
  47say "Committing LEFT UPDATE"
  48git cat-file blob 5873b67e:Makefile > branches/left/Makefile
  49i=$(commit $i "left update 1")
  50
  51git cat-file blob 75118b13:Makefile > branches/right/Makefile
  52say "Committing RIGHT UPDATE"
  53pre_right_update_1=$i
  54i=$(commit $i "right update 1")
  55
  56say "Making more commits on LEFT"
  57git cat-file blob ff5ebe39:Makefile > branches/left/Makefile
  58i=$(commit $i "left update 2")
  59git cat-file blob b5039db6:Makefile > branches/left/Makefile
  60i=$(commit $i "left update 3")
  61
  62say "Making a LEFT SUB-BRANCH"
  63svn cp branches/left branches/left-sub
  64sub_left_make=$i
  65i=$(commit $i "make left sub-branch")
  66
  67say "Making a commit on LEFT SUB-BRANCH"
  68echo "crunch" > branches/left-sub/README
  69svn add branches/left-sub/README
  70i=$(commit $i "left sub-branch update 1")
  71
  72say "Merging LEFT to TRUNK"
  73svn update
  74cd trunk
  75svn merge ../branches/left --accept postpone
  76git cat-file blob b5039db6:Makefile > Makefile
  77svn resolved Makefile
  78i=$(commit $i "Merge left to trunk 1")
  79cd ..
  80
  81say "Making more commits on LEFT and RIGHT"
  82echo "touche" > branches/left/zlonk
  83svn add branches/left/zlonk
  84i=$(commit $i "left update 4")
  85echo "thwacke" > branches/right/bang
  86svn add branches/right/bang
  87i=$(commit $i "right update 2")
  88
  89say "Squash merge of RIGHT tip 2 commits onto TRUNK"
  90svn update
  91cd trunk
  92svn merge -r$pre_right_update_1:$i ../branches/right
  93i=$(commit $i "Cherry-pick right 2 commits to trunk")
  94cd ..
  95
  96say "Merging RIGHT to TRUNK"
  97svn update
  98cd trunk
  99svn merge ../branches/right --accept postpone
 100git cat-file blob b51ad431:Makefile > Makefile
 101svn resolved Makefile
 102i=$(commit $i "Merge right to trunk 1")
 103cd ..
 104
 105say "Making more commits on RIGHT and TRUNK"
 106echo "whamm" > branches/right/urkkk
 107svn add branches/right/urkkk
 108i=$(commit $i "right update 3")
 109echo "pow" > trunk/vronk
 110svn add trunk/vronk
 111i=$(commit $i "trunk update 1")
 112
 113say "Merging RIGHT to LEFT SUB-BRANCH"
 114svn update
 115cd branches/left-sub
 116svn merge ../right --accept postpone
 117git cat-file blob b51ad431:Makefile > Makefile
 118svn resolved Makefile
 119i=$(commit $i "Merge right to left sub-branch")
 120cd ../..
 121
 122say "Making more commits on LEFT SUB-BRANCH and LEFT"
 123echo "zowie" > branches/left-sub/wham_eth
 124svn add branches/left-sub/wham_eth
 125pre_sub_left_update_2=$i
 126i=$(commit $i "left sub-branch update 2")
 127sub_left_update_2=$i
 128echo "eee_yow" > branches/left/glurpp
 129svn add branches/left/glurpp
 130i=$(commit $i "left update 5")
 131
 132say "Cherry pick LEFT SUB-BRANCH commit to LEFT"
 133svn update
 134cd branches/left
 135svn merge -r$pre_sub_left_update_2:$sub_left_update_2 ../left-sub
 136i=$(commit $i "Cherry-pick left sub-branch commit to left")
 137cd ../..
 138
 139say "Merging LEFT SUB-BRANCH back to LEFT"
 140svn update
 141cd branches/left
 142# it's only a merge because the previous merge cherry-picked the top commit
 143svn merge -r$sub_left_make:$sub_left_update_2 ../left-sub --accept postpone
 144i=$(commit $i "Merge left sub-branch to left")
 145cd ../..
 146
 147say "Merging EVERYTHING to TRUNK"
 148svn update
 149cd trunk
 150svn merge ../branches/left --accept postpone
 151svn resolved bang
 152i=$(commit $i "Merge left to trunk 2")
 153# this merge, svn happily updates the mergeinfo, but there is actually
 154# nothing to merge.  git-svn will not make a meaningless merge commit.
 155svn merge ../branches/right --accept postpone
 156i=$(commit $i "non-merge right to trunk 2")
 157cd ..
 158
 159say "Adding subdirectory to LEFT"
 160svn update
 161cd branches/left
 162mkdir subdir
 163echo "Yeehaw" > subdir/cowboy
 164svn add subdir
 165i=$(commit $i "add subdirectory to left branch")
 166cd ../../
 167
 168say "Merging LEFT to TRUNK"
 169svn update
 170cd trunk
 171svn merge ../branches/left --accept postpone
 172i=$(commit $i "merge left to trunk")
 173cd ..
 174
 175say "Make PARTIAL branch"
 176svn update
 177i=$(commit $i "make partial branch")
 178svn cp trunk/subdir branches/partial
 179
 180say "Make a commit to PARTIAL"
 181svn update
 182cd branches/partial
 183echo "racecar" > palindromes
 184svn add palindromes
 185i=$(commit $i "partial update")
 186cd ../../
 187
 188say "Merge PARTIAL to TRUNK"
 189svn update
 190cd trunk/subdir
 191svn merge ../../branches/partial --accept postpone
 192i=$(commit $i "merge partial to trunk")
 193cd ../../
 194
 195say "Tagging trunk"
 196svn update
 197i=$(commit $i "tagging v1.0")
 198svn cp trunk tags/v1.0
 199
 200say "Branching BUGFIX from v1.0"
 201svn update
 202i=$(commit $i "make bugfix branch from tag")
 203svn cp tags/v1.0 branches/bugfix
 204
 205say "Make a commit to BUGFIX"
 206svn update
 207cd branches/bugfix/
 208echo "kayak" >> subdir/palindromes
 209i=$(commit $i "commit to bugfix")
 210cd ../../
 211
 212say "Merge BUGFIX to TRUNK"
 213svn update
 214cd trunk
 215svn merge ../branches/bugfix/ --accept postpone
 216i=$(commit $i "Merge BUGFIX to TRUNK")
 217cd ..
 218
 219cd ..
 220svnadmin dump foo.svn > svn-mergeinfo.dump
 221
 222rm -rf foo foo.svn