Fossil SCM
Add the test-move-repository command.
Commit
4a198644196af9bc7387dde3bed66bbd2d4659d2
Parent
99dcff4d28359cb…
1 file changed
+30
M
src/db.c
+30
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -845,10 +845,40 @@ | ||
| 845 | 845 | rep_not_found: |
| 846 | 846 | if( errIfNotFound ){ |
| 847 | 847 | fossil_fatal("use --repository or -R to specify the repository database"); |
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | + | |
| 851 | +/* | |
| 852 | +** COMMAND: test-move-repository | |
| 853 | +** | |
| 854 | +** Usage: %fossil test-move-repository PATHNAME | |
| 855 | +** | |
| 856 | +** Change the location of the repository database on a local check-out. | |
| 857 | +** Use this command to avoid having to close and reopen a checkout | |
| 858 | +** when relocating the repository database. | |
| 859 | +*/ | |
| 860 | +void move_repo_cmd(void){ | |
| 861 | + Blob repo; | |
| 862 | + char *zRepo; | |
| 863 | + if( g.argc!=3 ){ | |
| 864 | + usage("PATHNAME"); | |
| 865 | + } | |
| 866 | + if( db_open_local()==0 ){ | |
| 867 | + fossil_fatal("not in a local checkout"); | |
| 868 | + return; | |
| 869 | + } | |
| 870 | + file_canonical_name(g.argv[2], &repo); | |
| 871 | + zRepo = blob_str(&repo); | |
| 872 | + if( access(zRepo, 0) ){ | |
| 873 | + fossil_fatal("no such file: %s", zRepo); | |
| 874 | + } | |
| 875 | + db_open_or_attach(zRepo, "test_repo"); | |
| 876 | + db_lset("repository", blob_str(&repo)); | |
| 877 | + db_close(); | |
| 878 | +} | |
| 879 | + | |
| 850 | 880 | |
| 851 | 881 | /* |
| 852 | 882 | ** Open the local database. If unable, exit with an error. |
| 853 | 883 | */ |
| 854 | 884 | void db_must_be_within_tree(void){ |
| 855 | 885 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -845,10 +845,40 @@ | |
| 845 | rep_not_found: |
| 846 | if( errIfNotFound ){ |
| 847 | fossil_fatal("use --repository or -R to specify the repository database"); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | /* |
| 852 | ** Open the local database. If unable, exit with an error. |
| 853 | */ |
| 854 | void db_must_be_within_tree(void){ |
| 855 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -845,10 +845,40 @@ | |
| 845 | rep_not_found: |
| 846 | if( errIfNotFound ){ |
| 847 | fossil_fatal("use --repository or -R to specify the repository database"); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | /* |
| 852 | ** COMMAND: test-move-repository |
| 853 | ** |
| 854 | ** Usage: %fossil test-move-repository PATHNAME |
| 855 | ** |
| 856 | ** Change the location of the repository database on a local check-out. |
| 857 | ** Use this command to avoid having to close and reopen a checkout |
| 858 | ** when relocating the repository database. |
| 859 | */ |
| 860 | void move_repo_cmd(void){ |
| 861 | Blob repo; |
| 862 | char *zRepo; |
| 863 | if( g.argc!=3 ){ |
| 864 | usage("PATHNAME"); |
| 865 | } |
| 866 | if( db_open_local()==0 ){ |
| 867 | fossil_fatal("not in a local checkout"); |
| 868 | return; |
| 869 | } |
| 870 | file_canonical_name(g.argv[2], &repo); |
| 871 | zRepo = blob_str(&repo); |
| 872 | if( access(zRepo, 0) ){ |
| 873 | fossil_fatal("no such file: %s", zRepo); |
| 874 | } |
| 875 | db_open_or_attach(zRepo, "test_repo"); |
| 876 | db_lset("repository", blob_str(&repo)); |
| 877 | db_close(); |
| 878 | } |
| 879 | |
| 880 | |
| 881 | /* |
| 882 | ** Open the local database. If unable, exit with an error. |
| 883 | */ |
| 884 | void db_must_be_within_tree(void){ |
| 885 |