-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfossil-uv-export
executable file
·58 lines (48 loc) · 1.28 KB
/
fossil-uv-export
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
_fossil()
{
# Use `unix-none` vfs to avoid locking over NFS
fossil --vfs unix-none "$@"
}
uv_extract()
{
local repo=$1
shift
local data=$(_fossil uv ls -l -R "$repo")
case $data in '' ) return 1 ;; esac
local basename=${repo##*/}
local uvdir=${basename%.fossil}.uv
local stamp=$(echo "$data" | sort -k2,2 | awk 'END { print $2 }')
local dst=$uvdir.$stamp
local err=0
mkdir -p "$dst"
echo "$data" |
{
while read cksum date time size1 size2 file; do
echo $dst/$file
if ! _fossil uv export -R "$repo" "$file" "$dst/$file" ; then
err=1
mv -v "$dst" "$dst.BAD"
break
fi
touch -d "$date $time" "$dst/$file"
if [ "$date $time" '>' "$fdate $ftime" ]; then
fdate=$date
ftime=$time
fi
done
# We have to do this in loop block to keep variable scope
if [ $err -eq 0 ] && [ "$fdate" != 0 ]; then
touch -d "$fdate $ftime" "$dst"
fi
}
}
main()
{
for repo in "$@"; do
echo "** $repo"
uv_extract "$repo"
done
}
main "$@"
# eof