~ubuntu-branches/debian/wheezy/bzr-fastimport/wheezy

« back to all changes in this revision

Viewing changes to exporters/darcs/x2d

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-02-29 13:42:26 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20120229134226-dlt6vlyy36vqqw3k
Tags: 0.13.0-1
* New upstream release.
* Bump standards version to 3.9.3 (no changes).
* Add tests for autopkgtest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
#   x2d - convert git, bzr or hg repos to darcs using fast-export
4
 
#
5
 
#   Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org>
6
 
#
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.
11
 
#
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.
16
 
#
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/>.
19
 
#
20
 
 
21
 
usage()
22
 
{
23
 
        echo "Usage: x2d -f format repo"
24
 
}
25
 
 
26
 
die()
27
 
{
28
 
        echo "$@"
29
 
        usage
30
 
        exit 1
31
 
}
32
 
 
33
 
check_up_to_date()
34
 
{
35
 
        upstreamnum=$(darcs show repo|grep 'Num Patches'|sed 's/.*: //')
36
 
        if [ "$upstreamnum" = "$(cd $origin; eval $*)" ]; then
37
 
                echo "No remote changes to pull!"
38
 
                exit 0
39
 
        fi
40
 
}
41
 
 
42
 
case $1 in
43
 
        -h|--help)
44
 
                usage
45
 
                exit 0
46
 
                ;;
47
 
        -f)
48
 
                format="$2"
49
 
                shift 2
50
 
                ;;
51
 
esac
52
 
 
53
 
[ -n "$format" ] || die "Source format is not given!"
54
 
 
55
 
case $format in
56
 
        git|bzr|hg)
57
 
                ;;
58
 
        *)
59
 
                die "The requested source format is not yet supported!"
60
 
                ;;
61
 
esac
62
 
 
63
 
common_opts=""
64
 
while [ -n "$2" ]
65
 
do
66
 
        common_opts="$common_opts $1"
67
 
        shift 1
68
 
done
69
 
origin="$1"
70
 
shift 1
71
 
 
72
 
[ -d "$origin" ] || die "Source repo does not exist!"
73
 
 
74
 
# convert to abspath
75
 
cd $origin
76
 
origin=$(pwd)
77
 
 
78
 
dmark="$origin.darcs/_darcs/fast-import/dfe-marks"
79
 
fmark="$origin.darcs/_darcs/fast-import/ffi-marks"
80
 
 
81
 
mkdir -p $origin.darcs
82
 
cd $origin.darcs
83
 
 
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:]')/"
86
 
 
87
 
if [ ! -f $dmark ]; then
88
 
        darcs init
89
 
        mkdir -p _darcs/fast-import
90
 
        case $format in
91
 
                git)
92
 
                        (cd $origin; git fast-export --export-marks=$fmark HEAD) | \
93
 
                                darcs-fast-import --export-marks=$dmark $common_opts
94
 
                        ;;
95
 
                bzr)
96
 
                        (cd $origin; bzr fast-export \
97
 
                                --export-marks=$fmark . ) | darcs-fast-import --export-marks=$dmark $common_opts
98
 
                        ;;
99
 
                hg)
100
 
                        (cd $origin; $pypath/bzrlib/plugins/fastimport/exporters/hg-fast-export.py -r . ) | \
101
 
                                darcs-fast-import --export-marks=$dmark $common_opts
102
 
        esac
103
 
else
104
 
        case $format in
105
 
                git)
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
109
 
                        ;;
110
 
                bzr)
111
 
                        # bzr revno is not good here, because at merges
112
 
                        # it produces less revision than the number we
113
 
                        # have in darcs
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
118
 
                        ;;
119
 
                hg)
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
123
 
                        ;;
124
 
        esac
125
 
fi