3
# x2d - convert git, bzr or hg repos to darcs using fast-export
5
# Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org>
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25
echo "Usage: x2d -f format repo"
37
upstreamnum=$(darcs show repo|grep 'Num Patches'|sed 's/.*: //')
38
if [ "$upstreamnum" = "$(cd $origin; eval $*)" ]; then
39
echo "No remote changes to pull!"
55
[ -n "$format" ] || die "Source format is not given!"
61
die "The requested source format is not yet supported!"
68
[ -d "$origin" ] || die "Source repo does not exist!"
74
dmark="$origin.darcs/_darcs/fast-import/dfe-marks"
75
fmark="$origin.darcs/_darcs/fast-import/ffi-marks"
77
mkdir -p $origin.darcs
80
common_opts="--logfile $origin.darcs/_darcs/fast-import/log"
81
pypath="/$(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()[1:]')/"
83
if [ ! -f $dmark ]; then
85
mkdir -p _darcs/fast-import
88
(cd $origin; git fast-export --export-marks=$fmark HEAD) | \
89
darcs-fast-import --export-marks=$dmark $common_opts
92
(cd $origin; bzr fast-export \
93
--export-marks=$fmark . ) | darcs-fast-import --export-marks=$dmark $common_opts
96
(cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \
97
darcs-fast-import --export-marks=$dmark $common_opts
102
check_up_to_date "git rev-list HEAD |wc -l"
103
(cd $origin; git fast-export --export-marks=$fmark --import-marks=$fmark HEAD) | \
104
darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts
107
# bzr revno is not good here, because at merges
108
# it produces less revision than the number we
110
check_up_to_date "bzr log --include-merges |grep -c revno:"
111
(cd $origin; bzr fast-export \
112
--export-marks=$fmark --import-marks=$fmark . ) | \
113
darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts
116
check_up_to_date 'echo $(($(hg tip --template "{rev}")+1))'
117
(cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \
118
darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts