Fossil SCM

Centralize and simplify the commit/ticket hook integration.

mistachkin 2013-10-15 01:21 UTC tkt-change-hook
Commit 6cf28968dbfb948d67034b344a57979cbd6f8268
+2 -2
--- src/attach.c
+++ src/attach.c
@@ -214,11 +214,11 @@
214214
}else{
215215
rid = content_put(pAttach);
216216
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
217217
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
218218
}
219
- manifest_crosslink(rid, pAttach);
219
+ manifest_crosslink(rid, pAttach, MC_NONE);
220220
}
221221
222222
223223
/*
224224
** WEBPAGE: attachadd
@@ -431,11 +431,11 @@
431431
blob_appendf(&manifest, "D %s\n", zDate);
432432
blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
433433
md5sum_blob(&manifest, &cksum);
434434
blob_appendf(&manifest, "Z %b\n", &cksum);
435435
rid = content_put(&manifest);
436
- manifest_crosslink(rid, &manifest);
436
+ manifest_crosslink(rid, &manifest, MC_NONE);
437437
db_end_transaction(0);
438438
@ <p>The attachment below has been deleted.</p>
439439
}
440440
441441
if( P("del")
442442
--- src/attach.c
+++ src/attach.c
@@ -214,11 +214,11 @@
214 }else{
215 rid = content_put(pAttach);
216 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
217 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
218 }
219 manifest_crosslink(rid, pAttach);
220 }
221
222
223 /*
224 ** WEBPAGE: attachadd
@@ -431,11 +431,11 @@
431 blob_appendf(&manifest, "D %s\n", zDate);
432 blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
433 md5sum_blob(&manifest, &cksum);
434 blob_appendf(&manifest, "Z %b\n", &cksum);
435 rid = content_put(&manifest);
436 manifest_crosslink(rid, &manifest);
437 db_end_transaction(0);
438 @ <p>The attachment below has been deleted.</p>
439 }
440
441 if( P("del")
442
--- src/attach.c
+++ src/attach.c
@@ -214,11 +214,11 @@
214 }else{
215 rid = content_put(pAttach);
216 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
217 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
218 }
219 manifest_crosslink(rid, pAttach, MC_NONE);
220 }
221
222
223 /*
224 ** WEBPAGE: attachadd
@@ -431,11 +431,11 @@
431 blob_appendf(&manifest, "D %s\n", zDate);
432 blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
433 md5sum_blob(&manifest, &cksum);
434 blob_appendf(&manifest, "Z %b\n", &cksum);
435 rid = content_put(&manifest);
436 manifest_crosslink(rid, &manifest, MC_NONE);
437 db_end_transaction(0);
438 @ <p>The attachment below has been deleted.</p>
439 }
440
441 if( P("del")
442
+1 -2
--- src/branch.c
+++ src/branch.c
@@ -153,12 +153,11 @@
153153
brid = content_put_ex(&branch, 0, 0, 0, isPrivate);
154154
if( brid==0 ){
155155
fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
156156
}
157157
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
158
- xfer_run_common_script();
159
- if( manifest_crosslink(brid, &branch)==0 ){
158
+ if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
160159
fossil_fatal("%s\n", g.zErrMsg);
161160
}
162161
assert( blob_is_reset(&branch) );
163162
content_deltify(rootid, brid, 0);
164163
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
165164
--- src/branch.c
+++ src/branch.c
@@ -153,12 +153,11 @@
153 brid = content_put_ex(&branch, 0, 0, 0, isPrivate);
154 if( brid==0 ){
155 fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
156 }
157 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
158 xfer_run_common_script();
159 if( manifest_crosslink(brid, &branch)==0 ){
160 fossil_fatal("%s\n", g.zErrMsg);
161 }
162 assert( blob_is_reset(&branch) );
163 content_deltify(rootid, brid, 0);
164 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
165
--- src/branch.c
+++ src/branch.c
@@ -153,12 +153,11 @@
153 brid = content_put_ex(&branch, 0, 0, 0, isPrivate);
154 if( brid==0 ){
155 fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
156 }
157 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
158 if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
 
159 fossil_fatal("%s\n", g.zErrMsg);
160 }
161 assert( blob_is_reset(&branch) );
162 content_deltify(rootid, brid, 0);
163 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", brid);
164
+2 -4
--- src/checkin.c
+++ src/checkin.c
@@ -1806,14 +1806,12 @@
18061806
nvid = content_put(&manifest);
18071807
if( nvid==0 ){
18081808
fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
18091809
}
18101810
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1811
- if( !dryRunFlag ){
1812
- xfer_run_common_script();
1813
- }
1814
- if( manifest_crosslink(nvid, &manifest)==0 ){
1811
+ if( manifest_crosslink(nvid, &manifest,
1812
+ dryRunFlag ? MC_NONE : MC_PERMIT_HOOKS)==0 ){
18151813
fossil_fatal("%s\n", g.zErrMsg);
18161814
}
18171815
assert( blob_is_reset(&manifest) );
18181816
content_deltify(vid, nvid, 0);
18191817
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
18201818
--- src/checkin.c
+++ src/checkin.c
@@ -1806,14 +1806,12 @@
1806 nvid = content_put(&manifest);
1807 if( nvid==0 ){
1808 fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
1809 }
1810 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1811 if( !dryRunFlag ){
1812 xfer_run_common_script();
1813 }
1814 if( manifest_crosslink(nvid, &manifest)==0 ){
1815 fossil_fatal("%s\n", g.zErrMsg);
1816 }
1817 assert( blob_is_reset(&manifest) );
1818 content_deltify(vid, nvid, 0);
1819 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1820
--- src/checkin.c
+++ src/checkin.c
@@ -1806,14 +1806,12 @@
1806 nvid = content_put(&manifest);
1807 if( nvid==0 ){
1808 fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
1809 }
1810 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
1811 if( manifest_crosslink(nvid, &manifest,
1812 dryRunFlag ? MC_NONE : MC_PERMIT_HOOKS)==0 ){
 
 
1813 fossil_fatal("%s\n", g.zErrMsg);
1814 }
1815 assert( blob_is_reset(&manifest) );
1816 content_deltify(vid, nvid, 0);
1817 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
1818
+2 -2
--- src/content.c
+++ src/content.c
@@ -388,11 +388,11 @@
388388
int i;
389389
390390
/* Parse the object rid itself */
391391
if( linkFlag ){
392392
content_get(rid, &content);
393
- manifest_crosslink(rid, &content);
393
+ manifest_crosslink(rid, &content, MC_NONE);
394394
assert( blob_is_reset(&content) );
395395
}
396396
397397
/* Parse all delta-manifests that depend on baseline-manifest rid */
398398
db_prepare(&q, "SELECT rid FROM orphan WHERE baseline=%d", rid);
@@ -405,11 +405,11 @@
405405
aChild[nChildUsed++] = child;
406406
}
407407
db_finalize(&q);
408408
for(i=0; i<nChildUsed; i++){
409409
content_get(aChild[i], &content);
410
- manifest_crosslink(aChild[i], &content);
410
+ manifest_crosslink(aChild[i], &content, MC_NONE);
411411
assert( blob_is_reset(&content) );
412412
}
413413
if( nChildUsed ){
414414
db_multi_exec("DELETE FROM orphan WHERE baseline=%d", rid);
415415
}
416416
--- src/content.c
+++ src/content.c
@@ -388,11 +388,11 @@
388 int i;
389
390 /* Parse the object rid itself */
391 if( linkFlag ){
392 content_get(rid, &content);
393 manifest_crosslink(rid, &content);
394 assert( blob_is_reset(&content) );
395 }
396
397 /* Parse all delta-manifests that depend on baseline-manifest rid */
398 db_prepare(&q, "SELECT rid FROM orphan WHERE baseline=%d", rid);
@@ -405,11 +405,11 @@
405 aChild[nChildUsed++] = child;
406 }
407 db_finalize(&q);
408 for(i=0; i<nChildUsed; i++){
409 content_get(aChild[i], &content);
410 manifest_crosslink(aChild[i], &content);
411 assert( blob_is_reset(&content) );
412 }
413 if( nChildUsed ){
414 db_multi_exec("DELETE FROM orphan WHERE baseline=%d", rid);
415 }
416
--- src/content.c
+++ src/content.c
@@ -388,11 +388,11 @@
388 int i;
389
390 /* Parse the object rid itself */
391 if( linkFlag ){
392 content_get(rid, &content);
393 manifest_crosslink(rid, &content, MC_NONE);
394 assert( blob_is_reset(&content) );
395 }
396
397 /* Parse all delta-manifests that depend on baseline-manifest rid */
398 db_prepare(&q, "SELECT rid FROM orphan WHERE baseline=%d", rid);
@@ -405,11 +405,11 @@
405 aChild[nChildUsed++] = child;
406 }
407 db_finalize(&q);
408 for(i=0; i<nChildUsed; i++){
409 content_get(aChild[i], &content);
410 manifest_crosslink(aChild[i], &content, MC_NONE);
411 assert( blob_is_reset(&content) );
412 }
413 if( nChildUsed ){
414 db_multi_exec("DELETE FROM orphan WHERE baseline=%d", rid);
415 }
416
+1 -1
--- src/db.c
+++ src/db.c
@@ -1412,11 +1412,11 @@
14121412
blob_appendf(&manifest, "U %F\n", g.zLogin);
14131413
md5sum_blob(&manifest, &hash);
14141414
blob_appendf(&manifest, "Z %b\n", &hash);
14151415
blob_reset(&hash);
14161416
rid = content_put(&manifest);
1417
- manifest_crosslink(rid, &manifest);
1417
+ manifest_crosslink(rid, &manifest, MC_NONE);
14181418
}
14191419
}
14201420
14211421
/*
14221422
** COMMAND: new*
14231423
--- src/db.c
+++ src/db.c
@@ -1412,11 +1412,11 @@
1412 blob_appendf(&manifest, "U %F\n", g.zLogin);
1413 md5sum_blob(&manifest, &hash);
1414 blob_appendf(&manifest, "Z %b\n", &hash);
1415 blob_reset(&hash);
1416 rid = content_put(&manifest);
1417 manifest_crosslink(rid, &manifest);
1418 }
1419 }
1420
1421 /*
1422 ** COMMAND: new*
1423
--- src/db.c
+++ src/db.c
@@ -1412,11 +1412,11 @@
1412 blob_appendf(&manifest, "U %F\n", g.zLogin);
1413 md5sum_blob(&manifest, &hash);
1414 blob_appendf(&manifest, "Z %b\n", &hash);
1415 blob_reset(&hash);
1416 rid = content_put(&manifest);
1417 manifest_crosslink(rid, &manifest, MC_NONE);
1418 }
1419 }
1420
1421 /*
1422 ** COMMAND: new*
1423
+1 -1
--- src/event.c
+++ src/event.c
@@ -351,11 +351,11 @@
351351
md5sum_blob(&event, &cksum);
352352
blob_appendf(&event, "Z %b\n", &cksum);
353353
blob_reset(&cksum);
354354
nrid = content_put(&event);
355355
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
356
- manifest_crosslink(nrid, &event);
356
+ manifest_crosslink(nrid, &event, MC_NONE);
357357
assert( blob_is_reset(&event) );
358358
content_deltify(rid, nrid, 0);
359359
db_end_transaction(0);
360360
cgi_redirectf("event?name=%T", zEventId);
361361
}
362362
--- src/event.c
+++ src/event.c
@@ -351,11 +351,11 @@
351 md5sum_blob(&event, &cksum);
352 blob_appendf(&event, "Z %b\n", &cksum);
353 blob_reset(&cksum);
354 nrid = content_put(&event);
355 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
356 manifest_crosslink(nrid, &event);
357 assert( blob_is_reset(&event) );
358 content_deltify(rid, nrid, 0);
359 db_end_transaction(0);
360 cgi_redirectf("event?name=%T", zEventId);
361 }
362
--- src/event.c
+++ src/event.c
@@ -351,11 +351,11 @@
351 md5sum_blob(&event, &cksum);
352 blob_appendf(&event, "Z %b\n", &cksum);
353 blob_reset(&cksum);
354 nrid = content_put(&event);
355 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
356 manifest_crosslink(nrid, &event, MC_NONE);
357 assert( blob_is_reset(&event) );
358 content_deltify(rid, nrid, 0);
359 db_end_transaction(0);
360 cgi_redirectf("event?name=%T", zEventId);
361 }
362
+1 -2
--- src/info.c
+++ src/info.c
@@ -2178,12 +2178,11 @@
21782178
md5sum_blob(&ctrl, &cksum);
21792179
blob_appendf(&ctrl, "Z %b\n", &cksum);
21802180
db_begin_transaction();
21812181
g.markPrivate = content_is_private(rid);
21822182
nrid = content_put(&ctrl);
2183
- xfer_run_common_script();
2184
- manifest_crosslink(nrid, &ctrl);
2183
+ manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS);
21852184
assert( blob_is_reset(&ctrl) );
21862185
db_end_transaction(0);
21872186
}
21882187
cgi_redirectf("ci?name=%s", zUuid);
21892188
}
21902189
--- src/info.c
+++ src/info.c
@@ -2178,12 +2178,11 @@
2178 md5sum_blob(&ctrl, &cksum);
2179 blob_appendf(&ctrl, "Z %b\n", &cksum);
2180 db_begin_transaction();
2181 g.markPrivate = content_is_private(rid);
2182 nrid = content_put(&ctrl);
2183 xfer_run_common_script();
2184 manifest_crosslink(nrid, &ctrl);
2185 assert( blob_is_reset(&ctrl) );
2186 db_end_transaction(0);
2187 }
2188 cgi_redirectf("ci?name=%s", zUuid);
2189 }
2190
--- src/info.c
+++ src/info.c
@@ -2178,12 +2178,11 @@
2178 md5sum_blob(&ctrl, &cksum);
2179 blob_appendf(&ctrl, "Z %b\n", &cksum);
2180 db_begin_transaction();
2181 g.markPrivate = content_is_private(rid);
2182 nrid = content_put(&ctrl);
2183 manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS);
 
2184 assert( blob_is_reset(&ctrl) );
2185 db_end_transaction(0);
2186 }
2187 cgi_redirectf("ci?name=%s", zUuid);
2188 }
2189
--- src/json_branch.c
+++ src/json_branch.c
@@ -291,12 +291,11 @@
291291
brid = content_put(&branch);
292292
if( brid==0 ){
293293
fossil_fatal("Problem committing manifest: %s", g.zErrMsg);
294294
}
295295
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
296
- xfer_run_common_script();
297
- if( manifest_crosslink(brid, &branch)==0 ){
296
+ if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
298297
fossil_fatal("%s\n", g.zErrMsg);
299298
}
300299
assert( blob_is_reset(&branch) );
301300
content_deltify(rootid, brid, 0);
302301
if( zNewRid ){
303302
--- src/json_branch.c
+++ src/json_branch.c
@@ -291,12 +291,11 @@
291 brid = content_put(&branch);
292 if( brid==0 ){
293 fossil_fatal("Problem committing manifest: %s", g.zErrMsg);
294 }
295 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
296 xfer_run_common_script();
297 if( manifest_crosslink(brid, &branch)==0 ){
298 fossil_fatal("%s\n", g.zErrMsg);
299 }
300 assert( blob_is_reset(&branch) );
301 content_deltify(rootid, brid, 0);
302 if( zNewRid ){
303
--- src/json_branch.c
+++ src/json_branch.c
@@ -291,12 +291,11 @@
291 brid = content_put(&branch);
292 if( brid==0 ){
293 fossil_fatal("Problem committing manifest: %s", g.zErrMsg);
294 }
295 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
296 if( manifest_crosslink(brid, &branch, MC_PERMIT_HOOKS)==0 ){
 
297 fossil_fatal("%s\n", g.zErrMsg);
298 }
299 assert( blob_is_reset(&branch) );
300 content_deltify(rootid, brid, 0);
301 if( zNewRid ){
302
+17 -6
--- src/manifest.c
+++ src/manifest.c
@@ -42,10 +42,16 @@
4242
*/
4343
#define PERM_REG 0 /* regular file */
4444
#define PERM_EXE 1 /* executable */
4545
#define PERM_LNK 2 /* symlink */
4646
47
+/*
48
+** Flags for use with manifest_crosslink().
49
+*/
50
+#define MC_NONE 0 /* default handling */
51
+#define MC_PERMIT_HOOKS 1 /* permit hooks to execute */
52
+
4753
/*
4854
** A single F-card within a manifest
4955
*/
5056
struct ManifestFile {
5157
char *zName; /* Name of a file */
@@ -1650,12 +1656,12 @@
16501656
** Historical note: This routine original processed manifests only.
16511657
** Processing for other control artifacts was added later. The name
16521658
** of the routine, "manifest_crosslink", and the name of this source
16531659
** file, is a legacy of its original use.
16541660
*/
1655
-int manifest_crosslink(int rid, Blob *pContent){
1656
- int i, result;
1661
+int manifest_crosslink(int rid, Blob *pContent, int flags){
1662
+ int i, result = 1;
16571663
Manifest *p;
16581664
Stmt q;
16591665
int parentid = 0;
16601666
const char *zScript = 0;
16611667
const char *zUuid = 0;
@@ -1679,11 +1685,11 @@
16791685
fossil_error(1, "cannot fetch baseline manifest");
16801686
return 0;
16811687
}
16821688
db_begin_transaction();
16831689
if( p->type==CFTYPE_MANIFEST ){
1684
- zScript = "xfer-commit-script";
1690
+ zScript = xfer_commit_code();
16851691
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
16861692
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
16871693
char *zCom;
16881694
for(i=0; i<p->nParent; i++){
16891695
int pid = uuid_to_rid(p->azParent[i], 1);
@@ -1877,11 +1883,11 @@
18771883
}
18781884
}
18791885
if( p->type==CFTYPE_TICKET ){
18801886
char *zTag;
18811887
1882
- zScript = "xfer-ticket-script";
1888
+ zScript = xfer_ticket_code();
18831889
zUuid = p->zTicketUuid;
18841890
assert( manifest_crosslink_busy==1 );
18851891
zTag = mprintf("tkt-%s", p->zTicketUuid);
18861892
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
18871893
free(zTag);
@@ -2030,11 +2036,16 @@
20302036
p->rDate, rid, p->zUser, blob_str(&comment)+1
20312037
);
20322038
blob_reset(&comment);
20332039
}
20342040
db_end_transaction(0);
2035
- result = (xfer_run_script(zScript, zUuid)==TH_OK);
2041
+ if( flags & MC_PERMIT_HOOKS ){
2042
+ result = (xfer_run_common_script()==TH_OK);
2043
+ if( result ){
2044
+ result = (xfer_run_script(zScript, zUuid)==TH_OK);
2045
+ }
2046
+ }
20362047
if( p->type==CFTYPE_MANIFEST ){
20372048
manifest_cache_insert(p);
20382049
}else{
20392050
manifest_destroy(p);
20402051
}
@@ -2055,7 +2066,7 @@
20552066
Blob content;
20562067
db_find_and_open_repository(0, 0);
20572068
if( g.argc!=3 ) usage("RECORDID");
20582069
rid = name_to_rid(g.argv[2]);
20592070
content_get(rid, &content);
2060
- manifest_crosslink(rid, &content);
2071
+ manifest_crosslink(rid, &content, MC_NONE);
20612072
}
20622073
--- src/manifest.c
+++ src/manifest.c
@@ -42,10 +42,16 @@
42 */
43 #define PERM_REG 0 /* regular file */
44 #define PERM_EXE 1 /* executable */
45 #define PERM_LNK 2 /* symlink */
46
 
 
 
 
 
 
47 /*
48 ** A single F-card within a manifest
49 */
50 struct ManifestFile {
51 char *zName; /* Name of a file */
@@ -1650,12 +1656,12 @@
1650 ** Historical note: This routine original processed manifests only.
1651 ** Processing for other control artifacts was added later. The name
1652 ** of the routine, "manifest_crosslink", and the name of this source
1653 ** file, is a legacy of its original use.
1654 */
1655 int manifest_crosslink(int rid, Blob *pContent){
1656 int i, result;
1657 Manifest *p;
1658 Stmt q;
1659 int parentid = 0;
1660 const char *zScript = 0;
1661 const char *zUuid = 0;
@@ -1679,11 +1685,11 @@
1679 fossil_error(1, "cannot fetch baseline manifest");
1680 return 0;
1681 }
1682 db_begin_transaction();
1683 if( p->type==CFTYPE_MANIFEST ){
1684 zScript = "xfer-commit-script";
1685 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1686 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
1687 char *zCom;
1688 for(i=0; i<p->nParent; i++){
1689 int pid = uuid_to_rid(p->azParent[i], 1);
@@ -1877,11 +1883,11 @@
1877 }
1878 }
1879 if( p->type==CFTYPE_TICKET ){
1880 char *zTag;
1881
1882 zScript = "xfer-ticket-script";
1883 zUuid = p->zTicketUuid;
1884 assert( manifest_crosslink_busy==1 );
1885 zTag = mprintf("tkt-%s", p->zTicketUuid);
1886 tag_insert(zTag, 1, 0, rid, p->rDate, rid);
1887 free(zTag);
@@ -2030,11 +2036,16 @@
2030 p->rDate, rid, p->zUser, blob_str(&comment)+1
2031 );
2032 blob_reset(&comment);
2033 }
2034 db_end_transaction(0);
2035 result = (xfer_run_script(zScript, zUuid)==TH_OK);
 
 
 
 
 
2036 if( p->type==CFTYPE_MANIFEST ){
2037 manifest_cache_insert(p);
2038 }else{
2039 manifest_destroy(p);
2040 }
@@ -2055,7 +2066,7 @@
2055 Blob content;
2056 db_find_and_open_repository(0, 0);
2057 if( g.argc!=3 ) usage("RECORDID");
2058 rid = name_to_rid(g.argv[2]);
2059 content_get(rid, &content);
2060 manifest_crosslink(rid, &content);
2061 }
2062
--- src/manifest.c
+++ src/manifest.c
@@ -42,10 +42,16 @@
42 */
43 #define PERM_REG 0 /* regular file */
44 #define PERM_EXE 1 /* executable */
45 #define PERM_LNK 2 /* symlink */
46
47 /*
48 ** Flags for use with manifest_crosslink().
49 */
50 #define MC_NONE 0 /* default handling */
51 #define MC_PERMIT_HOOKS 1 /* permit hooks to execute */
52
53 /*
54 ** A single F-card within a manifest
55 */
56 struct ManifestFile {
57 char *zName; /* Name of a file */
@@ -1650,12 +1656,12 @@
1656 ** Historical note: This routine original processed manifests only.
1657 ** Processing for other control artifacts was added later. The name
1658 ** of the routine, "manifest_crosslink", and the name of this source
1659 ** file, is a legacy of its original use.
1660 */
1661 int manifest_crosslink(int rid, Blob *pContent, int flags){
1662 int i, result = 1;
1663 Manifest *p;
1664 Stmt q;
1665 int parentid = 0;
1666 const char *zScript = 0;
1667 const char *zUuid = 0;
@@ -1679,11 +1685,11 @@
1685 fossil_error(1, "cannot fetch baseline manifest");
1686 return 0;
1687 }
1688 db_begin_transaction();
1689 if( p->type==CFTYPE_MANIFEST ){
1690 zScript = xfer_commit_code();
1691 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1692 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
1693 char *zCom;
1694 for(i=0; i<p->nParent; i++){
1695 int pid = uuid_to_rid(p->azParent[i], 1);
@@ -1877,11 +1883,11 @@
1883 }
1884 }
1885 if( p->type==CFTYPE_TICKET ){
1886 char *zTag;
1887
1888 zScript = xfer_ticket_code();
1889 zUuid = p->zTicketUuid;
1890 assert( manifest_crosslink_busy==1 );
1891 zTag = mprintf("tkt-%s", p->zTicketUuid);
1892 tag_insert(zTag, 1, 0, rid, p->rDate, rid);
1893 free(zTag);
@@ -2030,11 +2036,16 @@
2036 p->rDate, rid, p->zUser, blob_str(&comment)+1
2037 );
2038 blob_reset(&comment);
2039 }
2040 db_end_transaction(0);
2041 if( flags & MC_PERMIT_HOOKS ){
2042 result = (xfer_run_common_script()==TH_OK);
2043 if( result ){
2044 result = (xfer_run_script(zScript, zUuid)==TH_OK);
2045 }
2046 }
2047 if( p->type==CFTYPE_MANIFEST ){
2048 manifest_cache_insert(p);
2049 }else{
2050 manifest_destroy(p);
2051 }
@@ -2055,7 +2066,7 @@
2066 Blob content;
2067 db_find_and_open_repository(0, 0);
2068 if( g.argc!=3 ) usage("RECORDID");
2069 rid = name_to_rid(g.argv[2]);
2070 content_get(rid, &content);
2071 manifest_crosslink(rid, &content, MC_NONE);
2072 }
2073
+1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -250,11 +250,11 @@
250250
blob_copy(&copy, pBase);
251251
pUse = &copy;
252252
}
253253
if( zFNameFormat==0 ){
254254
/* We are doing "fossil rebuild" */
255
- manifest_crosslink(rid, pUse);
255
+ manifest_crosslink(rid, pUse, MC_NONE);
256256
}else{
257257
/* We are doing "fossil deconstruct" */
258258
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
259259
char *zFile = mprintf(zFNameFormat, zUuid, zUuid+prefixLength);
260260
blob_write_to_file(pUse,zFile);
261261
--- src/rebuild.c
+++ src/rebuild.c
@@ -250,11 +250,11 @@
250 blob_copy(&copy, pBase);
251 pUse = &copy;
252 }
253 if( zFNameFormat==0 ){
254 /* We are doing "fossil rebuild" */
255 manifest_crosslink(rid, pUse);
256 }else{
257 /* We are doing "fossil deconstruct" */
258 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
259 char *zFile = mprintf(zFNameFormat, zUuid, zUuid+prefixLength);
260 blob_write_to_file(pUse,zFile);
261
--- src/rebuild.c
+++ src/rebuild.c
@@ -250,11 +250,11 @@
250 blob_copy(&copy, pBase);
251 pUse = &copy;
252 }
253 if( zFNameFormat==0 ){
254 /* We are doing "fossil rebuild" */
255 manifest_crosslink(rid, pUse, MC_NONE);
256 }else{
257 /* We are doing "fossil deconstruct" */
258 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
259 char *zFile = mprintf(zFNameFormat, zUuid, zUuid+prefixLength);
260 blob_write_to_file(pUse,zFile);
261
+1 -2
--- src/tag.c
+++ src/tag.c
@@ -326,12 +326,11 @@
326326
}
327327
blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
328328
md5sum_blob(&ctrl, &cksum);
329329
blob_appendf(&ctrl, "Z %b\n", &cksum);
330330
nrid = content_put(&ctrl);
331
- xfer_run_common_script();
332
- manifest_crosslink(nrid, &ctrl);
331
+ manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS);
333332
assert( blob_is_reset(&ctrl) );
334333
}
335334
336335
/*
337336
** COMMAND: tag
338337
--- src/tag.c
+++ src/tag.c
@@ -326,12 +326,11 @@
326 }
327 blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
328 md5sum_blob(&ctrl, &cksum);
329 blob_appendf(&ctrl, "Z %b\n", &cksum);
330 nrid = content_put(&ctrl);
331 xfer_run_common_script();
332 manifest_crosslink(nrid, &ctrl);
333 assert( blob_is_reset(&ctrl) );
334 }
335
336 /*
337 ** COMMAND: tag
338
--- src/tag.c
+++ src/tag.c
@@ -326,12 +326,11 @@
326 }
327 blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
328 md5sum_blob(&ctrl, &cksum);
329 blob_appendf(&ctrl, "Z %b\n", &cksum);
330 nrid = content_put(&ctrl);
331 manifest_crosslink(nrid, &ctrl, MC_PERMIT_HOOKS);
 
332 assert( blob_is_reset(&ctrl) );
333 }
334
335 /*
336 ** COMMAND: tag
337
+1 -1
--- src/th_main.c
+++ src/th_main.c
@@ -849,11 +849,11 @@
849849
const char *zSep, *zType, *zRegexp, *zParams;
850850
Blob hdr, payload;
851851
ReCompiled *pRe = 0;
852852
UrlData urlData;
853853
854
- if( argc<2 || argl[1]<6 || fossil_strnicmp(argv[1], "-asynchronous", argl[1]) ){
854
+ if( argc<2 || fossil_strnicmp(argv[1], "-asynchronous", argl[1]) ){
855855
Th_ErrorMessage(interp,
856856
"synchronous http requests not yet implemented", 0, 0);
857857
return TH_ERROR;
858858
}
859859
--argc; ++argv; ++argl; /* advance to next argument */
860860
--- src/th_main.c
+++ src/th_main.c
@@ -849,11 +849,11 @@
849 const char *zSep, *zType, *zRegexp, *zParams;
850 Blob hdr, payload;
851 ReCompiled *pRe = 0;
852 UrlData urlData;
853
854 if( argc<2 || argl[1]<6 || fossil_strnicmp(argv[1], "-asynchronous", argl[1]) ){
855 Th_ErrorMessage(interp,
856 "synchronous http requests not yet implemented", 0, 0);
857 return TH_ERROR;
858 }
859 --argc; ++argv; ++argl; /* advance to next argument */
860
--- src/th_main.c
+++ src/th_main.c
@@ -849,11 +849,11 @@
849 const char *zSep, *zType, *zRegexp, *zParams;
850 Blob hdr, payload;
851 ReCompiled *pRe = 0;
852 UrlData urlData;
853
854 if( argc<2 || fossil_strnicmp(argv[1], "-asynchronous", argl[1]) ){
855 Th_ErrorMessage(interp,
856 "synchronous http requests not yet implemented", 0, 0);
857 return TH_ERROR;
858 }
859 --argc; ++argv; ++argl; /* advance to next argument */
860
+7 -9
--- src/tkt.c
+++ src/tkt.c
@@ -534,12 +534,11 @@
534534
}else{
535535
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
536536
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
537537
}
538538
manifest_crosslink_begin();
539
- xfer_run_common_script();
540
- result = manifest_crosslink(rid, pTicket)==0;
539
+ result = (manifest_crosslink(rid, pTicket, MC_PERMIT_HOOKS)==0);
541540
assert( blob_is_reset(pTicket) );
542541
manifest_crosslink_end();
543542
return result;
544543
}
545544
@@ -624,15 +623,16 @@
624623
@ <font color="blue">
625624
@ <p>Ticket artifact that would have been submitted:</p>
626625
@ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
627626
@ <hr /></font>
628627
return TH_OK;
629
- }else if( g.thTrace ){
630
- Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
631
- "}<br />\n",
632
- blob_str(&tktchng));
633628
}else{
629
+ if( g.thTrace ){
630
+ Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
631
+ "}<br />\n",
632
+ blob_str(&tktchng));
633
+ }
634634
ticket_put(&tktchng, zUuid,
635635
(g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
636636
}
637637
return ticket_change();
638638
}
@@ -683,11 +683,10 @@
683683
}
684684
captcha_generate(0);
685685
@ </form>
686686
if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1);
687687
style_footer();
688
- xfer_run_common_script();
689688
}
690689
691690
/*
692691
** WEBPAGE: tktedit
693692
** WEBPAGE: debug_tktedit
@@ -752,11 +751,10 @@
752751
}
753752
captcha_generate(0);
754753
@ </form>
755754
if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT<br />\n", -1);
756755
style_footer();
757
- xfer_run_common_script();
758756
}
759757
760758
/*
761759
** Check the ticket table schema in zSchema to see if it appears to
762760
** be well-formed. If everything is OK, return NULL. If something is
@@ -1348,14 +1346,14 @@
13481346
}
13491347
blob_appendf(&tktchng, "K %s\n", zTktUuid);
13501348
blob_appendf(&tktchng, "U %F\n", zUser);
13511349
md5sum_blob(&tktchng, &cksum);
13521350
blob_appendf(&tktchng, "Z %b\n", &cksum);
1353
- if( xfer_run_common_script() || ticket_put(&tktchng, zTktUuid, 0) ){
1351
+ if( ticket_put(&tktchng, zTktUuid, 0) ){
13541352
fossil_fatal("%s\n", g.zErrMsg);
13551353
}else{
13561354
fossil_print("ticket %s succeeded for %s\n",
13571355
(eCmd==set?"set":"add"),zTktUuid);
13581356
}
13591357
}
13601358
}
13611359
}
13621360
--- src/tkt.c
+++ src/tkt.c
@@ -534,12 +534,11 @@
534 }else{
535 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
536 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
537 }
538 manifest_crosslink_begin();
539 xfer_run_common_script();
540 result = manifest_crosslink(rid, pTicket)==0;
541 assert( blob_is_reset(pTicket) );
542 manifest_crosslink_end();
543 return result;
544 }
545
@@ -624,15 +623,16 @@
624 @ <font color="blue">
625 @ <p>Ticket artifact that would have been submitted:</p>
626 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
627 @ <hr /></font>
628 return TH_OK;
629 }else if( g.thTrace ){
630 Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
631 "}<br />\n",
632 blob_str(&tktchng));
633 }else{
 
 
 
 
 
634 ticket_put(&tktchng, zUuid,
635 (g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
636 }
637 return ticket_change();
638 }
@@ -683,11 +683,10 @@
683 }
684 captcha_generate(0);
685 @ </form>
686 if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1);
687 style_footer();
688 xfer_run_common_script();
689 }
690
691 /*
692 ** WEBPAGE: tktedit
693 ** WEBPAGE: debug_tktedit
@@ -752,11 +751,10 @@
752 }
753 captcha_generate(0);
754 @ </form>
755 if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT<br />\n", -1);
756 style_footer();
757 xfer_run_common_script();
758 }
759
760 /*
761 ** Check the ticket table schema in zSchema to see if it appears to
762 ** be well-formed. If everything is OK, return NULL. If something is
@@ -1348,14 +1346,14 @@
1348 }
1349 blob_appendf(&tktchng, "K %s\n", zTktUuid);
1350 blob_appendf(&tktchng, "U %F\n", zUser);
1351 md5sum_blob(&tktchng, &cksum);
1352 blob_appendf(&tktchng, "Z %b\n", &cksum);
1353 if( xfer_run_common_script() || ticket_put(&tktchng, zTktUuid, 0) ){
1354 fossil_fatal("%s\n", g.zErrMsg);
1355 }else{
1356 fossil_print("ticket %s succeeded for %s\n",
1357 (eCmd==set?"set":"add"),zTktUuid);
1358 }
1359 }
1360 }
1361 }
1362
--- src/tkt.c
+++ src/tkt.c
@@ -534,12 +534,11 @@
534 }else{
535 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
536 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
537 }
538 manifest_crosslink_begin();
539 result = (manifest_crosslink(rid, pTicket, MC_PERMIT_HOOKS)==0);
 
540 assert( blob_is_reset(pTicket) );
541 manifest_crosslink_end();
542 return result;
543 }
544
@@ -624,15 +623,16 @@
623 @ <font color="blue">
624 @ <p>Ticket artifact that would have been submitted:</p>
625 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
626 @ <hr /></font>
627 return TH_OK;
 
 
 
 
628 }else{
629 if( g.thTrace ){
630 Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
631 "}<br />\n",
632 blob_str(&tktchng));
633 }
634 ticket_put(&tktchng, zUuid,
635 (g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
636 }
637 return ticket_change();
638 }
@@ -683,11 +683,10 @@
683 }
684 captcha_generate(0);
685 @ </form>
686 if( g.thTrace ) Th_Trace("END_TKTVIEW<br />\n", -1);
687 style_footer();
 
688 }
689
690 /*
691 ** WEBPAGE: tktedit
692 ** WEBPAGE: debug_tktedit
@@ -752,11 +751,10 @@
751 }
752 captcha_generate(0);
753 @ </form>
754 if( g.thTrace ) Th_Trace("BEGIN_TKTEDIT<br />\n", -1);
755 style_footer();
 
756 }
757
758 /*
759 ** Check the ticket table schema in zSchema to see if it appears to
760 ** be well-formed. If everything is OK, return NULL. If something is
@@ -1348,14 +1346,14 @@
1346 }
1347 blob_appendf(&tktchng, "K %s\n", zTktUuid);
1348 blob_appendf(&tktchng, "U %F\n", zUser);
1349 md5sum_blob(&tktchng, &cksum);
1350 blob_appendf(&tktchng, "Z %b\n", &cksum);
1351 if( ticket_put(&tktchng, zTktUuid, 0) ){
1352 fossil_fatal("%s\n", g.zErrMsg);
1353 }else{
1354 fossil_print("ticket %s succeeded for %s\n",
1355 (eCmd==set?"set":"add"),zTktUuid);
1356 }
1357 }
1358 }
1359 }
1360
+1 -1
--- src/wiki.c
+++ src/wiki.c
@@ -294,11 +294,11 @@
294294
moderation_table_create();
295295
db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
296296
}
297297
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
298298
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
299
- manifest_crosslink(nrid, pWiki);
299
+ manifest_crosslink(nrid, pWiki, MC_NONE);
300300
}
301301
302302
/*
303303
** Formal names and common names for the various wiki styles.
304304
*/
305305
--- src/wiki.c
+++ src/wiki.c
@@ -294,11 +294,11 @@
294 moderation_table_create();
295 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
296 }
297 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
298 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
299 manifest_crosslink(nrid, pWiki);
300 }
301
302 /*
303 ** Formal names and common names for the various wiki styles.
304 */
305
--- src/wiki.c
+++ src/wiki.c
@@ -294,11 +294,11 @@
294 moderation_table_create();
295 db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
296 }
297 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
298 db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", nrid);
299 manifest_crosslink(nrid, pWiki, MC_NONE);
300 }
301
302 /*
303 ** Formal names and common names for the various wiki styles.
304 */
305
+43 -29
--- src/xfer.c
+++ src/xfer.c
@@ -191,11 +191,11 @@
191191
if( rid==0 ){
192192
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
193193
blob_reset(&content);
194194
}else{
195195
if( !isPriv ) content_make_public(rid);
196
- manifest_crosslink(rid, &content);
196
+ manifest_crosslink(rid, &content, MC_NONE);
197197
}
198198
assert( blob_is_reset(&content) );
199199
remote_has(rid);
200200
}
201201
@@ -819,31 +819,54 @@
819819
*/
820820
static void server_private_xfer_not_authorized(void){
821821
@ error not\sauthorized\sto\ssync\sprivate\scontent
822822
}
823823
824
-static int commonScriptRan = 0;
824
+/*
825
+** Return the common TH1 code to evaluate prior to evaluating any other
826
+** TH1 transfer notification scripts.
827
+*/
828
+const char *xfer_common_code(void){
829
+ return db_get("xfer-common-script", 0);
830
+}
831
+
832
+/*
833
+** Return the TH1 code to evaluate when a push is processed.
834
+*/
835
+const char *xfer_push_code(void){
836
+ return db_get("xfer-push-script", 0);
837
+}
838
+
839
+/*
840
+** Return the TH1 code to evaluate when a commit is processed.
841
+*/
842
+const char *xfer_commit_code(void){
843
+ return db_get("xfer-commit-script", 0);
844
+}
845
+
846
+/*
847
+** Return the TH1 code to evaluate when a ticket change is processed.
848
+*/
849
+const char *xfer_ticket_code(void){
850
+ return db_get("xfer-ticket-script", 0);
851
+}
825852
826853
/*
827854
** Run the specified TH1 script, if any, and returns 1 on error.
828855
*/
829856
int xfer_run_script(const char *zScript, const char *zUuid){
830
- int result = TH_ERROR;
831
- if( !commonScriptRan || !zScript || !(zScript = db_get(zScript, 0))){
832
- /* No script or common script didn't run, return success. */
833
- return TH_OK;
834
- }
835
- if( commonScriptRan == 1 ){
836
- if( zUuid ){
837
- result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
838
- if( result!=TH_OK ){
839
- fossil_error(1, "%s", Th_GetResult(g.interp, 0));
840
- return result;
841
- }
842
- }
843
- result = Th_Eval(g.interp, 0, zScript, -1);
844
- }
857
+ int result;
858
+ if( !zScript ) return TH_OK;
859
+ Th_FossilInit(TH_INIT_DEFAULT);
860
+ if( zUuid ){
861
+ result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
862
+ if( result!=TH_OK ){
863
+ fossil_error(1, "%s", Th_GetResult(g.interp, 0));
864
+ return result;
865
+ }
866
+ }
867
+ result = Th_Eval(g.interp, 0, zScript, -1);
845868
if( result!=TH_OK ){
846869
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
847870
}
848871
return result;
849872
}
@@ -850,21 +873,12 @@
850873
851874
/*
852875
** Runs the pre-transfer TH1 script, if any, and returns its return code.
853876
*/
854877
int xfer_run_common_script(void){
855
- int result = 0;
856
- if( !commonScriptRan ){
857
- Th_FossilInit(TH_INIT_DEFAULT); /* Make sure TH1 is ready. */
858
- commonScriptRan = 1; /* enable run_script to do something */
859
- result = xfer_run_script("xfer-common-script", 0);
860
- if( result == TH_ERROR ){
861
- /* Error message is left in th interpreter. */
862
- commonScriptRan = 2;
863
- }
864
- }
865
- return result;
878
+ Th_FossilInit(TH_INIT_DEFAULT);
879
+ return xfer_run_script(xfer_common_code(), 0);
866880
}
867881
868882
/*
869883
** If this variable is set, disable login checks. Used for debugging
870884
** only.
@@ -1249,11 +1263,11 @@
12491263
}
12501264
blobarray_reset(xfer.aToken, xfer.nToken);
12511265
blob_reset(&xfer.line);
12521266
}
12531267
if( isPush ){
1254
- if( xfer_run_script("xfer-push-script", 0)!=TH_OK ){
1268
+ if( xfer_run_script(xfer_push_code(), 0)!=TH_OK ){
12551269
cgi_reset_content();
12561270
@ error push\sscript\sfailed:\s%F(g.zErrMsg)
12571271
nErr++;
12581272
}
12591273
request_phantoms(&xfer, 500);
12601274
--- src/xfer.c
+++ src/xfer.c
@@ -191,11 +191,11 @@
191 if( rid==0 ){
192 blob_appendf(&pXfer->err, "%s", g.zErrMsg);
193 blob_reset(&content);
194 }else{
195 if( !isPriv ) content_make_public(rid);
196 manifest_crosslink(rid, &content);
197 }
198 assert( blob_is_reset(&content) );
199 remote_has(rid);
200 }
201
@@ -819,31 +819,54 @@
819 */
820 static void server_private_xfer_not_authorized(void){
821 @ error not\sauthorized\sto\ssync\sprivate\scontent
822 }
823
824 static int commonScriptRan = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
825
826 /*
827 ** Run the specified TH1 script, if any, and returns 1 on error.
828 */
829 int xfer_run_script(const char *zScript, const char *zUuid){
830 int result = TH_ERROR;
831 if( !commonScriptRan || !zScript || !(zScript = db_get(zScript, 0))){
832 /* No script or common script didn't run, return success. */
833 return TH_OK;
834 }
835 if( commonScriptRan == 1 ){
836 if( zUuid ){
837 result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
838 if( result!=TH_OK ){
839 fossil_error(1, "%s", Th_GetResult(g.interp, 0));
840 return result;
841 }
842 }
843 result = Th_Eval(g.interp, 0, zScript, -1);
844 }
845 if( result!=TH_OK ){
846 fossil_error(1, "%s", Th_GetResult(g.interp, 0));
847 }
848 return result;
849 }
@@ -850,21 +873,12 @@
850
851 /*
852 ** Runs the pre-transfer TH1 script, if any, and returns its return code.
853 */
854 int xfer_run_common_script(void){
855 int result = 0;
856 if( !commonScriptRan ){
857 Th_FossilInit(TH_INIT_DEFAULT); /* Make sure TH1 is ready. */
858 commonScriptRan = 1; /* enable run_script to do something */
859 result = xfer_run_script("xfer-common-script", 0);
860 if( result == TH_ERROR ){
861 /* Error message is left in th interpreter. */
862 commonScriptRan = 2;
863 }
864 }
865 return result;
866 }
867
868 /*
869 ** If this variable is set, disable login checks. Used for debugging
870 ** only.
@@ -1249,11 +1263,11 @@
1249 }
1250 blobarray_reset(xfer.aToken, xfer.nToken);
1251 blob_reset(&xfer.line);
1252 }
1253 if( isPush ){
1254 if( xfer_run_script("xfer-push-script", 0)!=TH_OK ){
1255 cgi_reset_content();
1256 @ error push\sscript\sfailed:\s%F(g.zErrMsg)
1257 nErr++;
1258 }
1259 request_phantoms(&xfer, 500);
1260
--- src/xfer.c
+++ src/xfer.c
@@ -191,11 +191,11 @@
191 if( rid==0 ){
192 blob_appendf(&pXfer->err, "%s", g.zErrMsg);
193 blob_reset(&content);
194 }else{
195 if( !isPriv ) content_make_public(rid);
196 manifest_crosslink(rid, &content, MC_NONE);
197 }
198 assert( blob_is_reset(&content) );
199 remote_has(rid);
200 }
201
@@ -819,31 +819,54 @@
819 */
820 static void server_private_xfer_not_authorized(void){
821 @ error not\sauthorized\sto\ssync\sprivate\scontent
822 }
823
824 /*
825 ** Return the common TH1 code to evaluate prior to evaluating any other
826 ** TH1 transfer notification scripts.
827 */
828 const char *xfer_common_code(void){
829 return db_get("xfer-common-script", 0);
830 }
831
832 /*
833 ** Return the TH1 code to evaluate when a push is processed.
834 */
835 const char *xfer_push_code(void){
836 return db_get("xfer-push-script", 0);
837 }
838
839 /*
840 ** Return the TH1 code to evaluate when a commit is processed.
841 */
842 const char *xfer_commit_code(void){
843 return db_get("xfer-commit-script", 0);
844 }
845
846 /*
847 ** Return the TH1 code to evaluate when a ticket change is processed.
848 */
849 const char *xfer_ticket_code(void){
850 return db_get("xfer-ticket-script", 0);
851 }
852
853 /*
854 ** Run the specified TH1 script, if any, and returns 1 on error.
855 */
856 int xfer_run_script(const char *zScript, const char *zUuid){
857 int result;
858 if( !zScript ) return TH_OK;
859 Th_FossilInit(TH_INIT_DEFAULT);
860 if( zUuid ){
861 result = Th_SetVar(g.interp, "uuid", -1, zUuid, -1);
862 if( result!=TH_OK ){
863 fossil_error(1, "%s", Th_GetResult(g.interp, 0));
864 return result;
865 }
866 }
867 result = Th_Eval(g.interp, 0, zScript, -1);
 
 
 
 
868 if( result!=TH_OK ){
869 fossil_error(1, "%s", Th_GetResult(g.interp, 0));
870 }
871 return result;
872 }
@@ -850,21 +873,12 @@
873
874 /*
875 ** Runs the pre-transfer TH1 script, if any, and returns its return code.
876 */
877 int xfer_run_common_script(void){
878 Th_FossilInit(TH_INIT_DEFAULT);
879 return xfer_run_script(xfer_common_code(), 0);
 
 
 
 
 
 
 
 
 
880 }
881
882 /*
883 ** If this variable is set, disable login checks. Used for debugging
884 ** only.
@@ -1249,11 +1263,11 @@
1263 }
1264 blobarray_reset(xfer.aToken, xfer.nToken);
1265 blob_reset(&xfer.line);
1266 }
1267 if( isPush ){
1268 if( xfer_run_script(xfer_push_code(), 0)!=TH_OK ){
1269 cgi_reset_content();
1270 @ error push\sscript\sfailed:\s%F(g.zErrMsg)
1271 nErr++;
1272 }
1273 request_phantoms(&xfer, 500);
1274

Keyboard Shortcuts

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