Fossil SCM
Issue a warning after a commit if the commit causes a fork.
Commit
49b59bc5593a0e2118604573a04b5f46496740fa
Parent
73a9b3d5d1539b1…
6 files changed
+1
-1
+5
-12
+1
-1
+11
-2
+1
-1
+1
-1
+1
-1
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -153,11 +153,11 @@ | ||
| 153 | 153 | |
| 154 | 154 | /* Commit */ |
| 155 | 155 | db_end_transaction(0); |
| 156 | 156 | |
| 157 | 157 | /* Do an autosync push, if requested */ |
| 158 | - autosync(0); | |
| 158 | + autosync(AUTOSYNC_PUSH); | |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /* |
| 162 | 162 | ** COMMAND: branch |
| 163 | 163 | ** |
| 164 | 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(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 @@ | ||
| 343 | 343 | verify_all_options(); |
| 344 | 344 | |
| 345 | 345 | /* |
| 346 | 346 | ** Autosync if requested. |
| 347 | 347 | */ |
| 348 | - autosync(1); | |
| 348 | + autosync(AUTOSYNC_PULL); | |
| 349 | 349 | |
| 350 | 350 | /* There are two ways this command may be executed. If there are |
| 351 | 351 | ** no arguments following the word "commit", then all modified files |
| 352 | 352 | ** in the checked out directory are committed. If one or more arguments |
| 353 | 353 | ** follows "commit", then only those files are committed. |
| @@ -545,21 +545,14 @@ | ||
| 545 | 545 | /* Clear the undo/redo stack */ |
| 546 | 546 | undo_reset(); |
| 547 | 547 | |
| 548 | 548 | /* Commit */ |
| 549 | 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"); | |
| 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"); | |
| 561 | 554 | } |
| 562 | 555 | } |
| 563 | 556 | |
| 564 | 557 | /* |
| 565 | 558 | ** COMMAND: test-import-manifest |
| 566 | 559 |
| --- 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 @@ | ||
| 371 | 371 | } |
| 372 | 372 | for(cnt=0; cnt<2; cnt++){ |
| 373 | 373 | if( http_send_recv(&hdr, &payload, pRecv) ) break; |
| 374 | 374 | } |
| 375 | 375 | if( cnt>=2 ){ |
| 376 | - fossil_panic("connection to server failed"); | |
| 376 | + fossil_fatal("connection to server failed"); | |
| 377 | 377 | } |
| 378 | 378 | blob_reset(&hdr); |
| 379 | 379 | blob_reset(&payload); |
| 380 | 380 | if( g.fHttpTrace ){ |
| 381 | 381 | printf("HTTP RECEIVE:\n%s\n=======================\n", blob_str(pRecv)); |
| 382 | 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_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 @@ | ||
| 25 | 25 | */ |
| 26 | 26 | #include "config.h" |
| 27 | 27 | #include "sync.h" |
| 28 | 28 | #include <assert.h> |
| 29 | 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 | + | |
| 30 | 39 | /* |
| 31 | 40 | ** If the respository is configured for autosyncing, then do an |
| 32 | 41 | ** autosync. This will be a pull if the argument is true or a push |
| 33 | 42 | ** if the argument is false. Return true if the autosync is done |
| 34 | 43 | ** and false if autosync is not requested for the current repository. |
| 35 | 44 | */ |
| 36 | -int autosync(int pullFlag){ | |
| 45 | +int autosync(int flags){ | |
| 37 | 46 | const char *zUrl; |
| 38 | 47 | if( db_get_boolean("autosync", 0)==0 ){ |
| 39 | 48 | return 0; |
| 40 | 49 | } |
| 41 | 50 | zUrl = db_get("last-sync-url", 0); |
| @@ -49,11 +58,11 @@ | ||
| 49 | 58 | if( g.urlPort!=80 ){ |
| 50 | 59 | printf("Autosync: http://%s:%d%s\n", g.urlName, g.urlPort, g.urlPath); |
| 51 | 60 | }else{ |
| 52 | 61 | printf("Autosync: http://%s%s\n", g.urlName, g.urlPath); |
| 53 | 62 | } |
| 54 | - client_sync(!pullFlag, pullFlag, 0); | |
| 63 | + client_sync((flags & AUTOSYNC_PUSH)!=0, 1, 0); | |
| 55 | 64 | return 1; |
| 56 | 65 | } |
| 57 | 66 | |
| 58 | 67 | /* |
| 59 | 68 | ** This routine processes the command-line argument for push, pull, |
| 60 | 69 |
| --- 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 @@ | ||
| 293 | 293 | nrid = content_put(&ctrl, 0, 0); |
| 294 | 294 | manifest_crosslink(nrid, &ctrl); |
| 295 | 295 | db_end_transaction(0); |
| 296 | 296 | |
| 297 | 297 | /* Do an autosync push if requested */ |
| 298 | - autosync(0); | |
| 298 | + autosync(AUTOSYNC_PUSH); | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /* |
| 302 | 302 | ** COMMAND: tag |
| 303 | 303 | ** Usage: %fossil tag SUBCOMMAND ... |
| 304 | 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(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 @@ | ||
| 92 | 92 | ** Do an autosync pull prior to the update, if autosync is on and they |
| 93 | 93 | ** did not want a specific version (i.e. another branch, a past revision). |
| 94 | 94 | ** By not giving a specific version, they are asking for the latest, thus |
| 95 | 95 | ** pull to get the latest, then update. |
| 96 | 96 | */ |
| 97 | - autosync(1); | |
| 97 | + autosync(AUTOSYNC_PULL); | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if( tid==0 ){ |
| 101 | 101 | compute_leaves(vid); |
| 102 | 102 | if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){ |
| 103 | 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(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 |