Fossil SCM
Fix typo in import/export documentation (ticket [a66760daeecca231d84]). Add flexibility to the command-line options to import/export to accommodate future enhancements.
Commit
1b53667d28e2398c95c0b1c86c02a8fb92a0b8f2
Parent
3ad5891c72016a9…
5 files changed
+3
-3
+11
-5
+7
-1
+1
-1
+18
-5
M
src/db.c
+3
-3
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -841,14 +841,14 @@ | ||
| 841 | 841 | ** option to locate the repository. If no such option is available, then |
| 842 | 842 | ** use the repository of the open checkout if there is one. |
| 843 | 843 | ** |
| 844 | 844 | ** Error out if the repository cannot be opened. |
| 845 | 845 | */ |
| 846 | -void db_find_and_open_repository(int bFlags, const char *zRepoFilename){ | |
| 846 | +void db_find_and_open_repository(int bFlags, int nArgUsed){ | |
| 847 | 847 | const char *zRep = find_option("repository", "R", 1); |
| 848 | - if( zRep==0 ){ | |
| 849 | - zRep = zRepoFilename; | |
| 848 | + if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ | |
| 849 | + zRep = g.argv[nArgUsed]; | |
| 850 | 850 | } |
| 851 | 851 | if( zRep==0 ){ |
| 852 | 852 | if( db_open_local()==0 ){ |
| 853 | 853 | goto rep_not_found; |
| 854 | 854 | } |
| 855 | 855 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -841,14 +841,14 @@ | |
| 841 | ** option to locate the repository. If no such option is available, then |
| 842 | ** use the repository of the open checkout if there is one. |
| 843 | ** |
| 844 | ** Error out if the repository cannot be opened. |
| 845 | */ |
| 846 | void db_find_and_open_repository(int bFlags, const char *zRepoFilename){ |
| 847 | const char *zRep = find_option("repository", "R", 1); |
| 848 | if( zRep==0 ){ |
| 849 | zRep = zRepoFilename; |
| 850 | } |
| 851 | if( zRep==0 ){ |
| 852 | if( db_open_local()==0 ){ |
| 853 | goto rep_not_found; |
| 854 | } |
| 855 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -841,14 +841,14 @@ | |
| 841 | ** option to locate the repository. If no such option is available, then |
| 842 | ** use the repository of the open checkout if there is one. |
| 843 | ** |
| 844 | ** Error out if the repository cannot be opened. |
| 845 | */ |
| 846 | void db_find_and_open_repository(int bFlags, int nArgUsed){ |
| 847 | const char *zRep = find_option("repository", "R", 1); |
| 848 | if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){ |
| 849 | zRep = g.argv[nArgUsed]; |
| 850 | } |
| 851 | if( zRep==0 ){ |
| 852 | if( db_open_local()==0 ){ |
| 853 | goto rep_not_found; |
| 854 | } |
| 855 |
+11
-5
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -82,29 +82,35 @@ | ||
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | /* |
| 85 | 85 | ** COMMAND: export |
| 86 | 86 | ** |
| 87 | -** Usage: %fossil export | |
| 87 | +** Usage: %fossil export --git ?REPOSITORY? | |
| 88 | 88 | ** |
| 89 | 89 | ** Write an export of all check-ins to standard output. The export is |
| 90 | -** written in the Git "fast-import" format. | |
| 90 | +** written in the git-fast-export file format assuming the --git option is | |
| 91 | +** provided. The git-fast-export format is currently the only VCS | |
| 92 | +** interchange format supported, though other formats may be added in | |
| 93 | +** the future. | |
| 91 | 94 | ** |
| 92 | 95 | ** Run this command within a checkout. Or use the -R or --repository |
| 93 | 96 | ** option to specify a Fossil repository to be exported. |
| 94 | 97 | ** |
| 95 | -** Only check-ins are exported. Git does not support tickets or wiki | |
| 96 | -** or events or attachments, so none of that is exported. | |
| 98 | +** Only check-ins are exported using --git. Git does not support tickets | |
| 99 | +** or wiki or events or attachments, so none of those are exported. | |
| 97 | 100 | */ |
| 98 | 101 | void export_cmd(void){ |
| 99 | 102 | Stmt q; |
| 100 | 103 | int i; |
| 101 | 104 | Bag blobs, vers; |
| 102 | 105 | bag_init(&blobs); |
| 103 | 106 | bag_init(&vers); |
| 104 | 107 | |
| 105 | - db_find_and_open_repository(0, 0); | |
| 108 | + find_option("git", 0, 0); /* Ignore the --git option for now */ | |
| 109 | + db_find_and_open_repository(0, 2); | |
| 110 | + verify_all_options(); | |
| 111 | + if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); } | |
| 106 | 112 | |
| 107 | 113 | /* Step 1: Generate "blob" records for every artifact that is part |
| 108 | 114 | ** of a check-in |
| 109 | 115 | */ |
| 110 | 116 | fossil_binary_mode(stdout); |
| 111 | 117 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -82,29 +82,35 @@ | |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | ** COMMAND: export |
| 86 | ** |
| 87 | ** Usage: %fossil export |
| 88 | ** |
| 89 | ** Write an export of all check-ins to standard output. The export is |
| 90 | ** written in the Git "fast-import" format. |
| 91 | ** |
| 92 | ** Run this command within a checkout. Or use the -R or --repository |
| 93 | ** option to specify a Fossil repository to be exported. |
| 94 | ** |
| 95 | ** Only check-ins are exported. Git does not support tickets or wiki |
| 96 | ** or events or attachments, so none of that is exported. |
| 97 | */ |
| 98 | void export_cmd(void){ |
| 99 | Stmt q; |
| 100 | int i; |
| 101 | Bag blobs, vers; |
| 102 | bag_init(&blobs); |
| 103 | bag_init(&vers); |
| 104 | |
| 105 | db_find_and_open_repository(0, 0); |
| 106 | |
| 107 | /* Step 1: Generate "blob" records for every artifact that is part |
| 108 | ** of a check-in |
| 109 | */ |
| 110 | fossil_binary_mode(stdout); |
| 111 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -82,29 +82,35 @@ | |
| 82 | |
| 83 | |
| 84 | /* |
| 85 | ** COMMAND: export |
| 86 | ** |
| 87 | ** Usage: %fossil export --git ?REPOSITORY? |
| 88 | ** |
| 89 | ** Write an export of all check-ins to standard output. The export is |
| 90 | ** written in the git-fast-export file format assuming the --git option is |
| 91 | ** provided. The git-fast-export format is currently the only VCS |
| 92 | ** interchange format supported, though other formats may be added in |
| 93 | ** the future. |
| 94 | ** |
| 95 | ** Run this command within a checkout. Or use the -R or --repository |
| 96 | ** option to specify a Fossil repository to be exported. |
| 97 | ** |
| 98 | ** Only check-ins are exported using --git. Git does not support tickets |
| 99 | ** or wiki or events or attachments, so none of those are exported. |
| 100 | */ |
| 101 | void export_cmd(void){ |
| 102 | Stmt q; |
| 103 | int i; |
| 104 | Bag blobs, vers; |
| 105 | bag_init(&blobs); |
| 106 | bag_init(&vers); |
| 107 | |
| 108 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| 109 | db_find_and_open_repository(0, 2); |
| 110 | verify_all_options(); |
| 111 | if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); } |
| 112 | |
| 113 | /* Step 1: Generate "blob" records for every artifact that is part |
| 114 | ** of a check-in |
| 115 | */ |
| 116 | fossil_binary_mode(stdout); |
| 117 |
+7
-1
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -576,20 +576,26 @@ | ||
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /* |
| 579 | 579 | ** COMMAND: import |
| 580 | 580 | ** |
| 581 | -** Usage: %fossil import NEW-REPOSITORY | |
| 581 | +** Usage: %fossil import --git NEW-REPOSITORY | |
| 582 | 582 | ** |
| 583 | 583 | ** Read text generated by the git-fast-export command and use it to |
| 584 | 584 | ** construct a new Fossil repository named by the NEW-REPOSITORY |
| 585 | 585 | ** argument. The get-fast-export text is read from standard input. |
| 586 | +** | |
| 587 | +** The git-fast-export file format is currently the only VCS interchange | |
| 588 | +** format that is understood, though other interchange formats may be added | |
| 589 | +** in the future. | |
| 586 | 590 | */ |
| 587 | 591 | void git_import_cmd(void){ |
| 588 | 592 | char *zPassword; |
| 589 | 593 | FILE *pIn; |
| 590 | 594 | int forceFlag = find_option("force", "f", 0)!=0; |
| 595 | + find_option("git",0,0); /* Skip the --git option for now */ | |
| 596 | + verify_all_options(); | |
| 591 | 597 | if( g.argc!=3 && g.argc!=4 ){ |
| 592 | 598 | usage("REPOSITORY-NAME"); |
| 593 | 599 | } |
| 594 | 600 | if( g.argc==4 ){ |
| 595 | 601 | pIn = fopen(g.argv[3], "rb"); |
| 596 | 602 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -576,20 +576,26 @@ | |
| 576 | } |
| 577 | |
| 578 | /* |
| 579 | ** COMMAND: import |
| 580 | ** |
| 581 | ** Usage: %fossil import NEW-REPOSITORY |
| 582 | ** |
| 583 | ** Read text generated by the git-fast-export command and use it to |
| 584 | ** construct a new Fossil repository named by the NEW-REPOSITORY |
| 585 | ** argument. The get-fast-export text is read from standard input. |
| 586 | */ |
| 587 | void git_import_cmd(void){ |
| 588 | char *zPassword; |
| 589 | FILE *pIn; |
| 590 | int forceFlag = find_option("force", "f", 0)!=0; |
| 591 | if( g.argc!=3 && g.argc!=4 ){ |
| 592 | usage("REPOSITORY-NAME"); |
| 593 | } |
| 594 | if( g.argc==4 ){ |
| 595 | pIn = fopen(g.argv[3], "rb"); |
| 596 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -576,20 +576,26 @@ | |
| 576 | } |
| 577 | |
| 578 | /* |
| 579 | ** COMMAND: import |
| 580 | ** |
| 581 | ** Usage: %fossil import --git NEW-REPOSITORY |
| 582 | ** |
| 583 | ** Read text generated by the git-fast-export command and use it to |
| 584 | ** construct a new Fossil repository named by the NEW-REPOSITORY |
| 585 | ** argument. The get-fast-export text is read from standard input. |
| 586 | ** |
| 587 | ** The git-fast-export file format is currently the only VCS interchange |
| 588 | ** format that is understood, though other interchange formats may be added |
| 589 | ** in the future. |
| 590 | */ |
| 591 | void git_import_cmd(void){ |
| 592 | char *zPassword; |
| 593 | FILE *pIn; |
| 594 | int forceFlag = find_option("force", "f", 0)!=0; |
| 595 | find_option("git",0,0); /* Skip the --git option for now */ |
| 596 | verify_all_options(); |
| 597 | if( g.argc!=3 && g.argc!=4 ){ |
| 598 | usage("REPOSITORY-NAME"); |
| 599 | } |
| 600 | if( g.argc==4 ){ |
| 601 | pIn = fopen(g.argv[3], "rb"); |
| 602 |
+1
-1
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -394,11 +394,11 @@ | ||
| 394 | 394 | ** the repository from ever again pushing or pulling to other |
| 395 | 395 | ** repositories. Used to create a "test" repository for development |
| 396 | 396 | ** testing by cloning a working project repository. |
| 397 | 397 | */ |
| 398 | 398 | void test_detach_cmd(void){ |
| 399 | - db_find_and_open_repository(0, g.argv[2]); | |
| 399 | + db_find_and_open_repository(0, 2); | |
| 400 | 400 | db_begin_transaction(); |
| 401 | 401 | db_multi_exec( |
| 402 | 402 | "DELETE FROM config WHERE name='last-sync-url';" |
| 403 | 403 | "UPDATE config SET value=lower(hex(randomblob(20)))" |
| 404 | 404 | " WHERE name='project-code';" |
| 405 | 405 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -394,11 +394,11 @@ | |
| 394 | ** the repository from ever again pushing or pulling to other |
| 395 | ** repositories. Used to create a "test" repository for development |
| 396 | ** testing by cloning a working project repository. |
| 397 | */ |
| 398 | void test_detach_cmd(void){ |
| 399 | db_find_and_open_repository(0, g.argv[2]); |
| 400 | db_begin_transaction(); |
| 401 | db_multi_exec( |
| 402 | "DELETE FROM config WHERE name='last-sync-url';" |
| 403 | "UPDATE config SET value=lower(hex(randomblob(20)))" |
| 404 | " WHERE name='project-code';" |
| 405 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -394,11 +394,11 @@ | |
| 394 | ** the repository from ever again pushing or pulling to other |
| 395 | ** repositories. Used to create a "test" repository for development |
| 396 | ** testing by cloning a working project repository. |
| 397 | */ |
| 398 | void test_detach_cmd(void){ |
| 399 | db_find_and_open_repository(0, 2); |
| 400 | db_begin_transaction(); |
| 401 | db_multi_exec( |
| 402 | "DELETE FROM config WHERE name='last-sync-url';" |
| 403 | "UPDATE config SET value=lower(hex(randomblob(20)))" |
| 404 | " WHERE name='project-code';" |
| 405 |
+18
-5
| --- www/inout.wiki | ||
| +++ www/inout.wiki | ||
| @@ -10,30 +10,43 @@ | ||
| 10 | 10 | |
| 11 | 11 | To import a Git repository into Fossil, run commands like this: |
| 12 | 12 | |
| 13 | 13 | <blockquote><pre> |
| 14 | 14 | cd git-repo |
| 15 | -git fast-export --all | fossil import new-repo.fossil | |
| 15 | +git fast-export --all | fossil import --git new-repo.fossil | |
| 16 | 16 | </pre></blockquote> |
| 17 | 17 | |
| 18 | 18 | In other words, simply pipe the output of the "git fast-export" command |
| 19 | -into the "fossil import" command. The 2nd argument to the "fossil import" | |
| 19 | +into the "fossil import --git" command. The 3rd argument to the "fossil import" | |
| 20 | 20 | command is the name of a new Fossil repository that is created to hold the Git |
| 21 | 21 | content. |
| 22 | + | |
| 23 | +The --git option is not actually required. The git-fast-export file format | |
| 24 | +is currently the only VCS interchange format that Fossil understands. But | |
| 25 | +future versions of Fossil might be enhanced to understand other VCS | |
| 26 | +interchange formats, and so for compatibility, use of the | |
| 27 | +--git option is recommended. | |
| 22 | 28 | |
| 23 | 29 | <h2>Fossil → Git</h2> |
| 24 | 30 | |
| 25 | 31 | To convert a Fossil repository into a Git repository, run commands like |
| 26 | 32 | this: |
| 27 | 33 | |
| 28 | 34 | <blockquote><pre> |
| 29 | 35 | git init new-repo |
| 30 | 36 | cd new-repo |
| 31 | -fossil export -R ../repo.fossil | git fast-import | |
| 37 | +fossil export --git ../repo.fossil | git fast-import | |
| 32 | 38 | </pre></blockquote> |
| 33 | 39 | |
| 34 | 40 | In other words, create a new Git repository, then pipe the output from the |
| 35 | -"fossil export" commandn into the "git fast-import" command. | |
| 41 | +"fossil export --git" command into the "git fast-import" command. | |
| 36 | 42 | |
| 37 | -Note that the "fossil export" command only exports the versioned files. | |
| 43 | +Note that the "fossil export --git" command only exports the versioned files. | |
| 38 | 44 | Tickets and wiki and events are not exported, since Git does not understand |
| 39 | 45 | those concepts. |
| 46 | + | |
| 47 | +As with the "import" command, the --git option is not required | |
| 48 | +since the git-fast-export file format is currently the only VCS interchange | |
| 49 | +format that Fossil will generate. However, | |
| 50 | +future versions of Fossil might add the ability to generate other | |
| 51 | +VCS interchange formats, and so for compatibility, the use of the --git | |
| 52 | +option recommented. | |
| 40 | 53 |
| --- www/inout.wiki | |
| +++ www/inout.wiki | |
| @@ -10,30 +10,43 @@ | |
| 10 | |
| 11 | To import a Git repository into Fossil, run commands like this: |
| 12 | |
| 13 | <blockquote><pre> |
| 14 | cd git-repo |
| 15 | git fast-export --all | fossil import new-repo.fossil |
| 16 | </pre></blockquote> |
| 17 | |
| 18 | In other words, simply pipe the output of the "git fast-export" command |
| 19 | into the "fossil import" command. The 2nd argument to the "fossil import" |
| 20 | command is the name of a new Fossil repository that is created to hold the Git |
| 21 | content. |
| 22 | |
| 23 | <h2>Fossil → Git</h2> |
| 24 | |
| 25 | To convert a Fossil repository into a Git repository, run commands like |
| 26 | this: |
| 27 | |
| 28 | <blockquote><pre> |
| 29 | git init new-repo |
| 30 | cd new-repo |
| 31 | fossil export -R ../repo.fossil | git fast-import |
| 32 | </pre></blockquote> |
| 33 | |
| 34 | In other words, create a new Git repository, then pipe the output from the |
| 35 | "fossil export" commandn into the "git fast-import" command. |
| 36 | |
| 37 | Note that the "fossil export" command only exports the versioned files. |
| 38 | Tickets and wiki and events are not exported, since Git does not understand |
| 39 | those concepts. |
| 40 |
| --- www/inout.wiki | |
| +++ www/inout.wiki | |
| @@ -10,30 +10,43 @@ | |
| 10 | |
| 11 | To import a Git repository into Fossil, run commands like this: |
| 12 | |
| 13 | <blockquote><pre> |
| 14 | cd git-repo |
| 15 | git fast-export --all | fossil import --git new-repo.fossil |
| 16 | </pre></blockquote> |
| 17 | |
| 18 | In other words, simply pipe the output of the "git fast-export" command |
| 19 | into the "fossil import --git" command. The 3rd argument to the "fossil import" |
| 20 | command is the name of a new Fossil repository that is created to hold the Git |
| 21 | content. |
| 22 | |
| 23 | The --git option is not actually required. The git-fast-export file format |
| 24 | is currently the only VCS interchange format that Fossil understands. But |
| 25 | future versions of Fossil might be enhanced to understand other VCS |
| 26 | interchange formats, and so for compatibility, use of the |
| 27 | --git option is recommended. |
| 28 | |
| 29 | <h2>Fossil → Git</h2> |
| 30 | |
| 31 | To convert a Fossil repository into a Git repository, run commands like |
| 32 | this: |
| 33 | |
| 34 | <blockquote><pre> |
| 35 | git init new-repo |
| 36 | cd new-repo |
| 37 | fossil export --git ../repo.fossil | git fast-import |
| 38 | </pre></blockquote> |
| 39 | |
| 40 | In other words, create a new Git repository, then pipe the output from the |
| 41 | "fossil export --git" command into the "git fast-import" command. |
| 42 | |
| 43 | Note that the "fossil export --git" command only exports the versioned files. |
| 44 | Tickets and wiki and events are not exported, since Git does not understand |
| 45 | those concepts. |
| 46 | |
| 47 | As with the "import" command, the --git option is not required |
| 48 | since the git-fast-export file format is currently the only VCS interchange |
| 49 | format that Fossil will generate. However, |
| 50 | future versions of Fossil might add the ability to generate other |
| 51 | VCS interchange formats, and so for compatibility, the use of the --git |
| 52 | option recommented. |
| 53 |