595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
595
596
597
598
599
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
if {[regexp {r(\d+)} $line -> rev]} {
lappend revs $rev
}
}
}
return $revs
}
# Return revision list of a FOSSIL file
proc eskil::rev::FOSSIL::GetRevList {filename} {
# Keep on current branch
set x [exec 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 [exec fossil timeline ancestors current -t ci -n 5000]
array 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]} {
if {[regexp {tags:\s+([^\)]+)} $lines -> tags]} {
if {$branch eq ""} {
set branch [lindex $tags 0]
}
if {$branch in $tags} {
set ancestors($currentArtefact) 1
}
}
set currentArtefact $newArtefact
set lines [string trim $line]
} else {
set line [string trim $line]
if {[string index $lines end] eq "-"} {
append lines $line
} else {
append lines \n$line
}
}
}
puts "Assuming branch '$branch'"
puts "Found [array size ancestors] ancestors in timeline"
# Now get all commits on the file. If finfo had a tag filter,
# this would be much easier.
set x [exec fossil finfo -l -b $filename]
set fAncestors {}
foreach line [split $x \n] {
if {[regexp {^(\w+)} $line -> artefact]} {
if {[info exists ancestors($artefact)]} {
lappend fAncestors $artefact
}
}
}
puts "Found [llength $fAncestors] ancestors for file"
puts [join $fAncestors \n]
return $fAncestors
}
# Figure out RCS revision from arguments
proc eskil::rev::RCS::ParseRevs {filename revs} {
if {$filename eq ""} {
# RCS does not support tree versions
return {}
}
|
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
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
|
-
-
-
+
+
+
+
+
+
+
+
+
|
return $result
}
# Figure out FOSSIL revision from arguments
proc eskil::rev::FOSSIL::ParseRevs {filename revs} {
set result ""
foreach rev $revs {
switch -glob -- $rev {
HEAD - master - * { # Let anything through for now FIXA
lappend result $rev
if {[string is integer -strict $rev] && $rev < 0} {
# A negative integer rev is a relative rev
set revs [eskil::rev::FOSSIL::GetRevList $filename]
set rev [lindex $revs [- $rev]]
if {$rev eq ""} {
set rev [lindex $revs end]
}
}
# Let anything through for now FIXA
lappend result $rev
}
return $result
}
# Figure out HG revision from arguments
proc eskil::rev::HG::ParseRevs {filename revs} {
set result ""
|