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

Subscribers

People subscribed via source and target branches

to all changes: