Fossil

Check-in [f809eb4c]
Login

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

Overview
Comment:First mostly-working version of the bundle proof-of-concept; trees can be exported and imported, although after import they don't hook up with their ancestors.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dtrg-bundles
Files: files | file ages | folders
SHA1:f809eb4c1abd6af870d576976ba699acfbe6f55f
User & Date: dg 2014-10-18 19:26:29
Context
2014-10-18
21:40
Optimised and simplified the exporter. Haven't figured out how to make the imported tree match up with its parent commit yet. check-in: df4435bf user: dg tags: dtrg-bundles
19:26
First mostly-working version of the bundle proof-of-concept; trees can be exported and imported, although after import they don't hook up with their ancestors. check-in: f809eb4c user: dg tags: dtrg-bundles
19:18
Enhance the "fossil timeline" command so that one can specify a file or directory as a command-line argument and the timeline only shows check-ins that involve that particular file or any of the files in the named directory. check-in: e05a74f1 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added test/make-bundle-data.sh.























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
# This script creates the two repositories used by the bundle test tools.
# Syntax: make-bundle-data.sh oldrepo.fossil newrepo.fossil
# Warning! The two repositories will be *destroyed*!

set -e -x

oldrepo=$(readlink -f "$1")
newrepo=$(readlink -f "$2")

tmpdir=/tmp/$$.make-bundle-data

rm -rf $oldrepo $newrepo $tmpdir
fossil init $oldrepo
mkdir $tmpdir
(cd $tmpdir && fossil open $oldrepo && fossil settings -R $oldrepo autosync off)
(cd $tmpdir && echo "empty" > 1 && fossil add 1 && fossil commit -m "Empty")
(cd $tmpdir && echo "data" >> 1 && fossil commit -m "Add: data")
(cd $tmpdir && echo "more data" >> 1 && fossil commit -m "Add: more data")

fossil clone $oldrepo $newrepo
rm -rf $tmpdir
mkdir $tmpdir
(cd $tmpdir && fossil open $newrepo && fossil settings -R $oldrepo autosync off)
(cd $tmpdir && echo "even more data" >> 1 && fossil commit -m "Clone, add: even more data")
(cd $tmpdir && echo "new file" > 2 && fossil add 2 && fossil commit -m "New file")

Added tools/exportbundle.sh.



















































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh
# This is a very, very prototype proof-of-concept tool to generate 'push
# requests'. It diffs two repositories (currently only local ones) and
# generates a bundle which contains all the artifacts needed to
# reproduce a particular artifact.
# 
# The intended workflow is: user says 'I want to make a bundle to update
# OLD.fossil to checkin X of NEW.fossil'; the tool walks the checkin tree
# of NEW.fossil to figure out what checkins are necessary to reproduce X;
# then it removes all the checkins which are present in OLD.fossil; then
# it emits the bundle.

set -e

oldrepo=$1
newrepo=$2
artifact=$3

ridlist=ridlist

fossil sqlite3 >$ridlist <<-EOF

ATTACH DATABASE "$newrepo" AS new;
ATTACH DATABASE "$oldrepo" AS old;

-- Map of parent -> child checkin artifacts. This contains our checkin graph.

CREATE TEMPORARY VIEW newcheckinmap AS
	SELECT
		child.uuid AS child,
		child.rid AS rid,
		parent.uuid AS parent,
		parent.rid AS parentrid,
		plink.mtime AS mtime
	FROM
		new.plink,
		new.blob AS parent,
		new.blob AS child
	WHERE
		(child.rid = plink.cid)
		AND (parent.rid = plink.pid);
	
CREATE TEMPORARY VIEW oldcheckinmap AS
	SELECT
		child.uuid AS child,
		child.rid AS rid,
		parent.uuid AS parent,
		parent.rid AS parentrid,
		plink.mtime AS mtime
	FROM
		old.plink,
		old.blob AS parent,
		old.blob AS child
	WHERE
		(child.rid = plink.cid)
		AND (parent.rid = plink.pid);
	
-- Create sets of all checkins (unordered). We construct these from the graph
-- so we get only checkin artifacts.

CREATE TEMPORARY VIEW newcheckins AS
	SELECT parent AS id, parentrid AS rid FROM newcheckinmap
	UNION
	SELECT child AS id, rid AS rid FROM newcheckinmap;

CREATE TEMPORARY VIEW oldcheckins AS
	SELECT parent AS id, parentrid AS rid FROM oldcheckinmap
	UNION
	SELECT child AS id, rid AS rid FROM oldcheckinmap;

-- Now create maps of checkin->file artifacts.

CREATE TEMPORARY VIEW newfiles AS
	SELECT
		checkin.uuid AS checkin,
		file.uuid AS file,
		file.rid AS rid
	FROM
		new.mlink,
		new.blob AS checkin,
		new.blob AS file
	WHERE
		(checkin.rid = mlink.mid)
		AND (file.rid = mlink.fid);

-- Walk the tree and figure out all the ancestors of the desired artifact.

CREATE TEMPORARY VIEW desiredcheckins AS
	WITH RECURSIVE
	  ancestors(id, mtime) AS (
			SELECT child AS id, mtime
			FROM newcheckinmap
			WHERE child LIKE "$artifact%"
		UNION 
			SELECT
				newcheckinmap.parent AS id,
				newcheckinmap.mtime
			FROM
				newcheckinmap INNER JOIN ancestors
			ON
				newcheckinmap.child = ancestors.id
			ORDER BY
				newcheckinmap.mtime DESC
	  )
	SELECT * FROM ancestors;

-- The set of checkins and files for newrepo's artifact which *aren't* in oldrepo.

CREATE TEMPORARY VIEW checkinsnotinnew AS
	SELECT
		desiredcheckins.id
	FROM
		desiredcheckins LEFT JOIN oldcheckins
	ON
		desiredcheckins.id = oldcheckins.id
	WHERE
		oldcheckins.id IS NULL;

CREATE TEMPORARY VIEW checkinsforbundle AS
	SELECT * FROM checkinsnotinnew;

CREATE TEMPORARY VIEW filesforbundle AS
	SELECT
		newfiles.file
	FROM
		newfiles,
		checkinsforbundle
	WHERE
		newfiles.checkin = checkinsforbundle.id;

-- Because this prototype is using the exporter to create bundles, and the
-- exporter's ability to select artifacts is based on having a list of rids
-- to ignore, we have to emit a list of all rids in newrepo which don't
-- correspond to the list above.

CREATE TEMPORARY VIEW skipcheckinrids AS
	SELECT
		"c" || oldcheckins.rid AS msg,
		oldcheckins.rid AS rid,
		oldcheckins.id AS id
	FROM
		oldcheckins LEFT JOIN checkinsforbundle
	ON
		checkinsforbundle.id = oldcheckins.id
	WHERE
		checkinsforbundle.id IS NULL
	ORDER BY
		rid ASC;

CREATE TEMPORARY VIEW skipfilerids AS
	SELECT
		"b" || newfiles.rid AS msg,
		newfiles.rid AS rid,
		newfiles.file AS id
	FROM
		newfiles, skipcheckinrids
	WHERE
		newfiles.checkin = skipcheckinrids.id
	ORDER BY
		rid ASC;

SELECT msg FROM skipfilerids
UNION
SELECT msg FROM skipcheckinrids;

EOF

fossil export --git --import-marks $ridlist $newrepo

Added tools/importbundle.sh.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
# Imports a bundle which has been exported with exportbundle.
# Syntax: exportbundle.sh oldrepo.fossil newrepo.fossil data.bundle

set -e

oldrepo="$1"
newrepo="$2"
bundle="$3"

fossil clone $oldrepo $newrepo
fossil import --incremental $newrepo < $bundle