300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
tcltest::removeFile {} _rev2_12
} -result {FOSSIL}
test rev-3.1 {
Subversion revisions
} -body {
eskil::rev::SVN::ParseRevs filename -1
} -result {157}
} -result {117}
test rev-3.2 {
Subversion revisions
} -body {
eskil::rev::SVN::ParseRevs filename -2
} -result {115}
test rev-3.3 {
Subversion revisions
} -body {
eskil::rev::SVN::ParseRevs filename 0
} -result {BASE}
# Tests below tries to use the real tools and temporary repos.
# They are dependent on running on a system with tools installed.
clearstub
proc Fill1 {} {
cd $::work
file mkdir dir1
file mkdir dir2
exec touch f1
exec touch f2
exec touch dir1/f11
exec touch dir1/f12
exec touch dir2/f21
exec touch dir2/f22
}
proc Fill2 {} {
cd $::work
exec echo Hej > f1
exec echo Hopp > f2
}
proc Fill3 {} {
cd $::work
exec echo Nisse > dir1/f11
exec echo Hult > dir2/f21
exec echo Lingonben >> f1
}
proc CreateRepo {type} {
set repoDir [tmpFile]
file mkdir $repoDir
switch $type {
FOSSIL {
set repo $repoDir/apa.fossil
set ::work $repoDir/wk
exec fossil new $repo
file mkdir $::work
cd $::work
exec fossil open $repo
set cmt "fossil commit -m"
}
GIT {
set ::work $repoDir
file mkdir $::work
cd $::work
exec git init
set cmt "git commit -am"
}
SVN {
exec svnadmin create $repoDir
set ::work [tmpFile]
exec svn checkout file://$repoDir $::work
cd $::work
set cmt "svn commit -m"
}
HG {
set ::work $repoDir
file mkdir $::work
cd $::work
exec hg init
set cmt "hg commit -u Eskil -m"
}
default { error MOO }
}
Fill1
switch $type {
FOSSIL { exec fossil addremove }
GIT { exec git add *}
SVN { exec svn add {*}[glob *]}
HG { exec hg add {*}[glob *]}
}
exec {*}$cmt "First"
Fill2
exec {*}$cmt "Second"
Fill3
exec {*}$cmt "Third"
# Any cleanup?
switch $type {
SVN { exec svn update }
}
}
foreach type {FOSSIL GIT SVN HG} {
test rev-4.$type.1 {
Setup fake repo
} -body {
CreateRepo $type
# Dump info for debug of setup
if 0 {
switch $type {
FOSSIL { puts [exec fossil timeline -v] }
GIT { puts [exec git log --name-only] }
SVN { puts [exec svn log --verbose] }
}
}
list
}
test rev-4.$type.2 {
GetTopDir
} -body {
cd ~
eskil::rev::${type}::GetTopDir $::work/dir1/f11 dir tail
list [expr {$dir eq $::work}] $tail
} -result {1 dir1/f11}
test rev-4.$type.3 {
get
} -body {
cd ~
set out [tmpFile]
eskil::rev::${type}::get $::work/dir1/f11 $out ""
exec cat $out
} -result {Nisse}
test rev-4.$type.4 {
getChangedFiles
} -body {
cd ~
set f $::work/dir1/f11
set revs [eskil::rev::${type}::ParseRevs $f "-1 0"]
lsort -dictionary [eskil::rev::${type}::getChangedFiles $f $revs]
} -match regexp -result {^/\S+/dir1/f11 /\S+/dir2/f21 /\S+/f1 /\S+/f2$}
test rev-4.$type.5 {
getChangedFiles
} -body {
cd ~
set f $::work/f1
set revs [eskil::rev::${type}::ParseRevs $f "-1 0"]
lsort -dictionary [eskil::rev::${type}::getChangedFiles $f $revs]
} -match regexp -result {^/\S+/dir1/f11 /\S+/dir2/f21 /\S+/f1$}
clearTmp
}
|