Fossil SCM
Add the "close" command.
Commit
4452576730808ff4669afba08536c3ef359c4b4e
Parent
f5588c800b85c0f…
1 file changed
+19
-1
+19
-1
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -123,11 +123,11 @@ | ||
| 123 | 123 | db_begin_transaction(); |
| 124 | 124 | forceFlag = find_option("force","f",0)!=0; |
| 125 | 125 | noWrite = find_option("dontwrite",0,0)!=0; |
| 126 | 126 | if( g.argc!=3 ) usage("?--force? VERSION"); |
| 127 | 127 | if( !forceFlag && unsaved_changes()==1 ){ |
| 128 | - fossil_panic("there are unsaved changes in the current checkout"); | |
| 128 | + fossil_fatal("there are unsaved changes in the current checkout"); | |
| 129 | 129 | } |
| 130 | 130 | if( forceFlag ){ |
| 131 | 131 | db_multi_exec("DELETE FROM vfile"); |
| 132 | 132 | prior = 0; |
| 133 | 133 | }else{ |
| @@ -155,5 +155,23 @@ | ||
| 155 | 155 | if( blob_compare(&cksum1, &cksum1b) ){ |
| 156 | 156 | printf("WARNING: manifest checksum does not agree with manifest\n"); |
| 157 | 157 | } |
| 158 | 158 | db_end_transaction(0); |
| 159 | 159 | } |
| 160 | + | |
| 161 | +/* | |
| 162 | +** COMMAND: close | |
| 163 | +** | |
| 164 | +** The opposite of "open". Close the current database connection. | |
| 165 | +** Require a -f or --force flag if there are unsaved changed in the | |
| 166 | +** current check-out. | |
| 167 | +*/ | |
| 168 | +void close_cmd(void){ | |
| 169 | + int forceFlag = find_option("force","f",0)!=0; | |
| 170 | + db_must_be_within_tree(); | |
| 171 | + if( !forceFlag && unsaved_changes()==1 ){ | |
| 172 | + fossil_fatal("there are unsaved changes in the current checkout"); | |
| 173 | + } | |
| 174 | + db_close(); | |
| 175 | + unlink(mprintf("%s_FOSSIL_", g.zLocalRoot)); | |
| 176 | + unlink(mprintf("%s_FOSSIL_-journal", g.zLocalRoot)); | |
| 177 | +} | |
| 160 | 178 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -123,11 +123,11 @@ | |
| 123 | db_begin_transaction(); |
| 124 | forceFlag = find_option("force","f",0)!=0; |
| 125 | noWrite = find_option("dontwrite",0,0)!=0; |
| 126 | if( g.argc!=3 ) usage("?--force? VERSION"); |
| 127 | if( !forceFlag && unsaved_changes()==1 ){ |
| 128 | fossil_panic("there are unsaved changes in the current checkout"); |
| 129 | } |
| 130 | if( forceFlag ){ |
| 131 | db_multi_exec("DELETE FROM vfile"); |
| 132 | prior = 0; |
| 133 | }else{ |
| @@ -155,5 +155,23 @@ | |
| 155 | if( blob_compare(&cksum1, &cksum1b) ){ |
| 156 | printf("WARNING: manifest checksum does not agree with manifest\n"); |
| 157 | } |
| 158 | db_end_transaction(0); |
| 159 | } |
| 160 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -123,11 +123,11 @@ | |
| 123 | db_begin_transaction(); |
| 124 | forceFlag = find_option("force","f",0)!=0; |
| 125 | noWrite = find_option("dontwrite",0,0)!=0; |
| 126 | if( g.argc!=3 ) usage("?--force? VERSION"); |
| 127 | if( !forceFlag && unsaved_changes()==1 ){ |
| 128 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 129 | } |
| 130 | if( forceFlag ){ |
| 131 | db_multi_exec("DELETE FROM vfile"); |
| 132 | prior = 0; |
| 133 | }else{ |
| @@ -155,5 +155,23 @@ | |
| 155 | if( blob_compare(&cksum1, &cksum1b) ){ |
| 156 | printf("WARNING: manifest checksum does not agree with manifest\n"); |
| 157 | } |
| 158 | db_end_transaction(0); |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | ** COMMAND: close |
| 163 | ** |
| 164 | ** The opposite of "open". Close the current database connection. |
| 165 | ** Require a -f or --force flag if there are unsaved changed in the |
| 166 | ** current check-out. |
| 167 | */ |
| 168 | void close_cmd(void){ |
| 169 | int forceFlag = find_option("force","f",0)!=0; |
| 170 | db_must_be_within_tree(); |
| 171 | if( !forceFlag && unsaved_changes()==1 ){ |
| 172 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 173 | } |
| 174 | db_close(); |
| 175 | unlink(mprintf("%s_FOSSIL_", g.zLocalRoot)); |
| 176 | unlink(mprintf("%s_FOSSIL_-journal", g.zLocalRoot)); |
| 177 | } |
| 178 |