Eskil

Diff
Login

Differences From Artifact [ed06ba24e1]:

To Artifact [f70f891b1a]:


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
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
664
665







-
+





+





-
+














-
+
+
+
+
+
+







-
+







    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 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
            if {[regexp {tags:\s+([^\)]+)} $lines -> tags]} {
                if {$branch eq ""} {
                    set branch [lindex $tags 0]
                }
                if {$branch in $tags} {
                    set ancestors($currentArtefact) 1
                    dict 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"
    #puts "Found [dict size $ancestors] ancestors in timeline"

    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 [exec fossil finfo -l -b $filename]
    set fAncestors {}
    foreach line [split $x \n] {
        if {[regexp {^(\w+)} $line -> artefact]} {
            if {[info exists ancestors($artefact)]} {
            if {[dict exists $ancestors $artefact]} {
                lappend fAncestors $artefact
            }
        }
    }
    #puts "Found [llength $fAncestors] ancestors for file"
    #puts [join $fAncestors \n]
    return $fAncestors