/
darcs-rewrite
executable file
·34 lines (31 loc) · 1.08 KB
/
darcs-rewrite
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
#!/bin/bash
#
if [ "$#" -eq "2" ]; then
WHERE=$1
NEW=$(cd $2; pwd)
SEDCOMMAND="s,http://darcs.haskell.org/packages,$NEW/libraries,g; s,http://darcs.haskell.org/hsc2hs,$NEW/utils/hsc2hs,g; s,http://darcs.haskell.org/haddock2,$NEW/utils/haddock,g; s,http://darcs.haskell.org/ghc,$NEW,g; s,http://darcs.haskell.org,$NEW,g"
elif [ "$#" -eq "3" ]; then
WHERE=$1
OLD=$(cd $2; pwd)
NEW=$(cd $3; pwd)
SEDCOMMAND="s,$OLD,$NEW,g"
else
echo "Usage: $0 directory [old-source] new-source"
exit 1
fi
find $WHERE \( -name repos -o -name defaultrepo \) -print0 | xargs -0 sed -i -e "$SEDCOMMAND"
exit $?
# Alternative version:
#
# if [ "$#" -eq "0" ]; then
# echo "Listing current defaultrepo/repos:"
# find . -path '*/_darcs/prefs/defaultrepo' -o -path '*/_darcs/prefs/repos' | xargs cat
# elif [ "$#" -eq "2" ]; then
# for file in $(find . -path '*/_darcs/prefs/defaultrepo' -o -path '*/_darcs/prefs/repos'); do
# echo "Rewriting $file from $1 to $2"
# sed 's/$1/$2/' $file
# done
# else
# echo "Usage: $0 old-prefix new-prefix"
# exit 1
# fi