File: pull_complement.sh

package info (click to toggle)
darcs 2.18.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,960 kB
  • sloc: haskell: 47,748; sh: 13,466; ansic: 447; perl: 134; makefile: 8
file content (145 lines) | stat: -rw-r--r-- 3,736 bytes parent folder | download
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash

## Public domain 2007  Kevin Quick
##
## This file is included as part of the Darcs test distribution,
## which is licensed to you under the following terms:
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation
## files (the "Software"), to deal in the Software without
## restriction, including without limitation the rights to use, copy,
## modify, merge, publish, distribute, sublicense, and/or sell copies
## of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
## BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
## ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.


. ./lib

rm -rf temp1 temp2 temp3 temp4 temp5

mkdir temp1
cd temp1
cat > foo <<EOF
line1
line2
line3
line4
line5
line6
line7
EOF
darcs initialize
darcs add foo
darcs record -a -m addfoo

cd ..
darcs get temp1 temp4

chgrec () {
    set -ev
    sed -e "$1" foo > foo.tmp
    mv foo.tmp foo
    darcs record -a -m "$2"
}

cd temp1
chgrec 's/line2/line2\nline2.1\nline2.2/' inssub2
chgrec 's/line4/Line 4/' Line4

darcs changes | grep ' \*'
echo done with changes on temp1 > /dev/null

cd ..
darcs get temp1 temp2
darcs get temp1 temp3
cd temp1

chgrec 's/line1/line0\nline1/' line0
chgrec 's/Line 4/LINE FOUR/' LINE4
chgrec 's/line7/line7\nLastLine/' LastLine
chgrec 's/LINE FOUR/LINE FOUR\nline4.1/' line4.1

darcs changes | grep ' \*'
echo done with changes on temp1 > /dev/null

cd ../temp3
darcs pull -p LastLine -av
chgrec 's/line1$/FirstLine/' FirstLine

cd ../temp4

darcs changes | grep ' \*'
echo done with changes on temp4 > /dev/null

darcs pull ../temp1 --dry-run | grep ' \*'
darcs pull ../temp1 --dry-run | grep ' \*' > p1.out
cat > p1.req <<EOF
  * inssub2
  * Line4
  * line0
  * LINE4
  * LastLine
  * line4.1
EOF
diff p1.req p1.out

darcs pull ../temp1 --dry-run --complement | grep ' \*' > p2.out
diff p1.out p2.out

darcs pull --dry-run --complement ../temp1 ../temp2 | grep ' \*' > p3.out
cat > p3.req <<EOF
  * line0
  * LastLine
EOF
diff p3.req p3.out

darcs pull --dry-run --complement ../temp1 ../temp3 | grep ' \*' > p4.out
cat > p4.req <<EOF
  * line0
EOF
diff p3.req p3.out

darcs pull --dry-run --complement ../temp1 ../temp2 ../temp3 | grep ' \*' > p5.out
diff p4.out p5.out

darcs pull --dry-run --complement ../temp1 ../temp2 ../temp3 ../temp2 ../temp2 ../temp3 ../temp3 ../temp2 | grep ' \*' > p6.out
diff p4.out p6.out

darcs pull --dry-run --complement ../temp3 ../temp2 | grep ' \*' > p7.out
cat > p7.req <<EOF
  * LastLine
EOF

darcs pull --dry-run --complement ../temp2 ../temp3 > p8.out
grep "No remote patches to pull in!" p8.out

# because duplicates are stripped before performing action,
# this is the same as: darcs pull ../temp1
darcs pull --dry-run --complement ../temp1 ../temp1 > fooout
cat fooout
grep ' \*' fooout > p9.out
diff p1.req p9.out

# so the "null" pull must be tested this way:
darcs get ../temp1 ../temp5
darcs pull --dry-run --complement ../temp1 ../temp5 > p9.out
grep "No remote patches to pull in!" p9.out

darcs pull -av --complement ../temp1 ../temp3
darcs check

cd ..
rm -rf temp1 temp2 temp3 temp4 temp5