Fossil SCM

Issue a warning after a commit if the commit causes a fork.

drh 2008-02-09 00:11 trunk
Commit 49b59bc5593a0e2118604573a04b5f46496740fa
+1 -1
--- src/branch.c
+++ src/branch.c
@@ -153,11 +153,11 @@
153153
154154
/* Commit */
155155
db_end_transaction(0);
156156
157157
/* Do an autosync push, if requested */
158
- autosync(0);
158
+ autosync(AUTOSYNC_PUSH);
159159
}
160160
161161
/*
162162
** COMMAND: branch
163163
**
164164
--- src/branch.c
+++ src/branch.c
@@ -153,11 +153,11 @@
153
154 /* Commit */
155 db_end_transaction(0);
156
157 /* Do an autosync push, if requested */
158 autosync(0);
159 }
160
161 /*
162 ** COMMAND: branch
163 **
164
--- src/branch.c
+++ src/branch.c
@@ -153,11 +153,11 @@
153
154 /* Commit */
155 db_end_transaction(0);
156
157 /* Do an autosync push, if requested */
158 autosync(AUTOSYNC_PUSH);
159 }
160
161 /*
162 ** COMMAND: branch
163 **
164
+5 -12
--- src/checkin.c
+++ src/checkin.c
@@ -343,11 +343,11 @@
343343
verify_all_options();
344344
345345
/*
346346
** Autosync if requested.
347347
*/
348
- autosync(1);
348
+ autosync(AUTOSYNC_PULL);
349349
350350
/* There are two ways this command may be executed. If there are
351351
** no arguments following the word "commit", then all modified files
352352
** in the checked out directory are committed. If one or more arguments
353353
** follows "commit", then only those files are committed.
@@ -545,21 +545,14 @@
545545
/* Clear the undo/redo stack */
546546
undo_reset();
547547
548548
/* Commit */
549549
db_end_transaction(0);
550
-
551
- if( wouldFork==0 ){
552
- /* Do an autosync push if requested. If wouldFork == 1, then they either
553
- ** forced this commit or safe merge is on, and this commit did indeed
554
- ** create a fork. In this case, we want the user to merge before sending
555
- ** their new commit back to the rest of the world, so do not auto-push.
556
- */
557
- autosync(0);
558
- }else{
559
- printf("Warning: commit caused a fork to occur. Please merge and push\n");
560
- printf(" your changes as soon as possible.\n");
550
+
551
+ autosync(AUTOSYNC_PUSH);
552
+ if( db_exists("SELECT 1 FROM plink WHERE pid=%d AND cid!=%d", vid, nvid) ){
553
+ printf("**** warning: a fork has occurred *****\n");
561554
}
562555
}
563556
564557
/*
565558
** COMMAND: test-import-manifest
566559
--- src/checkin.c
+++ src/checkin.c
@@ -343,11 +343,11 @@
343 verify_all_options();
344
345 /*
346 ** Autosync if requested.
347 */
348 autosync(1);
349
350 /* There are two ways this command may be executed. If there are
351 ** no arguments following the word "commit", then all modified files
352 ** in the checked out directory are committed. If one or more arguments
353 ** follows "commit", then only those files are committed.
@@ -545,21 +545,14 @@
545 /* Clear the undo/redo stack */
546 undo_reset();
547
548 /* Commit */
549 db_end_transaction(0);
550
551 if( wouldFork==0 ){
552 /* Do an autosync push if requested. If wouldFork == 1, then they either
553 ** forced this commit or safe merge is on, and this commit did indeed
554 ** create a fork. In this case, we want the user to merge before sending
555 ** their new commit back to the rest of the world, so do not auto-push.
556 */
557 autosync(0);
558 }else{
559 printf("Warning: commit caused a fork to occur. Please merge and push\n");
560 printf(" your changes as soon as possible.\n");
561 }
562 }
563
564 /*
565 ** COMMAND: test-import-manifest
566
--- src/checkin.c
+++ src/checkin.c
@@ -343,11 +343,11 @@
343 verify_all_options();
344
345 /*
346 ** Autosync if requested.
347 */
348 autosync(AUTOSYNC_PULL);
349
350 /* There are two ways this command may be executed. If there are
351 ** no arguments following the word "commit", then all modified files
352 ** in the checked out directory are committed. If one or more arguments
353 ** follows "commit", then only those files are committed.
@@ -545,21 +545,14 @@
545 /* Clear the undo/redo stack */
546 undo_reset();
547
548 /* Commit */
549 db_end_transaction(0);
550
551 autosync(AUTOSYNC_PUSH);
552 if( db_exists("SELECT 1 FROM plink WHERE pid=%d AND cid!=%d", vid, nvid) ){
553 printf("**** warning: a fork has occurred *****\n");
 
 
 
 
 
 
 
554 }
555 }
556
557 /*
558 ** COMMAND: test-import-manifest
559
+1 -1
--- src/http.c
+++ src/http.c
@@ -371,11 +371,11 @@
371371
}
372372
for(cnt=0; cnt<2; cnt++){
373373
if( http_send_recv(&hdr, &payload, pRecv) ) break;
374374
}
375375
if( cnt>=2 ){
376
- fossil_panic("connection to server failed");
376
+ fossil_fatal("connection to server failed");
377377
}
378378
blob_reset(&hdr);
379379
blob_reset(&payload);
380380
if( g.fHttpTrace ){
381381
printf("HTTP RECEIVE:\n%s\n=======================\n", blob_str(pRecv));
382382
--- src/http.c
+++ src/http.c
@@ -371,11 +371,11 @@
371 }
372 for(cnt=0; cnt<2; cnt++){
373 if( http_send_recv(&hdr, &payload, pRecv) ) break;
374 }
375 if( cnt>=2 ){
376 fossil_panic("connection to server failed");
377 }
378 blob_reset(&hdr);
379 blob_reset(&payload);
380 if( g.fHttpTrace ){
381 printf("HTTP RECEIVE:\n%s\n=======================\n", blob_str(pRecv));
382
--- src/http.c
+++ src/http.c
@@ -371,11 +371,11 @@
371 }
372 for(cnt=0; cnt<2; cnt++){
373 if( http_send_recv(&hdr, &payload, pRecv) ) break;
374 }
375 if( cnt>=2 ){
376 fossil_fatal("connection to server failed");
377 }
378 blob_reset(&hdr);
379 blob_reset(&payload);
380 if( g.fHttpTrace ){
381 printf("HTTP RECEIVE:\n%s\n=======================\n", blob_str(pRecv));
382
+11 -2
--- src/sync.c
+++ src/sync.c
@@ -25,17 +25,26 @@
2525
*/
2626
#include "config.h"
2727
#include "sync.h"
2828
#include <assert.h>
2929
30
+#if INTERFACE
31
+/*
32
+** Flags used to determine which direction(s) an autosync goes in.
33
+*/
34
+#define AUTOSYNC_PUSH 1
35
+#define AUTOSYNC_PULL 2
36
+
37
+#endif /* INTERFACE */
38
+
3039
/*
3140
** If the respository is configured for autosyncing, then do an
3241
** autosync. This will be a pull if the argument is true or a push
3342
** if the argument is false. Return true if the autosync is done
3443
** and false if autosync is not requested for the current repository.
3544
*/
36
-int autosync(int pullFlag){
45
+int autosync(int flags){
3746
const char *zUrl;
3847
if( db_get_boolean("autosync", 0)==0 ){
3948
return 0;
4049
}
4150
zUrl = db_get("last-sync-url", 0);
@@ -49,11 +58,11 @@
4958
if( g.urlPort!=80 ){
5059
printf("Autosync: http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
5160
}else{
5261
printf("Autosync: http://%s%s\n", g.urlName, g.urlPath);
5362
}
54
- client_sync(!pullFlag, pullFlag, 0);
63
+ client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0);
5564
return 1;
5665
}
5766
5867
/*
5968
** This routine processes the command-line argument for push, pull,
6069
--- src/sync.c
+++ src/sync.c
@@ -25,17 +25,26 @@
25 */
26 #include "config.h"
27 #include "sync.h"
28 #include <assert.h>
29
 
 
 
 
 
 
 
 
 
30 /*
31 ** If the respository is configured for autosyncing, then do an
32 ** autosync. This will be a pull if the argument is true or a push
33 ** if the argument is false. Return true if the autosync is done
34 ** and false if autosync is not requested for the current repository.
35 */
36 int autosync(int pullFlag){
37 const char *zUrl;
38 if( db_get_boolean("autosync", 0)==0 ){
39 return 0;
40 }
41 zUrl = db_get("last-sync-url", 0);
@@ -49,11 +58,11 @@
49 if( g.urlPort!=80 ){
50 printf("Autosync: http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
51 }else{
52 printf("Autosync: http://%s%s\n", g.urlName, g.urlPath);
53 }
54 client_sync(!pullFlag, pullFlag, 0);
55 return 1;
56 }
57
58 /*
59 ** This routine processes the command-line argument for push, pull,
60
--- src/sync.c
+++ src/sync.c
@@ -25,17 +25,26 @@
25 */
26 #include "config.h"
27 #include "sync.h"
28 #include <assert.h>
29
30 #if INTERFACE
31 /*
32 ** Flags used to determine which direction(s) an autosync goes in.
33 */
34 #define AUTOSYNC_PUSH 1
35 #define AUTOSYNC_PULL 2
36
37 #endif /* INTERFACE */
38
39 /*
40 ** If the respository is configured for autosyncing, then do an
41 ** autosync. This will be a pull if the argument is true or a push
42 ** if the argument is false. Return true if the autosync is done
43 ** and false if autosync is not requested for the current repository.
44 */
45 int autosync(int flags){
46 const char *zUrl;
47 if( db_get_boolean("autosync", 0)==0 ){
48 return 0;
49 }
50 zUrl = db_get("last-sync-url", 0);
@@ -49,11 +58,11 @@
58 if( g.urlPort!=80 ){
59 printf("Autosync: http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath);
60 }else{
61 printf("Autosync: http://%s%s\n", g.urlName, g.urlPath);
62 }
63 client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0);
64 return 1;
65 }
66
67 /*
68 ** This routine processes the command-line argument for push, pull,
69
+1 -1
--- src/tag.c
+++ src/tag.c
@@ -293,11 +293,11 @@
293293
nrid = content_put(&ctrl, 0, 0);
294294
manifest_crosslink(nrid, &ctrl);
295295
db_end_transaction(0);
296296
297297
/* Do an autosync push if requested */
298
- autosync(0);
298
+ autosync(AUTOSYNC_PUSH);
299299
}
300300
301301
/*
302302
** COMMAND: tag
303303
** Usage: %fossil tag SUBCOMMAND ...
304304
--- src/tag.c
+++ src/tag.c
@@ -293,11 +293,11 @@
293 nrid = content_put(&ctrl, 0, 0);
294 manifest_crosslink(nrid, &ctrl);
295 db_end_transaction(0);
296
297 /* Do an autosync push if requested */
298 autosync(0);
299 }
300
301 /*
302 ** COMMAND: tag
303 ** Usage: %fossil tag SUBCOMMAND ...
304
--- src/tag.c
+++ src/tag.c
@@ -293,11 +293,11 @@
293 nrid = content_put(&ctrl, 0, 0);
294 manifest_crosslink(nrid, &ctrl);
295 db_end_transaction(0);
296
297 /* Do an autosync push if requested */
298 autosync(AUTOSYNC_PUSH);
299 }
300
301 /*
302 ** COMMAND: tag
303 ** Usage: %fossil tag SUBCOMMAND ...
304
+1 -1
--- src/update.c
+++ src/update.c
@@ -92,11 +92,11 @@
9292
** Do an autosync pull prior to the update, if autosync is on and they
9393
** did not want a specific version (i.e. another branch, a past revision).
9494
** By not giving a specific version, they are asking for the latest, thus
9595
** pull to get the latest, then update.
9696
*/
97
- autosync(1);
97
+ autosync(AUTOSYNC_PULL);
9898
}
9999
100100
if( tid==0 ){
101101
compute_leaves(vid);
102102
if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
103103
--- src/update.c
+++ src/update.c
@@ -92,11 +92,11 @@
92 ** Do an autosync pull prior to the update, if autosync is on and they
93 ** did not want a specific version (i.e. another branch, a past revision).
94 ** By not giving a specific version, they are asking for the latest, thus
95 ** pull to get the latest, then update.
96 */
97 autosync(1);
98 }
99
100 if( tid==0 ){
101 compute_leaves(vid);
102 if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
103
--- src/update.c
+++ src/update.c
@@ -92,11 +92,11 @@
92 ** Do an autosync pull prior to the update, if autosync is on and they
93 ** did not want a specific version (i.e. another branch, a past revision).
94 ** By not giving a specific version, they are asking for the latest, thus
95 ** pull to get the latest, then update.
96 */
97 autosync(AUTOSYNC_PULL);
98 }
99
100 if( tid==0 ){
101 compute_leaves(vid);
102 if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
103

Keyboard Shortcuts

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