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, see <http://www.gnu.org/licenses/>.
23
echo "Usage: x2d -f format repo"
35
upstreamnum=$(darcs show repo|grep 'Num Patches'|sed 's/.*: //')
36
if [ "$upstreamnum" = "$(cd $origin; eval $*)" ]; then
37
echo "No remote changes to pull!"
53
[ -n "$format" ] || die "Source format is not given!"
59
die "The requested source format is not yet supported!"
66
common_opts="$common_opts $1"
72
[ -d "$origin" ] || die "Source repo does not exist!"
78
dmark="$origin.darcs/_darcs/fast-import/dfe-marks"
79
fmark="$origin.darcs/_darcs/fast-import/ffi-marks"
81
mkdir -p $origin.darcs
84
common_opts="$common_opts --logfile $origin.darcs/_darcs/fast-import/log"
85
pypath="/$(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()[1:]')/"
87
if [ ! -f $dmark ]; then
89
mkdir -p _darcs/fast-import
92
(cd $origin; git fast-export --export-marks=$fmark HEAD) | \
93
darcs-fast-import --export-marks=$dmark $common_opts
96
(cd $origin; bzr fast-export \
97
--export-marks=$fmark . ) | darcs-fast-import --export-marks=$dmark $common_opts
100
(cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \
101
darcs-fast-import --export-marks=$dmark $common_opts
106
check_up_to_date "git rev-list HEAD |wc -l"
107
(cd $origin; git fast-export --export-marks=$fmark --import-marks=$fmark HEAD) | \
108
darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts
111
# bzr revno is not good here, because at merges
112
# it produces less revision than the number we
114
check_up_to_date "bzr log --include-merges |grep -c revno:"
115
(cd $origin; bzr fast-export \
116
--export-marks=$fmark --import-marks=$fmark . ) | \
117
darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts
120
check_up_to_date 'echo $(($(hg tip --template "{rev}")+1))'
121
(cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \
122
darcs-fast-import --export-marks=$dmark --import-marks=$dmark $common_opts