Merge lp:~vmiklos/bzr-fastimport/darcs into lp:~bzr/bzr-fastimport/fastimport.dev
- darcs
- Merge into fastimport.dev
Proposed by
Miklos Vajna
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Ian Clatworthy | ||||||||
Approved revision: | no longer in the revision history of the source branch. | ||||||||
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~vmiklos/bzr-fastimport/darcs | ||||||||
Merge into: | lp:~bzr/bzr-fastimport/fastimport.dev | ||||||||
Diff against target: | None lines | ||||||||
To merge this branch: | bzr merge lp:~vmiklos/bzr-fastimport/darcs | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ian Clatworthy | Approve | ||
Review via email: mp+9270@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Ian Clatworthy (ian-clatworthy) : | # |
review:
Approve
lp:~vmiklos/bzr-fastimport/darcs
updated
- 189. By Ian Clatworthy
-
merge darcs-fast-export (Miklos Jayna)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'exporters/darcs' | |||
2 | === added file 'exporters/darcs/.gitignore' | |||
3 | --- exporters/darcs/.gitignore 1970-01-01 00:00:00 +0000 | |||
4 | +++ exporters/darcs/.gitignore 2008-10-19 12:51:00 +0000 | |||
5 | @@ -0,0 +1,3 @@ | |||
6 | 1 | Changelog | ||
7 | 2 | HEADER.html | ||
8 | 3 | .htaccess | ||
9 | 0 | 4 | ||
10 | === added file 'exporters/darcs/Makefile' | |||
11 | --- exporters/darcs/Makefile 1970-01-01 00:00:00 +0000 | |||
12 | +++ exporters/darcs/Makefile 2009-06-25 21:47:09 +0000 | |||
13 | @@ -0,0 +1,55 @@ | |||
14 | 1 | VERSION = 0.9 | ||
15 | 2 | DATE := $(shell date +%Y-%m-%d) | ||
16 | 3 | |||
17 | 4 | INSTALL = /usr/bin/install -c | ||
18 | 5 | DESTDIR = | ||
19 | 6 | prefix = /usr | ||
20 | 7 | bindir = $(prefix)/bin | ||
21 | 8 | mandir = $(prefix)/share/man/man1 | ||
22 | 9 | |||
23 | 10 | MAN_TXT = $(wildcard *.txt) | ||
24 | 11 | MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) | ||
25 | 12 | MAN=$(patsubst %.txt,%.1,$(MAN_TXT)) | ||
26 | 13 | |||
27 | 14 | PROGRAMS = darcs-fast-export darcs-fast-import d2x x2d git-darcs | ||
28 | 15 | |||
29 | 16 | all: man | ||
30 | 17 | |||
31 | 18 | install: all | ||
32 | 19 | $(INSTALL) -d $(DESTDIR)$(bindir) | ||
33 | 20 | $(INSTALL) -d $(DESTDIR)$(mandir) | ||
34 | 21 | $(INSTALL) -m755 $(PROGRAMS) $(DESTDIR)$(bindir) | ||
35 | 22 | $(INSTALL) -m644 *.1 $(DESTDIR)$(mandir) | ||
36 | 23 | |||
37 | 24 | doc: HEADER.html Changelog html | ||
38 | 25 | |||
39 | 26 | HEADER.html: README Makefile | ||
40 | 27 | asciidoc -a toc -a numbered -a sectids -o HEADER.html README | ||
41 | 28 | |||
42 | 29 | Changelog: .git/refs/heads/master | ||
43 | 30 | git log >Changelog | ||
44 | 31 | |||
45 | 32 | %.html: %.txt | ||
46 | 33 | asciidoc $^ | ||
47 | 34 | |||
48 | 35 | %.1: %.txt asciidoc.conf | ||
49 | 36 | a2x --asciidoc-opts="-f asciidoc.conf" \ | ||
50 | 37 | -a dfe_version=$(VERSION) -a dfe_date=$(DATE) -f manpage $< | ||
51 | 38 | |||
52 | 39 | man: $(MAN) | ||
53 | 40 | |||
54 | 41 | html: $(MAN_HTML) | ||
55 | 42 | |||
56 | 43 | dist: | ||
57 | 44 | git archive --format=tar --prefix=darcs-fast-export-$(VERSION)/ $(VERSION) > darcs-fast-export-$(VERSION).tar | ||
58 | 45 | mkdir -p darcs-fast-export-$(VERSION) | ||
59 | 46 | git log > darcs-fast-export-$(VERSION)/Changelog | ||
60 | 47 | tar rf darcs-fast-export-$(VERSION).tar darcs-fast-export-$(VERSION)/Changelog | ||
61 | 48 | rm -rf darcs-fast-export-$(VERSION) | ||
62 | 49 | gzip -f -9 darcs-fast-export-$(VERSION).tar | ||
63 | 50 | |||
64 | 51 | release: | ||
65 | 52 | git tag -l |grep -q $(VERSION) || dg tag $(VERSION) | ||
66 | 53 | $(MAKE) dist | ||
67 | 54 | gpg --comment "See http://vmiklos.hu/gpg/ for info" \ | ||
68 | 55 | -ba darcs-fast-export-$(VERSION).tar.gz | ||
69 | 0 | 56 | ||
70 | === added file 'exporters/darcs/NEWS' | |||
71 | --- exporters/darcs/NEWS 1970-01-01 00:00:00 +0000 | |||
72 | +++ exporters/darcs/NEWS 2009-06-25 21:47:09 +0000 | |||
73 | @@ -0,0 +1,26 @@ | |||
74 | 1 | VERSION DESCRIPTION | ||
75 | 2 | ----------------------------------------------------------------------------- | ||
76 | 3 | 0.9 - fix handling of accents in tag names | ||
77 | 4 | - warning fixes for Python-2.6 | ||
78 | 5 | - git-darcs: the add subcommand can now remember d-f-e | ||
79 | 6 | options | ||
80 | 7 | - git-darcs: new list, find-darcs and find-git subcommands | ||
81 | 8 | 0.8 - revert the "not exporting unchanged files multiple | ||
82 | 9 | times" optimization, it causes corrupted results in some | ||
83 | 10 | cases. | ||
84 | 11 | 0.7 - new darcs-fast-export option: --progress | ||
85 | 12 | - massive speedup in darcs-fast-export due to not | ||
86 | 13 | exporting unchanged files multiple times and reading | ||
87 | 14 | patches directly | ||
88 | 15 | 0.6 - add a new darcs-fast-import script, allowing two-way sync | ||
89 | 16 | - new darcs-fast-export option: --git-branch | ||
90 | 17 | - add a new git-darcs script, making two-way sync easy | ||
91 | 18 | 0.5 - new --help, --encoding, --authors-file, --working and | ||
92 | 19 | --logfile options | ||
93 | 20 | - add "hashed" support (see darcs init -h) | ||
94 | 21 | - add incremental conversion support for darcs1 as well | ||
95 | 22 | - add d2x wrapper script | ||
96 | 23 | 0.4 - add incremental conversion support | ||
97 | 24 | 0.3 - add darcs2 support | ||
98 | 25 | 0.2 - add bzr and hg support | ||
99 | 26 | 0.1 - initial short and fast version, supporting darcs1->git | ||
100 | 0 | 27 | ||
101 | === added file 'exporters/darcs/README' | |||
102 | --- exporters/darcs/README 1970-01-01 00:00:00 +0000 | |||
103 | +++ exporters/darcs/README 2009-06-25 22:21:33 +0000 | |||
104 | @@ -0,0 +1,192 @@ | |||
105 | 1 | = darcs backend for fast data importers | ||
106 | 2 | Miklos Vajna <vmiklos-at-frugalware-dot-org> | ||
107 | 3 | |||
108 | 4 | == Purpose and Features | ||
109 | 5 | |||
110 | 6 | darcs-fast-export is a tool to dump a http://darcs.net/[darcs] | ||
111 | 7 | repository in a format understood by "fast-importers" such as | ||
112 | 8 | http://git.or.cz/[git] | ||
113 | 9 | http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html[fast-import]. | ||
114 | 10 | It exhibits the following _features:_ | ||
115 | 11 | |||
116 | 12 | Fast:: | ||
117 | 13 | darcs-fast-export provides a fast darcs backend for fast-import. | ||
118 | 14 | See link:t/bench-results/[here] for exact details. | ||
119 | 15 | |||
120 | 16 | Correct:: | ||
121 | 17 | darcs-fast-export produces correct results in any extreme cases. | ||
122 | 18 | It has been tested with a collection of large darcs repos (called | ||
123 | 19 | http://code.haskell.org/darcs/big-zoo/[big-zoo]). And several testcases | ||
124 | 20 | under the `t/` directory. | ||
125 | 21 | |||
126 | 22 | Independent:: | ||
127 | 23 | Ideally it should work with any fast importer, but actually it has been | ||
128 | 24 | tested with git fast-import, bzr fast-import and hg fastimport. (These | ||
129 | 25 | are the three fast-import implementations available ATM.) | ||
130 | 26 | + | ||
131 | 27 | hg fastimport needs three patches. While they are not in the upstream, | ||
132 | 28 | you can get it from my repository using | ||
133 | 29 | + | ||
134 | 30 | ---- | ||
135 | 31 | $ hg clone static-http://frugalware.org/~vmiklos/hg/hg-fastimport | ||
136 | 32 | ---- | ||
137 | 33 | |||
138 | 34 | Formats:: | ||
139 | 35 | It supports the 'darcs-2', 'hashed', and 'old-fashioned-inventory' darcs | ||
140 | 36 | repository formats. | ||
141 | 37 | |||
142 | 38 | Incremental conversions:: | ||
143 | 39 | It supports the usual `--export-marks` / `--import-marks` switches to | ||
144 | 40 | allow incremental conversion. | ||
145 | 41 | |||
146 | 42 | Wrapper scripts:: | ||
147 | 43 | A wrapper script called `d2x` is available if you find typing | ||
148 | 44 | `--export-marks` / `--import-marks` all the time boring. A similar one | ||
149 | 45 | is also provided for the other direction, called `x2d`. Finally, if you | ||
150 | 46 | want to work on darcs repos with git, you can use the `git-darcs` | ||
151 | 47 | wrapper. | ||
152 | 48 | |||
153 | 49 | Author mappings:: | ||
154 | 50 | Supports `--authors-file` option like Git's SVN adaptor, for DARCS | ||
155 | 51 | repositories that originated in CVS or SVN. | ||
156 | 52 | |||
157 | 53 | Import script:: | ||
158 | 54 | The pair of `darcs-fast-export`, `darcs-fast-import` is also | ||
159 | 55 | included in this repo. It has been tested with the fast-expoters of Git, | ||
160 | 56 | Hg, Bzr and - of course - Darcs itself. | ||
161 | 57 | |||
162 | 58 | Two-way sync:: | ||
163 | 59 | Using `darcs-fast-export` / `darcs-fast-import`, it is possible to | ||
164 | 60 | convert a darcs repo to an other VCS, work there, then convert your work | ||
165 | 61 | back to Darcs (or vica versa). This has been tested with "darcs -> git; | ||
166 | 62 | hack hack; git -> darcs". | ||
167 | 63 | |||
168 | 64 | == Usage | ||
169 | 65 | |||
170 | 66 | See the manpages: | ||
171 | 67 | |||
172 | 68 | * link:darcs-fast-export.html[darcs-fast-export] | ||
173 | 69 | * link:darcs-fast-import.html[darcs-fast-import] | ||
174 | 70 | * link:d2x.html[d2x] | ||
175 | 71 | * link:x2d.html[x2d] | ||
176 | 72 | * link:git-darcs.html[git-darcs] | ||
177 | 73 | |||
178 | 74 | === Example | ||
179 | 75 | |||
180 | 76 | Assuming that `test/` is a darcs repo, you could do this: | ||
181 | 77 | ---- | ||
182 | 78 | $ mkdir test.git | ||
183 | 79 | $ cd test.git | ||
184 | 80 | $ git --bare init | ||
185 | 81 | $ cd .. | ||
186 | 82 | $ darcs-fast-export test |(cd test.git; git fast-import) | ||
187 | 83 | ---- | ||
188 | 84 | |||
189 | 85 | For more examples (especially for bzr and hg), see the `t/` directory. | ||
190 | 86 | |||
191 | 87 | == Download | ||
192 | 88 | |||
193 | 89 | Using git: | ||
194 | 90 | ---- | ||
195 | 91 | $ git clone git://vmiklos.hu/darcs-fast-export | ||
196 | 92 | ---- | ||
197 | 93 | |||
198 | 94 | == Status | ||
199 | 95 | |||
200 | 96 | In general, darcs-fast-export should work fine. darcs-fast-import has | ||
201 | 97 | known problems with tags - other than that it should be okay. git-darcs | ||
202 | 98 | should work properly as long as you are not paying too much attention to | ||
203 | 99 | the imported tags (newly created tags won't be pushed back). | ||
204 | 100 | |||
205 | 101 | darcs-fast-export has been tested with the following versions: | ||
206 | 102 | |||
207 | 103 | Darcs version (see http://bugs.darcs.net/issue844[this bug] on why do | ||
208 | 104 | you need such a new version): | ||
209 | 105 | ---- | ||
210 | 106 | $ darcs --version | ||
211 | 107 | 2.2.0 (release) | ||
212 | 108 | ---- | ||
213 | 109 | |||
214 | 110 | Git version: | ||
215 | 111 | ---- | ||
216 | 112 | $ git --version | ||
217 | 113 | git version 1.6.0.2 | ||
218 | 114 | ---- | ||
219 | 115 | |||
220 | 116 | Bzr versions: | ||
221 | 117 | ---- | ||
222 | 118 | $ bzr version | ||
223 | 119 | Bazaar (bzr) 1.12 | ||
224 | 120 | $ (cd ~/bzr/fastimport; bzr log --limit 1|grep revno) | ||
225 | 121 | revno: 181 | ||
226 | 122 | ---- | ||
227 | 123 | |||
228 | 124 | Yes, you need the fastiport plugin from BZR, the last hg release series | ||
229 | 125 | supported by fastimport-0.6 is hg-1.0.x. | ||
230 | 126 | |||
231 | 127 | Mercurial (Hg) version: | ||
232 | 128 | ---- | ||
233 | 129 | $ hg version | ||
234 | 130 | Mercurial Distributed SCM (version 1.2.1) | ||
235 | 131 | ---- | ||
236 | 132 | |||
237 | 133 | Strictly speaking this document is a wrong place to talk about enabling | ||
238 | 134 | hg plugins. However... | ||
239 | 135 | |||
240 | 136 | ---- | ||
241 | 137 | $ cat ~/.hgrc | ||
242 | 138 | [extensions] | ||
243 | 139 | hgext.fastimport= | ||
244 | 140 | ---- | ||
245 | 141 | |||
246 | 142 | and once you installed the plugin correctly, you should have something like: | ||
247 | 143 | |||
248 | 144 | ---- | ||
249 | 145 | $ ls /usr/lib/python*/site-packages/hgext/fastimport/__init__.py | ||
250 | 146 | /usr/lib/python2.5/site-packages/hgext/fastimport/__init__.py | ||
251 | 147 | ---- | ||
252 | 148 | |||
253 | 149 | == Additional resources | ||
254 | 150 | |||
255 | 151 | You can reach the Changelog link:Changelog[here], and a gitweb interface | ||
256 | 152 | http://vmiklos.hu/gitweb/?p=darcs-fast-export.git[here]. | ||
257 | 153 | |||
258 | 154 | The fast-import stream format documentation is | ||
259 | 155 | http://git.kernel.org/?p=git/git.git;a=blob;f=fast-import.c;hb=HEAD[here] | ||
260 | 156 | if you're interested. | ||
261 | 157 | |||
262 | 158 | == Alternatives | ||
263 | 159 | |||
264 | 160 | - http://repo.or.cz/w/darcs2git.git[darcs2git] tries to find conflict | ||
265 | 161 | resolutions (to map them to merge commits), but it's rather slow | ||
266 | 162 | because of this. It does not support the darcs2 format and/or | ||
267 | 163 | incremental conversions, either. darcs-fast-export may support mapping | ||
268 | 164 | to merge commits later, but not before | ||
269 | 165 | http://bugs.darcs.net/issue1261[this issue] is addressed. | ||
270 | 166 | |||
271 | 167 | - http://progetti.arstecnica.it/tailor[tailor] is an any2any VCS | ||
272 | 168 | converter, but it produces corrupted results when converting the | ||
273 | 169 | big-zoo - see http://progetti.arstecnica.it/tailor/ticket/171[this | ||
274 | 170 | ticket]. | ||
275 | 171 | |||
276 | 172 | - http://git.sanityinc.com/?p=darcs-to-git.git[darcs-to-git] is similar | ||
277 | 173 | to darcs2git, but it fails for the testcases found in the testsuite of | ||
278 | 174 | darcs-fast-export. | ||
279 | 175 | |||
280 | 176 | - http://github.com/freshtonic/undarcs/tree/master[undarcs] claims to be | ||
281 | 177 | fast, but its own README says it produces incorrect results. When I | ||
282 | 178 | tried, it did not handle the darcs2 format, binary files and incremental | ||
283 | 179 | support. | ||
284 | 180 | |||
285 | 181 | == Thanks | ||
286 | 182 | |||
287 | 183 | - Jason Dagit for helping me with darcs2 issues | ||
288 | 184 | - Shawn O. Pearce and Johannes Schindelin for writing `git-fast-import` | ||
289 | 185 | / `git-fast-export` | ||
290 | 186 | - Ian Clatworthy for writing bzr fast-import | ||
291 | 187 | - Paul Crowley for writing hg fast-import | ||
292 | 188 | - Matthias Andree for assorted improvements, among them the --help, | ||
293 | 189 | --encoding and --authors-file features (using Python's optparse), support | ||
294 | 190 | for hashed repositories, `_darcs/format` interpretation, and mangling | ||
295 | 191 | whitespace in tags to cope with repos imported into DARCS from CVS. | ||
296 | 192 | - Pieter de Bie for writing git-bzr, which was the base of git-darcs | ||
297 | 0 | 193 | ||
298 | === added file 'exporters/darcs/TODO' | |||
299 | --- exporters/darcs/TODO 1970-01-01 00:00:00 +0000 | |||
300 | +++ exporters/darcs/TODO 2008-12-26 01:09:24 +0000 | |||
301 | @@ -0,0 +1,6 @@ | |||
302 | 1 | more intelligent tests, such as detect if the hg fastimport extension is | ||
303 | 2 | not enabled, etc. | ||
304 | 3 | |||
305 | 4 | parse the patches manually so we can avoid re-adding existing files manually. | ||
306 | 5 | |||
307 | 6 | avoid darcs apply. | ||
308 | 0 | 7 | ||
309 | === added file 'exporters/darcs/asciidoc.conf' | |||
310 | --- exporters/darcs/asciidoc.conf 1970-01-01 00:00:00 +0000 | |||
311 | +++ exporters/darcs/asciidoc.conf 2008-12-22 23:48:45 +0000 | |||
312 | @@ -0,0 +1,21 @@ | |||
313 | 1 | ifdef::doctype-manpage[] | ||
314 | 2 | ifdef::backend-docbook[] | ||
315 | 3 | [header] | ||
316 | 4 | template::[header-declarations] | ||
317 | 5 | <refentry> | ||
318 | 6 | <refentryinfo> | ||
319 | 7 | <date>{dfe_date}</date> | ||
320 | 8 | </refentryinfo> | ||
321 | 9 | <refmeta> | ||
322 | 10 | <refentrytitle>{mantitle}</refentrytitle> | ||
323 | 11 | <manvolnum>{manvolnum}</manvolnum> | ||
324 | 12 | <refmiscinfo class="source">darcs-fast-export</refmiscinfo> | ||
325 | 13 | <refmiscinfo class="version">{dfe_version}</refmiscinfo> | ||
326 | 14 | <refmiscinfo class="manual">darcs-fast-export manual</refmiscinfo> | ||
327 | 15 | </refmeta> | ||
328 | 16 | <refnamediv> | ||
329 | 17 | <refname>{manname}</refname> | ||
330 | 18 | <refpurpose>{manpurpose}</refpurpose> | ||
331 | 19 | </refnamediv> | ||
332 | 20 | endif::backend-docbook[] | ||
333 | 21 | endif::doctype-manpage[] | ||
334 | 0 | 22 | ||
335 | === added file 'exporters/darcs/d2x' | |||
336 | --- exporters/darcs/d2x 1970-01-01 00:00:00 +0000 | |||
337 | +++ exporters/darcs/d2x 2008-11-27 13:36:26 +0000 | |||
338 | @@ -0,0 +1,114 @@ | |||
339 | 1 | #!/bin/sh | ||
340 | 2 | # | ||
341 | 3 | # d2x - convert darcs repos to git, bzr or hg using fast-import | ||
342 | 4 | # | ||
343 | 5 | # Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org> | ||
344 | 6 | # | ||
345 | 7 | # This program is free software; you can redistribute it and/or modify | ||
346 | 8 | # it under the terms of the GNU General Public License as published by | ||
347 | 9 | # the Free Software Foundation; either version 2 of the License, or | ||
348 | 10 | # (at your option) any later version. | ||
349 | 11 | # | ||
350 | 12 | # This program is distributed in the hope that it will be useful, | ||
351 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
352 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
353 | 15 | # GNU General Public License for more details. | ||
354 | 16 | # | ||
355 | 17 | # You should have received a copy of the GNU General Public License | ||
356 | 18 | # along with this program; if not, write to the Free Software | ||
357 | 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | ||
358 | 20 | # USA. | ||
359 | 21 | # | ||
360 | 22 | |||
361 | 23 | usage() | ||
362 | 24 | { | ||
363 | 25 | echo "Usage: d2x -f format darcsrepo" | ||
364 | 26 | } | ||
365 | 27 | |||
366 | 28 | die() | ||
367 | 29 | { | ||
368 | 30 | echo "$@" | ||
369 | 31 | usage | ||
370 | 32 | exit 1 | ||
371 | 33 | } | ||
372 | 34 | |||
373 | 35 | check_up_to_date() | ||
374 | 36 | { | ||
375 | 37 | upstreamnum=$(cd $origin; darcs show repo|grep 'Num Patches'|sed 's/.*: //') | ||
376 | 38 | if [ "$upstreamnum" = "$(eval $*)" ]; then | ||
377 | 39 | echo "No remote changes to pull!" | ||
378 | 40 | exit 0 | ||
379 | 41 | fi | ||
380 | 42 | } | ||
381 | 43 | |||
382 | 44 | case $1 in | ||
383 | 45 | -h|--help) | ||
384 | 46 | usage | ||
385 | 47 | exit 0 | ||
386 | 48 | ;; | ||
387 | 49 | -f) | ||
388 | 50 | format="$2" | ||
389 | 51 | shift 2 | ||
390 | 52 | ;; | ||
391 | 53 | esac | ||
392 | 54 | |||
393 | 55 | [ -n "$format" ] || die "Target format is not given!" | ||
394 | 56 | |||
395 | 57 | case $format in | ||
396 | 58 | git|bzr|hg) | ||
397 | 59 | ;; | ||
398 | 60 | *) | ||
399 | 61 | die "The requested target format is not yet supported!" | ||
400 | 62 | ;; | ||
401 | 63 | esac | ||
402 | 64 | |||
403 | 65 | origin="$1" | ||
404 | 66 | shift 1 | ||
405 | 67 | |||
406 | 68 | [ -d "$origin" ] || die "Source repo does not exist!" | ||
407 | 69 | |||
408 | 70 | # convert to abspath | ||
409 | 71 | cd $origin | ||
410 | 72 | origin=$(pwd) | ||
411 | 73 | |||
412 | 74 | dmark="$origin.$format/darcs/dfe-marks" | ||
413 | 75 | fmark="$origin.$format/darcs/ffi-marks" | ||
414 | 76 | |||
415 | 77 | mkdir -p $origin.$format/darcs | ||
416 | 78 | cd $origin.$format | ||
417 | 79 | |||
418 | 80 | common_opts="--working $origin.$format/darcs/repo --logfile $origin.$format/darcs/log $origin" | ||
419 | 81 | if [ ! -f $dmark ]; then | ||
420 | 82 | case $format in | ||
421 | 83 | git) | ||
422 | 84 | git --bare init | ||
423 | 85 | darcs-fast-export $* --export-marks=$dmark $common_opts | \ | ||
424 | 86 | git fast-import --export-marks=$fmark | ||
425 | 87 | ;; | ||
426 | 88 | bzr) | ||
427 | 89 | bzr init-repo . | ||
428 | 90 | darcs-fast-export $* --export-marks=$dmark $common_opts | \ | ||
429 | 91 | bzr fast-import --export-marks=$fmark - | ||
430 | 92 | ;; | ||
431 | 93 | hg) | ||
432 | 94 | hg init | ||
433 | 95 | darcs-fast-export $* $origin | \ | ||
434 | 96 | hg fastimport /dev/stdin | ||
435 | 97 | esac | ||
436 | 98 | else | ||
437 | 99 | case $format in | ||
438 | 100 | git) | ||
439 | 101 | check_up_to_date "git rev-list HEAD |wc -l" | ||
440 | 102 | darcs-fast-export $* --export-marks=$dmark --import-marks=$dmark $common_opts | \ | ||
441 | 103 | git fast-import --export-marks=$fmark --import-marks=$fmark | ||
442 | 104 | ;; | ||
443 | 105 | bzr) | ||
444 | 106 | check_up_to_date "cd master; bzr revno" | ||
445 | 107 | darcs-fast-export $* --export-marks=$dmark --import-marks=$dmark $common_opts | \ | ||
446 | 108 | bzr fast-import --export-marks=$fmark --import-marks=$fmark - | ||
447 | 109 | ;; | ||
448 | 110 | hg) | ||
449 | 111 | die "Incremental conversion to hg is not yet supported by hg fastimport." | ||
450 | 112 | ;; | ||
451 | 113 | esac | ||
452 | 114 | fi | ||
453 | 0 | 115 | ||
454 | === added file 'exporters/darcs/d2x.txt' | |||
455 | --- exporters/darcs/d2x.txt 1970-01-01 00:00:00 +0000 | |||
456 | +++ exporters/darcs/d2x.txt 2008-11-27 13:36:26 +0000 | |||
457 | @@ -0,0 +1,27 @@ | |||
458 | 1 | = d2x(1) | ||
459 | 2 | |||
460 | 3 | == NAME | ||
461 | 4 | |||
462 | 5 | d2x - convert darcs repos to git, bzr or hg using fast-import | ||
463 | 6 | |||
464 | 7 | == SYNOPSIS | ||
465 | 8 | |||
466 | 9 | d2x -f <format> <darcsrepo> [<darcs-fast-export options>] | ||
467 | 10 | |||
468 | 11 | == DESCRIPTION | ||
469 | 12 | |||
470 | 13 | d2x is a wrapper script that just automates doing an initial or | ||
471 | 14 | continuing an incremental conversion. All it does is initializing the | ||
472 | 15 | target repo, starting darcs-fast-export and the relevant importer with | ||
473 | 16 | the proper switches and pipe the exporter's output to the importer's | ||
474 | 17 | standard input. | ||
475 | 18 | |||
476 | 19 | == OPTIONS | ||
477 | 20 | |||
478 | 21 | --help:: | ||
479 | 22 | Display usage. | ||
480 | 23 | |||
481 | 24 | -f <format>:: | ||
482 | 25 | Specify the format of the target repo. Currently supported targets are | ||
483 | 26 | git, bzr and hg. Incremental conversion is supported in case of git and | ||
484 | 27 | bzr. | ||
485 | 0 | 28 | ||
486 | === added file 'exporters/darcs/darcs-fast-export' | |||
487 | --- exporters/darcs/darcs-fast-export 1970-01-01 00:00:00 +0000 | |||
488 | +++ exporters/darcs/darcs-fast-export 2009-06-26 02:10:04 +0000 | |||
489 | @@ -0,0 +1,337 @@ | |||
490 | 1 | #!/usr/bin/env python | ||
491 | 2 | |||
492 | 3 | """ | ||
493 | 4 | |||
494 | 5 | darcs-fast-export - darcs backend for fast data importers | ||
495 | 6 | |||
496 | 7 | Copyright (c) 2008 Miklos Vajna <vmiklos@frugalware.org> | ||
497 | 8 | Copyright (c) 2008 Matthias Andree <matthias.andree@gmx.de> | ||
498 | 9 | |||
499 | 10 | This program is free software; you can redistribute it and/or modify | ||
500 | 11 | it under the terms of the GNU General Public License as published by | ||
501 | 12 | the Free Software Foundation; either version 2, or (at your option) | ||
502 | 13 | any later version. | ||
503 | 14 | |||
504 | 15 | This program is distributed in the hope that it will be useful, | ||
505 | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
506 | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
507 | 18 | GNU General Public License for more details. | ||
508 | 19 | |||
509 | 20 | You should have received a copy of the GNU General Public License | ||
510 | 21 | along with this program; if not, write to the Free Software | ||
511 | 22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
512 | 23 | |||
513 | 24 | """ | ||
514 | 25 | |||
515 | 26 | import xml.dom.minidom | ||
516 | 27 | import xml.parsers.expat | ||
517 | 28 | import os | ||
518 | 29 | import sys | ||
519 | 30 | import gzip | ||
520 | 31 | import time | ||
521 | 32 | import shutil | ||
522 | 33 | import subprocess | ||
523 | 34 | import optparse | ||
524 | 35 | import re | ||
525 | 36 | |||
526 | 37 | sys = reload(sys) | ||
527 | 38 | sys.setdefaultencoding("utf-8") | ||
528 | 39 | |||
529 | 40 | def __get_zone(): | ||
530 | 41 | now = time.localtime() | ||
531 | 42 | if time.daylight and now[-1]: | ||
532 | 43 | offset = time.altzone | ||
533 | 44 | else: | ||
534 | 45 | offset = time.timezone | ||
535 | 46 | hours, minutes = divmod(abs(offset), 3600) | ||
536 | 47 | if offset > 0: | ||
537 | 48 | sign = "-" | ||
538 | 49 | else: | ||
539 | 50 | sign = "+" | ||
540 | 51 | return sign, hours, minutes | ||
541 | 52 | |||
542 | 53 | def get_zone_str(): | ||
543 | 54 | sign, hours, minutes = __get_zone() | ||
544 | 55 | return "%s%02d%02d" % (sign, hours, minutes // 60) | ||
545 | 56 | |||
546 | 57 | def get_zone_int(): | ||
547 | 58 | sign, hours, minutes = __get_zone() | ||
548 | 59 | ret = hours*3600+minutes*60 | ||
549 | 60 | if sign == "-": | ||
550 | 61 | ret *= -1 | ||
551 | 62 | return ret | ||
552 | 63 | |||
553 | 64 | def get_patchname(patch): | ||
554 | 65 | ret = [] | ||
555 | 66 | s = "" | ||
556 | 67 | if patch.attributes['inverted'].value == 'True': | ||
557 | 68 | s = "UNDO: " | ||
558 | 69 | ret.append(s + patch.getElementsByTagName("name")[0].childNodes[0].data) | ||
559 | 70 | lines = patch.getElementsByTagName("comment") | ||
560 | 71 | if lines: | ||
561 | 72 | for i in lines[0].childNodes[0].data.split('\n'): | ||
562 | 73 | if not i.startswith("Ignore-this: "): | ||
563 | 74 | ret.append(i) | ||
564 | 75 | return "\n".join(ret).encode('utf-8') | ||
565 | 76 | |||
566 | 77 | def get_author(patch): | ||
567 | 78 | """darcs allows any freeform string, but fast-import has a more | ||
568 | 79 | strict format, so fix up broken author names here.""" | ||
569 | 80 | |||
570 | 81 | author = patch.attributes['author'].value | ||
571 | 82 | if author in authormap: | ||
572 | 83 | author = authormap[author] | ||
573 | 84 | if not len(author): | ||
574 | 85 | author = "darcs-fast-export <darcs-fast-export>" | ||
575 | 86 | # add missing name | ||
576 | 87 | elif not ">" in author: | ||
577 | 88 | author = "%s <%s>" % (author.split('@')[0], author) | ||
578 | 89 | # avoid double quoting | ||
579 | 90 | elif author[0] == '"' and author[-1] == '"': | ||
580 | 91 | author = author[1:-1] | ||
581 | 92 | # name after email | ||
582 | 93 | elif author[-1] != '>': | ||
583 | 94 | author = author[author.index('>')+2:] + ' ' + author[:author.index('>')+1] | ||
584 | 95 | return author.encode('utf-8') | ||
585 | 96 | |||
586 | 97 | def get_date(patch): | ||
587 | 98 | try: | ||
588 | 99 | date = time.strptime(patch, "%Y%m%d%H%M%S") | ||
589 | 100 | except ValueError: | ||
590 | 101 | date = time.strptime(patch[:19] + patch[-5:], '%a %b %d %H:%M:%S %Y') | ||
591 | 102 | return int(time.mktime(date)) + get_zone_int() | ||
592 | 103 | |||
593 | 104 | def progress(s): | ||
594 | 105 | print "progress [%s] %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), s) | ||
595 | 106 | sys.stdout.flush() | ||
596 | 107 | |||
597 | 108 | def log(s): | ||
598 | 109 | logsock.write("[%s] %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), s)) | ||
599 | 110 | logsock.flush() | ||
600 | 111 | |||
601 | 112 | hashes = [] | ||
602 | 113 | def parse_inventory(sock=None): | ||
603 | 114 | prev = None | ||
604 | 115 | nextprev = False | ||
605 | 116 | buf = [] | ||
606 | 117 | if not sock: | ||
607 | 118 | sock = open(os.path.join("_darcs", "hashed_inventory")) | ||
608 | 119 | for i in sock.readlines(): | ||
609 | 120 | if i.startswith("hash"): | ||
610 | 121 | buf.insert(0, i[6:-1]) | ||
611 | 122 | if i.startswith("Starting with inventory:"): | ||
612 | 123 | nextprev = True | ||
613 | 124 | elif nextprev: | ||
614 | 125 | prev = i[:-1] | ||
615 | 126 | nextprev = False | ||
616 | 127 | sock.close() | ||
617 | 128 | for i in buf: | ||
618 | 129 | hashes.insert(0, i) | ||
619 | 130 | if prev: | ||
620 | 131 | sock = gzip.open(os.path.join("_darcs", "inventories", prev)) | ||
621 | 132 | parse_inventory(sock) | ||
622 | 133 | |||
623 | 134 | # Option Parser | ||
624 | 135 | usage="%prog [options] darcsrepo" | ||
625 | 136 | opp = optparse.OptionParser(usage=usage) | ||
626 | 137 | opp.add_option("--import-marks", metavar="IFILE", | ||
627 | 138 | help="read state for incremental imports from IFILE") | ||
628 | 139 | opp.add_option("--export-marks", metavar="OFILE", | ||
629 | 140 | help="write state for incremental imports from OFILE") | ||
630 | 141 | opp.add_option("--encoding", | ||
631 | 142 | help="encoding of log [default: %default], if unspecified and input isn't utf-8, guess") | ||
632 | 143 | opp.add_option("--authors-file", metavar="F", | ||
633 | 144 | help="read author transformations in old=new format from F") | ||
634 | 145 | opp.add_option("--working", metavar="W", | ||
635 | 146 | help="working directory which is removed at the end of non-incremental conversions") | ||
636 | 147 | opp.add_option("--logfile", metavar="L", | ||
637 | 148 | help="log file which contains the output of external programs invoked during the conversion") | ||
638 | 149 | opp.add_option("--git-branch", metavar="B", | ||
639 | 150 | help="git branch [default: refs/heads/master]") | ||
640 | 151 | opp.add_option("--progress", metavar="P", | ||
641 | 152 | help="insert progress statements after every n commit [default: 100]") | ||
642 | 153 | (options, args) = opp.parse_args() | ||
643 | 154 | if len(args) < 1: | ||
644 | 155 | opp.error("darcsrepo required") | ||
645 | 156 | |||
646 | 157 | export_marks = [] | ||
647 | 158 | import_marks = [] | ||
648 | 159 | if options.import_marks: | ||
649 | 160 | sock = open(options.import_marks) | ||
650 | 161 | for i in sock.readlines(): | ||
651 | 162 | line = i.strip() | ||
652 | 163 | if not len(line): | ||
653 | 164 | continue | ||
654 | 165 | import_marks.append(line.split(' ')[1]) | ||
655 | 166 | export_marks.append(line) | ||
656 | 167 | sock.close() | ||
657 | 168 | |||
658 | 169 | # read author mapping file in gitauthors format, | ||
659 | 170 | # i. e. in=out (one per # line) | ||
660 | 171 | authormap = {} | ||
661 | 172 | if options.authors_file: | ||
662 | 173 | sock = open(options.authors_file) | ||
663 | 174 | authormap = dict([i.strip().split('=',1) for i in sock]) | ||
664 | 175 | sock.close() | ||
665 | 176 | |||
666 | 177 | origin = os.path.abspath(args[0]) | ||
667 | 178 | if options.working: | ||
668 | 179 | working = os.path.abspath(options.working) | ||
669 | 180 | else: | ||
670 | 181 | working = "%s.darcs" % origin | ||
671 | 182 | patchfile = "%s.patch" % origin | ||
672 | 183 | if options.logfile: | ||
673 | 184 | logfile = os.path.abspath(options.logfile) | ||
674 | 185 | else: | ||
675 | 186 | logfile = "%s.log" % origin | ||
676 | 187 | logsock = open(logfile, "a") | ||
677 | 188 | if options.git_branch: | ||
678 | 189 | git_branch = options.git_branch | ||
679 | 190 | else: | ||
680 | 191 | git_branch = "refs/heads/master" | ||
681 | 192 | |||
682 | 193 | if options.progress: | ||
683 | 194 | prognum = int(options.progress) | ||
684 | 195 | else: | ||
685 | 196 | prognum = 100 | ||
686 | 197 | |||
687 | 198 | progress("getting list of patches") | ||
688 | 199 | if not len(import_marks): | ||
689 | 200 | sock = os.popen("darcs changes --xml --reverse --repo %s" % origin) | ||
690 | 201 | else: | ||
691 | 202 | sock = os.popen("darcs changes --xml --reverse --repo %s --from-match 'hash %s'" % (origin, import_marks[-1])) | ||
692 | 203 | buf = sock.read() | ||
693 | 204 | sock.close() | ||
694 | 205 | # this is hackish. we need to escape some bad chars, otherwise the xml | ||
695 | 206 | # will not be valid | ||
696 | 207 | buf = buf.replace('\x1b', '^[') | ||
697 | 208 | if options.encoding: | ||
698 | 209 | xmldoc = xml.dom.minidom.parseString(unicode(buf, options.encoding).encode('utf-8')) | ||
699 | 210 | else: | ||
700 | 211 | try: | ||
701 | 212 | xmldoc = xml.dom.minidom.parseString(buf) | ||
702 | 213 | except xml.parsers.expat.ExpatError: | ||
703 | 214 | import chardet | ||
704 | 215 | progress("encoding is not utf8, guessing charset") | ||
705 | 216 | encoding = chardet.detect(buf)['encoding'] | ||
706 | 217 | progress("detected encoding is %s" % encoding) | ||
707 | 218 | xmldoc = xml.dom.minidom.parseString(unicode(buf, encoding).encode('utf-8')) | ||
708 | 219 | sys.stdout.flush() | ||
709 | 220 | |||
710 | 221 | darcs2 = False | ||
711 | 222 | oldfashionedpatch = True | ||
712 | 223 | cwd = os.getcwd() | ||
713 | 224 | if os.path.exists(os.path.join(origin, "_darcs", "format")): | ||
714 | 225 | sock = open(os.path.join(origin, "_darcs", "format")) | ||
715 | 226 | format = [x.strip() for x in sock] | ||
716 | 227 | sock.close() | ||
717 | 228 | darcs2 = 'darcs-2' in format | ||
718 | 229 | oldfashionedpatch = not 'hashed' in format | ||
719 | 230 | if not oldfashionedpatch: | ||
720 | 231 | progress("parsing the inventory") | ||
721 | 232 | os.chdir(origin) | ||
722 | 233 | parse_inventory() | ||
723 | 234 | if not options.import_marks or not os.path.exists(working): | ||
724 | 235 | # init the tmp darcs repo | ||
725 | 236 | os.mkdir(working) | ||
726 | 237 | os.chdir(working) | ||
727 | 238 | if darcs2: | ||
728 | 239 | os.system("darcs init --darcs-2") | ||
729 | 240 | else: | ||
730 | 241 | os.system("darcs init --old-fashioned-inventory") | ||
731 | 242 | else: | ||
732 | 243 | os.chdir(working) | ||
733 | 244 | if options.import_marks: | ||
734 | 245 | sock = os.popen("darcs pull -a --match 'hash %s' %s" % (import_marks[-1], origin)) | ||
735 | 246 | log("Building/updating working directory:\n%s" % sock.read()) | ||
736 | 247 | sock.close() | ||
737 | 248 | |||
738 | 249 | # this is the number of the NEXT patch | ||
739 | 250 | count = 1 | ||
740 | 251 | patches = xmldoc.getElementsByTagName('patch') | ||
741 | 252 | if len(import_marks): | ||
742 | 253 | patches = patches[1:] | ||
743 | 254 | count = len(import_marks) + 1 | ||
744 | 255 | if len(export_marks): | ||
745 | 256 | # this is the mark number of the NEXT patch | ||
746 | 257 | markcount = int(export_marks[-1].split(' ')[0][1:]) + 1 | ||
747 | 258 | else: | ||
748 | 259 | markcount = count | ||
749 | 260 | # this may be huge and we need it many times | ||
750 | 261 | patchnum = len(patches) | ||
751 | 262 | |||
752 | 263 | if not len(import_marks): | ||
753 | 264 | progress("starting export, repo has %d patches" % patchnum) | ||
754 | 265 | else: | ||
755 | 266 | progress("continuing export, %d patches to convert" % patchnum) | ||
756 | 267 | paths = [] | ||
757 | 268 | for i in patches: | ||
758 | 269 | # apply the patch | ||
759 | 270 | hash = i.attributes['hash'].value | ||
760 | 271 | buf = ["\nNew patches:\n"] | ||
761 | 272 | if oldfashionedpatch: | ||
762 | 273 | sock = gzip.open(os.path.join(origin, "_darcs", "patches", hash)) | ||
763 | 274 | else: | ||
764 | 275 | sock = gzip.open(os.path.join(origin, "_darcs", "patches", hashes[count-1])) | ||
765 | 276 | buf.append(sock.read()) | ||
766 | 277 | sock.close() | ||
767 | 278 | sock = os.popen("darcs changes --context") | ||
768 | 279 | buf.append(sock.read()) | ||
769 | 280 | sock.close() | ||
770 | 281 | sock = subprocess.Popen(["darcs", "apply", "--allow-conflicts"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
771 | 282 | sock.stdin.write("".join(buf)) | ||
772 | 283 | sock.stdin.close() | ||
773 | 284 | log("Applying %s:\n%s" % (hash, sock.stdout.read())) | ||
774 | 285 | sock.stdout.close() | ||
775 | 286 | message = get_patchname(i) | ||
776 | 287 | # export the commit | ||
777 | 288 | print "commit %s" % git_branch | ||
778 | 289 | print "mark :%s" % markcount | ||
779 | 290 | if options.export_marks: | ||
780 | 291 | export_marks.append(":%s %s" % (markcount, hash)) | ||
781 | 292 | date = get_date(i.attributes['date'].value) | ||
782 | 293 | print "committer %s %s %s" % (get_author(i), date, get_zone_str()) | ||
783 | 294 | print "data %d\n%s" % (len(message), message) | ||
784 | 295 | if markcount > 1: | ||
785 | 296 | print "from :%s" % (markcount-1) | ||
786 | 297 | # export the files | ||
787 | 298 | for j in paths: | ||
788 | 299 | print "D %s" % j | ||
789 | 300 | paths = [] | ||
790 | 301 | for (root, dirs, files) in os.walk ("."): | ||
791 | 302 | for f in files: | ||
792 | 303 | j = os.path.normpath(os.path.join(root, f)) | ||
793 | 304 | if j.startswith("_darcs") or "-darcs-backup" in j: | ||
794 | 305 | continue | ||
795 | 306 | paths.append(j) | ||
796 | 307 | sock = open(j) | ||
797 | 308 | buf = sock.read() | ||
798 | 309 | sock.close() | ||
799 | 310 | # darcs does not track the executable bit :/ | ||
800 | 311 | print "M 644 inline %s" % j | ||
801 | 312 | print "data %s\n%s" % (len(buf), buf) | ||
802 | 313 | if message[:4] == "TAG ": | ||
803 | 314 | tag = re.sub('[^\xe9-\xf8\w.\-]+', '_', message[4:].strip().split('\n')[0]).strip('_') | ||
804 | 315 | print "tag %s" % tag | ||
805 | 316 | print "from :%s" % markcount | ||
806 | 317 | print "tagger %s %s %s" % (get_author(i), date, get_zone_str()) | ||
807 | 318 | print "data %d\n%s" % (len(message), message) | ||
808 | 319 | if count % prognum == 0: | ||
809 | 320 | progress("%d/%d patches" % (count, patchnum)) | ||
810 | 321 | count += 1 | ||
811 | 322 | markcount += 1 | ||
812 | 323 | |||
813 | 324 | os.chdir(cwd) | ||
814 | 325 | |||
815 | 326 | if not options.export_marks: | ||
816 | 327 | shutil.rmtree(working) | ||
817 | 328 | logsock.close() | ||
818 | 329 | |||
819 | 330 | if options.export_marks: | ||
820 | 331 | progress("writing export marks") | ||
821 | 332 | sock = open(options.export_marks, 'w') | ||
822 | 333 | sock.write("\n".join(export_marks)) | ||
823 | 334 | sock.write("\n") | ||
824 | 335 | sock.close() | ||
825 | 336 | |||
826 | 337 | progress("finished") | ||
827 | 0 | 338 | ||
828 | === added file 'exporters/darcs/darcs-fast-export.txt' | |||
829 | --- exporters/darcs/darcs-fast-export.txt 1970-01-01 00:00:00 +0000 | |||
830 | +++ exporters/darcs/darcs-fast-export.txt 2008-11-28 14:43:30 +0000 | |||
831 | @@ -0,0 +1,61 @@ | |||
832 | 1 | = darcs-fast-export(1) | ||
833 | 2 | |||
834 | 3 | == NAME | ||
835 | 4 | |||
836 | 5 | darcs-fast-export - darcs frontend to git fast-import | ||
837 | 6 | |||
838 | 7 | == SYNOPSIS | ||
839 | 8 | |||
840 | 9 | darcs-fast-export [<options>] <darcsrepo> | ||
841 | 10 | |||
842 | 11 | == DESCRIPTION | ||
843 | 12 | |||
844 | 13 | darcs-fast-export expects one argument, the path to the source darcs | ||
845 | 14 | repository. It will print the git fast-import format on standard output | ||
846 | 15 | (stdout). | ||
847 | 16 | |||
848 | 17 | The script can produce the fast-import stream format from the darcs | ||
849 | 18 | repository. It supports incremental conversion as well, via the | ||
850 | 19 | --import-marks / --export-marks switches. | ||
851 | 20 | |||
852 | 21 | == OPTIONS | ||
853 | 22 | |||
854 | 23 | -h, --help:: | ||
855 | 24 | Display usage. | ||
856 | 25 | |||
857 | 26 | --import-marks:: | ||
858 | 27 | Import marks from a given file. This is read at the beginning of the | ||
859 | 28 | conversion at once. Use it if you want to continue an incremental | ||
860 | 29 | conversion. | ||
861 | 30 | |||
862 | 31 | --export-marks:: | ||
863 | 32 | Export marks to a given file at the end of the conversion. It can be the | ||
864 | 33 | same as the one for --import-marks as it is written only once at the | ||
865 | 34 | end. Use it if you want to be able to incrementally update the target | ||
866 | 35 | repository later. | ||
867 | 36 | |||
868 | 37 | --encoding:: | ||
869 | 38 | The encoding of the author names and commit messages in the repository. | ||
870 | 39 | The default is utf-8. If it is not the default, it will be guessed. | ||
871 | 40 | Given that it takes some time, you can explicitly specify it as an | ||
872 | 41 | option to make the conversion faster. Content in the output will encoded | ||
873 | 42 | as utf-8 and will be written that way to the target repository, unless | ||
874 | 43 | the importer re-encodes it again to some other character set. | ||
875 | 44 | |||
876 | 45 | --working:: | ||
877 | 46 | The conversion is done by applying the patches one by one and recording | ||
878 | 47 | the state of the working directory. You can specify the path of this | ||
879 | 48 | directory using this option. | ||
880 | 49 | |||
881 | 50 | --logfile:: | ||
882 | 51 | The output of external commands are redirected to a log file. You can | ||
883 | 52 | specify the path of that file with this parameter. | ||
884 | 53 | |||
885 | 54 | --git-branch:: | ||
886 | 55 | There is only one branch in one darcs repository, but the fast-import | ||
887 | 56 | stream format allows multiple branches, thus the exporter has to name | ||
888 | 57 | darcs's branch. The default value is 'refs/heads/master'. | ||
889 | 58 | |||
890 | 59 | --progress:: | ||
891 | 60 | Insert progress statements after every <n> patches, to be shown by the | ||
892 | 61 | fast importer during import. | ||
893 | 0 | 62 | ||
894 | === added file 'exporters/darcs/darcs-fast-import' | |||
895 | --- exporters/darcs/darcs-fast-import 1970-01-01 00:00:00 +0000 | |||
896 | +++ exporters/darcs/darcs-fast-import 2009-06-26 02:05:21 +0000 | |||
897 | @@ -0,0 +1,310 @@ | |||
898 | 1 | #!/usr/bin/env python | ||
899 | 2 | |||
900 | 3 | """ | ||
901 | 4 | |||
902 | 5 | darcs-fast-export - darcs backend for fast data exporters | ||
903 | 6 | |||
904 | 7 | Copyright (c) 2008 Miklos Vajna <vmiklos@frugalware.org> | ||
905 | 8 | Copyright (c) 2008 Matthias Andree <matthias.andree@gmx.de> | ||
906 | 9 | |||
907 | 10 | This program is free software; you can redistribute it and/or modify | ||
908 | 11 | it under the terms of the GNU General Public License as published by | ||
909 | 12 | the Free Software Foundation; either version 2, or (at your option) | ||
910 | 13 | any later version. | ||
911 | 14 | |||
912 | 15 | This program is distributed in the hope that it will be useful, | ||
913 | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
914 | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
915 | 18 | GNU General Public License for more details. | ||
916 | 19 | |||
917 | 20 | You should have received a copy of the GNU General Public License | ||
918 | 21 | along with this program; if not, write to the Free Software | ||
919 | 22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
920 | 23 | |||
921 | 24 | """ | ||
922 | 25 | |||
923 | 26 | import sys | ||
924 | 27 | import os | ||
925 | 28 | import re | ||
926 | 29 | import time | ||
927 | 30 | import shutil | ||
928 | 31 | import optparse | ||
929 | 32 | import subprocess | ||
930 | 33 | |||
931 | 34 | class Handler: | ||
932 | 35 | def __init__(self): | ||
933 | 36 | self.marks = {} | ||
934 | 37 | self.files = [] | ||
935 | 38 | self.prevfiles = None | ||
936 | 39 | self.ch = None | ||
937 | 40 | self.line = None | ||
938 | 41 | self.unread_line = False | ||
939 | 42 | self.eof = False | ||
940 | 43 | self.debug = False | ||
941 | 44 | self.export_marks = [] | ||
942 | 45 | self.import_marks = [] | ||
943 | 46 | |||
944 | 47 | def read_next_line(self): | ||
945 | 48 | if self.unread_line: | ||
946 | 49 | self.unread_line = False | ||
947 | 50 | return | ||
948 | 51 | self.line = "" | ||
949 | 52 | if self.eof: | ||
950 | 53 | return | ||
951 | 54 | if self.ch: | ||
952 | 55 | self.line += self.ch | ||
953 | 56 | self.ch = None | ||
954 | 57 | buf = sys.stdin.readline() | ||
955 | 58 | if not len(buf): | ||
956 | 59 | self.eof = True | ||
957 | 60 | else: | ||
958 | 61 | self.line += buf | ||
959 | 62 | if self.debug: | ||
960 | 63 | print "read_next_line: '%s'" % self.line | ||
961 | 64 | |||
962 | 65 | def read(self, length): | ||
963 | 66 | buf = "" | ||
964 | 67 | if self.ch: | ||
965 | 68 | buf += self.ch | ||
966 | 69 | self.ch = None | ||
967 | 70 | buf += sys.stdin.read(length) | ||
968 | 71 | if self.debug: | ||
969 | 72 | print "read: '%s'" % buf | ||
970 | 73 | return buf | ||
971 | 74 | |||
972 | 75 | def skip_optional_lf(self): | ||
973 | 76 | self.ch = self.read(1) | ||
974 | 77 | if self.ch == "\n": | ||
975 | 78 | self.ch = None | ||
976 | 79 | |||
977 | 80 | def bug(self, s): | ||
978 | 81 | raise Exception(s) | ||
979 | 82 | |||
980 | 83 | def get_date(self, ts, tz): | ||
981 | 84 | # int(ts) is seconds since epoch. Since we're trying to | ||
982 | 85 | # capture both the absolute time of the commit and the | ||
983 | 86 | # localtime in the timezone of the committer, we need to turn | ||
984 | 87 | # the (seconds-since-epoch, committer-timezone-offset) pair | ||
985 | 88 | # that we get from the git-fast-export stream format into a | ||
986 | 89 | # localized-time-plus-timezone-marker string that darcs will | ||
987 | 90 | # accept. Therefore, we parse the timezone-offset (which | ||
988 | 91 | # looks like +0500 or +0000 or -0730 or something) and add it | ||
989 | 92 | # to seconds-since-epoch before calling gmtime(). | ||
990 | 93 | mo = re.search(r'^([\+\-])(\d\d)(\d\d)$', tz) | ||
991 | 94 | offset = 60*60*int(mo.group(2)) + 60*int(mo.group(3)) | ||
992 | 95 | if mo.group(1) == "-": | ||
993 | 96 | offset = -offset | ||
994 | 97 | offset_time = int(ts) + offset | ||
995 | 98 | s = time.strftime("%a %b %d %H:%M:%S %Y", time.gmtime(offset_time)) | ||
996 | 99 | items = s.split(' ') | ||
997 | 100 | return " ".join(items[:-1]) + " " + tz + " " + items[-1] | ||
998 | 101 | |||
999 | 102 | def handle_mark(self): | ||
1000 | 103 | if self.line.startswith("mark :"): | ||
1001 | 104 | self.mark_num = int(self.line[6:-1]) | ||
1002 | 105 | self.read_next_line() | ||
1003 | 106 | |||
1004 | 107 | def handle_data(self): | ||
1005 | 108 | if not self.line.startswith("data "): | ||
1006 | 109 | self.bug("Expected 'data n' command, found: '%s'" % self.line[:-1]) | ||
1007 | 110 | length = int(self.line[5:-1]) | ||
1008 | 111 | self.buf = self.read(length) | ||
1009 | 112 | self.skip_optional_lf() | ||
1010 | 113 | |||
1011 | 114 | def handle_blob(self): | ||
1012 | 115 | self.read_next_line() | ||
1013 | 116 | self.handle_mark() | ||
1014 | 117 | self.handle_data() | ||
1015 | 118 | self.marks[self.mark_num] = self.buf | ||
1016 | 119 | |||
1017 | 120 | def handle_ident(self, s): | ||
1018 | 121 | items = s.split(' ') | ||
1019 | 122 | self.ident = " ".join(items[:-2]) | ||
1020 | 123 | self.date = self.get_date(items[-2], items[-1]) | ||
1021 | 124 | |||
1022 | 125 | def handle_msg(self): | ||
1023 | 126 | items = self.buf.split('\n') | ||
1024 | 127 | self.short = items[0] | ||
1025 | 128 | self.long = "\n".join(items[1:]) | ||
1026 | 129 | |||
1027 | 130 | def handle_tag(self): | ||
1028 | 131 | version = self.line[:-1].split(' ')[1] | ||
1029 | 132 | self.read_next_line() | ||
1030 | 133 | if self.line.startswith("from "): | ||
1031 | 134 | self.read_next_line() | ||
1032 | 135 | if self.line.startswith("tagger "): | ||
1033 | 136 | self.handle_ident(self.line[7:-1]) | ||
1034 | 137 | self.read_next_line() | ||
1035 | 138 | self.handle_data() | ||
1036 | 139 | self.skip_optional_lf() | ||
1037 | 140 | sock = subprocess.Popen(["darcs", "tag", "--pipe"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
1038 | 141 | buf = [self.date, self.ident, version] | ||
1039 | 142 | sock.stdin.write("\n".join(buf)) | ||
1040 | 143 | sock.stdin.close() | ||
1041 | 144 | self.log("Tagging %s:\n%s" % (version, sock.stdout.read())) | ||
1042 | 145 | sock.stdout.close() | ||
1043 | 146 | |||
1044 | 147 | def handle_commit(self): | ||
1045 | 148 | if not self.prevfiles and self.options.import_marks: | ||
1046 | 149 | # first commit in an incremental continued | ||
1047 | 150 | # import | ||
1048 | 151 | for (root, dirs, files) in os.walk("."): | ||
1049 | 152 | for i in files: | ||
1050 | 153 | path = os.path.normpath(os.path.join(root, i)) | ||
1051 | 154 | if path.startswith("_darcs") or "-darcs-backup" in path: | ||
1052 | 155 | continue | ||
1053 | 156 | self.files.append(path) | ||
1054 | 157 | self.prevfiles = self.files[:] | ||
1055 | 158 | adds = [] | ||
1056 | 159 | |||
1057 | 160 | self.read_next_line() | ||
1058 | 161 | self.handle_mark() | ||
1059 | 162 | if self.line.startswith("author "): | ||
1060 | 163 | self.handle_ident(self.line[7:-1]) | ||
1061 | 164 | self.read_next_line() | ||
1062 | 165 | if self.line.startswith("committer "): | ||
1063 | 166 | self.handle_ident(self.line[10:-1]) | ||
1064 | 167 | self.read_next_line() | ||
1065 | 168 | self.handle_data() | ||
1066 | 169 | self.skip_optional_lf() | ||
1067 | 170 | self.handle_msg() | ||
1068 | 171 | self.read_next_line() | ||
1069 | 172 | if self.line.startswith("from "): | ||
1070 | 173 | self.read_next_line() | ||
1071 | 174 | while self.line.startswith("merge "): | ||
1072 | 175 | self.read_next_line() | ||
1073 | 176 | while len(self.line) > 0: | ||
1074 | 177 | if self.line.startswith("deleteall"): | ||
1075 | 178 | path = self.line[2:-1] | ||
1076 | 179 | for path in self.files: | ||
1077 | 180 | os.unlink(path) | ||
1078 | 181 | self.files = [] | ||
1079 | 182 | elif self.line.startswith("D "): | ||
1080 | 183 | path = self.line[2:-1] | ||
1081 | 184 | if os.path.exists(path): | ||
1082 | 185 | os.unlink(path) | ||
1083 | 186 | if path in self.files: | ||
1084 | 187 | self.files.remove(path) | ||
1085 | 188 | elif self.line.startswith("R "): | ||
1086 | 189 | os.system("darcs mv %s" % self.line[2:]) | ||
1087 | 190 | elif self.line.startswith("C "): | ||
1088 | 191 | src, dest = self.line[:-1].split(' ')[1:] | ||
1089 | 192 | shutil.copy(src.strip('"'), dest.strip('"')) | ||
1090 | 193 | os.system("darcs add %s" % dest) | ||
1091 | 194 | elif self.line.startswith("M "): | ||
1092 | 195 | items = self.line.split(' ') | ||
1093 | 196 | path = items[3][:-1] | ||
1094 | 197 | sock = open(path, "w") | ||
1095 | 198 | if items[2] != "inline": | ||
1096 | 199 | idx = int(items[2][1:]) | ||
1097 | 200 | sock.write(self.marks[idx]) | ||
1098 | 201 | del self.marks[idx] | ||
1099 | 202 | else: | ||
1100 | 203 | self.read_next_line() | ||
1101 | 204 | self.handle_data() | ||
1102 | 205 | sock.write(self.buf) | ||
1103 | 206 | sock.close() | ||
1104 | 207 | if path not in self.prevfiles: | ||
1105 | 208 | adds.append(path) | ||
1106 | 209 | if path not in self.files: | ||
1107 | 210 | self.files.append(path) | ||
1108 | 211 | else: | ||
1109 | 212 | self.unread_line = True | ||
1110 | 213 | break | ||
1111 | 214 | self.read_next_line() | ||
1112 | 215 | if not len(self.line): | ||
1113 | 216 | break | ||
1114 | 217 | |||
1115 | 218 | for i in adds: | ||
1116 | 219 | os.system("darcs add %s" % i) | ||
1117 | 220 | sock = subprocess.Popen(["darcs", "record", "--ignore-times", "-a", "--pipe"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
1118 | 221 | buf = [self.date, self.ident, self.short, self.long] | ||
1119 | 222 | sock.stdin.write("\n".join(buf)) | ||
1120 | 223 | sock.stdin.close() | ||
1121 | 224 | self.log("Recording :%s:\n%s" % (self.mark_num, sock.stdout.read())) | ||
1122 | 225 | sock.stdout.close() | ||
1123 | 226 | |||
1124 | 227 | if self.options.export_marks: | ||
1125 | 228 | # yeah, an xml parser would be better, but | ||
1126 | 229 | # should we mess with encodings just because of | ||
1127 | 230 | # this? i hope not | ||
1128 | 231 | sock = os.popen("darcs changes --last=1 --xml", "r") | ||
1129 | 232 | buf = sock.read() | ||
1130 | 233 | sock.close() | ||
1131 | 234 | hash = buf.split('\n')[1].split("'")[-2] | ||
1132 | 235 | self.export_marks.append(":%s %s" % (self.mark_num, hash)) | ||
1133 | 236 | |||
1134 | 237 | def handle_progress(self, s): | ||
1135 | 238 | print "progress [%s] %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), s.strip()) | ||
1136 | 239 | sys.stdout.flush() | ||
1137 | 240 | |||
1138 | 241 | def handle_opts(self): | ||
1139 | 242 | # Option Parser | ||
1140 | 243 | usage="%prog [options]" | ||
1141 | 244 | opp = optparse.OptionParser(usage=usage) | ||
1142 | 245 | opp.add_option("--import-marks", metavar="IFILE", | ||
1143 | 246 | help="read state for incremental imports from IFILE") | ||
1144 | 247 | opp.add_option("--export-marks", metavar="OFILE", | ||
1145 | 248 | help="write state for incremental imports to OFILE") | ||
1146 | 249 | opp.add_option("--logfile", metavar="L", | ||
1147 | 250 | help="log file which contains the output of external programs invoked during the conversion") | ||
1148 | 251 | (self.options, args) = opp.parse_args() | ||
1149 | 252 | |||
1150 | 253 | if self.options.logfile: | ||
1151 | 254 | logfile = self.options.logfile | ||
1152 | 255 | else: | ||
1153 | 256 | logfile = "_darcs/import.log" | ||
1154 | 257 | self.logsock = open(os.path.abspath(logfile), "a") | ||
1155 | 258 | |||
1156 | 259 | def log(self, s): | ||
1157 | 260 | self.logsock.write("[%s] %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), s)) | ||
1158 | 261 | self.logsock.flush() | ||
1159 | 262 | |||
1160 | 263 | def handle_export_marks(self): | ||
1161 | 264 | if self.options.export_marks: | ||
1162 | 265 | sock = open(self.options.export_marks, 'w') | ||
1163 | 266 | sock.write("\n".join(self.export_marks)) | ||
1164 | 267 | sock.write("\n") | ||
1165 | 268 | sock.close() | ||
1166 | 269 | |||
1167 | 270 | def handle_import_marks(self): | ||
1168 | 271 | if self.options.import_marks: | ||
1169 | 272 | sock = open(self.options.import_marks) | ||
1170 | 273 | for i in sock.readlines(): | ||
1171 | 274 | line = i.strip() | ||
1172 | 275 | if not len(line): | ||
1173 | 276 | continue | ||
1174 | 277 | self.import_marks.append(line.split(' ')[1]) | ||
1175 | 278 | self.export_marks.append(line) | ||
1176 | 279 | sock.close() | ||
1177 | 280 | |||
1178 | 281 | def handle(self): | ||
1179 | 282 | self.handle_opts() | ||
1180 | 283 | self.handle_import_marks() | ||
1181 | 284 | |||
1182 | 285 | while not self.eof: | ||
1183 | 286 | self.read_next_line() | ||
1184 | 287 | if not len(self.line[:-1]): | ||
1185 | 288 | pass | ||
1186 | 289 | elif self.line.startswith("blob"): | ||
1187 | 290 | self.handle_blob() | ||
1188 | 291 | elif self.line.startswith("commit"): | ||
1189 | 292 | self.handle_commit() | ||
1190 | 293 | elif self.line.startswith("tag"): | ||
1191 | 294 | self.handle_tag() | ||
1192 | 295 | elif self.line.startswith("reset"): | ||
1193 | 296 | self.read_next_line() | ||
1194 | 297 | if not self.line.startswith("from "): | ||
1195 | 298 | self.unread_line = True | ||
1196 | 299 | elif self.line.startswith("checkpoint"): | ||
1197 | 300 | pass | ||
1198 | 301 | elif self.line.startswith("progress"): | ||
1199 | 302 | self.handle_progress(self.line[9:]) | ||
1200 | 303 | else: | ||
1201 | 304 | self.bug("'%s': invalid command" % self.line[:-1]) | ||
1202 | 305 | |||
1203 | 306 | self.handle_export_marks() | ||
1204 | 307 | |||
1205 | 308 | if __name__ == "__main__": | ||
1206 | 309 | h = Handler() | ||
1207 | 310 | h.handle() | ||
1208 | 0 | 311 | ||
1209 | === added file 'exporters/darcs/darcs-fast-import.txt' | |||
1210 | --- exporters/darcs/darcs-fast-import.txt 1970-01-01 00:00:00 +0000 | |||
1211 | +++ exporters/darcs/darcs-fast-import.txt 2008-11-23 22:11:24 +0000 | |||
1212 | @@ -0,0 +1,35 @@ | |||
1213 | 1 | = darcs-fast-import(1) | ||
1214 | 2 | |||
1215 | 3 | == NAME | ||
1216 | 4 | |||
1217 | 5 | darcs-fast-import - darcs backend to the 'fast-import stream' format | ||
1218 | 6 | |||
1219 | 7 | == SYNOPSIS | ||
1220 | 8 | |||
1221 | 9 | darcs-fast-import [<options>] | ||
1222 | 10 | |||
1223 | 11 | == DESCRIPTION | ||
1224 | 12 | |||
1225 | 13 | darcs-fast-import can produce a darcs repository from a fast-import | ||
1226 | 14 | stream, read from the standard input. It supports incremental conversion | ||
1227 | 15 | as well, via the --import-marks / --export-marks switches. | ||
1228 | 16 | |||
1229 | 17 | == OPTIONS | ||
1230 | 18 | |||
1231 | 19 | -h, --help:: | ||
1232 | 20 | Display usage. | ||
1233 | 21 | |||
1234 | 22 | --import-marks:: | ||
1235 | 23 | Import marks from a given file. This is read at the beginning of the | ||
1236 | 24 | conversion at once. Use it if you want to continue an incremental | ||
1237 | 25 | conversion. | ||
1238 | 26 | |||
1239 | 27 | --export-marks:: | ||
1240 | 28 | Export marks to a given file at the end of the conversion. It can be the | ||
1241 | 29 | same as the one for --import-marks as it is written only once at the | ||
1242 | 30 | end. Use it if you want to be able to incrementally update the target | ||
1243 | 31 | repository later. | ||
1244 | 32 | |||
1245 | 33 | --logfile:: | ||
1246 | 34 | The output of external commands are redirected to a log file. You can | ||
1247 | 35 | specify the path of that file with this parameter. | ||
1248 | 0 | 36 | ||
1249 | === added file 'exporters/darcs/git-darcs' | |||
1250 | --- exporters/darcs/git-darcs 1970-01-01 00:00:00 +0000 | |||
1251 | +++ exporters/darcs/git-darcs 2009-07-14 15:05:28 +0000 | |||
1252 | @@ -0,0 +1,264 @@ | |||
1253 | 1 | #!/bin/bash | ||
1254 | 2 | # | ||
1255 | 3 | # git-darcs - bidirectional operation between a darcs repo and git | ||
1256 | 4 | # | ||
1257 | 5 | # Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org> | ||
1258 | 6 | # | ||
1259 | 7 | # Based on git-bzr, which is | ||
1260 | 8 | # | ||
1261 | 9 | # Copyright (c) 2008 Pieter de Bie <pdebie@ai.rug.nl> | ||
1262 | 10 | # | ||
1263 | 11 | # This program is free software; you can redistribute it and/or modify | ||
1264 | 12 | # it under the terms of the GNU General Public License as published by | ||
1265 | 13 | # the Free Software Foundation; either version 2 of the License, or | ||
1266 | 14 | # (at your option) any later version. | ||
1267 | 15 | # | ||
1268 | 16 | # This program is distributed in the hope that it will be useful, | ||
1269 | 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1270 | 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1271 | 19 | # GNU General Public License for more details. | ||
1272 | 20 | # | ||
1273 | 21 | # You should have received a copy of the GNU General Public License | ||
1274 | 22 | # along with this program; if not, write to the Free Software | ||
1275 | 23 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | ||
1276 | 24 | # USA. | ||
1277 | 25 | # | ||
1278 | 26 | |||
1279 | 27 | add() | ||
1280 | 28 | { | ||
1281 | 29 | name="$1" | ||
1282 | 30 | shift | ||
1283 | 31 | location="$1" | ||
1284 | 32 | shift | ||
1285 | 33 | if ! [ -n "$name" -a -n "$location" ]; then | ||
1286 | 34 | echo "Usage: git darcs add name location [darcs-fast-export options]" | ||
1287 | 35 | exit | ||
1288 | 36 | fi | ||
1289 | 37 | if git remote show |grep -q $name; then | ||
1290 | 38 | echo "There is already a remote with that name" | ||
1291 | 39 | exit | ||
1292 | 40 | fi | ||
1293 | 41 | if [ -n "$(git config git-darcs.$name.location)" ]; then | ||
1294 | 42 | echo "There is already a darcs repo with that name" | ||
1295 | 43 | exit | ||
1296 | 44 | fi | ||
1297 | 45 | if [ ! -d $location/_darcs ]; then | ||
1298 | 46 | echo "Remote is not a darcs repository" | ||
1299 | 47 | exit | ||
1300 | 48 | fi | ||
1301 | 49 | git config git-darcs.$name.location $location | ||
1302 | 50 | git config git-darcs.$name.darcs-fast-export-options "$*" | ||
1303 | 51 | echo "Darcs repo $name added. You can fetch it with 'git darcs fetch $name'" | ||
1304 | 52 | if ! [ -z "$*" ]; then | ||
1305 | 53 | echo "darcs-fast-export will get options: $*" | ||
1306 | 54 | fi | ||
1307 | 55 | } | ||
1308 | 56 | |||
1309 | 57 | get_location() | ||
1310 | 58 | { | ||
1311 | 59 | l=$(git config git-darcs.$remote.location) | ||
1312 | 60 | if [ -z "$l" ]; then | ||
1313 | 61 | echo "Cannot find darcs remote with name '$remote'." >&2 | ||
1314 | 62 | exit | ||
1315 | 63 | fi | ||
1316 | 64 | echo $l | ||
1317 | 65 | } | ||
1318 | 66 | |||
1319 | 67 | fetch() | ||
1320 | 68 | { | ||
1321 | 69 | remote="$1" | ||
1322 | 70 | shift | ||
1323 | 71 | if ! [ -n "$remote" -a -z "$*" ]; then | ||
1324 | 72 | echo "Usage: git darcs fetch reponame" | ||
1325 | 73 | exit | ||
1326 | 74 | fi | ||
1327 | 75 | location=$(get_location $remote) | ||
1328 | 76 | git_map=$git_dir/darcs-git/$remote-git-map | ||
1329 | 77 | darcs_map=$git_dir/darcs-git/$remote-darcs-map | ||
1330 | 78 | common_opts="--working $git_dir/darcs-git/repo --logfile $git_dir/darcs-git/fetch.log --git-branch=darcs/$remote" | ||
1331 | 79 | dfe_opts=$(git config git-darcs.$remote.darcs-fast-export-options) | ||
1332 | 80 | if [ ! -f $git_map -a ! -f $darcs_map ]; then | ||
1333 | 81 | echo "There doesn't seem to be an existing refmap." | ||
1334 | 82 | echo "Doing an initial import" | ||
1335 | 83 | mkdir -p $git_dir/darcs-git | ||
1336 | 84 | darcs-fast-export --export-marks=$darcs_map $common_opts $dfe_opts $location | \ | ||
1337 | 85 | git fast-import --export-marks=$git_map | ||
1338 | 86 | elif [ -f $git_map -a -f $darcs_map ]; then | ||
1339 | 87 | echo "Updating remote $remote" | ||
1340 | 88 | old_rev=$(git rev-parse darcs/$remote) | ||
1341 | 89 | darcs-fast-export --import-marks=$darcs_map --export-marks=$darcs_map $common_opts $dfe_opts $location | \ | ||
1342 | 90 | git fast-import --quiet --import-marks=$git_map --export-marks=$git_map | ||
1343 | 91 | new_rev=$(git rev-parse darcs/$remote) | ||
1344 | 92 | if [ "$old_rev" != "$new_rev" ]; then | ||
1345 | 93 | echo "Fetched the following updates:" | ||
1346 | 94 | git shortlog $old_rev..$new_rev | ||
1347 | 95 | else | ||
1348 | 96 | echo "Nothing fetched." | ||
1349 | 97 | exit | ||
1350 | 98 | fi | ||
1351 | 99 | else | ||
1352 | 100 | echo "One of the mapfiles is missing! Something went wrong!" | ||
1353 | 101 | exit | ||
1354 | 102 | fi | ||
1355 | 103 | } | ||
1356 | 104 | |||
1357 | 105 | pull() | ||
1358 | 106 | { | ||
1359 | 107 | remote="$1" | ||
1360 | 108 | shift | ||
1361 | 109 | if ! [ -n "$remote" -a -z "$*" ]; then | ||
1362 | 110 | echo "Usage: git darcs pull reponame" | ||
1363 | 111 | exit | ||
1364 | 112 | fi | ||
1365 | 113 | fetch $remote | ||
1366 | 114 | # see if we need to merge or rebase | ||
1367 | 115 | branch=$(git symbolic-ref HEAD|sed 's|.*/||') | ||
1368 | 116 | if [ "$(git config branch.$branch.rebase)" = "true" ]; then | ||
1369 | 117 | git rebase darcs/$remote | ||
1370 | 118 | else | ||
1371 | 119 | git merge darcs/$remote | ||
1372 | 120 | fi | ||
1373 | 121 | } | ||
1374 | 122 | |||
1375 | 123 | push() | ||
1376 | 124 | { | ||
1377 | 125 | remote="$1" | ||
1378 | 126 | shift | ||
1379 | 127 | if ! [ -n "$remote" -a -z "$*" ]; then | ||
1380 | 128 | echo "Usage: git darcs push reponame" | ||
1381 | 129 | exit | ||
1382 | 130 | fi | ||
1383 | 131 | location=$(get_location $remote) | ||
1384 | 132 | if [ -n "$(git rev-list --left-right HEAD...darcs/$remote | sed -n '/^>/ p')" ]; then | ||
1385 | 133 | echo "HEAD is not a strict child of $remote, cannot push. Merge first" | ||
1386 | 134 | exit | ||
1387 | 135 | fi | ||
1388 | 136 | if [ -z "$(git rev-list --left-right HEAD...darcs/$remote | sed -n '/^</ p')" ]; then | ||
1389 | 137 | echo "Nothing to push. Commit something first" | ||
1390 | 138 | exit | ||
1391 | 139 | fi | ||
1392 | 140 | git_map=$git_dir/darcs-git/$remote-git-map | ||
1393 | 141 | darcs_map=$git_dir/darcs-git/$remote-darcs-map | ||
1394 | 142 | if [ ! -f $git_map -o ! -f $darcs_map ]; then | ||
1395 | 143 | echo "We do not have refmapping yet. Then how can I push?" | ||
1396 | 144 | exit | ||
1397 | 145 | fi | ||
1398 | 146 | echo "Pushing the following updates:" | ||
1399 | 147 | git shortlog darcs/$remote.. | ||
1400 | 148 | git fast-export --import-marks=$git_map --export-marks=$git_map HEAD | \ | ||
1401 | 149 | (cd $location; darcs-fast-import --import-marks=$darcs_map --export-marks=$darcs_map \ | ||
1402 | 150 | --logfile $git_dir/darcs-git/push.log) | ||
1403 | 151 | if [ $? == 0 ]; then | ||
1404 | 152 | git update-ref darcs/$remote HEAD | ||
1405 | 153 | fi | ||
1406 | 154 | } | ||
1407 | 155 | |||
1408 | 156 | # List the darcs remotes | ||
1409 | 157 | list() | ||
1410 | 158 | { | ||
1411 | 159 | if [ -z "$*" ] | ||
1412 | 160 | then | ||
1413 | 161 | git config -l | sed -n -e '/git-darcs\..*/ {s/git-darcs\.//; s/\.location=.*//p}' | ||
1414 | 162 | exit | ||
1415 | 163 | elif [ "$#" -eq 1 ] | ||
1416 | 164 | then | ||
1417 | 165 | case $1 in | ||
1418 | 166 | -v|--verbose) | ||
1419 | 167 | git config -l | sed -n -e '/git-darcs\..*/ {s/git-darcs\.//; s/\.location=/\t/p}' | ||
1420 | 168 | exit | ||
1421 | 169 | ;; | ||
1422 | 170 | esac | ||
1423 | 171 | fi | ||
1424 | 172 | echo "Usage: git darcs list [-v|--verbose]" | ||
1425 | 173 | exit 1 | ||
1426 | 174 | } | ||
1427 | 175 | |||
1428 | 176 | # Find the darcs commit(s) supporting a git SHA1 prefix | ||
1429 | 177 | find_darcs() | ||
1430 | 178 | { | ||
1431 | 179 | sha1="$1" | ||
1432 | 180 | shift | ||
1433 | 181 | if [ -z "$sha1" -o -n "$*" ] | ||
1434 | 182 | then | ||
1435 | 183 | echo "Usage: git darcs find-darcs <sha1-prefix>" | ||
1436 | 184 | exit 1 | ||
1437 | 185 | fi | ||
1438 | 186 | for remote in $git_dir/darcs/* | ||
1439 | 187 | do | ||
1440 | 188 | remote=`basename $remote` | ||
1441 | 189 | git_map=$git_dir/darcs-git/$remote-git-map | ||
1442 | 190 | darcs_map=$git_dir/darcs-git/$remote-darcs-map | ||
1443 | 191 | if [ ! -f $git_map -o ! -f $darcs_map ] | ||
1444 | 192 | then | ||
1445 | 193 | echo "Missing mappings for remote $remote" | ||
1446 | 194 | exit 1 | ||
1447 | 195 | fi | ||
1448 | 196 | for row in `sed -n -e "/:.* $sha1.*/ s/[^ ]*/&/p" $git_map` | ||
1449 | 197 | do | ||
1450 | 198 | sed -n -e "/$row / {s/[^ ]*//; s/.*/$remote\t&/p}" $darcs_map | ||
1451 | 199 | done | ||
1452 | 200 | done | ||
1453 | 201 | } | ||
1454 | 202 | |||
1455 | 203 | # Find the git commit(s) supporting a darcs patch prefix | ||
1456 | 204 | find_git() | ||
1457 | 205 | { | ||
1458 | 206 | patch="$1" | ||
1459 | 207 | shift | ||
1460 | 208 | if [ -z "$patch" -o -n "$*" ] | ||
1461 | 209 | then | ||
1462 | 210 | echo "Usage: git darcs find-git <patch-prefix>" | ||
1463 | 211 | exit 1 | ||
1464 | 212 | fi | ||
1465 | 213 | for remote in $git_dir/darcs/* | ||
1466 | 214 | do | ||
1467 | 215 | remote=`basename $remote` | ||
1468 | 216 | git_map=$git_dir/darcs-git/$remote-git-map | ||
1469 | 217 | darcs_map=$git_dir/darcs-git/$remote-darcs-map | ||
1470 | 218 | if [ ! -f $git_map -o ! -f $darcs_map ] | ||
1471 | 219 | then | ||
1472 | 220 | echo "Missing mappings for remote $remote" | ||
1473 | 221 | exit 1 | ||
1474 | 222 | fi | ||
1475 | 223 | for row in `sed -n -e "/:.* $patch.*/ s/[^ ]*/&/p" $darcs_map` | ||
1476 | 224 | do | ||
1477 | 225 | sed -n -e "/$row / {s/[^ ]* \(.*\)/$remote\t\1/p}" $git_map | ||
1478 | 226 | done | ||
1479 | 227 | done | ||
1480 | 228 | } | ||
1481 | 229 | |||
1482 | 230 | git rev-parse 2> /dev/null | ||
1483 | 231 | if [ $? != 0 ]; then | ||
1484 | 232 | echo "Must be inside a git repository to work" | ||
1485 | 233 | exit | ||
1486 | 234 | fi | ||
1487 | 235 | |||
1488 | 236 | git_dir=$(git rev-parse --git-dir) | ||
1489 | 237 | # make it absolute | ||
1490 | 238 | cd $git_dir | ||
1491 | 239 | git_dir=$(pwd) | ||
1492 | 240 | cd - >/dev/null | ||
1493 | 241 | command="$1" | ||
1494 | 242 | shift | ||
1495 | 243 | |||
1496 | 244 | case $command in | ||
1497 | 245 | add|push|fetch|pull|list) | ||
1498 | 246 | ;; | ||
1499 | 247 | find-darcs) | ||
1500 | 248 | command=find_darcs | ||
1501 | 249 | ;; | ||
1502 | 250 | find-git) | ||
1503 | 251 | command=find_git | ||
1504 | 252 | ;; | ||
1505 | 253 | *) | ||
1506 | 254 | echo "Usage: git darcs [COMMAND] [OPTIONS]" | ||
1507 | 255 | echo "Commands: add, push, fetch, pull, list, find-darcs, find-git" | ||
1508 | 256 | exit | ||
1509 | 257 | ;; | ||
1510 | 258 | esac | ||
1511 | 259 | |||
1512 | 260 | |||
1513 | 261 | up=$(git rev-parse --show-cdup) | ||
1514 | 262 | [ -z "$up" ] && up="." | ||
1515 | 263 | cd $up | ||
1516 | 264 | $command "$@" | ||
1517 | 0 | 265 | ||
1518 | === added file 'exporters/darcs/git-darcs.txt' | |||
1519 | --- exporters/darcs/git-darcs.txt 1970-01-01 00:00:00 +0000 | |||
1520 | +++ exporters/darcs/git-darcs.txt 2009-06-28 22:31:05 +0000 | |||
1521 | @@ -0,0 +1,72 @@ | |||
1522 | 1 | = git-darcs(1) | ||
1523 | 2 | |||
1524 | 3 | == NAME | ||
1525 | 4 | |||
1526 | 5 | git-darcs - a bidirectional git - darcs gateway | ||
1527 | 6 | |||
1528 | 7 | == SYNOPSIS | ||
1529 | 8 | |||
1530 | 9 | git-darcs <command> <options> | ||
1531 | 10 | |||
1532 | 11 | == DESCRIPTION | ||
1533 | 12 | |||
1534 | 13 | git darcs can convert a darcs repo to a git one, can update such an | ||
1535 | 14 | existing git repo later, and finally can push back your changes from the | ||
1536 | 15 | git repo to the darcs one. | ||
1537 | 16 | |||
1538 | 17 | A typical workflow is: | ||
1539 | 18 | |||
1540 | 19 | ---- | ||
1541 | 20 | $ mkdir git-repo | ||
1542 | 21 | $ cd git-repo | ||
1543 | 22 | $ git init | ||
1544 | 23 | $ git darcs add upstream ../darcs-repo | ||
1545 | 24 | $ git darcs pull upstream | ||
1546 | 25 | |||
1547 | 26 | ... hack, hack, hack ... | ||
1548 | 27 | |||
1549 | 28 | $ git darcs push upstream | ||
1550 | 29 | ---- | ||
1551 | 30 | |||
1552 | 31 | == GLOBAL OPTIONS | ||
1553 | 32 | |||
1554 | 33 | -h, --help:: | ||
1555 | 34 | Display usage. | ||
1556 | 35 | |||
1557 | 36 | == COMMANDS | ||
1558 | 37 | |||
1559 | 38 | The supported commands are the followings: | ||
1560 | 39 | |||
1561 | 40 | add:: | ||
1562 | 41 | This can register a new darcs repo in the git one, so that you | ||
1563 | 42 | can fetch from it. The syntax is `add nick path [dfe-options]`. | ||
1564 | 43 | Add any options you want to be passed to darcs-fast-export, | ||
1565 | 44 | like --encoding=utf-8, or --authors-file AUTHORMAP. Remember | ||
1566 | 45 | that if AUTHORMAP is not absolute, it will be interpreted | ||
1567 | 46 | relative to the git repository's root directory. | ||
1568 | 47 | |||
1569 | 48 | push:: | ||
1570 | 49 | Transfers your changes created in the current branch back the | ||
1571 | 50 | darcs one. The syntax is `push nick`. | ||
1572 | 51 | |||
1573 | 52 | fetch:: | ||
1574 | 53 | Downloads changes from the darcs repo and updates the | ||
1575 | 54 | `darcs/<nick>` branch. None of your local branches are updated. | ||
1576 | 55 | |||
1577 | 56 | pull:: | ||
1578 | 57 | Calls `fetch` then `git merge` or `git rebase` based on the | ||
1579 | 58 | `branch.<branchname>.rebase` configuration setting, where `<branchname>` | ||
1580 | 59 | is the current branch. The default is - just like with `git pull` - is | ||
1581 | 60 | to `git merge`. | ||
1582 | 61 | |||
1583 | 62 | list:: | ||
1584 | 63 | List the name [and location] of each registered darcs repo. | ||
1585 | 64 | The syntax is `list [-v|--verbose]`. | ||
1586 | 65 | |||
1587 | 66 | find-darcs:: | ||
1588 | 67 | Searches for darcs patches matching a SHA1 prefix. | ||
1589 | 68 | The syntax is `find-darcs <sha1-prefix>`. | ||
1590 | 69 | |||
1591 | 70 | find-git:: | ||
1592 | 71 | Searches for git commits matching a darcs patch prefix. | ||
1593 | 72 | The syntax is `find-git <patch-prefix>`. | ||
1594 | 0 | 73 | ||
1595 | === added directory 'exporters/darcs/t' | |||
1596 | === added file 'exporters/darcs/t/Makefile' | |||
1597 | --- exporters/darcs/t/Makefile 1970-01-01 00:00:00 +0000 | |||
1598 | +++ exporters/darcs/t/Makefile 2008-11-11 00:38:24 +0000 | |||
1599 | @@ -0,0 +1,9 @@ | |||
1600 | 1 | T = $(wildcard test*.sh) | ||
1601 | 2 | |||
1602 | 3 | all: $(T) | ||
1603 | 4 | @echo "passed $$(echo $(T)|wc -w) tests." | ||
1604 | 5 | |||
1605 | 6 | $(T): | ||
1606 | 7 | @echo "*** $@ ***"; sh $@ | ||
1607 | 8 | |||
1608 | 9 | .PHONY: $(T) | ||
1609 | 0 | 10 | ||
1610 | === added directory 'exporters/darcs/t/bench-results' | |||
1611 | === added file 'exporters/darcs/t/bench-results/Makefile' | |||
1612 | --- exporters/darcs/t/bench-results/Makefile 1970-01-01 00:00:00 +0000 | |||
1613 | +++ exporters/darcs/t/bench-results/Makefile 2008-12-26 00:36:08 +0000 | |||
1614 | @@ -0,0 +1,5 @@ | |||
1615 | 1 | bench-results.png: bench-results.gnu bench-results.dat | ||
1616 | 2 | gnuplot bench-results.gnu | ||
1617 | 3 | |||
1618 | 4 | bench-results.dat: bench-results.py $(wildcard ../darcs-benchmark/big-zoo/*.log) | ||
1619 | 5 | python bench-results.py > bench-results.dat | ||
1620 | 0 | 6 | ||
1621 | === added file 'exporters/darcs/t/bench-results/bench-results.gnu' | |||
1622 | --- exporters/darcs/t/bench-results/bench-results.gnu 1970-01-01 00:00:00 +0000 | |||
1623 | +++ exporters/darcs/t/bench-results/bench-results.gnu 2008-12-26 00:36:08 +0000 | |||
1624 | @@ -0,0 +1,6 @@ | |||
1625 | 1 | set terminal png | ||
1626 | 2 | set output 'bench-results.png' | ||
1627 | 3 | unset key | ||
1628 | 4 | set xlabel "number of patches" | ||
1629 | 5 | set ylabel "elapsed time in hours" | ||
1630 | 6 | plot 'bench-results.dat' with linespoints | ||
1631 | 0 | 7 | ||
1632 | === added file 'exporters/darcs/t/bench-results/bench-results.py' | |||
1633 | --- exporters/darcs/t/bench-results/bench-results.py 1970-01-01 00:00:00 +0000 | |||
1634 | +++ exporters/darcs/t/bench-results/bench-results.py 2008-12-26 00:36:08 +0000 | |||
1635 | @@ -0,0 +1,23 @@ | |||
1636 | 1 | from glob import glob | ||
1637 | 2 | import re | ||
1638 | 3 | |||
1639 | 4 | def cmp_data(a, b): | ||
1640 | 5 | return cmp(a[0], b[0]) | ||
1641 | 6 | |||
1642 | 7 | logs = glob("../darcs-benchmark/big-zoo/*.log") | ||
1643 | 8 | |||
1644 | 9 | data = [] | ||
1645 | 10 | |||
1646 | 11 | for i in logs: | ||
1647 | 12 | sock = open(i) | ||
1648 | 13 | for j in sock.readlines(): | ||
1649 | 14 | if "Num Patches:" in j: | ||
1650 | 15 | patches = int(j.split(": ")[1].strip()) | ||
1651 | 16 | elif j.startswith("real"): | ||
1652 | 17 | l = re.sub("real\t([0-9]+)m([0-9.]+)s\n", r"\1 \2", j).split(" ") | ||
1653 | 18 | secs = int(l[0])*60 + float(l[1]) | ||
1654 | 19 | hours = secs / 3600 | ||
1655 | 20 | data.append([patches, hours]) | ||
1656 | 21 | data.sort(cmp=cmp_data) | ||
1657 | 22 | for i in data: | ||
1658 | 23 | print "%s %s" % (i[0], i[1]) | ||
1659 | 0 | 24 | ||
1660 | === added file 'exporters/darcs/t/bench-tailor.sh' | |||
1661 | --- exporters/darcs/t/bench-tailor.sh 1970-01-01 00:00:00 +0000 | |||
1662 | +++ exporters/darcs/t/bench-tailor.sh 2008-11-29 13:34:30 +0000 | |||
1663 | @@ -0,0 +1,59 @@ | |||
1664 | 1 | #!/bin/sh | ||
1665 | 2 | |||
1666 | 3 | create_config() | ||
1667 | 4 | { | ||
1668 | 5 | cd $1 | ||
1669 | 6 | mypath=$(pwd) | ||
1670 | 7 | cd - >/dev/null | ||
1671 | 8 | myname=$(basename $mypath) | ||
1672 | 9 | |||
1673 | 10 | cat > config << EOF | ||
1674 | 11 | [DEFAULT] | ||
1675 | 12 | encoding-errors-policy = replace | ||
1676 | 13 | |||
1677 | 14 | [$myname] | ||
1678 | 15 | source = darcs:$myname | ||
1679 | 16 | target = git:$myname | ||
1680 | 17 | |||
1681 | 18 | [darcs:$myname] | ||
1682 | 19 | subdir = darcs | ||
1683 | 20 | repository = $mypath | ||
1684 | 21 | |||
1685 | 22 | [git:$myname] | ||
1686 | 23 | subdir = git | ||
1687 | 24 | repository = $mypath.git | ||
1688 | 25 | EOF | ||
1689 | 26 | } | ||
1690 | 27 | |||
1691 | 28 | PATH=$HOME/darcs/tailor:$PATH | ||
1692 | 29 | if [ ! -d darcs-benchmark ]; then | ||
1693 | 30 | darcs get http://code.haskell.org/darcs/darcs-benchmark | ||
1694 | 31 | cd darcs-benchmark | ||
1695 | 32 | else | ||
1696 | 33 | cd darcs-benchmark | ||
1697 | 34 | darcs pull -a | ||
1698 | 35 | fi | ||
1699 | 36 | sh initialise.sh | ||
1700 | 37 | cd big-zoo | ||
1701 | 38 | if [ -n "$1" ]; then | ||
1702 | 39 | targets=$1 | ||
1703 | 40 | else | ||
1704 | 41 | targets=*_play.tar.gz | ||
1705 | 42 | fi | ||
1706 | 43 | for i in $targets | ||
1707 | 44 | do | ||
1708 | 45 | echo "benchmarking $i" | ||
1709 | 46 | rm -rf _playground | ||
1710 | 47 | tar xf $i | ||
1711 | 48 | cd _playground | ||
1712 | 49 | log="../$i.tailor-$(tailor --version).log" | ||
1713 | 50 | create_config sandbox | ||
1714 | 51 | sh -c 'time tailor --configfile config' 2>&1 |tee $log | ||
1715 | 52 | if diff --exclude _darcs --exclude .git -Nur sandbox git >/dev/null; then | ||
1716 | 53 | echo "ok, the result is correct" >> $log | ||
1717 | 54 | else | ||
1718 | 55 | echo "ouch, the result is corrupted" >> $log | ||
1719 | 56 | exit 1 | ||
1720 | 57 | fi | ||
1721 | 58 | cd .. | ||
1722 | 59 | done | ||
1723 | 0 | 60 | ||
1724 | === added file 'exporters/darcs/t/bench.sh' | |||
1725 | --- exporters/darcs/t/bench.sh 1970-01-01 00:00:00 +0000 | |||
1726 | +++ exporters/darcs/t/bench.sh 2008-12-25 23:50:21 +0000 | |||
1727 | @@ -0,0 +1,38 @@ | |||
1728 | 1 | #!/bin/sh | ||
1729 | 2 | |||
1730 | 3 | # this is a test as well, but it would take a lot of time, so don't | ||
1731 | 4 | # prefix it with 'test'. | ||
1732 | 5 | |||
1733 | 6 | . lib.sh | ||
1734 | 7 | |||
1735 | 8 | if [ ! -d darcs-benchmark ]; then | ||
1736 | 9 | darcs get http://code.haskell.org/darcs/darcs-benchmark | ||
1737 | 10 | cd darcs-benchmark | ||
1738 | 11 | else | ||
1739 | 12 | cd darcs-benchmark | ||
1740 | 13 | darcs pull -a | ||
1741 | 14 | fi | ||
1742 | 15 | sh initialise.sh | ||
1743 | 16 | cd big-zoo | ||
1744 | 17 | if [ -n "$1" ]; then | ||
1745 | 18 | targets=$1 | ||
1746 | 19 | else | ||
1747 | 20 | targets=*_play.tar.gz | ||
1748 | 21 | fi | ||
1749 | 22 | for i in $targets | ||
1750 | 23 | do | ||
1751 | 24 | echo "benchmarking $i" | ||
1752 | 25 | rm -rf _playground | ||
1753 | 26 | tar xf $i | ||
1754 | 27 | cd _playground | ||
1755 | 28 | log="../$i.d-f-e-$(git describe).log" | ||
1756 | 29 | sh -c 'time d2x -f git sandbox' 2>&1 |tee $log | ||
1757 | 30 | darcs show repo --repodir sandbox |egrep -v 'Root|Cache|Default' >> $log | ||
1758 | 31 | if diff_git sandbox >/dev/null; then | ||
1759 | 32 | echo "ok, the result is correct" >> $log | ||
1760 | 33 | else | ||
1761 | 34 | echo "ouch, the result is corrupted" >> $log | ||
1762 | 35 | exit 1 | ||
1763 | 36 | fi | ||
1764 | 37 | cd .. | ||
1765 | 38 | done | ||
1766 | 0 | 39 | ||
1767 | === added directory 'exporters/darcs/t/data' | |||
1768 | === added file 'exporters/darcs/t/data/hungarian.gif' | |||
1769 | 1 | Binary files exporters/darcs/t/data/hungarian.gif 1970-01-01 00:00:00 +0000 and exporters/darcs/t/data/hungarian.gif 2008-11-11 00:27:43 +0000 differ | 40 | Binary files exporters/darcs/t/data/hungarian.gif 1970-01-01 00:00:00 +0000 and exporters/darcs/t/data/hungarian.gif 2008-11-11 00:27:43 +0000 differ |
1770 | === added file 'exporters/darcs/t/lib.sh' | |||
1771 | --- exporters/darcs/t/lib.sh 1970-01-01 00:00:00 +0000 | |||
1772 | +++ exporters/darcs/t/lib.sh 2009-06-25 22:21:33 +0000 | |||
1773 | @@ -0,0 +1,303 @@ | |||
1774 | 1 | export DARCS_EMAIL="user@example.com" | ||
1775 | 2 | export GIT_PAGER=cat | ||
1776 | 3 | export PATH="$(pwd)/..:$PATH" | ||
1777 | 4 | pypath="/$(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()[1:]')/" | ||
1778 | 5 | |||
1779 | 6 | _drrec() | ||
1780 | 7 | { | ||
1781 | 8 | darcs rec --ignore-times "$@" | ||
1782 | 9 | } | ||
1783 | 10 | |||
1784 | 11 | _drrec_multiline() | ||
1785 | 12 | { | ||
1786 | 13 | echo -e "`LANG= LC_ALL= date +"%a %b %d %H:%M:%S %Z %Y"` | ||
1787 | 14 | $DARCS_EMAIL | ||
1788 | 15 | $@" | darcs rec --ignore-times -a --pipe . | ||
1789 | 16 | } | ||
1790 | 17 | |||
1791 | 18 | _drrecamend() | ||
1792 | 19 | { | ||
1793 | 20 | echo y |darcs amend-rec --ignore-times -a | ||
1794 | 21 | } | ||
1795 | 22 | |||
1796 | 23 | create_darcs() | ||
1797 | 24 | { | ||
1798 | 25 | rm -rf $1 | ||
1799 | 26 | mkdir -p $1 | ||
1800 | 27 | cd $1 | ||
1801 | 28 | darcs init $2 | ||
1802 | 29 | echo A > file | ||
1803 | 30 | darcs add file | ||
1804 | 31 | _drrec -a -m A | ||
1805 | 32 | cd .. | ||
1806 | 33 | rm -rf $1.tmp | ||
1807 | 34 | darcs get $1 $1.tmp | ||
1808 | 35 | cd $1 | ||
1809 | 36 | echo B > file | ||
1810 | 37 | _drrec -a -m B | ||
1811 | 38 | cd ../$1.tmp | ||
1812 | 39 | echo C > file | ||
1813 | 40 | _drrec -a -m C | ||
1814 | 41 | cd ../$1 | ||
1815 | 42 | darcs pull -a ../$1.tmp | ||
1816 | 43 | echo D > file | ||
1817 | 44 | _drrec_multiline "first line | ||
1818 | 45 | second line | ||
1819 | 46 | third line" | ||
1820 | 47 | darcs tag 1.0 | ||
1821 | 48 | echo e > file | ||
1822 | 49 | _drrec -a -m e | ||
1823 | 50 | echo f > file | ||
1824 | 51 | _drrec --author="éáõû <$DARCS_EMAIL>" -a -m f | ||
1825 | 52 | echo g > file | ||
1826 | 53 | _drrec --author="" -a -m g | ||
1827 | 54 | cp ../data/hungarian.gif . | ||
1828 | 55 | darcs add hungarian.gif | ||
1829 | 56 | _drrec -a -m "add a binary file" | ||
1830 | 57 | rm file | ||
1831 | 58 | echo test > file2 | ||
1832 | 59 | darcs add file2 | ||
1833 | 60 | _drrec -a -m "replace file with file2" | ||
1834 | 61 | touch file3 | ||
1835 | 62 | darcs add file3 | ||
1836 | 63 | _drrec -a -m "add empty file" | ||
1837 | 64 | rm file3 | ||
1838 | 65 | _drrec -a -m "remove file" | ||
1839 | 66 | mkdir dir dir2 | ||
1840 | 67 | darcs add dir | ||
1841 | 68 | darcs add dir2 | ||
1842 | 69 | _drrec -a -m "add empty dirs" | ||
1843 | 70 | darcs mv dir dir-p | ||
1844 | 71 | darcs mv dir2 dir2-p | ||
1845 | 72 | _drrec -a -m "rename empty dirs" | ||
1846 | 73 | echo a > a | ||
1847 | 74 | echo b > b | ||
1848 | 75 | darcs add a b | ||
1849 | 76 | _drrec -a -m "add a b" | ||
1850 | 77 | rm b | ||
1851 | 78 | _drrec -a -m "remove and rename" | ||
1852 | 79 | darcs mv a b | ||
1853 | 80 | _drrecamend | ||
1854 | 81 | cd .. | ||
1855 | 82 | } | ||
1856 | 83 | |||
1857 | 84 | create_bzr() | ||
1858 | 85 | { | ||
1859 | 86 | rm -rf $1 | ||
1860 | 87 | mkdir -p $1 | ||
1861 | 88 | cd $1 | ||
1862 | 89 | bzr init $2 | ||
1863 | 90 | echo A > file | ||
1864 | 91 | bzr add file | ||
1865 | 92 | bzr commit -m A | ||
1866 | 93 | cd .. | ||
1867 | 94 | rm -rf $1.tmp | ||
1868 | 95 | bzr branch $1 $1.tmp | ||
1869 | 96 | cd $1 | ||
1870 | 97 | echo B > file | ||
1871 | 98 | bzr commit -m B | ||
1872 | 99 | cd ../$1.tmp | ||
1873 | 100 | echo C > file | ||
1874 | 101 | bzr commit -m C | ||
1875 | 102 | cd ../$1 | ||
1876 | 103 | bzr merge ../$1.tmp | ||
1877 | 104 | echo D > file | ||
1878 | 105 | bzr resolve file | ||
1879 | 106 | echo "first line | ||
1880 | 107 | second line | ||
1881 | 108 | third line" | bzr commit -F /dev/stdin | ||
1882 | 109 | bzr tag 1.0 | ||
1883 | 110 | echo e > file | ||
1884 | 111 | bzr commit -m e | ||
1885 | 112 | #echo f > file | ||
1886 | 113 | #bzr commit --author="éáõû <$DARCS_EMAIL>" -m f | ||
1887 | 114 | #echo g > file | ||
1888 | 115 | #_drrec --author="" -a -m g | ||
1889 | 116 | cp ../data/hungarian.gif . | ||
1890 | 117 | bzr add hungarian.gif | ||
1891 | 118 | bzr commit -m "add a binary file" | ||
1892 | 119 | rm file | ||
1893 | 120 | echo test > file2 | ||
1894 | 121 | bzr add file2 | ||
1895 | 122 | bzr commit -m "replace file with file2" | ||
1896 | 123 | touch file3 | ||
1897 | 124 | bzr add file3 | ||
1898 | 125 | bzr commit -m "add empty file" | ||
1899 | 126 | rm file3 | ||
1900 | 127 | bzr commit -m "remove file" | ||
1901 | 128 | cd .. | ||
1902 | 129 | } | ||
1903 | 130 | |||
1904 | 131 | create_hg() | ||
1905 | 132 | { | ||
1906 | 133 | rm -rf $1 | ||
1907 | 134 | mkdir -p $1 | ||
1908 | 135 | cd $1 | ||
1909 | 136 | hg init $2 | ||
1910 | 137 | echo A > file | ||
1911 | 138 | hg add file | ||
1912 | 139 | hg commit -m A | ||
1913 | 140 | cd .. | ||
1914 | 141 | rm -rf $1.tmp | ||
1915 | 142 | hg clone $1 $1.tmp | ||
1916 | 143 | cd $1 | ||
1917 | 144 | echo B > file | ||
1918 | 145 | hg commit -m B | ||
1919 | 146 | cd ../$1.tmp | ||
1920 | 147 | echo C > file | ||
1921 | 148 | hg commit -m C | ||
1922 | 149 | cd ../$1 | ||
1923 | 150 | hg pull ../$1.tmp | ||
1924 | 151 | hg merge | ||
1925 | 152 | echo D > file | ||
1926 | 153 | echo "first line | ||
1927 | 154 | second line | ||
1928 | 155 | third line" | hg commit -l /dev/stdin | ||
1929 | 156 | hg tag 1.0 | ||
1930 | 157 | echo e > file | ||
1931 | 158 | hg commit -m e | ||
1932 | 159 | #echo f > file | ||
1933 | 160 | #bzr commit --author="éáõû <$DARCS_EMAIL>" -m f | ||
1934 | 161 | #echo g > file | ||
1935 | 162 | #_drrec --author="" -a -m g | ||
1936 | 163 | cp ../data/hungarian.gif . | ||
1937 | 164 | hg add hungarian.gif | ||
1938 | 165 | hg commit -m "add a binary file" | ||
1939 | 166 | hg rm file | ||
1940 | 167 | echo test > file2 | ||
1941 | 168 | hg add file2 | ||
1942 | 169 | hg commit -m "replace file with file2" | ||
1943 | 170 | touch file3 | ||
1944 | 171 | hg add file3 | ||
1945 | 172 | hg commit -m "add empty file" | ||
1946 | 173 | hg rm file3 | ||
1947 | 174 | hg commit -m "remove file" | ||
1948 | 175 | cd .. | ||
1949 | 176 | } | ||
1950 | 177 | create_git() | ||
1951 | 178 | { | ||
1952 | 179 | rm -rf $1 | ||
1953 | 180 | mkdir -p $1 | ||
1954 | 181 | cd $1 | ||
1955 | 182 | git init $2 | ||
1956 | 183 | echo A > file | ||
1957 | 184 | git add file | ||
1958 | 185 | git commit -a -m A | ||
1959 | 186 | echo B > file | ||
1960 | 187 | git commit -a -m B | ||
1961 | 188 | git checkout -b tmp HEAD~1 | ||
1962 | 189 | echo C > file | ||
1963 | 190 | git commit -a -m C | ||
1964 | 191 | git checkout master | ||
1965 | 192 | git merge tmp | ||
1966 | 193 | echo D > file | ||
1967 | 194 | echo "first line | ||
1968 | 195 | second line | ||
1969 | 196 | third line" | git commit -a -F - | ||
1970 | 197 | git branch -d tmp | ||
1971 | 198 | git tag 1.0 | ||
1972 | 199 | echo e > file | ||
1973 | 200 | git commit -a -m e | ||
1974 | 201 | echo f > file | ||
1975 | 202 | git config i18n.commitencoding ISO-8859-2 | ||
1976 | 203 | git commit --author="éáõû <$DARCS_EMAIL>" -a -m f | ||
1977 | 204 | cp ../data/hungarian.gif . | ||
1978 | 205 | git add hungarian.gif | ||
1979 | 206 | git commit -a -m "add a binary file" | ||
1980 | 207 | rm file | ||
1981 | 208 | echo test > file2 | ||
1982 | 209 | git add file2 | ||
1983 | 210 | git commit -a -m "replace file with file2" | ||
1984 | 211 | touch file3 | ||
1985 | 212 | git add file3 | ||
1986 | 213 | git commit -a -m "add empty file" | ||
1987 | 214 | rm file3 | ||
1988 | 215 | git commit -a -m "remove file" | ||
1989 | 216 | cd .. | ||
1990 | 217 | } | ||
1991 | 218 | |||
1992 | 219 | diff_git() | ||
1993 | 220 | { | ||
1994 | 221 | rm -rf $1.git.nonbare | ||
1995 | 222 | git clone -q $1.git $1.git.nonbare | ||
1996 | 223 | diff --exclude _darcs --exclude .git --exclude '*-darcs-backup*' -Nur $1.git.nonbare $1 | ||
1997 | 224 | return $? | ||
1998 | 225 | } | ||
1999 | 226 | |||
2000 | 227 | diff_importgit() | ||
2001 | 228 | { | ||
2002 | 229 | diff --exclude _darcs --exclude .git --exclude '*-darcs-backup*' -Nur $1 $1.darcs | ||
2003 | 230 | return $? | ||
2004 | 231 | } | ||
2005 | 232 | |||
2006 | 233 | diff_importhg() | ||
2007 | 234 | { | ||
2008 | 235 | diff --exclude _darcs --exclude .hg --exclude '*-darcs-backup*' --exclude 'hg-export.*' \ | ||
2009 | 236 | --exclude '.hgtags' --exclude '*.orig' -Nur $1 $1.darcs | ||
2010 | 237 | return $? | ||
2011 | 238 | } | ||
2012 | 239 | |||
2013 | 240 | diff_importdarcs() | ||
2014 | 241 | { | ||
2015 | 242 | diff --exclude _darcs --exclude '*-darcs-backup*' -Nur $1 $2 | ||
2016 | 243 | return $? | ||
2017 | 244 | } | ||
2018 | 245 | |||
2019 | 246 | diff_importbzr() | ||
2020 | 247 | { | ||
2021 | 248 | diff --exclude _darcs --exclude .bzr --exclude '*-darcs-backup*' -Nur $1 $1.darcs | ||
2022 | 249 | return $? | ||
2023 | 250 | } | ||
2024 | 251 | |||
2025 | 252 | diff_bzr() | ||
2026 | 253 | { | ||
2027 | 254 | cd $1.bzr/trunk | ||
2028 | 255 | bzr update | ||
2029 | 256 | cd - >/dev/null | ||
2030 | 257 | diff --exclude _darcs --exclude .bzr --exclude '*-darcs-backup*' -Nur $1.bzr/trunk $1 | ||
2031 | 258 | return $? | ||
2032 | 259 | } | ||
2033 | 260 | |||
2034 | 261 | diff_hg() | ||
2035 | 262 | { | ||
2036 | 263 | diff --exclude _darcs --exclude .hg --exclude '*-darcs-backup*' -Nur $1.hg $1 | ||
2037 | 264 | return $? | ||
2038 | 265 | } | ||
2039 | 266 | |||
2040 | 267 | die() | ||
2041 | 268 | { | ||
2042 | 269 | echo "fatal: $@" | ||
2043 | 270 | exit 1 | ||
2044 | 271 | } | ||
2045 | 272 | |||
2046 | 273 | upd_file_darcs() | ||
2047 | 274 | { | ||
2048 | 275 | cd $1 | ||
2049 | 276 | echo $3 > $2 | ||
2050 | 277 | _drrec -a -m "updated '$2' to '$3'" | ||
2051 | 278 | cd .. | ||
2052 | 279 | } | ||
2053 | 280 | |||
2054 | 281 | upd_file_git() | ||
2055 | 282 | { | ||
2056 | 283 | cd $1 | ||
2057 | 284 | echo $3 > $2 | ||
2058 | 285 | git commit -a -m "updated '$2' to '$3'" | ||
2059 | 286 | cd .. | ||
2060 | 287 | } | ||
2061 | 288 | |||
2062 | 289 | upd_file_bzr() | ||
2063 | 290 | { | ||
2064 | 291 | cd $1 | ||
2065 | 292 | echo $3 > $2 | ||
2066 | 293 | bzr commit -m "updated '$2' to '$3'" | ||
2067 | 294 | cd .. | ||
2068 | 295 | } | ||
2069 | 296 | |||
2070 | 297 | upd_file_hg() | ||
2071 | 298 | { | ||
2072 | 299 | cd $1 | ||
2073 | 300 | echo $3 > $2 | ||
2074 | 301 | hg commit -m "updated '$2' to '$3'" | ||
2075 | 302 | cd .. | ||
2076 | 303 | } | ||
2077 | 0 | 304 | ||
2078 | === added directory 'exporters/darcs/t/test' | |||
2079 | === added file 'exporters/darcs/t/test-bzr.sh' | |||
2080 | --- exporters/darcs/t/test-bzr.sh 1970-01-01 00:00:00 +0000 | |||
2081 | +++ exporters/darcs/t/test-bzr.sh 2008-11-15 22:35:31 +0000 | |||
2082 | @@ -0,0 +1,16 @@ | |||
2083 | 1 | . lib.sh | ||
2084 | 2 | |||
2085 | 3 | create_darcs test --old-fashioned-inventory | ||
2086 | 4 | |||
2087 | 5 | rm -rf test.darcs test.bzr | ||
2088 | 6 | mkdir test.bzr | ||
2089 | 7 | cd test.bzr | ||
2090 | 8 | bzr init-repo . | ||
2091 | 9 | cd .. | ||
2092 | 10 | if [ "$1" != "--stdout" ]; then | ||
2093 | 11 | darcs-fast-export test |(cd test.bzr; bzr fast-import -) | ||
2094 | 12 | diff_bzr test | ||
2095 | 13 | exit $? | ||
2096 | 14 | else | ||
2097 | 15 | darcs-fast-export test | ||
2098 | 16 | fi | ||
2099 | 0 | 17 | ||
2100 | === added file 'exporters/darcs/t/test-git-d2x.sh' | |||
2101 | --- exporters/darcs/t/test-git-d2x.sh 1970-01-01 00:00:00 +0000 | |||
2102 | +++ exporters/darcs/t/test-git-d2x.sh 2008-11-16 00:57:20 +0000 | |||
2103 | @@ -0,0 +1,19 @@ | |||
2104 | 1 | . lib.sh | ||
2105 | 2 | |||
2106 | 3 | create_darcs test --old-fashioned-inventory | ||
2107 | 4 | |||
2108 | 5 | rm -rf test.git | ||
2109 | 6 | if [ "$1" != "--stdout" ]; then | ||
2110 | 7 | d2x -f git test | ||
2111 | 8 | diff_git test || die "initial conversion differs" | ||
2112 | 9 | upd_file_darcs test file2 upd_contents | ||
2113 | 10 | d2x -f git test | ||
2114 | 11 | diff_git test || die "update differs" | ||
2115 | 12 | upd_file_darcs test hungarian.gif "binary to text" | ||
2116 | 13 | d2x -f git test | ||
2117 | 14 | diff_git test || die "update2 differs" | ||
2118 | 15 | d2x -f git test | ||
2119 | 16 | diff_git test || die "update3 (noop) differs" | ||
2120 | 17 | else | ||
2121 | 18 | darcs-fast-export test | ||
2122 | 19 | fi | ||
2123 | 0 | 20 | ||
2124 | === added file 'exporters/darcs/t/test-git-incremental.sh' | |||
2125 | --- exporters/darcs/t/test-git-incremental.sh 1970-01-01 00:00:00 +0000 | |||
2126 | +++ exporters/darcs/t/test-git-incremental.sh 2008-11-15 22:35:31 +0000 | |||
2127 | @@ -0,0 +1,24 @@ | |||
2128 | 1 | . lib.sh | ||
2129 | 2 | |||
2130 | 3 | create_darcs test --old-fashioned-inventory | ||
2131 | 4 | |||
2132 | 5 | rm -rf test.darcs test.git | ||
2133 | 6 | mkdir test.git | ||
2134 | 7 | cd test.git | ||
2135 | 8 | git --bare init | ||
2136 | 9 | cd .. | ||
2137 | 10 | if [ "$1" != "--stdout" ]; then | ||
2138 | 11 | dmark="$(pwd)/test.dfe-marks" | ||
2139 | 12 | gmark="$(pwd)/test.gfi-marks" | ||
2140 | 13 | rm -f $mark $gmark | ||
2141 | 14 | darcs-fast-export --export-marks=$dmark test |(cd test.git; git fast-import --export-marks=$gmark) | ||
2142 | 15 | diff_git test || die "initial conversion differs" | ||
2143 | 16 | upd_file_darcs test file2 upd_contents | ||
2144 | 17 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark test |(cd test.git; git fast-import --export-marks=$gmark --import-marks=$gmark) | ||
2145 | 18 | diff_git test || die "update differs" | ||
2146 | 19 | upd_file_darcs test hungarian.gif "binary to text" | ||
2147 | 20 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark test |(cd test.git; git fast-import --export-marks=$gmark --import-marks=$gmark) | ||
2148 | 21 | diff_git test || die "update2 differs" | ||
2149 | 22 | else | ||
2150 | 23 | darcs-fast-export test | ||
2151 | 24 | fi | ||
2152 | 0 | 25 | ||
2153 | === added file 'exporters/darcs/t/test-git-progress.sh' | |||
2154 | --- exporters/darcs/t/test-git-progress.sh 1970-01-01 00:00:00 +0000 | |||
2155 | +++ exporters/darcs/t/test-git-progress.sh 2008-11-28 14:43:30 +0000 | |||
2156 | @@ -0,0 +1,18 @@ | |||
2157 | 1 | . lib.sh | ||
2158 | 2 | |||
2159 | 3 | create_darcs test --old-fashioned-inventory | ||
2160 | 4 | |||
2161 | 5 | rm -rf test.darcs test.git | ||
2162 | 6 | mkdir test.git | ||
2163 | 7 | cd test.git | ||
2164 | 8 | git --bare init | ||
2165 | 9 | cd .. | ||
2166 | 10 | if [ "$1" != "--stdout" ]; then | ||
2167 | 11 | darcs-fast-export --progres 2 test |(cd test.git; git fast-import) | ||
2168 | 12 | if [ $? = 0 ]; then | ||
2169 | 13 | diff_git test | ||
2170 | 14 | exit $? | ||
2171 | 15 | fi | ||
2172 | 16 | else | ||
2173 | 17 | darcs-fast-export test | ||
2174 | 18 | fi | ||
2175 | 0 | 19 | ||
2176 | === added file 'exporters/darcs/t/test-git.sh' | |||
2177 | --- exporters/darcs/t/test-git.sh 1970-01-01 00:00:00 +0000 | |||
2178 | +++ exporters/darcs/t/test-git.sh 2008-11-15 22:35:31 +0000 | |||
2179 | @@ -0,0 +1,18 @@ | |||
2180 | 1 | . lib.sh | ||
2181 | 2 | |||
2182 | 3 | create_darcs test --old-fashioned-inventory | ||
2183 | 4 | |||
2184 | 5 | rm -rf test.darcs test.git | ||
2185 | 6 | mkdir test.git | ||
2186 | 7 | cd test.git | ||
2187 | 8 | git --bare init | ||
2188 | 9 | cd .. | ||
2189 | 10 | if [ "$1" != "--stdout" ]; then | ||
2190 | 11 | darcs-fast-export test |(cd test.git; git fast-import) | ||
2191 | 12 | if [ $? = 0 ]; then | ||
2192 | 13 | diff_git test | ||
2193 | 14 | exit $? | ||
2194 | 15 | fi | ||
2195 | 16 | else | ||
2196 | 17 | darcs-fast-export test | ||
2197 | 18 | fi | ||
2198 | 0 | 19 | ||
2199 | === added file 'exporters/darcs/t/test-hg-d2x.sh' | |||
2200 | --- exporters/darcs/t/test-hg-d2x.sh 1970-01-01 00:00:00 +0000 | |||
2201 | +++ exporters/darcs/t/test-hg-d2x.sh 2008-11-15 22:47:45 +0000 | |||
2202 | @@ -0,0 +1,12 @@ | |||
2203 | 1 | . lib.sh | ||
2204 | 2 | |||
2205 | 3 | create_darcs test --old-fashioned-inventory | ||
2206 | 4 | |||
2207 | 5 | rm -rf test.hg | ||
2208 | 6 | if [ "$1" != "--stdout" ]; then | ||
2209 | 7 | d2x -f hg test | ||
2210 | 8 | diff_hg test | ||
2211 | 9 | exit $? | ||
2212 | 10 | else | ||
2213 | 11 | darcs-fast-export test | ||
2214 | 12 | fi | ||
2215 | 0 | 13 | ||
2216 | === added file 'exporters/darcs/t/test-hg.sh' | |||
2217 | --- exporters/darcs/t/test-hg.sh 1970-01-01 00:00:00 +0000 | |||
2218 | +++ exporters/darcs/t/test-hg.sh 2008-11-15 22:35:31 +0000 | |||
2219 | @@ -0,0 +1,16 @@ | |||
2220 | 1 | . lib.sh | ||
2221 | 2 | |||
2222 | 3 | create_darcs test --old-fashioned-inventory | ||
2223 | 4 | |||
2224 | 5 | rm -rf test.darcs test.hg | ||
2225 | 6 | mkdir test.hg | ||
2226 | 7 | cd test.hg | ||
2227 | 8 | hg init | ||
2228 | 9 | cd .. | ||
2229 | 10 | if [ "$1" != "--stdout" ]; then | ||
2230 | 11 | darcs-fast-export test |(cd test.hg; hg fastimport /dev/stdin) | ||
2231 | 12 | diff_hg test | ||
2232 | 13 | exit $? | ||
2233 | 14 | else | ||
2234 | 15 | darcs-fast-export test | ||
2235 | 16 | fi | ||
2236 | 0 | 17 | ||
2237 | === added directory 'exporters/darcs/t/test/_darcs' | |||
2238 | === added directory 'exporters/darcs/t/test/_darcs/patches' | |||
2239 | === added directory 'exporters/darcs/t/test/_darcs/prefs' | |||
2240 | === added directory 'exporters/darcs/t/test/_darcs/pristine' | |||
2241 | === added directory 'exporters/darcs/t/test2' | |||
2242 | === added file 'exporters/darcs/t/test2-bzr-d2x.sh' | |||
2243 | --- exporters/darcs/t/test2-bzr-d2x.sh 1970-01-01 00:00:00 +0000 | |||
2244 | +++ exporters/darcs/t/test2-bzr-d2x.sh 2008-11-16 00:57:20 +0000 | |||
2245 | @@ -0,0 +1,19 @@ | |||
2246 | 1 | . lib.sh | ||
2247 | 2 | |||
2248 | 3 | create_darcs test2 --darcs-2 | ||
2249 | 4 | |||
2250 | 5 | rm -rf test2.bzr | ||
2251 | 6 | if [ "$1" != "--stdout" ]; then | ||
2252 | 7 | d2x -f bzr test2 | ||
2253 | 8 | diff_bzr test2 || die "initial conversion differs" | ||
2254 | 9 | upd_file_darcs test2 file2 upd_contents | ||
2255 | 10 | d2x -f bzr test2 | ||
2256 | 11 | diff_bzr test2 || die "update differs" | ||
2257 | 12 | upd_file_darcs test2 hungarian.gif "binary to text" | ||
2258 | 13 | d2x -f bzr test2 | ||
2259 | 14 | diff_bzr test2 || die "update2 differs" | ||
2260 | 15 | d2x -f bzr test2 | ||
2261 | 16 | diff_bzr test2 || die "update3 (noop) differs" | ||
2262 | 17 | else | ||
2263 | 18 | darcs-fast-export test2 | ||
2264 | 19 | fi | ||
2265 | 0 | 20 | ||
2266 | === added file 'exporters/darcs/t/test2-bzr-incremental.sh' | |||
2267 | --- exporters/darcs/t/test2-bzr-incremental.sh 1970-01-01 00:00:00 +0000 | |||
2268 | +++ exporters/darcs/t/test2-bzr-incremental.sh 2008-11-15 22:35:31 +0000 | |||
2269 | @@ -0,0 +1,21 @@ | |||
2270 | 1 | . lib.sh | ||
2271 | 2 | |||
2272 | 3 | create_darcs test2 --darcs-2 | ||
2273 | 4 | |||
2274 | 5 | rm -rf test2.darcs test2.bzr | ||
2275 | 6 | mkdir test2.bzr | ||
2276 | 7 | cd test2.bzr | ||
2277 | 8 | bzr init-repo . | ||
2278 | 9 | cd .. | ||
2279 | 10 | if [ "$1" != "--stdout" ]; then | ||
2280 | 11 | dmark="$(pwd)/test2.dfe-marks" | ||
2281 | 12 | bmark="$(pwd)/test2.bfi-marks" | ||
2282 | 13 | rm -f $mark $gmark | ||
2283 | 14 | darcs-fast-export --export-marks=$dmark test2 |(cd test2.bzr; bzr fast-import --export-marks=$bmark -) | ||
2284 | 15 | diff_bzr test2 || die "initial conversion differs" | ||
2285 | 16 | upd_file_darcs test2 file2 upd_contents | ||
2286 | 17 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark test2 |(cd test2.bzr; bzr fast-import --export-marks=$bmark --import-marks=$bmark -) | ||
2287 | 18 | diff_bzr test2 || die "update differs" | ||
2288 | 19 | else | ||
2289 | 20 | darcs-fast-export test2 | ||
2290 | 21 | fi | ||
2291 | 0 | 22 | ||
2292 | === added file 'exporters/darcs/t/test2-git-funny-tagname.sh' | |||
2293 | --- exporters/darcs/t/test2-git-funny-tagname.sh 1970-01-01 00:00:00 +0000 | |||
2294 | +++ exporters/darcs/t/test2-git-funny-tagname.sh 2009-01-24 19:09:46 +0000 | |||
2295 | @@ -0,0 +1,25 @@ | |||
2296 | 1 | . lib.sh | ||
2297 | 2 | |||
2298 | 3 | create_darcs test2 --darcs-2 | ||
2299 | 4 | cd test2 | ||
2300 | 5 | darcs tag "this :just (won't work; die)" | ||
2301 | 6 | darcs tag "accent-tag-éáőű" | ||
2302 | 7 | cd .. | ||
2303 | 8 | |||
2304 | 9 | rm -rf test2.darcs test2.git | ||
2305 | 10 | mkdir test2.git | ||
2306 | 11 | cd test2.git | ||
2307 | 12 | git --bare init | ||
2308 | 13 | cd .. | ||
2309 | 14 | if [ "$1" != "--stdout" ]; then | ||
2310 | 15 | darcs-fast-export test2 |(cd test2.git; git fast-import) | ||
2311 | 16 | ret=$? | ||
2312 | 17 | if [ $ret = 0 ]; then | ||
2313 | 18 | diff_git test2 | ||
2314 | 19 | exit $? | ||
2315 | 20 | else | ||
2316 | 21 | exit $ret | ||
2317 | 22 | fi | ||
2318 | 23 | else | ||
2319 | 24 | darcs-fast-export test2 | ||
2320 | 25 | fi | ||
2321 | 0 | 26 | ||
2322 | === added file 'exporters/darcs/t/test2-git-incremental-specworkdir.sh' | |||
2323 | --- exporters/darcs/t/test2-git-incremental-specworkdir.sh 1970-01-01 00:00:00 +0000 | |||
2324 | +++ exporters/darcs/t/test2-git-incremental-specworkdir.sh 2008-11-15 22:35:31 +0000 | |||
2325 | @@ -0,0 +1,22 @@ | |||
2326 | 1 | . lib.sh | ||
2327 | 2 | |||
2328 | 3 | create_darcs test2 --darcs-2 | ||
2329 | 4 | |||
2330 | 5 | rm -rf test2.darcs test2.git | ||
2331 | 6 | mkdir test2.git | ||
2332 | 7 | cd test2.git | ||
2333 | 8 | git --bare init | ||
2334 | 9 | mkdir darcs | ||
2335 | 10 | cd .. | ||
2336 | 11 | if [ "$1" != "--stdout" ]; then | ||
2337 | 12 | dmark="$(pwd)/test2.git/darcs/test2.dfe-marks" | ||
2338 | 13 | gmark="$(pwd)/test2.git/darcs/test2.gfi-marks" | ||
2339 | 14 | rm -f $mark $gmark | ||
2340 | 15 | darcs-fast-export --export-marks=$dmark test2 --working test2.git/darcs/repo |(cd test2.git; git fast-import --export-marks=$gmark) | ||
2341 | 16 | diff_git test2 || die "initial conversion differs" | ||
2342 | 17 | upd_file_darcs test2 file2 upd_contents | ||
2343 | 18 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark test2 --working test2.git/darcs/repo |(cd test2.git; git fast-import --export-marks=$gmark --import-marks=$gmark) | ||
2344 | 19 | diff_git test2 || die "update differs" | ||
2345 | 20 | else | ||
2346 | 21 | darcs-fast-export test2 | ||
2347 | 22 | fi | ||
2348 | 0 | 23 | ||
2349 | === added file 'exporters/darcs/t/test2-git-incremental.sh' | |||
2350 | --- exporters/darcs/t/test2-git-incremental.sh 1970-01-01 00:00:00 +0000 | |||
2351 | +++ exporters/darcs/t/test2-git-incremental.sh 2008-11-15 22:35:31 +0000 | |||
2352 | @@ -0,0 +1,21 @@ | |||
2353 | 1 | . lib.sh | ||
2354 | 2 | |||
2355 | 3 | create_darcs test2 --darcs-2 | ||
2356 | 4 | |||
2357 | 5 | rm -rf test2.darcs test2.git | ||
2358 | 6 | mkdir test2.git | ||
2359 | 7 | cd test2.git | ||
2360 | 8 | git --bare init | ||
2361 | 9 | cd .. | ||
2362 | 10 | if [ "$1" != "--stdout" ]; then | ||
2363 | 11 | dmark="$(pwd)/test2.dfe-marks" | ||
2364 | 12 | gmark="$(pwd)/test2.gfi-marks" | ||
2365 | 13 | rm -f $mark $gmark | ||
2366 | 14 | darcs-fast-export --export-marks=$dmark test2 |(cd test2.git; git fast-import --export-marks=$gmark) | ||
2367 | 15 | diff_git test2 || die "initial conversion differs" | ||
2368 | 16 | upd_file_darcs test2 file2 upd_contents | ||
2369 | 17 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark test2 |(cd test2.git; git fast-import --export-marks=$gmark --import-marks=$gmark) | ||
2370 | 18 | diff_git test2 || die "update differs" | ||
2371 | 19 | else | ||
2372 | 20 | darcs-fast-export test2 | ||
2373 | 21 | fi | ||
2374 | 0 | 22 | ||
2375 | === added file 'exporters/darcs/t/test2-git.sh' | |||
2376 | --- exporters/darcs/t/test2-git.sh 1970-01-01 00:00:00 +0000 | |||
2377 | +++ exporters/darcs/t/test2-git.sh 2008-11-15 22:35:31 +0000 | |||
2378 | @@ -0,0 +1,18 @@ | |||
2379 | 1 | . lib.sh | ||
2380 | 2 | |||
2381 | 3 | create_darcs test2 --darcs-2 | ||
2382 | 4 | |||
2383 | 5 | rm -rf test2.darcs test2.git | ||
2384 | 6 | mkdir test2.git | ||
2385 | 7 | cd test2.git | ||
2386 | 8 | git --bare init | ||
2387 | 9 | cd .. | ||
2388 | 10 | if [ "$1" != "--stdout" ]; then | ||
2389 | 11 | darcs-fast-export test2 |(cd test2.git; git fast-import) | ||
2390 | 12 | if [ $? = 0 ]; then | ||
2391 | 13 | diff_git test2 | ||
2392 | 14 | exit $? | ||
2393 | 15 | fi | ||
2394 | 16 | else | ||
2395 | 17 | darcs-fast-export test2 | ||
2396 | 18 | fi | ||
2397 | 0 | 19 | ||
2398 | === added directory 'exporters/darcs/t/test2/_darcs' | |||
2399 | === added directory 'exporters/darcs/t/test2/_darcs/inventories' | |||
2400 | === added directory 'exporters/darcs/t/test2/_darcs/patches' | |||
2401 | === added directory 'exporters/darcs/t/test2/_darcs/prefs' | |||
2402 | === added directory 'exporters/darcs/t/test2/_darcs/pristine.hashed' | |||
2403 | === added file 'exporters/darcs/t/testimport-bzr-x2d.sh' | |||
2404 | --- exporters/darcs/t/testimport-bzr-x2d.sh 1970-01-01 00:00:00 +0000 | |||
2405 | +++ exporters/darcs/t/testimport-bzr-x2d.sh 2008-11-23 02:50:58 +0000 | |||
2406 | @@ -0,0 +1,15 @@ | |||
2407 | 1 | . lib.sh | ||
2408 | 2 | |||
2409 | 3 | create_bzr test | ||
2410 | 4 | |||
2411 | 5 | rm -rf test.darcs | ||
2412 | 6 | x2d -f bzr test | ||
2413 | 7 | diff_importbzr test || die "initial conversion differs" | ||
2414 | 8 | upd_file_bzr test file2 upd_contents | ||
2415 | 9 | x2d -f bzr test | ||
2416 | 10 | diff_importbzr test || die "update differs" | ||
2417 | 11 | upd_file_bzr test hungarian.gif "binary to text" | ||
2418 | 12 | x2d -f bzr test | ||
2419 | 13 | diff_importbzr test || die "update2 differs" | ||
2420 | 14 | x2d -f bzr test | ||
2421 | 15 | diff_importbzr test || die "update3 (noop) differs" | ||
2422 | 0 | 16 | ||
2423 | === added file 'exporters/darcs/t/testimport-bzr.sh' | |||
2424 | --- exporters/darcs/t/testimport-bzr.sh 1970-01-01 00:00:00 +0000 | |||
2425 | +++ exporters/darcs/t/testimport-bzr.sh 2009-06-25 22:21:33 +0000 | |||
2426 | @@ -0,0 +1,15 @@ | |||
2427 | 1 | . lib.sh | ||
2428 | 2 | |||
2429 | 3 | create_bzr test | ||
2430 | 4 | |||
2431 | 5 | rm -rf test.darcs | ||
2432 | 6 | mkdir test.darcs | ||
2433 | 7 | cd test.darcs | ||
2434 | 8 | darcs init | ||
2435 | 9 | cd .. | ||
2436 | 10 | (cd test; bzr fast-export .) | (cd test.darcs; darcs-fast-import) | ||
2437 | 11 | if [ $? != 0 ]; then | ||
2438 | 12 | exit 1 | ||
2439 | 13 | fi | ||
2440 | 14 | diff_importbzr test | ||
2441 | 15 | exit $? | ||
2442 | 0 | 16 | ||
2443 | === added file 'exporters/darcs/t/testimport-copy.sh' | |||
2444 | --- exporters/darcs/t/testimport-copy.sh 1970-01-01 00:00:00 +0000 | |||
2445 | +++ exporters/darcs/t/testimport-copy.sh 2008-11-22 19:37:26 +0000 | |||
2446 | @@ -0,0 +1,26 @@ | |||
2447 | 1 | . lib.sh | ||
2448 | 2 | |||
2449 | 3 | rm -rf test | ||
2450 | 4 | mkdir test | ||
2451 | 5 | cd test | ||
2452 | 6 | git init | ||
2453 | 7 | echo a > file | ||
2454 | 8 | git add file | ||
2455 | 9 | git commit -m a1 | ||
2456 | 10 | cp file file2 | ||
2457 | 11 | git add file2 | ||
2458 | 12 | git commit -m b | ||
2459 | 13 | cd .. | ||
2460 | 14 | |||
2461 | 15 | rm -rf test.darcs | ||
2462 | 16 | mkdir test.darcs | ||
2463 | 17 | cd test.darcs | ||
2464 | 18 | darcs init | ||
2465 | 19 | cd .. | ||
2466 | 20 | (cd test; git fast-export -C -C HEAD) > out | ||
2467 | 21 | cat out | (cd test.darcs; darcs-fast-import) | ||
2468 | 22 | if [ $? != 0 ]; then | ||
2469 | 23 | exit 1 | ||
2470 | 24 | fi | ||
2471 | 25 | diff_importgit test | ||
2472 | 26 | exit $? | ||
2473 | 0 | 27 | ||
2474 | === added file 'exporters/darcs/t/testimport-darcs.sh' | |||
2475 | --- exporters/darcs/t/testimport-darcs.sh 1970-01-01 00:00:00 +0000 | |||
2476 | +++ exporters/darcs/t/testimport-darcs.sh 2008-11-22 17:44:00 +0000 | |||
2477 | @@ -0,0 +1,17 @@ | |||
2478 | 1 | . lib.sh | ||
2479 | 2 | |||
2480 | 3 | create_darcs test2 --darcs-2 | ||
2481 | 4 | |||
2482 | 5 | rm -rf test2.importdarcs test2.darcs | ||
2483 | 6 | mkdir test2.importdarcs | ||
2484 | 7 | cd test2.importdarcs | ||
2485 | 8 | darcs init | ||
2486 | 9 | cd .. | ||
2487 | 10 | |||
2488 | 11 | darcs-fast-export test2 | (cd test2.importdarcs; darcs-fast-import) | ||
2489 | 12 | |||
2490 | 13 | if [ $? != 0 ]; then | ||
2491 | 14 | exit 1 | ||
2492 | 15 | fi | ||
2493 | 16 | diff_importdarcs test2 test2.importdarcs | ||
2494 | 17 | exit $? | ||
2495 | 0 | 18 | ||
2496 | === added file 'exporters/darcs/t/testimport-deleteall.sh' | |||
2497 | --- exporters/darcs/t/testimport-deleteall.sh 1970-01-01 00:00:00 +0000 | |||
2498 | +++ exporters/darcs/t/testimport-deleteall.sh 2008-11-22 19:19:32 +0000 | |||
2499 | @@ -0,0 +1,31 @@ | |||
2500 | 1 | . lib.sh | ||
2501 | 2 | |||
2502 | 3 | rm -rf test | ||
2503 | 4 | mkdir test | ||
2504 | 5 | cd test | ||
2505 | 6 | git init | ||
2506 | 7 | echo a > file | ||
2507 | 8 | git add file | ||
2508 | 9 | echo A > file2 | ||
2509 | 10 | git add file2 | ||
2510 | 11 | git commit -m a12 | ||
2511 | 12 | git rm file* | ||
2512 | 13 | echo b>file3 | ||
2513 | 14 | git add file3 | ||
2514 | 15 | git commit -m b | ||
2515 | 16 | cd .. | ||
2516 | 17 | |||
2517 | 18 | rm -rf test.darcs | ||
2518 | 19 | mkdir test.darcs | ||
2519 | 20 | cd test.darcs | ||
2520 | 21 | darcs init | ||
2521 | 22 | cd .. | ||
2522 | 23 | (cd test; git fast-export --progress=2 HEAD) > out | ||
2523 | 24 | sed -i '/^D file$/d' out | ||
2524 | 25 | sed -i 's/^D file2$/deleteall/' out | ||
2525 | 26 | cat out | (cd test.darcs; darcs-fast-import) | ||
2526 | 27 | if [ $? != 0 ]; then | ||
2527 | 28 | exit 1 | ||
2528 | 29 | fi | ||
2529 | 30 | diff_importgit test | ||
2530 | 31 | exit $? | ||
2531 | 0 | 32 | ||
2532 | === added file 'exporters/darcs/t/testimport-git-incremental.sh' | |||
2533 | --- exporters/darcs/t/testimport-git-incremental.sh 1970-01-01 00:00:00 +0000 | |||
2534 | +++ exporters/darcs/t/testimport-git-incremental.sh 2008-11-22 22:20:00 +0000 | |||
2535 | @@ -0,0 +1,16 @@ | |||
2536 | 1 | . lib.sh | ||
2537 | 2 | |||
2538 | 3 | create_git test | ||
2539 | 4 | |||
2540 | 5 | rm -rf test.darcs | ||
2541 | 6 | mkdir test.darcs | ||
2542 | 7 | cd test.darcs | ||
2543 | 8 | darcs init | ||
2544 | 9 | cd .. | ||
2545 | 10 | gmark="$(pwd)/test.gfe-marks" | ||
2546 | 11 | dmark="$(pwd)/test.dfi-marks" | ||
2547 | 12 | (cd test; git fast-export --export-marks=$gmark HEAD) | (cd test.darcs; darcs-fast-import --export-marks=$dmark) | ||
2548 | 13 | diff_importgit test || die "initial conversion differs" | ||
2549 | 14 | upd_file_git test file2 upd_contents | ||
2550 | 15 | (cd test; git fast-export --export-marks=$gmark --import-marks=$gmark HEAD) | (cd test.darcs; darcs-fast-import --export-marks=$dmark --import-marks=$dmark) | ||
2551 | 16 | diff_importgit test || die "update differs" | ||
2552 | 0 | 17 | ||
2553 | === added file 'exporters/darcs/t/testimport-git-twoway-gd.sh' | |||
2554 | --- exporters/darcs/t/testimport-git-twoway-gd.sh 1970-01-01 00:00:00 +0000 | |||
2555 | +++ exporters/darcs/t/testimport-git-twoway-gd.sh 2008-11-23 21:00:12 +0000 | |||
2556 | @@ -0,0 +1,34 @@ | |||
2557 | 1 | . lib.sh | ||
2558 | 2 | |||
2559 | 3 | create_darcs test | ||
2560 | 4 | |||
2561 | 5 | rm -rf test.git | ||
2562 | 6 | mkdir test.git | ||
2563 | 7 | cd test.git | ||
2564 | 8 | git init | ||
2565 | 9 | git darcs add upstream ../test | ||
2566 | 10 | git darcs pull upstream | ||
2567 | 11 | cd .. | ||
2568 | 12 | diff_git test || die "initial fetch differs" | ||
2569 | 13 | upd_file_darcs test file2 upd_contents | ||
2570 | 14 | cd test.git | ||
2571 | 15 | git darcs pull upstream | ||
2572 | 16 | cd .. | ||
2573 | 17 | diff_git test || die "fetch #1 differs" | ||
2574 | 18 | upd_file_git test.git file2 upd_contents2 | ||
2575 | 19 | cd test.git | ||
2576 | 20 | git darcs push upstream | ||
2577 | 21 | cd .. | ||
2578 | 22 | diff_git test || die "push #1 difers" | ||
2579 | 23 | upd_file_darcs test file2 upd_contents3 | ||
2580 | 24 | upd_file_darcs test file2 upd_contents32 | ||
2581 | 25 | cd test.git | ||
2582 | 26 | git darcs pull upstream | ||
2583 | 27 | cd .. | ||
2584 | 28 | diff_git test || die "fetch #2 (multiple commits) differs" | ||
2585 | 29 | upd_file_git test.git file2 upd_contents4 | ||
2586 | 30 | upd_file_git test.git file2 upd_contents42 | ||
2587 | 31 | cd test.git | ||
2588 | 32 | git darcs push upstream | ||
2589 | 33 | cd .. | ||
2590 | 34 | diff_git test || die "push #2 (multiple commits) differs" | ||
2591 | 0 | 35 | ||
2592 | === added file 'exporters/darcs/t/testimport-git-twoway.sh' | |||
2593 | --- exporters/darcs/t/testimport-git-twoway.sh 1970-01-01 00:00:00 +0000 | |||
2594 | +++ exporters/darcs/t/testimport-git-twoway.sh 2008-11-27 01:45:46 +0000 | |||
2595 | @@ -0,0 +1,30 @@ | |||
2596 | 1 | . lib.sh | ||
2597 | 2 | |||
2598 | 3 | create_git test | ||
2599 | 4 | |||
2600 | 5 | rm -rf test.darcs | ||
2601 | 6 | mkdir test.darcs | ||
2602 | 7 | cd test.darcs | ||
2603 | 8 | darcs init | ||
2604 | 9 | cd .. | ||
2605 | 10 | gmark="$(pwd)/test.gmarks" | ||
2606 | 11 | dmark="$(pwd)/test.dmarks" | ||
2607 | 12 | |||
2608 | 13 | (cd test; git fast-export --export-marks=$gmark HEAD) | (cd test.darcs; darcs-fast-import --export-marks=$dmark) | ||
2609 | 14 | diff_importgit test || die "initial conversion differs" | ||
2610 | 15 | upd_file_git test file2 upd_contents | ||
2611 | 16 | (cd test; git fast-export --export-marks=$gmark --import-marks=$gmark HEAD) | (cd test.darcs; darcs-fast-import --export-marks=$dmark --import-marks=$dmark) | ||
2612 | 17 | diff_importgit test || die "git -> darcs update #1 differs" | ||
2613 | 18 | upd_file_darcs test.darcs file2 upd_contents2 | ||
2614 | 19 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark --working test/.git/darcs test.darcs | (cd test; git fast-import --export-marks=$gmark --import-marks=$gmark) | ||
2615 | 20 | (cd test; git checkout -f) | ||
2616 | 21 | diff_importgit test || die "darcs -> git update #2 differs" | ||
2617 | 22 | upd_file_git test file2 upd_contents3 | ||
2618 | 23 | upd_file_git test file2 upd_contents32 | ||
2619 | 24 | (cd test; git fast-export --export-marks=$gmark --import-marks=$gmark HEAD) | (cd test.darcs; darcs-fast-import --export-marks=$dmark --import-marks=$dmark) | ||
2620 | 25 | diff_importgit test || die "git -> darcs update #3 differs" | ||
2621 | 26 | upd_file_darcs test.darcs file2 upd_contents4 | ||
2622 | 27 | upd_file_darcs test.darcs file2 upd_contents42 | ||
2623 | 28 | darcs-fast-export --export-marks=$dmark --import-marks=$dmark --working test/.git/darcs test.darcs | (cd test; git fast-import --export-marks=$gmark --import-marks=$gmark) | ||
2624 | 29 | (cd test; git checkout -f) | ||
2625 | 30 | diff_importgit test || die "darcs -> git update #4 differs" | ||
2626 | 0 | 31 | ||
2627 | === added file 'exporters/darcs/t/testimport-git-x2d.sh' | |||
2628 | --- exporters/darcs/t/testimport-git-x2d.sh 1970-01-01 00:00:00 +0000 | |||
2629 | +++ exporters/darcs/t/testimport-git-x2d.sh 2008-11-23 02:42:25 +0000 | |||
2630 | @@ -0,0 +1,15 @@ | |||
2631 | 1 | . lib.sh | ||
2632 | 2 | |||
2633 | 3 | create_git test | ||
2634 | 4 | |||
2635 | 5 | rm -rf test.darcs | ||
2636 | 6 | x2d -f git test | ||
2637 | 7 | diff_importgit test || die "initial conversion differs" | ||
2638 | 8 | upd_file_git test file2 upd_contents | ||
2639 | 9 | x2d -f git test | ||
2640 | 10 | diff_importgit test || die "update differs" | ||
2641 | 11 | upd_file_git test hungarian.gif "binary to text" | ||
2642 | 12 | x2d -f git test | ||
2643 | 13 | diff_importgit test || die "update2 differs" | ||
2644 | 14 | x2d -f git test | ||
2645 | 15 | diff_importgit test || die "update3 (noop) differs" | ||
2646 | 0 | 16 | ||
2647 | === added file 'exporters/darcs/t/testimport-git.sh' | |||
2648 | --- exporters/darcs/t/testimport-git.sh 1970-01-01 00:00:00 +0000 | |||
2649 | +++ exporters/darcs/t/testimport-git.sh 2008-11-22 01:36:29 +0000 | |||
2650 | @@ -0,0 +1,15 @@ | |||
2651 | 1 | . lib.sh | ||
2652 | 2 | |||
2653 | 3 | create_git test | ||
2654 | 4 | |||
2655 | 5 | rm -rf test.darcs | ||
2656 | 6 | mkdir test.darcs | ||
2657 | 7 | cd test.darcs | ||
2658 | 8 | darcs init | ||
2659 | 9 | cd .. | ||
2660 | 10 | (cd test; git fast-export --progress=2 HEAD) | (cd test.darcs; darcs-fast-import) | ||
2661 | 11 | if [ $? != 0 ]; then | ||
2662 | 12 | exit 1 | ||
2663 | 13 | fi | ||
2664 | 14 | diff_importgit test | ||
2665 | 15 | exit $? | ||
2666 | 0 | 16 | ||
2667 | === added file 'exporters/darcs/t/testimport-hg-x2d.sh' | |||
2668 | --- exporters/darcs/t/testimport-hg-x2d.sh 1970-01-01 00:00:00 +0000 | |||
2669 | +++ exporters/darcs/t/testimport-hg-x2d.sh 2008-11-23 02:53:21 +0000 | |||
2670 | @@ -0,0 +1,15 @@ | |||
2671 | 1 | . lib.sh | ||
2672 | 2 | |||
2673 | 3 | create_hg test | ||
2674 | 4 | |||
2675 | 5 | rm -rf test.darcs | ||
2676 | 6 | x2d -f hg test | ||
2677 | 7 | diff_importhg test || die "initial conversion differs" | ||
2678 | 8 | upd_file_hg test file2 upd_contents | ||
2679 | 9 | x2d -f hg test | ||
2680 | 10 | diff_importhg test || die "update differs" | ||
2681 | 11 | upd_file_hg test hungarian.gif "binary to text" | ||
2682 | 12 | x2d -f hg test | ||
2683 | 13 | diff_importhg test || die "update2 differs" | ||
2684 | 14 | x2d -f hg test | ||
2685 | 15 | diff_importhg test || die "update3 (noop) differs" | ||
2686 | 0 | 16 | ||
2687 | === added file 'exporters/darcs/t/testimport-hg.sh' | |||
2688 | --- exporters/darcs/t/testimport-hg.sh 1970-01-01 00:00:00 +0000 | |||
2689 | +++ exporters/darcs/t/testimport-hg.sh 2008-11-23 02:02:24 +0000 | |||
2690 | @@ -0,0 +1,16 @@ | |||
2691 | 1 | . lib.sh | ||
2692 | 2 | |||
2693 | 3 | create_hg test | ||
2694 | 4 | |||
2695 | 5 | rm -rf test.darcs | ||
2696 | 6 | mkdir test.darcs | ||
2697 | 7 | cd test.darcs | ||
2698 | 8 | darcs init | ||
2699 | 9 | cd .. | ||
2700 | 10 | (cd test; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r .) | (cd test.darcs; darcs-fast-import) | ||
2701 | 11 | rm test/{*.orig,hg-export.status} | ||
2702 | 12 | if [ $? != 0 ]; then | ||
2703 | 13 | exit 1 | ||
2704 | 14 | fi | ||
2705 | 15 | diff_importhg test | ||
2706 | 16 | exit $? | ||
2707 | 0 | 17 | ||
2708 | === added file 'exporters/darcs/t/testimport-rename.sh' | |||
2709 | --- exporters/darcs/t/testimport-rename.sh 1970-01-01 00:00:00 +0000 | |||
2710 | +++ exporters/darcs/t/testimport-rename.sh 2008-11-22 19:30:35 +0000 | |||
2711 | @@ -0,0 +1,25 @@ | |||
2712 | 1 | . lib.sh | ||
2713 | 2 | |||
2714 | 3 | rm -rf test | ||
2715 | 4 | mkdir test | ||
2716 | 5 | cd test | ||
2717 | 6 | git init | ||
2718 | 7 | echo a > file | ||
2719 | 8 | git add file | ||
2720 | 9 | git commit -m a1 | ||
2721 | 10 | git mv file file2 | ||
2722 | 11 | git commit -m b | ||
2723 | 12 | cd .. | ||
2724 | 13 | |||
2725 | 14 | rm -rf test.darcs | ||
2726 | 15 | mkdir test.darcs | ||
2727 | 16 | cd test.darcs | ||
2728 | 17 | darcs init | ||
2729 | 18 | cd .. | ||
2730 | 19 | (cd test; git fast-export -M HEAD) > out | ||
2731 | 20 | cat out | (cd test.darcs; darcs-fast-import) | ||
2732 | 21 | if [ $? != 0 ]; then | ||
2733 | 22 | exit 1 | ||
2734 | 23 | fi | ||
2735 | 24 | diff_importgit test | ||
2736 | 25 | exit $? | ||
2737 | 0 | 26 | ||
2738 | === added file 'exporters/darcs/x2d' | |||
2739 | --- exporters/darcs/x2d 1970-01-01 00:00:00 +0000 | |||
2740 | +++ exporters/darcs/x2d 2009-06-25 22:21:33 +0000 | |||
2741 | @@ -0,0 +1,121 @@ | |||
2742 | 1 | #!/bin/sh | ||
2743 | 2 | # | ||
2744 | 3 | # x2d - convert git, bzr or hg repos to darcs using fast-export | ||
2745 | 4 | # | ||
2746 | 5 | # Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org> | ||
2747 | 6 | # | ||
2748 | 7 | # This program is free software; you can redistribute it and/or modify | ||
2749 | 8 | # it under the terms of the GNU General Public License as published by | ||
2750 | 9 | # the Free Software Foundation; either version 2 of the License, or | ||
2751 | 10 | # (at your option) any later version. | ||
2752 | 11 | # | ||
2753 | 12 | # This program is distributed in the hope that it will be useful, | ||
2754 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2755 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2756 | 15 | # GNU General Public License for more details. | ||
2757 | 16 | # | ||
2758 | 17 | # You should have received a copy of the GNU General Public License | ||
2759 | 18 | # along with this program; if not, write to the Free Software | ||
2760 | 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | ||
2761 | 20 | # USA. | ||
2762 | 21 | # | ||
2763 | 22 | |||
2764 | 23 | usage() | ||
2765 | 24 | { | ||
2766 | 25 | echo "Usage: x2d -f format repo" | ||
2767 | 26 | } | ||
2768 | 27 | |||
2769 | 28 | die() | ||
2770 | 29 | { | ||
2771 | 30 | echo "$@" | ||
2772 | 31 | usage | ||
2773 | 32 | exit 1 | ||
2774 | 33 | } | ||
2775 | 34 | |||
2776 | 35 | check_up_to_date() | ||
2777 | 36 | { | ||
2778 | 37 | upstreamnum=$(darcs show repo|grep 'Num Patches'|sed 's/.*: //') | ||
2779 | 38 | if [ "$upstreamnum" = "$(cd $origin; eval $*)" ]; then | ||
2780 | 39 | echo "No remote changes to pull!" | ||
2781 | 40 | exit 0 | ||
2782 | 41 | fi | ||
2783 | 42 | } | ||
2784 | 43 | |||
2785 | 44 | case $1 in | ||
2786 | 45 | -h|--help) | ||
2787 | 46 | usage | ||
2788 | 47 | exit 0 | ||
2789 | 48 | ;; | ||
2790 | 49 | -f) | ||
2791 | 50 | format="$2" | ||
2792 | 51 | shift 2 | ||
2793 | 52 | ;; | ||
2794 | 53 | esac | ||
2795 | 54 | |||
2796 | 55 | [ -n "$format" ] || die "Source format is not given!" | ||
2797 | 56 | |||
2798 | 57 | case $format in | ||
2799 | 58 | git|bzr|hg) | ||
2800 | 59 | ;; | ||
2801 | 60 | *) | ||
2802 | 61 | die "The requested source format is not yet supported!" | ||
2803 | 62 | ;; | ||
2804 | 63 | esac | ||
2805 | 64 | |||
2806 | 65 | origin="$1" | ||
2807 | 66 | shift 1 | ||
2808 | 67 | |||
2809 | 68 | [ -d "$origin" ] || die "Source repo does not exist!" | ||
2810 | 69 | |||
2811 | 70 | # convert to abspath | ||
2812 | 71 | cd $origin | ||
2813 | 72 | origin=$(pwd) | ||
2814 | 73 | |||
2815 | 74 | dmark="$origin.darcs/_darcs/fast-import/dfe-marks" | ||
2816 | 75 | fmark="$origin.darcs/_darcs/fast-import/ffi-marks" | ||
2817 | 76 | |||
2818 | 77 | mkdir -p $origin.darcs | ||
2819 | 78 | cd $origin.darcs | ||
2820 | 79 | |||
2821 | 80 | common_opts="--logfile $origin.darcs/_darcs/fast-import/log" | ||
2822 | 81 | pypath="/$(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()[1:]')/" | ||
2823 | 82 | |||
2824 | 83 | if [ ! -f $dmark ]; then | ||
2825 | 84 | darcs init | ||
2826 | 85 | mkdir -p _darcs/fast-import | ||
2827 | 86 | case $format in | ||
2828 | 87 | git) | ||
2829 | 88 | (cd $origin; git fast-export --export-marks=$fmark HEAD) | \ | ||
2830 | 89 | darcs-fast-import --export-marks=$dmark $common_opts | ||
2831 | 90 | ;; | ||
2832 | 91 | bzr) | ||
2833 | 92 | (cd $origin; bzr fast-export \ | ||
2834 | 93 | --export-marks=$fmark . ) | darcs-fast-import --export-marks=$dmark $common_opts | ||
2835 | 94 | ;; | ||
2836 | 95 | hg) | ||
2837 | 96 | (cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \ | ||
2838 | 97 | darcs-fast-import --export-marks=$dmark $common_opts | ||
2839 | 98 | esac | ||
2840 | 99 | else | ||
2841 | 100 | case $format in | ||
2842 | 101 | git) | ||
2843 | 102 | check_up_to_date "git rev-list HEAD |wc -l" | ||
2844 | 103 | (cd $origin; git fast-export --export-marks=$fmark --import-marks=$fmark HEAD) | \ | ||
2845 | 104 | darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts | ||
2846 | 105 | ;; | ||
2847 | 106 | bzr) | ||
2848 | 107 | # bzr revno is not good here, because at merges | ||
2849 | 108 | # it produces less revision than the number we | ||
2850 | 109 | # have in darcs | ||
2851 | 110 | check_up_to_date "bzr log|grep -c revno:" | ||
2852 | 111 | (cd $origin; bzr fast-export \ | ||
2853 | 112 | --export-marks=$fmark --import-marks=$fmark . ) | \ | ||
2854 | 113 | darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts | ||
2855 | 114 | ;; | ||
2856 | 115 | hg) | ||
2857 | 116 | check_up_to_date 'echo $(($(hg tip --template "{rev}")+1))' | ||
2858 | 117 | (cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \ | ||
2859 | 118 | darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts | ||
2860 | 119 | ;; | ||
2861 | 120 | esac | ||
2862 | 121 | fi | ||
2863 | 0 | 122 | ||
2864 | === added file 'exporters/darcs/x2d.txt' | |||
2865 | --- exporters/darcs/x2d.txt 1970-01-01 00:00:00 +0000 | |||
2866 | +++ exporters/darcs/x2d.txt 2008-11-23 22:26:27 +0000 | |||
2867 | @@ -0,0 +1,26 @@ | |||
2868 | 1 | = x2d(1) | ||
2869 | 2 | |||
2870 | 3 | == NAME | ||
2871 | 4 | |||
2872 | 5 | x2d - convert git, bzr or hg repos to a darcs one using fast-export | ||
2873 | 6 | |||
2874 | 7 | == SYNOPSIS | ||
2875 | 8 | |||
2876 | 9 | x2d -f <format> <otherrepo> | ||
2877 | 10 | |||
2878 | 11 | == DESCRIPTION | ||
2879 | 12 | |||
2880 | 13 | x2d is a wrapper script that just automates doing an initial or | ||
2881 | 14 | continuing an incremental conversion. All it does is initializing the | ||
2882 | 15 | target darcs repo, starting darcs-fast-import and the relevant exporter | ||
2883 | 16 | with the proper switches and pipe the importer's output to the | ||
2884 | 17 | importer's standard input. | ||
2885 | 18 | |||
2886 | 19 | == OPTIONS | ||
2887 | 20 | |||
2888 | 21 | --help:: | ||
2889 | 22 | Display usage. | ||
2890 | 23 | |||
2891 | 24 | -f <format>:: | ||
2892 | 25 | Specify the format of the source repo. Currently supported sources are | ||
2893 | 26 | git, bzr and hg. Incremental conversion is supported for all of them. |