︙ | | |
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-
+
-
+
|
** Store the result in DELTA.
*/
void delta_create_cmd(void){
Blob orig, target, delta;
if( g.argc!=5 ){
usage("ORIGIN TARGET DELTA");
}
if( blob_read_from_file(&orig, g.argv[2])<0 ){
if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){
fossil_fatal("cannot read %s", g.argv[2]);
}
if( blob_read_from_file(&target, g.argv[3])<0 ){
if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){
fossil_fatal("cannot read %s", g.argv[3]);
}
blob_delta_create(&orig, &target, &delta);
if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){
fossil_fatal("cannot write %s", g.argv[4]);
}
blob_reset(&orig);
|
︙ | | |
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
-
+
-
+
|
Blob orig, target, delta;
int nCopy = 0;
int nInsert = 0;
int sz1, sz2, sz3;
if( g.argc!=4 ){
usage("ORIGIN TARGET");
}
if( blob_read_from_file(&orig, g.argv[2])<0 ){
if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){
fossil_fatal("cannot read %s", g.argv[2]);
}
if( blob_read_from_file(&target, g.argv[3])<0 ){
if( blob_read_from_file(&target, g.argv[3], ExtFILE)<0 ){
fossil_fatal("cannot read %s", g.argv[3]);
}
blob_delta_create(&orig, &target, &delta);
delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert);
sz1 = blob_size(&orig);
sz2 = blob_size(&target);
sz3 = blob_size(&delta);
|
︙ | | |
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
+
-
+
|
** Apply DELTA to FILE1 and output the result.
*/
void delta_apply_cmd(void){
Blob orig, target, delta;
if( g.argc!=5 ){
usage("ORIGIN DELTA TARGET");
}
if( blob_read_from_file(&orig, g.argv[2])<0 ){
if( blob_read_from_file(&orig, g.argv[2], ExtFILE)<0 ){
fossil_fatal("cannot read %s", g.argv[2]);
}
if( blob_read_from_file(&delta, g.argv[3])<0 ){
if( blob_read_from_file(&delta, g.argv[3], ExtFILE)<0 ){
fossil_fatal("cannot read %s", g.argv[3]);
}
blob_delta_apply(&orig, &delta, &target);
if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){
fossil_fatal("cannot write %s", g.argv[4]);
}
blob_reset(&orig);
|
︙ | | |
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
-
-
+
+
|
** correctly recovered.
*/
void cmd_test_delta(void){
Blob f1, f2; /* Original file content */
Blob d12, d21; /* Deltas from f1->f2 and f2->f1 */
Blob a1, a2; /* Recovered file content */
if( g.argc!=4 ) usage("FILE1 FILE2");
blob_read_from_file(&f1, g.argv[2]);
blob_read_from_file(&f2, g.argv[3]);
blob_read_from_file(&f1, g.argv[2], ExtFILE);
blob_read_from_file(&f2, g.argv[3], ExtFILE);
blob_delta_create(&f1, &f2, &d12);
blob_delta_create(&f2, &f1, &d21);
blob_delta_apply(&f1, &d12, &a2);
blob_delta_apply(&f2, &d21, &a1);
if( blob_compare(&f1,&a1) || blob_compare(&f2, &a2) ){
fossil_fatal("delta test failed");
}
fossil_print("ok\n");
}
|