Fossil SCM

Fix typo in import/export documentation (ticket [a66760daeecca231d84]). Add flexibility to the command-line options to import/export to accommodate future enhancements.

drh 2010-12-03 21:06 trunk
Commit 1b53667d28e2398c95c0b1c86c02a8fb92a0b8f2
+3 -3
--- src/db.c
+++ src/db.c
@@ -841,14 +841,14 @@
841841
** option to locate the repository. If no such option is available, then
842842
** use the repository of the open checkout if there is one.
843843
**
844844
** Error out if the repository cannot be opened.
845845
*/
846
-void db_find_and_open_repository(int bFlags, const char *zRepoFilename){
846
+void db_find_and_open_repository(int bFlags, int nArgUsed){
847847
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];
850850
}
851851
if( zRep==0 ){
852852
if( db_open_local()==0 ){
853853
goto rep_not_found;
854854
}
855855
--- 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 @@
8282
8383
8484
/*
8585
** COMMAND: export
8686
**
87
-** Usage: %fossil export
87
+** Usage: %fossil export --git ?REPOSITORY?
8888
**
8989
** 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.
9194
**
9295
** Run this command within a checkout. Or use the -R or --repository
9396
** option to specify a Fossil repository to be exported.
9497
**
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.
97100
*/
98101
void export_cmd(void){
99102
Stmt q;
100103
int i;
101104
Bag blobs, vers;
102105
bag_init(&blobs);
103106
bag_init(&vers);
104107
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?"); }
106112
107113
/* Step 1: Generate "blob" records for every artifact that is part
108114
** of a check-in
109115
*/
110116
fossil_binary_mode(stdout);
111117
--- 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 @@
576576
}
577577
578578
/*
579579
** COMMAND: import
580580
**
581
-** Usage: %fossil import NEW-REPOSITORY
581
+** Usage: %fossil import --git NEW-REPOSITORY
582582
**
583583
** Read text generated by the git-fast-export command and use it to
584584
** construct a new Fossil repository named by the NEW-REPOSITORY
585585
** 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.
586590
*/
587591
void git_import_cmd(void){
588592
char *zPassword;
589593
FILE *pIn;
590594
int forceFlag = find_option("force", "f", 0)!=0;
595
+ find_option("git",0,0); /* Skip the --git option for now */
596
+ verify_all_options();
591597
if( g.argc!=3 && g.argc!=4 ){
592598
usage("REPOSITORY-NAME");
593599
}
594600
if( g.argc==4 ){
595601
pIn = fopen(g.argv[3], "rb");
596602
--- 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 @@
394394
** the repository from ever again pushing or pulling to other
395395
** repositories. Used to create a "test" repository for development
396396
** testing by cloning a working project repository.
397397
*/
398398
void test_detach_cmd(void){
399
- db_find_and_open_repository(0, g.argv[2]);
399
+ db_find_and_open_repository(0, 2);
400400
db_begin_transaction();
401401
db_multi_exec(
402402
"DELETE FROM config WHERE name='last-sync-url';"
403403
"UPDATE config SET value=lower(hex(randomblob(20)))"
404404
" WHERE name='project-code';"
405405
--- 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 @@
1010
1111
To import a Git repository into Fossil, run commands like this:
1212
1313
<blockquote><pre>
1414
cd git-repo
15
-git fast-export --all | fossil import new-repo.fossil
15
+git fast-export --all | fossil import --git new-repo.fossil
1616
</pre></blockquote>
1717
1818
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"
2020
command is the name of a new Fossil repository that is created to hold the Git
2121
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.
2228
2329
<h2>Fossil &rarr; Git</h2>
2430
2531
To convert a Fossil repository into a Git repository, run commands like
2632
this:
2733
2834
<blockquote><pre>
2935
git init new-repo
3036
cd new-repo
31
-fossil export -R ../repo.fossil | git fast-import
37
+fossil export --git ../repo.fossil | git fast-import
3238
</pre></blockquote>
3339
3440
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.
3642
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.
3844
Tickets and wiki and events are not exported, since Git does not understand
3945
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.
4053
--- 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 &rarr; 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 &rarr; 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

Keyboard Shortcuts

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