Mercurial > hg > soundsoftware-site
comparison extra/soundsoftware/export-git.sh @ 1543:05d639e5d59b feature_1136
First cut of a git export script
author | Chris Cannam |
---|---|
date | Tue, 12 Jan 2016 15:15:02 +0000 |
parents | |
children | 248c402992ba |
comparison
equal
deleted
inserted
replaced
1542:60acfbd8f6d6 | 1543:05d639e5d59b |
---|---|
1 #!/bin/bash | |
2 | |
3 set -e | |
4 | |
5 progdir=$(dirname $0) | |
6 case "$progdir" in | |
7 /*) ;; | |
8 *) progdir="$(pwd)/$progdir" ;; | |
9 esac | |
10 | |
11 rails_scriptdir="$progdir/../../script" | |
12 rails="$rails_scriptdir/rails" | |
13 | |
14 if [ ! -x "$rails" ]; then | |
15 echo "Expected to find rails executable at $rails" | |
16 exit 2 | |
17 fi | |
18 | |
19 fastexport="$progdir/../fast-export/hg-fast-export.sh" | |
20 if [ ! -x "$fastexport" ]; then | |
21 echo "Expected to find hg-fast-export.sh executable at $fastexport" | |
22 exit 2 | |
23 fi | |
24 | |
25 hgdir="$1" | |
26 gitdir="$2" | |
27 | |
28 if [ -z "$hgdir" ] || [ -z "$gitdir" ]; then | |
29 echo "Usage: $0 <hgdir> <gitdir>" | |
30 echo "where hgdir is the directory containing project Mercurial repositories," | |
31 echo "and gitdir is the directory in which output git repositories are" | |
32 echo "to be created or updated" | |
33 exit 2 | |
34 fi | |
35 | |
36 if [ ! -d "$hgdir" ]; then | |
37 echo "Mercurial repository directory $hgdir not found" | |
38 exit 1 | |
39 fi | |
40 | |
41 if [ ! -d "$gitdir" ]; then | |
42 echo "Target git repository dir $gitdir not found (please create at least the empty directory)" | |
43 exit 1 | |
44 fi | |
45 | |
46 set -u | |
47 | |
48 authordir="$gitdir/AUTHORMAPS" | |
49 | |
50 mkdir -p "$authordir" | |
51 | |
52 "$rails" runner -e production "$progdir/create-repo-authormaps.rb" \ | |
53 -s "$hgdir" -o "$authordir" | |
54 | |
55 for hgrepo in "$hgdir"/*; do | |
56 | |
57 if [ ! -d "$hgrepo/.hg" ]; then | |
58 echo "Directory $hgrepo does not appear to be a Mercurial repo, skipping" | |
59 continue | |
60 fi | |
61 | |
62 reponame=$(basename "$hgrepo") | |
63 authormap="$authordir/authormap_$reponame" | |
64 gitrepo="$gitdir/$reponame" | |
65 | |
66 if [ ! -f "$authormap" ]; then | |
67 echo "Authormap file $authormap not found for repo $hgrepo, skipping: the create-repo-authormaps script already run by this script should have created an authormap file (even if empty) for every repo with a corresponding project" | |
68 continue | |
69 fi | |
70 | |
71 if [ ! -d "$gitrepo" ]; then | |
72 git init "$gitrepo" | |
73 fi | |
74 | |
75 echo "About to run fast export..." | |
76 | |
77 ( | |
78 cd "$gitrepo" | |
79 "$fastexport" -r "$hgrepo" -A "$authormap" | |
80 ) | |
81 | |
82 echo "Fast export done" | |
83 | |
84 done | |
85 | |
86 echo "All done" | |
87 |