Fossil SCM

remove hook command to be compatible with other hook designs

wolfgang 2010-11-08 23:01 UTC StvPrivateHook2
Commit a06121740a37e703b1e2645bc71c3b516fac9ac3
3 files changed -42 +2 -8 +1 -148
-42
--- src/db.c
+++ src/db.c
@@ -1526,19 +1526,10 @@
15261526
{ "localauth", 0, 0, "off" },
15271527
{ "manifest", 0, 0, "off" },
15281528
{ "mtime-changes", 0, 0, "on" },
15291529
{ "pgp-command", 0, 32, "gpg --clearsign -o " },
15301530
{ "proxy", 0, 32, "off" },
1531
- { "push-hook-cmd", 0, 32, "" },
1532
- { "push-hook-force",
1533
- 0, 0, "" },
1534
- { "push-hook-pattern-client",
1535
- 0, 32, "" },
1536
- { "push-hook-pattern-server",
1537
- 0, 32, "" },
1538
- { "push-hook-privilege",
1539
- 0, 1, "" },
15401531
{ "repo-cksum", 0, 0, "on" },
15411532
{ "ssh-command", 0, 32, "" },
15421533
{ "web-browser", 0, 32, "" },
15431534
{ 0,0,0,0 }
15441535
};
@@ -1612,43 +1603,10 @@
16121603
** proxy URL of the HTTP proxy. If undefined or "off" then
16131604
** the "http_proxy" environment variable is consulted.
16141605
** If the http_proxy environment variable is undefined
16151606
** then a direct HTTP connection is used.
16161607
**
1617
-** push-hook-cmd this is the command line, that will be activated
1618
-** as push hook. Output redirects should be added to
1619
-** this command line.
1620
-** The complete command line looks like:
1621
-** command name: the configured value for push-hook-cmd
1622
-** argument 1: timestamp followed by random-number
1623
-** argument 2: pattern sent by client
1624
-** As fallback, stdin/stderr are redirected to files
1625
-** hook-log-<timestamp followed by random-number>
1626
-**
1627
-** push-hook-force
1628
-** if this is set on the client, it will request always
1629
-** the hook activation, even if no files where pushed on
1630
-** the sync.
1631
-** if this is set on the server, it will accept hook
1632
-** activiation, even if no files where pushed.
1633
-** Default: on
1634
-**
1635
-** push-hook-pattern-client
1636
-** if set, a client push will sent this message to the
1637
-** server, to activate the push hook command.
1638
-** Default: on
1639
-**
1640
-** push-hook-pattern-server
1641
-** if set, and a client send this pattern at the end of
1642
-** a push, the push hook command will be executed. This
1643
-** might be a prefix of the pattern, sent by the client.
1644
-**
1645
-** push-hook-privilege
1646
-** if set, the user doing the push needs this privilege
1647
-** to trigger the hook. Valid privileges are:
1648
-** s (setup), a (admin), i (checkin) or o (checkout)
1649
-**
16501608
** repo-cksum Compute checksums over all files in each checkout
16511609
** as a double-check of correctness. Defaults to "on".
16521610
** Disable on large repositories for a performance
16531611
** improvement.
16541612
**
16551613
--- src/db.c
+++ src/db.c
@@ -1526,19 +1526,10 @@
1526 { "localauth", 0, 0, "off" },
1527 { "manifest", 0, 0, "off" },
1528 { "mtime-changes", 0, 0, "on" },
1529 { "pgp-command", 0, 32, "gpg --clearsign -o " },
1530 { "proxy", 0, 32, "off" },
1531 { "push-hook-cmd", 0, 32, "" },
1532 { "push-hook-force",
1533 0, 0, "" },
1534 { "push-hook-pattern-client",
1535 0, 32, "" },
1536 { "push-hook-pattern-server",
1537 0, 32, "" },
1538 { "push-hook-privilege",
1539 0, 1, "" },
1540 { "repo-cksum", 0, 0, "on" },
1541 { "ssh-command", 0, 32, "" },
1542 { "web-browser", 0, 32, "" },
1543 { 0,0,0,0 }
1544 };
@@ -1612,43 +1603,10 @@
1612 ** proxy URL of the HTTP proxy. If undefined or "off" then
1613 ** the "http_proxy" environment variable is consulted.
1614 ** If the http_proxy environment variable is undefined
1615 ** then a direct HTTP connection is used.
1616 **
1617 ** push-hook-cmd this is the command line, that will be activated
1618 ** as push hook. Output redirects should be added to
1619 ** this command line.
1620 ** The complete command line looks like:
1621 ** command name: the configured value for push-hook-cmd
1622 ** argument 1: timestamp followed by random-number
1623 ** argument 2: pattern sent by client
1624 ** As fallback, stdin/stderr are redirected to files
1625 ** hook-log-<timestamp followed by random-number>
1626 **
1627 ** push-hook-force
1628 ** if this is set on the client, it will request always
1629 ** the hook activation, even if no files where pushed on
1630 ** the sync.
1631 ** if this is set on the server, it will accept hook
1632 ** activiation, even if no files where pushed.
1633 ** Default: on
1634 **
1635 ** push-hook-pattern-client
1636 ** if set, a client push will sent this message to the
1637 ** server, to activate the push hook command.
1638 ** Default: on
1639 **
1640 ** push-hook-pattern-server
1641 ** if set, and a client send this pattern at the end of
1642 ** a push, the push hook command will be executed. This
1643 ** might be a prefix of the pattern, sent by the client.
1644 **
1645 ** push-hook-privilege
1646 ** if set, the user doing the push needs this privilege
1647 ** to trigger the hook. Valid privileges are:
1648 ** s (setup), a (admin), i (checkin) or o (checkout)
1649 **
1650 ** repo-cksum Compute checksums over all files in each checkout
1651 ** as a double-check of correctness. Defaults to "on".
1652 ** Disable on large repositories for a performance
1653 ** improvement.
1654 **
1655
--- src/db.c
+++ src/db.c
@@ -1526,19 +1526,10 @@
1526 { "localauth", 0, 0, "off" },
1527 { "manifest", 0, 0, "off" },
1528 { "mtime-changes", 0, 0, "on" },
1529 { "pgp-command", 0, 32, "gpg --clearsign -o " },
1530 { "proxy", 0, 32, "off" },
 
 
 
 
 
 
 
 
 
1531 { "repo-cksum", 0, 0, "on" },
1532 { "ssh-command", 0, 32, "" },
1533 { "web-browser", 0, 32, "" },
1534 { 0,0,0,0 }
1535 };
@@ -1612,43 +1603,10 @@
1603 ** proxy URL of the HTTP proxy. If undefined or "off" then
1604 ** the "http_proxy" environment variable is consulted.
1605 ** If the http_proxy environment variable is undefined
1606 ** then a direct HTTP connection is used.
1607 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1608 ** repo-cksum Compute checksums over all files in each checkout
1609 ** as a double-check of correctness. Defaults to "on".
1610 ** Disable on large repositories for a performance
1611 ** improvement.
1612 **
1613
+2 -8
--- src/sync.c
+++ src/sync.c
@@ -165,14 +165,11 @@
165165
** The URL specified normally becomes the new "remote-url" used for
166166
** subsequent <a>push</a>, <a>pull</a>, and <a>sync</a> operations. However,
167167
** the "--once" command-line option makes the URL a one-time-use URL
168168
** that is not saved.
169169
**
170
-** If configured (<a>setting</a> push-hook-..), the push hook command will be
171
-** executed on the server after pushing files.
172
-**
173
-** See also: <a>callhook</a>, <a>clone</a>, <a>pull</a>, <a>sync</a>, <a>remote-url</a>
170
+** See also: <a>clone</a>, <a>pull</a>, <a>sync</a>, <a>remote-url</a>
174171
*/
175172
void push_cmd(void){
176173
process_sync_args();
177174
client_sync(1,0,0,0,0);
178175
}
@@ -199,14 +196,11 @@
199196
** The URL specified normally becomes the new "remote-url" used for
200197
** subsequent <a>push</a>, <a>pull</a>, and <a>sync</a> operations. However,
201198
** the "--once" command-line option makes the URL a one-time-use URL
202199
** that is not saved.
203200
**
204
-** If configured (<a>setting</a> push-hook-..), the push hook command will be
205
-** executed on the server after pushing files.
206
-**
207
-** See also: <a>callhook</a>, <a>clone</a>, <a>push</a>, <a>pull</a>, <a>remote-url</a>
201
+** See also: <a>clone</a>, <a>push</a>, <a>pull</a>, <a>remote-url</a>
208202
*/
209203
void sync_cmd(void){
210204
int syncFlags = process_sync_args();
211205
client_sync(1,1,0,syncFlags,0);
212206
}
213207
--- src/sync.c
+++ src/sync.c
@@ -165,14 +165,11 @@
165 ** The URL specified normally becomes the new "remote-url" used for
166 ** subsequent <a>push</a>, <a>pull</a>, and <a>sync</a> operations. However,
167 ** the "--once" command-line option makes the URL a one-time-use URL
168 ** that is not saved.
169 **
170 ** If configured (<a>setting</a> push-hook-..), the push hook command will be
171 ** executed on the server after pushing files.
172 **
173 ** See also: <a>callhook</a>, <a>clone</a>, <a>pull</a>, <a>sync</a>, <a>remote-url</a>
174 */
175 void push_cmd(void){
176 process_sync_args();
177 client_sync(1,0,0,0,0);
178 }
@@ -199,14 +196,11 @@
199 ** The URL specified normally becomes the new "remote-url" used for
200 ** subsequent <a>push</a>, <a>pull</a>, and <a>sync</a> operations. However,
201 ** the "--once" command-line option makes the URL a one-time-use URL
202 ** that is not saved.
203 **
204 ** If configured (<a>setting</a> push-hook-..), the push hook command will be
205 ** executed on the server after pushing files.
206 **
207 ** See also: <a>callhook</a>, <a>clone</a>, <a>push</a>, <a>pull</a>, <a>remote-url</a>
208 */
209 void sync_cmd(void){
210 int syncFlags = process_sync_args();
211 client_sync(1,1,0,syncFlags,0);
212 }
213
--- src/sync.c
+++ src/sync.c
@@ -165,14 +165,11 @@
165 ** The URL specified normally becomes the new "remote-url" used for
166 ** subsequent <a>push</a>, <a>pull</a>, and <a>sync</a> operations. However,
167 ** the "--once" command-line option makes the URL a one-time-use URL
168 ** that is not saved.
169 **
170 ** See also: <a>clone</a>, <a>pull</a>, <a>sync</a>, <a>remote-url</a>
 
 
 
171 */
172 void push_cmd(void){
173 process_sync_args();
174 client_sync(1,0,0,0,0);
175 }
@@ -199,14 +196,11 @@
196 ** The URL specified normally becomes the new "remote-url" used for
197 ** subsequent <a>push</a>, <a>pull</a>, and <a>sync</a> operations. However,
198 ** the "--once" command-line option makes the URL a one-time-use URL
199 ** that is not saved.
200 **
201 ** See also: <a>clone</a>, <a>push</a>, <a>pull</a>, <a>remote-url</a>
 
 
 
202 */
203 void sync_cmd(void){
204 int syncFlags = process_sync_args();
205 client_sync(1,1,0,syncFlags,0);
206 }
207
+1 -148
--- src/xfer.c
+++ src/xfer.c
@@ -40,130 +40,10 @@
4040
int nDeltaRcvd; /* Number of deltas received */
4141
int nDanglingFile; /* Number of dangling deltas received */
4242
int mxSend; /* Stop sending "file" with pOut reaches this size */
4343
};
4444
45
-/*
46
-** COMMAND: callhook
47
-** %fossil callhook PUSHHOOKPATTERN ?--force|-f?
48
-**
49
-** Call the push hook command on a server, which will normally be called
50
-** after a client push (<a>setting</a> push-hook-cmd).
51
-**
52
-** If --force is used, the given pattern is not checked against the
53
-** configuration (<a>setting</a> push-hook-pattern-server).
54
-**
55
-** This command only works on the server side, it does not send a message
56
-** from a client, but executes the hook directly on the server.
57
-**
58
-** See also <a>push</a>, <a>sync</a>, <a>setting</a>
59
-*/
60
-void callhook_cmd(void){
61
- int forceFlag = find_option("force","f",0)!=0;
62
-
63
- db_open_config(1);
64
- db_find_and_open_repository(0);
65
- if( (g.argc!=3) || (!g.argv[2]) || (!g.argv[2][0]) ){
66
- usage("PUSHHOOKPATTERN ?--force?");
67
- }
68
- if( !forceFlag ){
69
- const char *zPushHookPattern = db_get("push-hook-pattern-server", "");
70
- int lenPushHookPattern = (zPushHookPattern && zPushHookPattern[0])
71
- ? strlen(zPushHookPattern) : 0;
72
- if( (!lenPushHookPattern)
73
- || memcmp(g.argv[2], zPushHookPattern, lenPushHookPattern)
74
- ){
75
- fossil_fatal("push hook pattern '%s' doesn't match configuration '%s'\n",
76
- g.argv[2],zPushHookPattern);
77
- }
78
- }
79
- post_push_hook(g.argv[2],'C');
80
-}
81
-
82
-/*
83
-** Let a server-side external agent know that a push has completed. /fatman
84
-** The second argument controls, how the command is called:
85
-** P - client request with pushed files
86
-** F - client request without pushed files(FORCE!)
87
-** C - server side command line activation
88
-*/
89
-void post_push_hook(char const * const zPushHookLine, const char requestType){
90
- /*
91
- ** TO DO: get the string cmd from a config file? Or the database local
92
- ** settings, as someone suggested? Ditto output and error logs. /fatman
93
- */
94
- const char *zCmd = db_get("push-hook-cmd", "");
95
- int allowForced = db_get_boolean("push-hook-force", 0);
96
- const char *zHookPriv = db_get("push-hook-privilege","");
97
- int privOk = 0;
98
-
99
- if( zHookPriv && *zHookPriv ){
100
- switch( *zHookPriv ){
101
-
102
- case 's':
103
- if( g.okSetup ) privOk = 1;
104
- break;
105
- case 'a':
106
- if( g.okAdmin ) privOk = 1;
107
- break;
108
- case 'i':
109
- if( g.okWrite ) privOk = 1;
110
- break;
111
- case 'o':
112
- if( g.okRead ) privOk = 1;
113
- break;
114
- default:
115
- fossil_print("Push hook wrong privilege type '%s'\n", zHookPriv);
116
- }
117
- }else{
118
- privOk = 1;
119
- }
120
- if( !privOk ){
121
- fossil_print("No privilege to activate hook!\n");
122
- }else if( requestType!='P' && requestType!='C' && requestType!='F' ){
123
- fossil_print("Push hook wrong request type '%c'\n", requestType);
124
- }else if( requestType=='F' && !allowForced ){
125
- fossil_print("Forced push call from client not allowed,"
126
- " skipping call for '%s'\n", zPushHookLine);
127
- }else if( zCmd && zCmd[0] ){
128
- int rc;
129
- char * zCalledCmd;
130
- char * zDate;
131
- const char *zRnd;
132
-
133
-
134
- zDate = db_text(0, "SELECT strftime('%%Y%%m%%d%%H%%M%%f','now')");
135
- zRnd = db_text(0, "SELECT lower(hex(randomblob(6)))");
136
-
137
- zCalledCmd = mprintf("%s %s-%s %s >hook-log-%s-%s 2>&1",zCmd,zDate,zRnd,zPushHookLine,zDate,zRnd);
138
- { /* remove newlines from command */
139
- char *zSrc, *zDest;
140
-
141
- for (zSrc=zDest=zCalledCmd;;zSrc++){
142
- switch( *zSrc ){
143
- case '\0':
144
- *zDest=0;
145
- break;
146
- default:
147
- *zDest++ = *zSrc;
148
- /* fall through is intended! */
149
- case '\n':
150
- continue;
151
- }
152
- break;
153
- }
154
- }
155
- rc = system(zCalledCmd);
156
- if (rc != 0) {
157
- fossil_print("The post-push-hook command '%s' failed.", zCalledCmd);
158
- }
159
- free(zCalledCmd);
160
- free(zDate);
161
- }else{
162
- fossil_print("No push hook configured, skipping call for '%s'\n", zPushHookLine);
163
- }
164
-}
16545
16646
/*
16747
** The input blob contains a UUID. Convert it into a record ID.
16848
** Create a phantom record if no prior record exists and
16949
** phantomize is true.
@@ -747,13 +627,10 @@
747627
int isClone = 0;
748628
int nGimme = 0;
749629
int size;
750630
int recvConfig = 0;
751631
char *zNow;
752
- const char *zPushHookPattern = db_get("push-hook-pattern-server", "");
753
- int lenPushHookPattern = (zPushHookPattern && zPushHookPattern[0])
754
- ? strlen(zPushHookPattern) : 0;
755632
756633
if( strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
757634
fossil_redirect_home();
758635
}
759636
memset(&xfer, 0, sizeof(xfer));
@@ -769,21 +646,11 @@
769646
db_multi_exec(
770647
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
771648
);
772649
manifest_crosslink_begin();
773650
while( blob_line(xfer.pIn, &xfer.line) ){
774
- if( blob_buffer(&xfer.line)[0]=='#' ){
775
- if( lenPushHookPattern
776
- && blob_buffer(&xfer.line)[1]
777
- && blob_buffer(&xfer.line)[2]
778
- && (0 == memcmp(blob_buffer(&xfer.line)+2,
779
- zPushHookPattern, lenPushHookPattern))
780
- ){
781
- post_push_hook(blob_buffer(&xfer.line)+2,blob_buffer(&xfer.line)[1]);
782
- }
783
- continue;
784
- }
651
+ if( blob_buffer(&xfer.line)[0]=='#' ) continue;
785652
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
786653
787654
/* file UUID SIZE \n CONTENT
788655
** file UUID DELTASRC SIZE \n CONTENT
789656
**
@@ -1138,13 +1005,10 @@
11381005
int pctDone; /* Percentage done with a message */
11391006
int lastPctDone = -1; /* Last displayed pctDone */
11401007
double rArrivalTime; /* Time at which a message arrived */
11411008
const char *zSCode = db_get("server-code", "x");
11421009
const char *zPCode = db_get("project-code", 0);
1143
- const char *zPushHookPattern = db_get("push-hook-pattern-client", "");
1144
- int allowForced = db_get_boolean("push-hook-force", 0);
1145
-
11461010
11471011
if( db_get_boolean("dont-push", 0) ) pushFlag = 0;
11481012
if( pushFlag + pullFlag + cloneFlag == 0
11491013
&& configRcvMask==0 && configSendMask==0 ) return;
11501014
@@ -1553,21 +1417,10 @@
15531417
if( cloneFlag && nCycle==1 ) go = 1;
15541418
15551419
/* Stop the cycle if the server sends a "clone_seqno 0" card */
15561420
if( cloneSeqno<=0 ) go = 0;
15571421
};
1558
- if( pushFlag && ( (nFileSend > 0) || allowForced ) ){
1559
- if( zPushHookPattern && zPushHookPattern[0] ){
1560
- blob_appendf(&send, "#%s%s\n",
1561
- ((nFileSend > 0)?"P":"F"), zPushHookPattern);
1562
- fossil_print("Triggering push hook %s '%s'\n",((nFileSend > 0)?"P":"F"),zPushHookPattern);
1563
- http_exchange(&send, &recv, cloneFlag==0 || nCycle>0);
1564
- blob_reset(&send);
1565
- nCardSent++;
1566
- }
1567
- int allowForced = db_get_boolean("push-hook-force", 0);
1568
- }
15691422
transport_stats(&nSent, &nRcvd, 1);
15701423
fossil_print("Total network traffic: %d bytes sent, %d bytes received\n",
15711424
nSent, nRcvd);
15721425
transport_close();
15731426
transport_global_shutdown();
15741427
--- src/xfer.c
+++ src/xfer.c
@@ -40,130 +40,10 @@
40 int nDeltaRcvd; /* Number of deltas received */
41 int nDanglingFile; /* Number of dangling deltas received */
42 int mxSend; /* Stop sending "file" with pOut reaches this size */
43 };
44
45 /*
46 ** COMMAND: callhook
47 ** %fossil callhook PUSHHOOKPATTERN ?--force|-f?
48 **
49 ** Call the push hook command on a server, which will normally be called
50 ** after a client push (<a>setting</a> push-hook-cmd).
51 **
52 ** If --force is used, the given pattern is not checked against the
53 ** configuration (<a>setting</a> push-hook-pattern-server).
54 **
55 ** This command only works on the server side, it does not send a message
56 ** from a client, but executes the hook directly on the server.
57 **
58 ** See also <a>push</a>, <a>sync</a>, <a>setting</a>
59 */
60 void callhook_cmd(void){
61 int forceFlag = find_option("force","f",0)!=0;
62
63 db_open_config(1);
64 db_find_and_open_repository(0);
65 if( (g.argc!=3) || (!g.argv[2]) || (!g.argv[2][0]) ){
66 usage("PUSHHOOKPATTERN ?--force?");
67 }
68 if( !forceFlag ){
69 const char *zPushHookPattern = db_get("push-hook-pattern-server", "");
70 int lenPushHookPattern = (zPushHookPattern && zPushHookPattern[0])
71 ? strlen(zPushHookPattern) : 0;
72 if( (!lenPushHookPattern)
73 || memcmp(g.argv[2], zPushHookPattern, lenPushHookPattern)
74 ){
75 fossil_fatal("push hook pattern '%s' doesn't match configuration '%s'\n",
76 g.argv[2],zPushHookPattern);
77 }
78 }
79 post_push_hook(g.argv[2],'C');
80 }
81
82 /*
83 ** Let a server-side external agent know that a push has completed. /fatman
84 ** The second argument controls, how the command is called:
85 ** P - client request with pushed files
86 ** F - client request without pushed files(FORCE!)
87 ** C - server side command line activation
88 */
89 void post_push_hook(char const * const zPushHookLine, const char requestType){
90 /*
91 ** TO DO: get the string cmd from a config file? Or the database local
92 ** settings, as someone suggested? Ditto output and error logs. /fatman
93 */
94 const char *zCmd = db_get("push-hook-cmd", "");
95 int allowForced = db_get_boolean("push-hook-force", 0);
96 const char *zHookPriv = db_get("push-hook-privilege","");
97 int privOk = 0;
98
99 if( zHookPriv && *zHookPriv ){
100 switch( *zHookPriv ){
101
102 case 's':
103 if( g.okSetup ) privOk = 1;
104 break;
105 case 'a':
106 if( g.okAdmin ) privOk = 1;
107 break;
108 case 'i':
109 if( g.okWrite ) privOk = 1;
110 break;
111 case 'o':
112 if( g.okRead ) privOk = 1;
113 break;
114 default:
115 fossil_print("Push hook wrong privilege type '%s'\n", zHookPriv);
116 }
117 }else{
118 privOk = 1;
119 }
120 if( !privOk ){
121 fossil_print("No privilege to activate hook!\n");
122 }else if( requestType!='P' && requestType!='C' && requestType!='F' ){
123 fossil_print("Push hook wrong request type '%c'\n", requestType);
124 }else if( requestType=='F' && !allowForced ){
125 fossil_print("Forced push call from client not allowed,"
126 " skipping call for '%s'\n", zPushHookLine);
127 }else if( zCmd && zCmd[0] ){
128 int rc;
129 char * zCalledCmd;
130 char * zDate;
131 const char *zRnd;
132
133
134 zDate = db_text(0, "SELECT strftime('%%Y%%m%%d%%H%%M%%f','now')");
135 zRnd = db_text(0, "SELECT lower(hex(randomblob(6)))");
136
137 zCalledCmd = mprintf("%s %s-%s %s >hook-log-%s-%s 2>&1",zCmd,zDate,zRnd,zPushHookLine,zDate,zRnd);
138 { /* remove newlines from command */
139 char *zSrc, *zDest;
140
141 for (zSrc=zDest=zCalledCmd;;zSrc++){
142 switch( *zSrc ){
143 case '\0':
144 *zDest=0;
145 break;
146 default:
147 *zDest++ = *zSrc;
148 /* fall through is intended! */
149 case '\n':
150 continue;
151 }
152 break;
153 }
154 }
155 rc = system(zCalledCmd);
156 if (rc != 0) {
157 fossil_print("The post-push-hook command '%s' failed.", zCalledCmd);
158 }
159 free(zCalledCmd);
160 free(zDate);
161 }else{
162 fossil_print("No push hook configured, skipping call for '%s'\n", zPushHookLine);
163 }
164 }
165
166 /*
167 ** The input blob contains a UUID. Convert it into a record ID.
168 ** Create a phantom record if no prior record exists and
169 ** phantomize is true.
@@ -747,13 +627,10 @@
747 int isClone = 0;
748 int nGimme = 0;
749 int size;
750 int recvConfig = 0;
751 char *zNow;
752 const char *zPushHookPattern = db_get("push-hook-pattern-server", "");
753 int lenPushHookPattern = (zPushHookPattern && zPushHookPattern[0])
754 ? strlen(zPushHookPattern) : 0;
755
756 if( strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
757 fossil_redirect_home();
758 }
759 memset(&xfer, 0, sizeof(xfer));
@@ -769,21 +646,11 @@
769 db_multi_exec(
770 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
771 );
772 manifest_crosslink_begin();
773 while( blob_line(xfer.pIn, &xfer.line) ){
774 if( blob_buffer(&xfer.line)[0]=='#' ){
775 if( lenPushHookPattern
776 && blob_buffer(&xfer.line)[1]
777 && blob_buffer(&xfer.line)[2]
778 && (0 == memcmp(blob_buffer(&xfer.line)+2,
779 zPushHookPattern, lenPushHookPattern))
780 ){
781 post_push_hook(blob_buffer(&xfer.line)+2,blob_buffer(&xfer.line)[1]);
782 }
783 continue;
784 }
785 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
786
787 /* file UUID SIZE \n CONTENT
788 ** file UUID DELTASRC SIZE \n CONTENT
789 **
@@ -1138,13 +1005,10 @@
1138 int pctDone; /* Percentage done with a message */
1139 int lastPctDone = -1; /* Last displayed pctDone */
1140 double rArrivalTime; /* Time at which a message arrived */
1141 const char *zSCode = db_get("server-code", "x");
1142 const char *zPCode = db_get("project-code", 0);
1143 const char *zPushHookPattern = db_get("push-hook-pattern-client", "");
1144 int allowForced = db_get_boolean("push-hook-force", 0);
1145
1146
1147 if( db_get_boolean("dont-push", 0) ) pushFlag = 0;
1148 if( pushFlag + pullFlag + cloneFlag == 0
1149 && configRcvMask==0 && configSendMask==0 ) return;
1150
@@ -1553,21 +1417,10 @@
1553 if( cloneFlag && nCycle==1 ) go = 1;
1554
1555 /* Stop the cycle if the server sends a "clone_seqno 0" card */
1556 if( cloneSeqno<=0 ) go = 0;
1557 };
1558 if( pushFlag && ( (nFileSend > 0) || allowForced ) ){
1559 if( zPushHookPattern && zPushHookPattern[0] ){
1560 blob_appendf(&send, "#%s%s\n",
1561 ((nFileSend > 0)?"P":"F"), zPushHookPattern);
1562 fossil_print("Triggering push hook %s '%s'\n",((nFileSend > 0)?"P":"F"),zPushHookPattern);
1563 http_exchange(&send, &recv, cloneFlag==0 || nCycle>0);
1564 blob_reset(&send);
1565 nCardSent++;
1566 }
1567 int allowForced = db_get_boolean("push-hook-force", 0);
1568 }
1569 transport_stats(&nSent, &nRcvd, 1);
1570 fossil_print("Total network traffic: %d bytes sent, %d bytes received\n",
1571 nSent, nRcvd);
1572 transport_close();
1573 transport_global_shutdown();
1574
--- src/xfer.c
+++ src/xfer.c
@@ -40,130 +40,10 @@
40 int nDeltaRcvd; /* Number of deltas received */
41 int nDanglingFile; /* Number of dangling deltas received */
42 int mxSend; /* Stop sending "file" with pOut reaches this size */
43 };
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
46 /*
47 ** The input blob contains a UUID. Convert it into a record ID.
48 ** Create a phantom record if no prior record exists and
49 ** phantomize is true.
@@ -747,13 +627,10 @@
627 int isClone = 0;
628 int nGimme = 0;
629 int size;
630 int recvConfig = 0;
631 char *zNow;
 
 
 
632
633 if( strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
634 fossil_redirect_home();
635 }
636 memset(&xfer, 0, sizeof(xfer));
@@ -769,21 +646,11 @@
646 db_multi_exec(
647 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
648 );
649 manifest_crosslink_begin();
650 while( blob_line(xfer.pIn, &xfer.line) ){
651 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
 
 
 
 
 
 
 
 
 
 
652 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
653
654 /* file UUID SIZE \n CONTENT
655 ** file UUID DELTASRC SIZE \n CONTENT
656 **
@@ -1138,13 +1005,10 @@
1005 int pctDone; /* Percentage done with a message */
1006 int lastPctDone = -1; /* Last displayed pctDone */
1007 double rArrivalTime; /* Time at which a message arrived */
1008 const char *zSCode = db_get("server-code", "x");
1009 const char *zPCode = db_get("project-code", 0);
 
 
 
1010
1011 if( db_get_boolean("dont-push", 0) ) pushFlag = 0;
1012 if( pushFlag + pullFlag + cloneFlag == 0
1013 && configRcvMask==0 && configSendMask==0 ) return;
1014
@@ -1553,21 +1417,10 @@
1417 if( cloneFlag && nCycle==1 ) go = 1;
1418
1419 /* Stop the cycle if the server sends a "clone_seqno 0" card */
1420 if( cloneSeqno<=0 ) go = 0;
1421 };
 
 
 
 
 
 
 
 
 
 
 
1422 transport_stats(&nSent, &nRcvd, 1);
1423 fossil_print("Total network traffic: %d bytes sent, %d bytes received\n",
1424 nSent, nRcvd);
1425 transport_close();
1426 transport_global_shutdown();
1427

Keyboard Shortcuts

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