|
| 1 | +#!/usr/bin/perl |
| 2 | +use strict; |
| 3 | +use warnings; |
| 4 | +use FindBin qw($Bin); |
| 5 | + |
| 6 | +use lib "$Bin/lib"; |
| 7 | +$ENV{PATH} = "$Bin/../bin:$ENV{PATH}"; # so we find git-cvs |
| 8 | + |
| 9 | +#use MyTest qw(barf git_cvs); |
| 10 | +use MyTest::Dirs; |
| 11 | +use MyTest::Replay; |
| 12 | + |
| 13 | +use Test::More tests => 1; |
| 14 | + |
| 15 | +# This tests that merged branches get synced correctly |
| 16 | +# |
| 17 | +# i.e. a git tree like this |
| 18 | +# |
| 19 | +# a-b-c |
| 20 | +# \ \ |
| 21 | +# d-e-f-g |
| 22 | +# |
| 23 | +# with |
| 24 | +# remotes/cvs/HEAD = c |
| 25 | +# master = g |
| 26 | +# |
| 27 | +# commits f,g |
| 28 | +# and not d,e,f,g, or -b,-a,d,e,f,g |
| 29 | + |
| 30 | + |
| 31 | +my %D = MyTest::Dirs->hash( |
| 32 | + data => [], |
| 33 | + temp => [cvs_repo => 'cvs', |
| 34 | + cvs_work => 'cvs_work', |
| 35 | + git_repo => 'git'], |
| 36 | +); |
| 37 | + |
| 38 | +my $cvs_module = 'module1'; |
| 39 | + |
| 40 | +## Create a cvs repo and working dir |
| 41 | +my $cvs = MyTest::Replay::CVS->new(path => $D{cvs_work}, |
| 42 | + module => $cvs_module, |
| 43 | + cvsroot => $D{cvs_repo}); |
| 44 | + |
| 45 | + |
| 46 | +## Create a git repo |
| 47 | +my $git = MyTest::Replay::Git->new(path => $D{git_repo}); |
| 48 | +$git->playback(<<ACTIONS); |
| 49 | +# init .git-cvs and make the first import from CVS |
| 50 | ++.git-cvs cvsroot=$D{cvs_repo} |
| 51 | ++.git-cvs cvsmodule=$cvs_module |
| 52 | +ACTIONS |
| 53 | + |
| 54 | +## Create the basic starting point |
| 55 | +$cvs->playback(<<ACTIONS); |
| 56 | ++A |
| 57 | +*cvs add A |
| 58 | +*cvs ci -m "added A" |
| 59 | +ACTIONS |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +## Pull these into git |
| 64 | +$git->playback(<<ACTIONS); |
| 65 | +*git-cvs pull |
| 66 | +?A |
| 67 | +ACTIONS |
| 68 | +## giving: |
| 69 | +# C |
| 70 | +# M |
| 71 | +# a |
| 72 | + |
| 73 | + |
| 74 | +### Now create the git testbranch |
| 75 | +#$git->playback(<<ACTIONS); |
| 76 | +#*git checkout -b testbranch |
| 77 | +#ACTIONS |
| 78 | + |
| 79 | +## Add some changesets d e f to git master |
| 80 | +$git->playback(<<ACTIONS); |
| 81 | ++D |
| 82 | +*git add D |
| 83 | +*git commit -m "added D" |
| 84 | +
|
| 85 | ++E |
| 86 | +*git add E |
| 87 | +*git commit -m "added E" |
| 88 | +
|
| 89 | ++F |
| 90 | +*git add F |
| 91 | +*git commit -m "added F" |
| 92 | +ACTIONS |
| 93 | +## Giving |
| 94 | +# C M |
| 95 | +# a |
| 96 | +# \ |
| 97 | +# d-e-f |
| 98 | + |
| 99 | +## In CVS, add some changes b c |
| 100 | +$cvs->playback(<<ACTIONS); |
| 101 | ++B |
| 102 | +*cvs add B |
| 103 | +*cvs ci -m "added B" |
| 104 | +
|
| 105 | ++C |
| 106 | +*cvs add C |
| 107 | +*cvs ci -m "added C" |
| 108 | +ACTIONS |
| 109 | + |
| 110 | +## And pull them back into git - not forgetting to push our local |
| 111 | +## changes first, else we'll get a CVS history with the changes |
| 112 | +## lumped into the merge (if we push after, or not at all): |
| 113 | +# C M |
| 114 | +# a-------b-c |
| 115 | +# \ \ |
| 116 | +# d-e-f-----g |
| 117 | +$git->playback(<<ACTIONS); |
| 118 | +*git-cvs push |
| 119 | +ACTIONS |
| 120 | + |
| 121 | +$git->playback(<<ACTIONS); |
| 122 | +*git-cvs pull |
| 123 | +ACTIONS |
| 124 | +## Instead of what we want, a CVS history with all the |
| 125 | +## changes in separate commits, like this: |
| 126 | +# C M |
| 127 | +# a-------b-c-d'-e'-f' |
| 128 | +# \ \ |
| 129 | +# d-e-f-------------g |
| 130 | + |
| 131 | +## Now add some more commits h, i |
| 132 | +$git->playback(<<ACTIONS); |
| 133 | ++H |
| 134 | +*git add H |
| 135 | +*git commit -m "added H" |
| 136 | +
|
| 137 | ++I |
| 138 | +*git add I |
| 139 | +*git commit -m "added I" |
| 140 | +ACTIONS |
| 141 | +## Giving |
| 142 | +# C M |
| 143 | +# a-------b-c-d'-e'-f' |
| 144 | +# \ \ |
| 145 | +# d-e-f-------------g-h-i |
| 146 | + |
| 147 | + |
| 148 | +## Now commit this back to CVS |
| 149 | +$git->playback(<<ACTIONS); |
| 150 | +*git-cvs push |
| 151 | +ACTIONS |
| 152 | + |
| 153 | + |
| 154 | +# Have the commits appeared? |
| 155 | +$cvs->playback(<<ACTIONS); |
| 156 | +*cvs up -d |
| 157 | +?H |
| 158 | +?I |
| 159 | +
|
| 160 | ++J |
| 161 | +*cvs add J |
| 162 | +*cvs ci -m "Added J" |
| 163 | +ACTIONS |
| 164 | + |
| 165 | +## Now commit this back to CVS |
| 166 | +# This will test that the commit g has |
| 167 | +# the correct parent specified to git-cvsexportcommit |
| 168 | +$git->playback(<<ACTIONS); |
| 169 | +*git-cvs pull |
| 170 | +
|
| 171 | +?J |
| 172 | +ACTIONS |
| 173 | +## Giving |
| 174 | +# C M |
| 175 | +# a-------b-c-d'-e'-f'------h'-i'-j |
| 176 | +# \ \ \ |
| 177 | +# d-e-f-------------g-h-i---------k |
| 178 | + |
| 179 | + |
| 180 | +# how do we check that g has f and f' as parents? likewise k? |
| 181 | + |
| 182 | +# is this pattern of merging the one we want (it should be like pulling) |
| 183 | + |
| 184 | + |
| 185 | +print "done"; |
| 186 | + |
| 187 | +## We can't get rid of Now try to commit |
| 188 | + |
| 189 | +__END__ |
| 190 | +git: add h |
| 191 | +
|
| 192 | +# C T |
| 193 | +# M |
| 194 | +# a-------b-c |
| 195 | +# \ \ |
| 196 | +# d-e-f-----g-h |
| 197 | +
|
| 198 | +git-cvs push |
| 199 | +# T C |
| 200 | +# M |
| 201 | +# a-------b-c |
| 202 | +# \ \ |
| 203 | +# d-e-f-----g-h |
| 204 | +
|
| 205 | +
|
| 206 | +
|
| 207 | +__END__ |
| 208 | +
|
| 209 | +
|
| 210 | +$cvs->playback(<<ACTIONS); |
| 211 | +# pull that back to CVS |
| 212 | +*cvs up -d |
| 213 | +?three |
| 214 | +
|
| 215 | +# add a new file in CVS |
| 216 | ++four |
| 217 | +*cvs add four |
| 218 | +*cvs ci -m "added four" |
| 219 | +ACTIONS |
| 220 | +
|
| 221 | +$git->playback(<<ACTIONS); |
| 222 | +# pull back a second time from CVS |
| 223 | +*git-cvs pull |
| 224 | +*git reset --hard cvs/cvshead |
| 225 | +?one |
| 226 | +?two |
| 227 | +?three |
| 228 | +?four |
| 229 | +ACTIONS |
| 230 | +
|
| 231 | +$cvs->playback(<<ACTIONS); |
| 232 | +# branch in CVS |
| 233 | +*cvs tag -b BRANCH1 |
| 234 | +*cvs update -r BRANCH1 |
| 235 | +*cvs tag BRANCH1_BASE |
| 236 | +*cvs tag BRANCH1_LAST_MERGE |
| 237 | +*cvs ci -m "created BRANCH1" |
| 238 | +
|
| 239 | +# create a file to identify that branch |
| 240 | ++cvs_branch1 |
| 241 | +*cvs add cvs_branch1 |
| 242 | +*cvs ci -m "added file cvs_branch1" |
| 243 | +ACTIONS |
| 244 | +
|
| 245 | +
|
| 246 | +# can we see the branches? |
| 247 | +
|
| 248 | +$git->playback(<<ACTIONS); |
| 249 | +# pull the changes back to git |
| 250 | +*git-cvs pull |
| 251 | +
|
| 252 | +# can we see the remote branches? |
| 253 | +?.git/refs/remotes/cvs/cvshead |
| 254 | +?.git/refs/remotes/cvs/HEAD |
| 255 | +?.git/refs/remotes/cvs/BRANCH1 |
| 256 | +
|
| 257 | +# and the tracking branch? |
| 258 | +?.git/refs/heads/cvsworking/BRANCH1 |
| 259 | +
|
| 260 | +# but is the branch1 absent? |
| 261 | +!cvs_branch1 |
| 262 | +
|
| 263 | +# now switch to BRANCH1 |
| 264 | +*git checkout cvsworking/BRANCH1 |
| 265 | +*git reset --hard cvs/BRANCH1 |
| 266 | +?cvs_branch1 |
| 267 | +
|
| 268 | +# and modify it |
| 269 | ++git/branch1 hello |
| 270 | +*git add git/branch1 |
| 271 | +*git commit -m "added git/branch1" |
| 272 | +
|
| 273 | +# push it back |
| 274 | +*git-cvs push |
| 275 | +ACTIONS |
| 276 | +
|
| 277 | +
|
| 278 | +$cvs->playback(<<ACTIONS); |
| 279 | +# check the changes appear in CVS |
| 280 | +*cvs up -d |
| 281 | +?git/branch1? |
| 282 | +ACTIONS |
| 283 | +
|
| 284 | +
|
| 285 | +# Up to here, same as basic.t |
| 286 | +# This test aims to test the problem I experienced where a |
| 287 | +# file added in one branch block it being added in another. |
| 288 | +
|
| 289 | +$git->playback(<<ACTIONS); |
| 290 | +# pull last changes back into git |
| 291 | +*git-cvs pull |
| 292 | +*git reset --hard cvs/BRANCH1 |
| 293 | +ACTIONS |
| 294 | +
|
| 295 | +
|
| 296 | +$cvs->playback(<<ACTIONS); |
| 297 | +# add a file in HEAD |
| 298 | +*cvs up -d -A |
| 299 | ++cvs_nasty |
| 300 | +*cvs add cvs_nasty |
| 301 | +*cvs ci -m "added cvs_nasty in cvs HEAD" |
| 302 | +ACTIONS |
| 303 | +
|
| 304 | +$git->playback(<<ACTIONS); |
| 305 | +# now add another with the same name in BRANCH1 |
| 306 | +#*git checkout BRANCH1 |
| 307 | ++cvs_nasty |
| 308 | +*git add cvs_nasty |
| 309 | +*git commit -m "added cvs_nasty in Git BRANCH1" |
| 310 | +ACTIONS |
| 311 | +
|
| 312 | +
|
| 313 | +# PUSH: |
| 314 | +# Checking if patch will apply |
| 315 | +# U cvs_nasty |
| 316 | +# Huh? Status reported for unexpected file 'cvs_nasty' |
| 317 | +# Applying |
| 318 | +# error: cvs_nasty: already exists in working directory |
| 319 | +# cannot patch at /usr/bin/git-cvsexportcommit line 282. |
| 320 | +
|
| 321 | +
|
| 322 | +# PULL: |
| 323 | +# Running cvsps... |
| 324 | +# cvs_direct initialized to CVSROOT /home/nick/svkworking/noofac/trunk/git-cvs/t/temp/basic/cvs |
| 325 | +# cvs rlog: Logging module1 |
| 326 | +# cvs rlog: Logging module1/git |
| 327 | +# WARNING: branch_add already set! |
| 328 | +# skip patchset 1: 1227900176 before 1227900182 |
| 329 | +# skip patchset 2: 1227900179 before 1227900182 |
| 330 | +# skip patchset 3: 1227900182 before 1227900182 |
| 331 | +# skip patchset 4: 1227900184 before 1227900187 |
| 332 | +# skip patchset 5: 1227900187 before 1227900187 |
| 333 | +# Fetching cvs_nasty v 1.1.2.1 |
| 334 | +# Update cvs_nasty: 1 bytes |
| 335 | +# Tree ID f4f6d39d1bf27228774ada9855166726a3932919 |
| 336 | +# Parent ID 9fe53101457f4b08af7c456255b68458e55beb39 |
| 337 | +# Committed patch 6 (BRANCH1 +0000 2008-11-28 19:23:10) |
| 338 | +# Commit ID e2714f3aae88d4bbcb554ba692e8789a6bb41498 |
| 339 | +# DONE. |
| 340 | +# Already up-to-date. |
| 341 | +# invoking: git --git-dir '/home/nick/svkworking/noofac/trunk/git-cvs/t/temp/basic/git/.git' show-ref |
| 342 | +
|
| 343 | +
|
| 344 | +$git->playback(<<ACTIONS); |
| 345 | +# and push to cvs |
| 346 | +*git-cvs push |
| 347 | +
|
| 348 | +# pull the changes back to git |
| 349 | +*git-cvs pull |
| 350 | +
|
| 351 | +# is it ok? |
| 352 | +?cvs_nasty |
| 353 | +*git checkout cvsworking/BRANCH1 |
| 354 | +?cvs_nasty |
| 355 | +ACTIONS |
0 commit comments