Fossil SCM
Optimised and simplified the exporter. Haven't figured out how to make the imported tree match up with its parent commit yet.
Commit
df4435bf4d9e035ced8113690d9e48b5f7811496
Parent
f809eb4c1abd6af…
1 file changed
+24
-23
+24
-23
| --- tools/exportbundle.sh | ||
| +++ tools/exportbundle.sh | ||
| @@ -7,10 +7,13 @@ | ||
| 7 | 7 | # The intended workflow is: user says 'I want to make a bundle to update |
| 8 | 8 | # OLD.fossil to checkin X of NEW.fossil'; the tool walks the checkin tree |
| 9 | 9 | # of NEW.fossil to figure out what checkins are necessary to reproduce X; |
| 10 | 10 | # then it removes all the checkins which are present in OLD.fossil; then |
| 11 | 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. | |
| 12 | 15 | |
| 13 | 16 | set -e |
| 14 | 17 | |
| 15 | 18 | oldrepo=$1 |
| 16 | 19 | newrepo=$2 |
| @@ -81,11 +84,11 @@ | ||
| 81 | 84 | new.blob AS file |
| 82 | 85 | WHERE |
| 83 | 86 | (checkin.rid = mlink.mid) |
| 84 | 87 | AND (file.rid = mlink.fid); |
| 85 | 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. | |
| 86 | 90 | |
| 87 | 91 | CREATE TEMPORARY VIEW desiredcheckins AS |
| 88 | 92 | WITH RECURSIVE |
| 89 | 93 | ancestors(id, mtime) AS ( |
| 90 | 94 | SELECT child AS id, mtime |
| @@ -94,58 +97,50 @@ | ||
| 94 | 97 | UNION |
| 95 | 98 | SELECT |
| 96 | 99 | newcheckinmap.parent AS id, |
| 97 | 100 | newcheckinmap.mtime |
| 98 | 101 | FROM |
| 99 | - newcheckinmap INNER JOIN ancestors | |
| 102 | + newcheckinmap, ancestors | |
| 100 | 103 | ON |
| 101 | 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) | |
| 102 | 109 | ORDER BY |
| 103 | 110 | newcheckinmap.mtime DESC |
| 104 | 111 | ) |
| 105 | 112 | SELECT * FROM ancestors; |
| 106 | 113 | |
| --- 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 | |
| 124 | 120 | FROM |
| 125 | 121 | newfiles, |
| 126 | - checkinsforbundle | |
| 122 | + desiredcheckins | |
| 127 | 123 | WHERE |
| 128 | - newfiles.checkin = checkinsforbundle.id; | |
| 124 | + newfiles.checkin = desiredcheckins.id; | |
| 129 | 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 | 130 | |
| 131 | 131 | CREATE TEMPORARY VIEW skipcheckinrids AS |
| 132 | 132 | SELECT |
| 133 | 133 | "c" || oldcheckins.rid AS msg, |
| 134 | 134 | oldcheckins.rid AS rid, |
| 135 | 135 | oldcheckins.id AS id |
| 136 | 136 | FROM |
| 137 | - oldcheckins LEFT JOIN checkinsforbundle | |
| 137 | + oldcheckins LEFT JOIN desiredcheckins | |
| 138 | 138 | ON |
| 139 | - checkinsforbundle.id = oldcheckins.id | |
| 139 | + desiredcheckins.id = oldcheckins.id | |
| 140 | 140 | WHERE |
| 141 | - checkinsforbundle.id IS NULL | |
| 141 | + desiredcheckins.id IS NULL | |
| 142 | 142 | ORDER BY |
| 143 | 143 | rid ASC; |
| 144 | 144 | |
| 145 | 145 | CREATE TEMPORARY VIEW skipfilerids AS |
| 146 | 146 | SELECT |
| 147 | 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 | 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 |