Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added getChangedFiles APi to rev. Cleanup and testing of rev stuff. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
aef7106e32392470bb7a4d63a0b4ef1f |
User & Date: | peter 2018-05-14 21:11:15.308 |
Context
2018-05-14
| ||
21:12 | Make sure tmp files are deleted. check-in: 3e288e8b7d user: peter tags: trunk | |
21:11 | Added getChangedFiles APi to rev. Cleanup and testing of rev stuff. check-in: aef7106e32 user: peter tags: trunk | |
2018-05-13
| ||
08:02 | Refactor fourway code check-in: 97e70bc905 user: peter tags: trunk | |
Changes
Changes to src/rev.tcl.
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # eskil::rev::XXX::getPatch {revs {files {}}} # # Get a patch of the file tree, between the revisions given. # revs is in any format understood by this system, and # should be retrieved from ParseRevs # An optional list of files that should be included can be given. # eskil::rev::XXX::commitFile {top args} # # If implemented, enables the commit feature when comparing edited # file(s) agains latest check in. # If no files are given, all edited files are committed. | > > > > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # eskil::rev::XXX::getPatch {revs {files {}}} # # Get a patch of the file tree, between the revisions given. # revs is in any format understood by this system, and # should be retrieved from ParseRevs # An optional list of files that should be included can be given. # Note that current directory must be correct before calling. # eskil::rev::XXX::getChangedFiles {dir revs} # # Get a list of files changed between the revisions given. # revs is in any format understood by this system, and # should be retrieved from ParseRevs # eskil::rev::XXX::commitFile {top args} # # If implemented, enables the commit feature when comparing edited # file(s) agains latest check in. # If no files are given, all edited files are committed. |
︙ | ︙ | |||
179 180 181 182 183 184 185 186 187 188 189 190 191 192 | proc eskil::rev::P4::detect {file} { if {[auto_execok icmp4] != ""} { if {[catch {exec csh -c "icmp4 have $file"} p4have]} { return 0 } if {[lindex $p4have 1] eq "-"} { return 1 } } return 0 } # Get a CVS revision proc eskil::rev::CVS::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | proc eskil::rev::P4::detect {file} { if {[auto_execok icmp4] != ""} { if {[catch {exec csh -c "icmp4 have $file"} p4have]} { return 0 } if {[lindex $p4have 1] eq "-"} { return 1 } } return 0 } # Find the repo top dir given a file/dir reference. # Return the tail relative to top dir. # cands is a list of candidates for top marker proc GetTopDirCand {ref cands dirName tailName} { upvar 1 $dirName dir $tailName tail if {[file isdirectory $ref]} { set dir $ref set tail "" } else { set dir [file dirname $ref] set tail [file tail $ref] } # Locate the top directory while {[file readable $dir] && [file isdirectory $dir]} { set found 0 foreach candidate $cands { if {[file exists [file join $dir $candidate]]} { set found 1 break } } if {$found} break set parent [file dirname $dir] # Make sure to stop if we reach a dead end if {$parent eq $dir} break set tail [file join [file tail $dir] $tail] set dir $parent } } # Find the repo top dir given a file/dir reference. # Return the tail relative to top dir. proc eskil::rev::SVN::GetTopDir {ref dirName tailName} { upvar 1 $dirName dir $tailName tail GetTopDirCand $ref .svn dir tail } # Find the repo top dir given a file/dir reference. # Return the tail relative to top dir. proc eskil::rev::GIT::GetTopDir {ref dirName tailName} { upvar 1 $dirName dir $tailName tail GetTopDirCand $ref .git dir tail } # Find the repo top dir given a file/dir reference. # Return the tail relative to top dir. proc eskil::rev::HG::GetTopDir {ref dirName tailName} { upvar 1 $dirName dir $tailName tail GetTopDirCand $ref .hg dir tail } # Find the repo top dir given a file/dir reference. # Return the tail relative to top dir. proc eskil::rev::FOSSIL::GetTopDir {ref dirName tailName} { upvar 1 $dirName dir $tailName tail GetTopDirCand $ref ".fos .fslckout _FOSSIL_" dir tail } # Get a CVS revision proc eskil::rev::CVS::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] |
︙ | ︙ | |||
228 229 230 231 232 233 234 235 236 237 238 239 240 241 | if {![string match "*=========*" $res]} { tk_messageBox -icon error -title "CVS error" -message $res return "" } } return $res } # Get a SVN revision proc eskil::rev::SVN::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] | > > > > > | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | if {![string match "*=========*" $res]} { tk_messageBox -icon error -title "CVS error" -message $res return "" } } return $res } proc eskil::rev::CVS::getChangedFiles {dir revs} { # Not supported yet return "" } # Get a SVN revision proc eskil::rev::SVN::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] |
︙ | ︙ | |||
328 329 330 331 332 333 334 335 336 337 338 339 340 341 | if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "SVN error" -message $res return "" } return $res } # Get a HG revision proc eskil::rev::HG::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "SVN error" -message $res return "" } return $res } proc eskil::rev::SVN::getChangedFiles {dir revs} { # Must call SVN in top dir to get full changeset GetTopDir $dir top tail set cmd [list execDir $top svn diff --summarize] set revs2 {} foreach rev $revs { # TODO: What happens in strange combinations ? if {[string match "*://*" $rev]} { # Full URL lappend cmd $rev } else { lappend revs2 $rev } } if {[llength $revs2] > 0} { lappend cmd -r [join $revs2 :] } if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "SVN error" -message $res return "" } # Result is one file per line, with an info word before set files {} foreach line [split $res \n] { if {[regexp {^\S+\s+(.*)} $line -> f]} { lappend files [file join $top $f] } } return $files } # Get a HG revision proc eskil::rev::HG::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] |
︙ | ︙ | |||
370 371 372 373 374 375 376 377 378 379 380 381 382 383 | if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "HG error" -message $res return "" } return $res } # Get a BZR revision proc eskil::rev::BZR::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] | > > > > > > > > > > > > > > > > > > > > > > | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "HG error" -message $res return "" } return $res } proc eskil::rev::HG::getChangedFiles {dir revs} { set cmd [list execDir $dir hg diff --stat] foreach rev $revs { lappend cmd -r $rev } if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "HG error" -message $res return "" } # Result is one file per line, with an info word before GetTopDir $dir top tail set files {} foreach line [split $res \n] { if {[regexp {(.+)\|} $line -> f]} { set f [string trim $f] lappend files [file join $top $f] } } return $files } # Get a BZR revision proc eskil::rev::BZR::get {filename outfile rev} { set old "" set dir [file dirname $filename] if {$dir != "."} { set old [pwd] |
︙ | ︙ | |||
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | if {![string match "*===*" $res]} { tk_messageBox -icon error -title "BZR error" -message $res return "" } } return $res } # Get an RCS revision proc eskil::rev::RCS::get {filename outfile {rev {}}} { catch {exec co -p$rev [file nativename $filename] \ > $outfile} } # Get a RCS patch proc eskil::rev::RCS::getPatch {revs {files {}}} { # Not supported yet. return "" } # Get a GIT revision # No support for revisions yet proc eskil::rev::GIT::get {filename outfile rev} { | > > > > > > > > > > < < | < < < < < < < | < < < | < < < < < < < | < | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | if {![string match "*===*" $res]} { tk_messageBox -icon error -title "BZR error" -message $res return "" } } return $res } proc eskil::rev::BZR::getChangedFiles {dir revs} { # Not supported yet return "" } # Get an RCS revision proc eskil::rev::RCS::get {filename outfile {rev {}}} { catch {exec co -p$rev [file nativename $filename] \ > $outfile} } # Get a RCS patch proc eskil::rev::RCS::getPatch {revs {files {}}} { # Not supported yet. return "" } proc eskil::rev::RCS::getChangedFiles {dir revs} { # Not supported yet. return "" } # Get a GIT revision # No support for revisions yet proc eskil::rev::GIT::get {filename outfile rev} { GetTopDir $filename dir tail if {$rev eq ""} { set rev HEAD } catch {execDir $dir git show $rev:$tail > $outfile} # example: git show HEAD^^^:apa } # Add file to GIT index proc eskil::rev::GIT::add {filename} { GetTopDir $filename dir tail catch {execDir $dir git add $tail} } # Get a GIT patch proc eskil::rev::GIT::getPatch {revs {files {}}} { set cmd [list exec git diff -p] if {[llength $revs] == 0} { # Always default to HEAD to see changes regardless of index |
︙ | ︙ | |||
485 486 487 488 489 490 491 492 | if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "GIT error" -message $res return "" } return $res } | | < | | > | | | | > > > | | > > > > | | > | > > | > > > > | | < | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "GIT error" -message $res return "" } return $res } # Get a GIT change set proc eskil::rev::GIT::getChangedFiles {dir revs} { set cmd [list execDir $dir git diff --name-only] if {[llength $revs] == 0} { # Always default to HEAD to see changes regardless of index lappend cmd HEAD } else { foreach rev $revs { lappend cmd $rev } } if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "GIT error" -message $res return "" } # Result is one file per line, relative to repo GetTopDir $dir top tail set files {} foreach line [split $res \n] { lappend files [file join $top $line] } return $files } # Get a FOSSIL revision # No support for revisions yet proc eskil::rev::FOSSIL::get {filename outfile rev} { GetTopDir $filename dir tail if {$rev eq "HEAD" || $rev eq ""} { catch {execDir $dir fossil finfo -p $tail > $outfile} } else { catch {execDir $dir fossil finfo -p $tail -r $rev > $outfile} } } # Get a FOSSIL patch proc eskil::rev::FOSSIL::getPatch {revs {files {}}} { set cmd [list exec fossil diff] if {[llength $revs] >= 1} { |
︙ | ︙ | |||
534 535 536 537 538 539 540 | return "" } # Fake the per-file rows append res "Index: $file\n==================================\n" append res $fres } } else { | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | return "" } # Fake the per-file rows append res "Index: $file\n==================================\n" append res $fres } } else { # Include added files contents lappend cmd -N if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "FOSSIL error" -message $res return "" } } return $res } proc eskil::rev::FOSSIL::getChangedFiles {dir revs} { set cmd [list execDir $dir fossil diff] if {[llength $revs] >= 1} { lappend cmd --from [lindex $revs 0] } if {[llength $revs] >= 2} { lappend cmd --to [lindex $revs 1] } lappend cmd --brief if {[catch {eval $cmd} res]} { tk_messageBox -icon error -title "FOSSIL error" -message $res return "" } # Result is one file per line, with an info word before GetTopDir $dir top tail set files {} foreach line [split $res \n] { regexp {\S+\s+(.*)} $line -> f lappend files [file join $top $f] } return $files } # Get a ClearCase revision proc eskil::rev::CT::get {filename outfile rev} { set filerev [file nativename $filename@@$rev] if {[catch {exec cleartool get -to $outfile $filerev} msg]} { tk_messageBox -icon error -title "Cleartool error" -message $msg return } } # Get a CT patch proc eskil::rev::CT::getPatch {revs {files {}}} { # Not supported yet return "" } proc eskil::rev::CT::getChangedFiles {dir revs} { # Not supported yet return "" } # Get a P4 revision proc eskil::rev::P4::get {filename outfile rev} { set dir [file dirname $filename] if {[catch {exec csh -c "icmp4 print -q $filename\\#$rev" > $outfile} msg]} { tk_messageBox -icon error -title "P4 error" -message $msg return |
︙ | ︙ | |||
652 653 654 655 656 657 658 659 660 661 662 663 664 665 | if {[regexp {r(\d+)} $line -> rev]} { lappend revs $rev } } } return $revs } # Return revision list of a GIT file proc eskil::rev::GIT::GetRevList {filename} { set old "" set cmd [list exec git log --first-parent --oneline -n 50] if {$filename eq ""} { # Nothing | > > > > > > > > > > > > > > > > > > > > > | 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | if {[regexp {r(\d+)} $line -> rev]} { lappend revs $rev } } } return $revs } # Return revision list of a HG file proc eskil::rev::HG::GetRevList {filename} { if {$filename eq ""} { set cmd [list exec hg log -q -l 50] } else { set cmd [list exec hg log -q -l 50 [file nativename $filename]] } if {[catch {eval $cmd} res]} { # What to do here? set revs [list 1] } else { set revs {} foreach line [split $res \n] { if {[regexp {^(\d+):} $line -> rev]} { lappend revs $rev } } } return $revs } # Return revision list of a GIT file proc eskil::rev::GIT::GetRevList {filename} { set old "" set cmd [list exec git log --first-parent --oneline -n 50] if {$filename eq ""} { # Nothing |
︙ | ︙ | |||
689 690 691 692 693 694 695 | } return $revs } # Return revision list of a FOSSIL file proc eskil::rev::FOSSIL::GetRevList {filename} { # Keep on current branch | | | | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | } return $revs } # Return revision list of a FOSSIL file proc eskil::rev::FOSSIL::GetRevList {filename} { # Keep on current branch set x [execDir $filename fossil branch list] if { ! [regexp -line {^\* (.*)$} $x -> branch]} { set branch "" } # First, traverse timeline to get a set of ancestor checkins on the # current branch set x [execDir $filename fossil timeline ancestors current -t ci -n 5000] set ancestors {} set lines "" set currentArtefact "" foreach line [split $x \n] { # Recognise the first line of each checkin if {[regexp {^\d\d:\d\d:\d\d \[(\w+)\]} $line -> newArtefact]} { # Check the accumulated lines before this for tags |
︙ | ︙ | |||
733 734 735 736 737 738 739 | if {[file isdirectory $filename]} { # Just use the ancestors as is. TBD to filter this for a sub directory return [dict keys $ancestors] } # Now get all commits on the file. If finfo had a tag filter, # this would be much easier. | | | 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 | if {[file isdirectory $filename]} { # Just use the ancestors as is. TBD to filter this for a sub directory return [dict keys $ancestors] } # Now get all commits on the file. If finfo had a tag filter, # this would be much easier. set x [execDir $filename fossil finfo -l -b $filename] set fAncestors {} foreach line [split $x \n] { if {[regexp {^(\w+)} $line -> artefact]} { if {[dict exists $ancestors $artefact]} { lappend fAncestors $artefact } } |
︙ | ︙ | |||
794 795 796 797 798 799 800 | if {[string is integer -strict $rev] && $rev < 0} { # A negative integer rev is a relative rev set revList [eskil::rev::FOSSIL::GetRevList $filename] set rev [lindex $revList [- $rev]] if {$rev eq ""} { | | | > | | > > > | > | < | | 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | if {[string is integer -strict $rev] && $rev < 0} { # A negative integer rev is a relative rev set revList [eskil::rev::FOSSIL::GetRevList $filename] set rev [lindex $revList [- $rev]] if {$rev eq ""} { set rev [lindex $revList end] } } # Let anything else through lappend result $rev } return $result } # Figure out HG revision from arguments proc eskil::rev::HG::ParseRevs {filename revs} { set result "" foreach rev $revs { # Shortcut to HG special names if {$rev eq "_" || $rev eq "0"} {set rev tip} if {[string is integer -strict $rev] && $rev < 0} { # A negative integer rev is a relative rev set revList [eskil::rev::HG::GetRevList $filename] set rev [lindex $revList [- $rev]] if {$rev eq ""} { set rev [lindex $revList end] } } lappend result $rev } return $result } # Figure out BZR revision from arguments proc eskil::rev::BZR::ParseRevs {filename revs} { |
︙ | ︙ | |||
921 922 923 924 925 926 927 | # Use BASE since SVN then knows to use the local copy and avoid # server calls. set rev BASE #set rev [eskil::rev::SVN::GetCurrent $filename] } elseif {[string is integer -strict $rev] && $rev <= 0} { # Zero means current # A negative integer rev is a relative rev | < < < < < < | | | | | | | | | | | | < | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 | # Use BASE since SVN then knows to use the local copy and avoid # server calls. set rev BASE #set rev [eskil::rev::SVN::GetCurrent $filename] } elseif {[string is integer -strict $rev] && $rev <= 0} { # Zero means current # A negative integer rev is a relative rev # Get a list from the log if {$filename eq ""} { set filename "." } if {$Url ne ""} { set revs [eskil::rev::SVN::GetRevList $Url] } else { set revs [eskil::rev::SVN::GetRevList $filename] } set rev [lindex $revs [- $rev]] if {$rev eq ""} { set rev [lindex $revs end] } } if {$Url ne ""} { if {$rev ne ""} { append Url @$rev } lappend result $Url |
︙ | ︙ | |||
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 | if {[$::widgets($top,log) cget -state] eq "disabled"} return set type $::eskil($top,modetype) eskil::rev::${type}::viewLog $top $::eskil($top,RevFile) \ $::eskil($top,RevRevs) } # Get a complete tree patch from this system. proc getFullPatch {top} { $::widgets($top,commit) configure -state disabled $::widgets($top,revert) configure -state disabled $::widgets($top,log) configure -state disabled set type $::eskil($top,modetype) set files $::eskil($top,reviewFiles) | > | 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | if {[$::widgets($top,log) cget -state] eq "disabled"} return set type $::eskil($top,modetype) eskil::rev::${type}::viewLog $top $::eskil($top,RevFile) \ $::eskil($top,RevRevs) } # Get a complete tree patch from this system. # Note that current directory must be correct before calling. proc getFullPatch {top} { $::widgets($top,commit) configure -state disabled $::widgets($top,revert) configure -state disabled $::widgets($top,log) configure -state disabled set type $::eskil($top,modetype) set files $::eskil($top,reviewFiles) |
︙ | ︙ | |||
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 | return [eskil::rev::${type}::getPatch $revs $files] } ############################################################################## # Utilities ############################################################################## # Search upwards the directory structure for a file proc SearchUpwardsFromFile {file args} { if {$file eq ""} { set dir [pwd] } elseif {[file isdirectory $file]} { set dir $file | > > > > > > > > > > > > > > > > | 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 | return [eskil::rev::${type}::getPatch $revs $files] } ############################################################################## # Utilities ############################################################################## # Execute a command within a specific dir as pwd proc execDir {dir args} { set old [pwd] if {[file isdirectory $dir]} { cd $dir } else { # A file may be given as reference cd [file dirname $dir] } try { exec {*}$args } finally { cd $old } } # Search upwards the directory structure for a file proc SearchUpwardsFromFile {file args} { if {$file eq ""} { set dir [pwd] } elseif {[file isdirectory $file]} { set dir $file |
︙ | ︙ |
Changes to tests/rev.test.
︙ | ︙ | |||
300 301 302 303 304 305 306 | tcltest::removeFile {} _rev2_12 } -result {FOSSIL} test rev-3.1 { Subversion revisions } -body { eskil::rev::SVN::ParseRevs filename -1 | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 {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 } |