forked from nbp/spidermonkey-dev-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-hg-push.sh
executable file
·42 lines (32 loc) · 943 Bytes
/
git-hg-push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
# This script is made to be used as a post-update hook of the git clone produced
# by hg-git.
error=0
# Remove current bookmarks.
for ref in "$@"; do
bookmark=${ref#refs/heads/}
repo=${bookmark%%/*}
hg bookmark -d $bookmark || true
done
# Import changes into mercurial.
echo "Import changes into mercurial."
hg gimport
for ref in "$@"; do
bookmark=${ref#refs/heads/}
repo=${bookmark%%/*}
force=
test "$repo" = try && force=-f
# Push to the repository named as first member of the branch.
if hg push $force -r $bookmark $repo; then
test "$repo" = try && continue
# Update the bookmark of the main branch of the repository where we pushed.
branch=$repo/master
hg bookmark -f $branch -r $bookmark
# Export the bookmarks update to git.
hg gexport
else
error=$?
echo "Error during push: exit $error"
fi
done
exit $error