blob: 16b71c84a1c503928afaebb956961736c3f306c3 (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/bin/rc
rfork e
if(! ~ $#* 1){
echo 'usage: patch/apply patch-name' >[1=2]
exit usage
}
if(! test -d /n/sources/patch){
rfork n
9fs sources
}
if(! test -d /n/sources/patch/$1){
echo 'no such patch' /n/sources/patch/$1 >[1=2]
exit nopatch
}
builtin cd /n/sources/patch/$1 || exit nopatch
if(! patch/okay .){
echo 'bad patch: '$status >[1=2]
exit badpatch
}
if(! echo >.tmp || ! rm .tmp){
echo no write permission >[1=2]
exit 'no write permission'
}
echo -n merge... >[1=2]
fn xxx {
if(! test -f $1)
cp $2 $2.new
if not
ape/diff3 -m $1 $2.orig $2 >$2.new
if(grep -s '^<<<<' $2.new){
echo conflicts merging $1';' see `{pwd}^/$2.new >[1=2]
touch failed
}
}
rm -f failed
cat files | sed 's/^/xxx /' | rc
if(test -f failed){
echo exiting without changes >[1=2]
exit failed
}
echo -n backup... >[1=2]
fn xxx {
# echo cp $1 $2.backup
cp $1 $2.backup
}
cat files | sed 's/^/xxx /' |rc
echo -n copy... >[1=2]
fn xxx {
# echo cp $2.new $1
cp $2.new $1 || touch failed
}
cat files | sed 's/^/xxx /' | rc
fn xxx {
# echo cp $2.backup $1
cp $2.backup $1
}
if(test -f failed){
echo copying failed, restoring backups >[1=2]
cat files | sed 's/^/xxx /' | rc
exit failed
}
echo >[1=2]
echo to update sources: >[1=2]
cat files | awk '{print " update " $1 }' >[1=2]
|