fx

Check-in [69d2628ff2]
Login

Check-in [69d2628ff2]

Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed issue with the calculation of the file changeset of a commit, for databases with a schema >= 2015-01-24. The extended mlink records more information, forcing us to modify the query to filter out these new and unwanted entries. Plus two new test commands, "schema" and "mlink".
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 69d2628ff2570766bbe64a928fc6bcd9accfa659
User & Date: andreask 2015-02-10 22:09:14
Context
2015-02-12
00:48
Tweaked reporting of file changeset to note full number of edited, added, removed files, in the face of possible truncation. check-in: e04d83fed6 user: andreask tags: trunk
2015-02-10
22:09
Fixed issue with the calculation of the file changeset of a commit, for databases with a schema >= 2015-01-24. The extended mlink records more information, forcing us to modify the query to filter out these new and unwanted entries. Plus two new test commands, "schema" and "mlink". check-in: 69d2628ff2 user: andreask tags: trunk
2015-02-06
22:44
Extended the mail for internal errors. Making note of the repository the issue happened for. check-in: f398848f03 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/fossil.tcl.

31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
50
51
    namespace export fossil
    namespace ensemble create
}
namespace eval ::fx::fossil {
    namespace export \
	c_show_repository c_set_repository c_reset_repository \
	c_default_repository test-tags test-branch test-last-uuid \
	branch-of changeset date-of last-uuid reveal user-info \
	users user-config get-manifest fx-tables fx-maps \
	fx-map-keys fx-map-get fx-enums fx-enum-items ticket-title \
	ticket-fields global global-location show-global-location \
	repository repository-location show-repository-location \

	set-repository-location repository-find repository-open \
	global-has has empty global-empty exchange
	
    namespace ensemble create

    namespace import ::cmdr::color
    namespace import ::fx::atexit
    namespace import ::fx::table::do
    rename do table







|
|
|
|
|
>
|
|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    namespace export fossil
    namespace ensemble create
}
namespace eval ::fx::fossil {
    namespace export \
	c_show_repository c_set_repository c_reset_repository \
	c_default_repository test-tags test-branch test-last-uuid \
	test-schema test-mlink branch-of changeset date-of last-uuid \
	reveal user-info users user-config get-manifest fx-tables \
	fx-maps fx-map-keys fx-map-get fx-enums fx-enum-items \
	ticket-title ticket-fields global global-location \
	show-global-location repository repository-location \
	show-repository-location set-repository-location \
	repository-find repository-open global-has has empty \
	global-empty exchange schema has-ext-mlink
	
    namespace ensemble create

    namespace import ::cmdr::color
    namespace import ::fx::atexit
    namespace import ::fx::table::do
    rename do table
98
99
100
101
102
103
104
















105
106
107
108
109
110
111

proc ::fx::fossil::test-last-uuid {config} {
    debug.fx/fossil {}
    show-repository-location
    puts [last-uuid]
    return
}

















# # ## ### ##### ######## ############# ######################

proc ::fx::fossil::c_show_repository {config} {
    debug.fx/fossil {}
    show-repository-location
    return







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

proc ::fx::fossil::test-last-uuid {config} {
    debug.fx/fossil {}
    show-repository-location
    puts [last-uuid]
    return
}

proc ::fx::fossil::test-schema {config} {
    debug.fx/fossil {}
    show-repository-location
    puts [schema]
    return
}

proc ::fx::fossil::test-mlink {config} {
    debug.fx/fossil {}
    show-repository-location
    puts [expr {[has-ext-mlink]
		? "Extended mlink"
		: "Basic mlink"}]
    return
}

# # ## ### ##### ######## ############# ######################

proc ::fx::fossil::c_show_repository {config} {
    debug.fx/fossil {}
    show-repository-location
    return
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
    debug.fx/fossil {==> $uuid}
    return $uuid
}

proc ::fx::fossil::changeset {uuid} {
    debug.fx/fossil {}
    set r {}







    repository eval {
        SELECT filename.name AS thepath,
               CASE WHEN nullif(mlink.pid,0) is null THEN 'added'
                    WHEN nullif(mlink.fid,0) is null THEN 'deleted'
                    ELSE                                  'edited'
               END AS theaction
        FROM   mlink, filename, blob
        WHERE  mlink.mid  = blob.rid
	AND    blob.uuid = :uuid
        AND    mlink.fnid = filename.fnid

        ORDER BY filename.name
    } {
	dict lappend r $theaction $thepath
    }



















    return $r
}

proc ::fx::fossil::reveal {value} {
    debug.fx/fossil {}
    if {$value eq {}} { return $value }
    repository eval {







>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
730
731
732
733
734
735
    debug.fx/fossil {==> $uuid}
    return $uuid
}

proc ::fx::fossil::changeset {uuid} {
    debug.fx/fossil {}
    set r {}

    if {[has-ext-mlink]} {
	# An extended mlink table (having the "isaux" column) records
	# not just the changed files from the primary parent, but also
	# from any auxiliary parents (i.e. merged commits). We have to
	# exclude these records to get the proper change-set.

	repository eval {
	    SELECT filename.name AS thepath,
	    CASE WHEN nullif(mlink.pid,0) is null THEN 'added'
	    WHEN nullif(mlink.fid,0) is null THEN 'deleted'
	    ELSE                                  'edited'
	    END AS theaction
	    FROM   mlink, filename, blob
	    WHERE  mlink.mid  = blob.rid
	    AND    blob.uuid = :uuid
	    AND    mlink.fnid = filename.fnid
	    AND    NOT mlink.isaux
	    ORDER BY filename.name
	} {
	    dict lappend r $theaction $thepath
	}
    } else {
	# Regular mlink table, no extended data. Nothing to exclude.

	repository eval {
	    SELECT filename.name AS thepath,
	    CASE WHEN nullif(mlink.pid,0) is null THEN 'added'
	    WHEN nullif(mlink.fid,0) is null THEN 'deleted'
	    ELSE                                  'edited'
	    END AS theaction
	    FROM   mlink, filename, blob
	    WHERE  mlink.mid  = blob.rid
	    AND    blob.uuid = :uuid
	    AND    mlink.fnid = filename.fnid
	    ORDER BY filename.name
	} {
	    dict lappend r $theaction $thepath
	}
    }

    return $r
}

proc ::fx::fossil::reveal {value} {
    debug.fx/fossil {}
    if {$value eq {}} { return $value }
    repository eval {
722
723
724
725
726
727
728




















729
730
731
732
733
734
735
proc ::fx::fossil::users {} {
    debug.fx/fossil {}
    return [repository eval {
	SELECT login
	FROM user
    }]
}





















# # ## ### ##### ######## ############# ######################

proc ::fx::fossil::is {dir} {
    debug.fx/fossil {}
    foreach control {
	_FOSSIL_







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
proc ::fx::fossil::users {} {
    debug.fx/fossil {}
    return [repository eval {
	SELECT login
	FROM user
    }]
}

proc ::fx::fossil::schema {} {
    debug.fx/fossil {}
    return [repository one {
	SELECT value
	FROM   config
	WHERE name = 'aux-schema'
    }]
}

proc ::fx::fossil::has-ext-mlink {} {
    set result [repository one {
	SELECT 1
	FROM   sqlite_master
	WHERE  sql LIKE '%isaux%'
	AND    name = 'mlink'
    }]
    if {$result eq {}} { set result 0 }
    return $result
}

# # ## ### ##### ######## ############# ######################

proc ::fx::fossil::is {dir} {
    debug.fx/fossil {}
    foreach control {
	_FOSSIL_

Changes to lib/fx.tcl.

1811
1812
1813
1814
1815
1816
1817














1818
1819
1820
1821
1822
1823
1824
	    description {
		Determine the uuid of the last commit (on any branch).
		In other words, the uuid of the repository tip.
	    }
	    use .repository
	} [fx::call fossil test-last-uuid]
	alias tip = last-uuid














    }

    # # ## ### ##### ######## ############# ######################
    ## Developer support, debugging.

    officer debug {
	description {







>
>
>
>
>
>
>
>
>
>
>
>
>
>







1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
	    description {
		Determine the uuid of the last commit (on any branch).
		In other words, the uuid of the repository tip.
	    }
	    use .repository
	} [fx::call fossil test-last-uuid]
	alias tip = last-uuid

	private schema {
	    description {
		Determine the aux-schema of the repository.
	    }
	    use .repository
	} [fx::call fossil test-schema]

	private mlink {
	    description {
		Determine the state of the mlink table in the repository.
	    }
	    use .repository
	} [fx::call fossil test-mlink]
    }

    # # ## ### ##### ######## ############# ######################
    ## Developer support, debugging.

    officer debug {
	description {