Fossil SCM

Optimised and simplified the exporter. Haven't figured out how to make the imported tree match up with its parent commit yet.

dg 2014-10-18 21:40 dtrg-bundles
Commit df4435bf4d9e035ced8113690d9e48b5f7811496
1 file changed +24 -23
--- tools/exportbundle.sh
+++ tools/exportbundle.sh
@@ -7,10 +7,13 @@
77
# The intended workflow is: user says 'I want to make a bundle to update
88
# OLD.fossil to checkin X of NEW.fossil'; the tool walks the checkin tree
99
# of NEW.fossil to figure out what checkins are necessary to reproduce X;
1010
# then it removes all the checkins which are present in OLD.fossil; then
1111
# it emits the bundle.
12
+#
13
+# To import, simple clone oldrepo (or not, if you're feeling brave);
14
+# then fossil import --incremental the bundle.
1215
1316
set -e
1417
1518
oldrepo=$1
1619
newrepo=$2
@@ -81,11 +84,11 @@
8184
new.blob AS file
8285
WHERE
8386
(checkin.rid = mlink.mid)
8487
AND (file.rid = mlink.fid);
8588
--- Walk the tree and figure out all the ancestors of the desired artifact.
89
+-- Walk the tree and figure out what checkins need to go into the bundle.
8690
8791
CREATE TEMPORARY VIEW desiredcheckins AS
8892
WITH RECURSIVE
8993
ancestors(id, mtime) AS (
9094
SELECT child AS id, mtime
@@ -94,58 +97,50 @@
9497
UNION
9598
SELECT
9699
newcheckinmap.parent AS id,
97100
newcheckinmap.mtime
98101
FROM
99
- newcheckinmap INNER JOIN ancestors
102
+ newcheckinmap, ancestors
100103
ON
101104
newcheckinmap.child = ancestors.id
105
+ WHERE
106
+ -- Filter to include checkins which *aren't* in oldrepo.
107
+ NOT EXISTS(SELECT * FROM oldcheckinmap WHERE
108
+ oldcheckinmap.child = newcheckinmap.parent)
102109
ORDER BY
103110
newcheckinmap.mtime DESC
104111
)
105112
SELECT * FROM ancestors;
106113
--- The set of checkins and files for newrepo's artifact which *aren't* in oldrepo.
107
-
108
-CREATE TEMPORARY VIEW checkinsnotinnew AS
109
- SELECT
110
- desiredcheckins.id
111
- FROM
112
- desiredcheckins LEFT JOIN oldcheckins
113
- ON
114
- desiredcheckins.id = oldcheckins.id
115
- WHERE
116
- oldcheckins.id IS NULL;
117
-
118
-CREATE TEMPORARY VIEW checkinsforbundle AS
119
- SELECT * FROM checkinsnotinnew;
120
-
121
-CREATE TEMPORARY VIEW filesforbundle AS
122
- SELECT
123
- newfiles.file
114
+-- Now we know what checkins are going in the bundle, figure out which
115
+-- files get included.
116
+
117
+CREATE TEMPORARY VIEW desiredfiles AS
118
+ SELECT
119
+ newfiles.file AS id
124120
FROM
125121
newfiles,
126
- checkinsforbundle
122
+ desiredcheckins
127123
WHERE
128
- newfiles.checkin = checkinsforbundle.id;
124
+ newfiles.checkin = desiredcheckins.id;
129125
--- 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.
126
+-- Because this prototype is using the git exporter to create bundles, and the
127
+-- exporter's ability to select artifacts is based on having a list of rids to
128
+-- ignore, we have to emit a list of all rids in newrepo which don't correspond
129
+-- to the list above.
130130
131131
CREATE TEMPORARY VIEW skipcheckinrids AS
132132
SELECT
133133
"c" || oldcheckins.rid AS msg,
134134
oldcheckins.rid AS rid,
135135
oldcheckins.id AS id
136136
FROM
137
- oldcheckins LEFT JOIN checkinsforbundle
137
+ oldcheckins LEFT JOIN desiredcheckins
138138
ON
139
- checkinsforbundle.id = oldcheckins.id
139
+ desiredcheckins.id = oldcheckins.id
140140
WHERE
141
- checkinsforbundle.id IS NULL
141
+ desiredcheckins.id IS NULL
142142
ORDER BY
143143
rid ASC;
144144
145145
CREATE TEMPORARY VIEW skipfilerids AS
146146
SELECT
147147
--- tools/exportbundle.sh
+++ tools/exportbundle.sh
@@ -7,10 +7,13 @@
7 # The intended workflow is: user says 'I want to make a bundle to update
8 # OLD.fossil to checkin X of NEW.fossil'; the tool walks the checkin tree
9 # of NEW.fossil to figure out what checkins are necessary to reproduce X;
10 # then it removes all the checkins which are present in OLD.fossil; then
11 # it emits the bundle.
 
 
 
12
13 set -e
14
15 oldrepo=$1
16 newrepo=$2
@@ -81,11 +84,11 @@
81 new.blob AS file
82 WHERE
83 (checkin.rid = mlink.mid)
84 AND (file.rid = mlink.fid);
85
--- Walk the tree and figure out all the ancestors of the desired artifact.
 
86
87 CREATE TEMPORARY VIEW desiredcheckins AS
88 WITH RECURSIVE
89 ancestors(id, mtime) AS (
90 SELECT child AS id, mtime
@@ -94,58 +97,50 @@
94 UNION
95 SELECT
96 newcheckinmap.parent AS id,
97 newcheckinmap.mtime
98 FROM
99 newcheckinmap INNER JOIN ancestors
100 ON
101 newcheckinmap.child = ancestors.id
 
 
 
 
102 ORDER BY
103 newcheckinmap.mtime DESC
104 )
105 SELECT * FROM ancestors;
106
--- The set of checkins and files for newrepo's artifact which *aren't* in oldrepo.
107
108 CREATE TEMPORARY VIEW checkinsnotinnew AS
109 SELECT
110 desiredcheckins.id
111 FROM
112 desiredcheckins LEFT JOIN oldcheckins
113 ON
114 desiredcheckins.id = oldcheckins.id
115 WHERE
116 oldcheckins.id IS NULL;
117
118 CREATE TEMPORARY VIEW checkinsforbundle AS
119 SELECT * FROM checkinsnotinnew;
120
121 CREATE TEMPORARY VIEW filesforbundle AS
122 SELECT
123 newfiles.file
124 FROM
125 newfiles,
126 checkinsforbundle
127 WHERE
128 newfiles.checkin = checkinsforbundle.id;
129
--- 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.
 
 
 
 
130
131 CREATE TEMPORARY VIEW skipcheckinrids AS
132 SELECT
133 "c" || oldcheckins.rid AS msg,
134 oldcheckins.rid AS rid,
135 oldcheckins.id AS id
136 FROM
137 oldcheckins LEFT JOIN checkinsforbundle
138 ON
139 checkinsforbundle.id = oldcheckins.id
140 WHERE
141 checkinsforbundle.id IS NULL
142 ORDER BY
143 rid ASC;
144
145 CREATE TEMPORARY VIEW skipfilerids AS
146 SELECT
147
--- tools/exportbundle.sh
+++ tools/exportbundle.sh
@@ -7,10 +7,13 @@
7 # The intended workflow is: user says 'I want to make a bundle to update
8 # OLD.fossil to checkin X of NEW.fossil'; the tool walks the checkin tree
9 # of NEW.fossil to figure out what checkins are necessary to reproduce X;
10 # then it removes all the checkins which are present in OLD.fossil; then
11 # it emits the bundle.
12 #
13 # To import, simple clone oldrepo (or not, if you're feeling brave);
14 # then fossil import --incremental the bundle.
15
16 set -e
17
18 oldrepo=$1
19 newrepo=$2
@@ -81,11 +84,11 @@
84 new.blob AS file
85 WHERE
86 (checkin.rid = mlink.mid)
87 AND (file.rid = mlink.fid);
88
--- Walk the tree and figure out all the ancestors of the desired artifact.
89 -- Walk the tree and figure out what checkins need to go into the bundle.
90
91 CREATE TEMPORARY VIEW desiredcheckins AS
92 WITH RECURSIVE
93 ancestors(id, mtime) AS (
94 SELECT child AS id, mtime
@@ -94,58 +97,50 @@
97 UNION
98 SELECT
99 newcheckinmap.parent AS id,
100 newcheckinmap.mtime
101 FROM
102 newcheckinmap, ancestors
103 ON
104 newcheckinmap.child = ancestors.id
105 WHERE
106 -- Filter to include checkins which *aren't* in oldrepo.
107 NOT EXISTS(SELECT * FROM oldcheckinmap WHERE
108 oldcheckinmap.child = newcheckinmap.parent)
109 ORDER BY
110 newcheckinmap.mtime DESC
111 )
112 SELECT * FROM ancestors;
113
--- The set of checkins and files for newrepo's artifact which *aren't* in oldrepo.
114 -- Now we know what checkins are going in the bundle, figure out which
115 -- files get included.
116
117 CREATE TEMPORARY VIEW desiredfiles AS
118 SELECT
119 newfiles.file AS id
 
 
 
 
 
 
 
 
 
 
 
120 FROM
121 newfiles,
122 desiredcheckins
123 WHERE
124 newfiles.checkin = desiredcheckins.id;
125
--- 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.
126 -- Because this prototype is using the git exporter to create bundles, and the
127 -- exporter's ability to select artifacts is based on having a list of rids to
128 -- ignore, we have to emit a list of all rids in newrepo which don't correspond
129 -- to the list above.
130
131 CREATE TEMPORARY VIEW skipcheckinrids AS
132 SELECT
133 "c" || oldcheckins.rid AS msg,
134 oldcheckins.rid AS rid,
135 oldcheckins.id AS id
136 FROM
137 oldcheckins LEFT JOIN desiredcheckins
138 ON
139 desiredcheckins.id = oldcheckins.id
140 WHERE
141 desiredcheckins.id IS NULL
142 ORDER BY
143 rid ASC;
144
145 CREATE TEMPORARY VIEW skipfilerids AS
146 SELECT
147

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button