Fossil

Check-in [df4435bf]
Login

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

Overview
Comment:Optimised and simplified the exporter. Haven't figured out how to make the imported tree match up with its parent commit yet.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dtrg-bundles
Files: files | file ages | folders
SHA1:df4435bf4d9e035ced8113690d9e48b5f7811496
User & Date: dg 2014-10-18 21:40:33
Context
2014-10-18
22:13
More simplification; now correctly handles branches in newrepo (i.e. only the desired branch is exported). Closed-Leaf check-in: 22048c41 user: dg tags: dtrg-bundles
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/exportbundle.sh.

5
6
7
8
9
10
11



12
13
14
15
16
17
18
..
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
# 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

................................................................................
		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,







>
>
>







 







|












|


>
>
>
>





|
>

<
<
<
<
<
<
<
<
<
<
<
<
<
|

|


|

|

|
|
|
|







|

|

|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
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
# 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.
#
# To import, simple clone oldrepo (or not, if you're feeling brave);
# then fossil import --incremental the bundle.

set -e

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

................................................................................
		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 what checkins need to go into the bundle.

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, ancestors
			ON
				newcheckinmap.child = ancestors.id
			WHERE
				-- Filter to include checkins which *aren't* in oldrepo.
				NOT EXISTS(SELECT * FROM oldcheckinmap WHERE
					oldcheckinmap.child = newcheckinmap.parent)
			ORDER BY
				newcheckinmap.mtime DESC
	  )
	SELECT * FROM ancestors;

-- Now we know what checkins are going in the bundle, figure out which
-- files get included.














CREATE TEMPORARY VIEW desiredfiles AS
	SELECT
		newfiles.file AS id
	FROM
		newfiles,
		desiredcheckins
	WHERE
		newfiles.checkin = desiredcheckins.id;

-- Because this prototype is using the git 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 desiredcheckins
	ON
		desiredcheckins.id = oldcheckins.id
	WHERE
		desiredcheckins.id IS NULL
	ORDER BY
		rid ASC;

CREATE TEMPORARY VIEW skipfilerids AS
	SELECT
		"b" || newfiles.rid AS msg,
		newfiles.rid AS rid,