t / t9151 / make-svnmerge-dumpon commit Merge branch 'ta/remove-stale-translated-tut' into maint (f6f3921)
   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 "Branching b1 from trunk"
 160svn update
 161svn cp trunk branches/b1
 162i=$(commit $i "make b1 branch from trunk")
 163
 164say "Branching b2 from trunk"
 165svn update
 166svn cp trunk branches/b2
 167i=$(commit $i "make b2 branch from trunk")
 168
 169say "Make a commit to b2"
 170svn update
 171cd branches/b2
 172echo "b2" > b2file
 173svn add b2file
 174i=$(commit $i "b2 update 1")
 175cd ../..
 176
 177say "Make a commit to b1"
 178svn update
 179cd branches/b1
 180echo "b1" > b1file
 181svn add b1file
 182i=$(commit $i "b1 update 1")
 183cd ../..
 184
 185say "Merge b1 to trunk"
 186svn update
 187cd trunk
 188svn merge ../branches/b1/ --accept postpone
 189i=$(commit $i "Merge b1 to trunk")
 190cd ..
 191
 192say "Make a commit to trunk before merging trunk to b2"
 193svn update
 194cd trunk
 195echo "trunk" > trunkfile
 196svn add trunkfile
 197i=$(commit $i "trunk commit before merging trunk to b2")
 198cd ..
 199
 200say "Merge trunk to b2"
 201svn update
 202cd branches/b2
 203svn merge ../../trunk/ --accept postpone
 204i=$(commit $i "Merge trunk to b2")
 205cd ../..
 206
 207say "Merge b2 to trunk"
 208svn update
 209cd trunk
 210svn merge ../branches/b2/ --accept postpone
 211svn resolved b1file
 212svn resolved trunkfile
 213i=$(commit $i "Merge b2 to trunk")
 214cd ..
 215
 216say "Creating f1 from trunk with a new file"
 217svn update
 218svn cp trunk branches/f1
 219cd branches/f1
 220echo "f1" > f1file
 221svn add f1file
 222cd ../..
 223i=$(commit $i "make f1 branch from trunk with a new file")
 224
 225say "Creating f2 from trunk with a new file"
 226svn update
 227svn cp trunk branches/f2
 228cd branches/f2
 229echo "f2" > f2file
 230svn add f2file
 231cd ../..
 232i=$(commit $i "make f2 branch from trunk with a new file")
 233
 234say "Merge f1 and f2 to trunk in one go"
 235svn update
 236cd trunk
 237svn merge ../branches/f1/ --accept postpone
 238svn merge ../branches/f2/ --accept postpone
 239i=$(commit $i "Merge f1 and f2 to trunk")
 240cd ..
 241
 242say "Adding subdirectory to LEFT"
 243svn update
 244cd branches/left
 245mkdir subdir
 246echo "Yeehaw" > subdir/cowboy
 247svn add subdir
 248i=$(commit $i "add subdirectory to left branch")
 249cd ../../
 250
 251say "Merging LEFT to TRUNK"
 252svn update
 253cd trunk
 254svn merge ../branches/left --accept postpone
 255i=$(commit $i "merge left to trunk")
 256cd ..
 257
 258say "Make PARTIAL branch"
 259svn update
 260svn cp trunk/subdir branches/partial
 261i=$(commit $i "make partial branch")
 262
 263say "Make a commit to PARTIAL"
 264svn update
 265cd branches/partial
 266echo "racecar" > palindromes
 267svn add palindromes
 268i=$(commit $i "partial update")
 269cd ../../
 270
 271say "Merge PARTIAL to TRUNK"
 272svn update
 273cd trunk/subdir
 274svn merge ../../branches/partial --accept postpone
 275i=$(commit $i "merge partial to trunk")
 276cd ../../
 277
 278say "Tagging trunk"
 279svn update
 280svn cp trunk tags/v1.0
 281i=$(commit $i "tagging v1.0")
 282
 283say "Branching BUGFIX from v1.0"
 284svn update
 285svn cp tags/v1.0 branches/bugfix
 286i=$(commit $i "make bugfix branch from tag")
 287
 288say "Make a commit to BUGFIX"
 289svn update
 290cd branches/bugfix/
 291echo "kayak" >> subdir/palindromes
 292i=$(commit $i "commit to bugfix")
 293cd ../../
 294
 295say "Merge BUGFIX to TRUNK"
 296svn update
 297cd trunk
 298svn merge ../branches/bugfix/ --accept postpone
 299i=$(commit $i "Merge BUGFIX to TRUNK")
 300cd ..
 301
 302cd ..
 303svnadmin dump foo.svn > svn-mergeinfo.dump
 304
 305rm -rf foo foo.svn