|
ae0628a…
|
drh
|
1 |
<title>Import And Export</title> |
|
ae0628a…
|
drh
|
2 |
|
|
f47b705…
|
jan.nijtmans
|
3 |
Fossil has the ability to import and export repositories from and to |
|
ae0628a…
|
drh
|
4 |
[http://git-scm.com/ | Git]. And since most other version control |
|
f47b705…
|
jan.nijtmans
|
5 |
systems will also import/export from Git, that means that you can |
|
ae0628a…
|
drh
|
6 |
import/export a Fossil repository to most version control systems using |
|
ae0628a…
|
drh
|
7 |
Git as an intermediary. |
|
ae0628a…
|
drh
|
8 |
|
|
927d07c…
|
jan.nijtmans
|
9 |
<h2>Git → Fossil</h2> |
|
ae0628a…
|
drh
|
10 |
|
|
19c347b…
|
wyoung
|
11 |
To import a Git repository into Fossil, say something like: |
|
ae0628a…
|
drh
|
12 |
|
|
8a1ba49…
|
wyoung
|
13 |
<pre> |
|
ae0628a…
|
drh
|
14 |
cd git-repo |
|
1b53667…
|
drh
|
15 |
git fast-export --all | fossil import --git new-repo.fossil |
|
8a1ba49…
|
wyoung
|
16 |
</pre> |
|
ae0628a…
|
drh
|
17 |
|
|
19c347b…
|
wyoung
|
18 |
The 3rd argument to the "fossil import" |
|
ae0628a…
|
drh
|
19 |
command is the name of a new Fossil repository that is created to hold the Git |
|
ae0628a…
|
drh
|
20 |
content. |
|
ae0628a…
|
drh
|
21 |
|
|
1b53667…
|
drh
|
22 |
The --git option is not actually required. The git-fast-export file format |
|
1b53667…
|
drh
|
23 |
is currently the only VCS interchange format that Fossil understands. But |
|
f47b705…
|
jan.nijtmans
|
24 |
future versions of Fossil might be enhanced to understand other VCS |
|
1b53667…
|
drh
|
25 |
interchange formats, and so for compatibility, use of the |
|
1b53667…
|
drh
|
26 |
--git option is recommended. |
|
f47b705…
|
jan.nijtmans
|
27 |
|
|
93cee1f…
|
wyoung
|
28 |
<a id="fx_git"></a> |
|
dd15d28…
|
jamsek
|
29 |
Note that in new imports, Fossil defaults to using the email component of the |
|
dd15d28…
|
jamsek
|
30 |
Git <em>committer</em> (or <em>author</em> if <code>--use-author</code> is |
|
dd15d28…
|
jamsek
|
31 |
passed) to attribute check-ins in the imported repository. Alternatively, the |
|
c64f28d…
|
drh
|
32 |
[/help/import | <code>--attribute</code>] option can be passed to have all |
|
dd15d28…
|
jamsek
|
33 |
commits by a given committer attributed to a desired username. This will create |
|
dd15d28…
|
jamsek
|
34 |
and populate the new <code>fx_git</code> table in the repository database to |
|
dd15d28…
|
jamsek
|
35 |
maintain a record of correspondent usernames and email addresses that can be |
|
dd15d28…
|
jamsek
|
36 |
used in subsequent exports or incremental imports. |
|
19c347b…
|
wyoung
|
37 |
|
|
19c347b…
|
wyoung
|
38 |
<h3>Converting Repositories on Windows</h3> |
|
19c347b…
|
wyoung
|
39 |
|
|
19c347b…
|
wyoung
|
40 |
The above commands work best on proper POSIX systems like Linux, macOS, |
|
19c347b…
|
wyoung
|
41 |
and the BSDs, where everything <tt>git</tt> sends is consumed by |
|
19c347b…
|
wyoung
|
42 |
<tt>fossil</tt> as soon as it can manage, with both programs working |
|
19c347b…
|
wyoung
|
43 |
concurrently. |
|
19c347b…
|
wyoung
|
44 |
|
|
c07468c…
|
danield
|
45 |
Historically, PowerShell indiscriminately sent objects — as opposed to raw |
|
c07468c…
|
danield
|
46 |
bytes — through its pipes, and buffered standard input for external processes. |
|
c07468c…
|
danield
|
47 |
This made it choke on the conversion when the in-flight repository size |
|
c07468c…
|
danield
|
48 |
exceeded available memory. Starting with version 7.4 (2023-11-16), PowerShell |
|
c07468c…
|
danield
|
49 |
supports byte stream piping between native commands and file redirection. |
|
c07468c…
|
danield
|
50 |
|
|
c07468c…
|
danield
|
51 |
If you are stuck with an older version, one workaround is to fall back to |
|
c07468c…
|
danield
|
52 |
<tt>cmd.exe</tt> — which doesn't seem to be affected by this problem. |
|
c07468c…
|
danield
|
53 |
Nevertheless, we instead recommend using |
|
a186d8b…
|
drh
|
54 |
Microsoft's own [https://learn.microsoft.com/en-us/windows/wsl/ | Windows |
|
3e464b0…
|
wyoung
|
55 |
Subsystem for Linux] or either of the two popular "Git for Windows" |
|
3e464b0…
|
wyoung
|
56 |
distributions based on MSYS2. They handle pipes the POSIX way, avoiding |
|
3e464b0…
|
wyoung
|
57 |
any dependency on the amount of data involved. |
|
dd15d28…
|
jamsek
|
58 |
|
|
927d07c…
|
jan.nijtmans
|
59 |
<h2>Fossil → Git</h2> |
|
ae0628a…
|
drh
|
60 |
|
|
ae0628a…
|
drh
|
61 |
To convert a Fossil repository into a Git repository, run commands like |
|
ae0628a…
|
drh
|
62 |
this: |
|
ae0628a…
|
drh
|
63 |
|
|
8a1ba49…
|
wyoung
|
64 |
<pre> |
|
ae0628a…
|
drh
|
65 |
git init new-repo |
|
ae0628a…
|
drh
|
66 |
cd new-repo |
|
1b53667…
|
drh
|
67 |
fossil export --git ../repo.fossil | git fast-import |
|
8a1ba49…
|
wyoung
|
68 |
</pre> |
|
ae0628a…
|
drh
|
69 |
|
|
ae0628a…
|
drh
|
70 |
In other words, create a new Git repository, then pipe the output from the |
|
1b53667…
|
drh
|
71 |
"fossil export --git" command into the "git fast-import" command. |
|
ae0628a…
|
drh
|
72 |
|
|
1b53667…
|
drh
|
73 |
Note that the "fossil export --git" command only exports the versioned files. |
|
ae0628a…
|
drh
|
74 |
Tickets and wiki and events are not exported, since Git does not understand |
|
ae0628a…
|
drh
|
75 |
those concepts. |
|
1b53667…
|
drh
|
76 |
|
|
1b53667…
|
drh
|
77 |
As with the "import" command, the --git option is not required |
|
f47b705…
|
jan.nijtmans
|
78 |
since the git-fast-export file format is currently the only VCS interchange |
|
1b53667…
|
drh
|
79 |
format that Fossil will generate. However, |
|
1b53667…
|
drh
|
80 |
future versions of Fossil might add the ability to generate other |
|
f47b705…
|
jan.nijtmans
|
81 |
VCS interchange formats, and so for compatibility, the use of the --git |
|
a186d8b…
|
drh
|
82 |
option is recommended. |
|
bcea529…
|
drh
|
83 |
|
|
bcea529…
|
drh
|
84 |
<h2>Mirror A Fossil Repository In Git</h2> |
|
bcea529…
|
drh
|
85 |
|
|
bcea529…
|
drh
|
86 |
Fossil version 2.9 and later supports a simple mechanism for |
|
bcea529…
|
drh
|
87 |
doing a Git or |
|
bcea529…
|
drh
|
88 |
[./mirrortogithub.md|GitHub mirror of a Fossil repository]. |
|
bcea529…
|
drh
|
89 |
See that separate document for details. Fossil is self-hosting, |
|
bcea529…
|
drh
|
90 |
but a [https://github.com/drhsqlite/fossil-mirror|GitHub mirror of Fossil] |
|
bcea529…
|
drh
|
91 |
is available as a proof-of-concept. |
|
27c8985…
|
mistachkin
|
92 |
|
|
27c8985…
|
mistachkin
|
93 |
<h2>Bidirectional Synchronization</h2> |
|
27c8985…
|
mistachkin
|
94 |
Fossil also has the ability to synchronize with a Git repository via repeated |
|
27c8985…
|
mistachkin
|
95 |
imports and/or exports. To do this, it uses marks files to store a record of |
|
27c8985…
|
mistachkin
|
96 |
artifacts which are known by both Git and Fossil to exist at a given point in |
|
27c8985…
|
mistachkin
|
97 |
time. |
|
27c8985…
|
mistachkin
|
98 |
|
|
27c8985…
|
mistachkin
|
99 |
To illustrate, consider the example of a remote Fossil repository that a |
|
27c8985…
|
mistachkin
|
100 |
user wants to import into a local Git repository. First, the user would clone |
|
27c8985…
|
mistachkin
|
101 |
the remote repository and import it into a new Git repository: |
|
27c8985…
|
mistachkin
|
102 |
|
|
8a1ba49…
|
wyoung
|
103 |
<pre> |
|
27c8985…
|
mistachkin
|
104 |
fossil clone /path/to/remote/repo.fossil repo.fossil |
|
27c8985…
|
mistachkin
|
105 |
mkdir repo |
|
27c8985…
|
mistachkin
|
106 |
cd repo |
|
27c8985…
|
mistachkin
|
107 |
fossil open ../repo.fossil |
|
27c8985…
|
mistachkin
|
108 |
mkdir ../repo.git |
|
27c8985…
|
mistachkin
|
109 |
cd ../repo.git |
|
27c8985…
|
mistachkin
|
110 |
git init . |
|
27c8985…
|
mistachkin
|
111 |
fossil export --git --export-marks ../repo/fossil.marks \ |
|
27c8985…
|
mistachkin
|
112 |
../repo.fossil | git fast-import \ |
|
27c8985…
|
mistachkin
|
113 |
--export-marks=../repo/git.marks |
|
8a1ba49…
|
wyoung
|
114 |
</pre> |
|
27c8985…
|
mistachkin
|
115 |
|
|
27c8985…
|
mistachkin
|
116 |
Once the import has completed, the user would need to <tt>git checkout |
|
27c8985…
|
mistachkin
|
117 |
trunk</tt>. At any point after this, new changes can be imported from the |
|
27c8985…
|
mistachkin
|
118 |
remote Fossil repository: |
|
27c8985…
|
mistachkin
|
119 |
|
|
8a1ba49…
|
wyoung
|
120 |
<pre> |
|
27c8985…
|
mistachkin
|
121 |
cd ../repo |
|
27c8985…
|
mistachkin
|
122 |
fossil pull |
|
27c8985…
|
mistachkin
|
123 |
cd ../repo.git |
|
27c8985…
|
mistachkin
|
124 |
fossil export --git --import-marks ../repo/fossil.marks \ |
|
27c8985…
|
mistachkin
|
125 |
--export-marks ../repo/fossil.marks \ |
|
27c8985…
|
mistachkin
|
126 |
../repo.fossil | git fast-import \ |
|
27c8985…
|
mistachkin
|
127 |
--import-marks=../repo/git.marks \ |
|
27c8985…
|
mistachkin
|
128 |
--export-marks=../repo/git.marks |
|
8a1ba49…
|
wyoung
|
129 |
</pre> |
|
27c8985…
|
mistachkin
|
130 |
|
|
27c8985…
|
mistachkin
|
131 |
Changes in the Git repository can be exported to the Fossil repository and then |
|
27c8985…
|
mistachkin
|
132 |
pushed to the remote: |
|
27c8985…
|
mistachkin
|
133 |
|
|
8a1ba49…
|
wyoung
|
134 |
<pre> |
|
27c8985…
|
mistachkin
|
135 |
git fast-export --import-marks=../repo/git.marks \ |
|
27c8985…
|
mistachkin
|
136 |
--export-marks=../repo/git.marks --all | fossil import --git \ |
|
27c8985…
|
mistachkin
|
137 |
--incremental --import-marks ../repo/fossil.marks \ |
|
27c8985…
|
mistachkin
|
138 |
--export-marks ../repo/fossil.marks ../repo.fossil |
|
27c8985…
|
mistachkin
|
139 |
cd ../repo |
|
27c8985…
|
mistachkin
|
140 |
fossil push |
|
8a1ba49…
|
wyoung
|
141 |
</pre> |