File: pull.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 (344 lines) | stat: -rw-r--r-- 6,433 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
#!/usr/bin/env bash

. lib

rm -rf temp1 temp2

darcs init temp1
cd temp1

cd ..
darcs init temp2
cd temp2

mkdir one
cd one
mkdir two
cd two
# darcs pull should work relative to the current directory
darcs pull -a ../../../temp1 | grep -i 'No remote patches to pull in'

# darcs pull should pull into repo specified with --repo
cd ../..  # now in temp2
darcs add one;
darcs record --name uno --all
cd ..     # now outside of any repo
darcs pull --set-default --repodir temp1 --all temp2 | grep -i 'Finished pulling.' # temp2 is not relative to temp1

# set up server repo
date > temp2/one/date.t
darcs add --repodir ./temp2 one/date.t
darcs record --repodir ./temp2 -a -m foo

# set up client repo for failure
if ! os_is_windows; then
    chmod a-rwx ./temp1/one # remove all permissions
    # this fails only with --ignore-times because otherwise the index
    # will be used
    not darcs pull --repodir ./temp1 -a --ignore-times 2> err
    chmod u+rwx temp1/one # restore permission
    grep 'permission denied' err
    rm -rf temp1/one
fi

cd temp1

echo Before trying to pull from self, defaultrepo is something else
not grep temp1 _darcs/prefs/defaultrepo

#return special message when you try to pull from yourself
DIR="`pwd`"
not darcs pull --debug -a "$DIR" 2> out
grep 'Can.t pull from current repository' out

not darcs pull --debug -a . 2> out
grep 'Can.t pull from current repository' out

# and do not update the default repo to be the current di
not grep temp1 _darcs/prefs/defaultrepo

rm -f _darcs/prefs/defaultrepo
not darcs pull 2> err
grep 'please specify one' err
echo . > _darcs/prefs/defaultrepo
not darcs pull --debug 2> err
grep 'Can.t pull from current repository' err

not darcs pull --debug ../* 2> out
not grep 'Can.t pull from current repository' out
cd .. # now outside of any repo

cd temp1
echo a > foo
darcs record -lam AA
echo b > foo
darcs record -lam BB
echo c > foo
darcs record -lam CC
darcs rollback -p CC -a
darcs record -am unC
cd ..
rm -rf temp2
darcs get --to-patch B temp1 temp2
cd temp2
darcs rollback -p BB -a
darcs record -am unB
darcs pull -a ../temp1 2> err2
not grep 'Error applying patch' err2
cd ..

cd temp1
echo -n foo > baz
darcs add baz
darcs record  -am newbaz
cd ../temp2
darcs pull -a | grep Finished
echo -n bar > baz
darcs record  -am bazbar
cd ../temp1
darcs pull ../temp2 -a
echo -n bar > correct_baz
diff baz correct_baz
cd ..

#   my $test_name = "when a patch creating a directory is attempted to be applied
#       while a directory with that name already exists, a warning is raised, but
#       the pull succeeds.";
mkdir temp1/newdir
cd temp1
darcs add newdir
darcs record -am newdir
cd ../temp2
mkdir newdir
darcs pull -a --set-default ../temp1 &> out2
grep Backing out2
grep 'Finished pulling' out2
grep newdir out2
cd ..

rm -rf temp1 temp2


# issue662, which triggered:
#  darcs failed:  Error applying hunk to file ./t.t
#  Error applying patch to the working tree.

darcs init temp1
cd temp1

touch t.t
echo 'content'> t.t
darcs record -lam 'initial add'
echo 'content: remote change'> t.t
darcs record -am 'remote change' --ignore
cd ..
darcs clone temp1 temp2
cd temp2
darcs obliterate --last 1 --all
echo 'content: local change'> t.t
# this is now recognized as a conflict with working:
echo y | darcs pull -a ../temp1
darcs w -s
darcs revert -a
cd ..
rm -rf temp1 temp2

# pull with conflicts

darcs initialize temp1
cd temp1
echo foo > bar
darcs record -lam addbar

cd ..
darcs clone temp1 temp2
cd temp1
date > bar
darcs record -a -m datebar
cd ../temp2
echo aack >> bar
darcs record -a -m aackbar
darcs pull -a
darcs check

cd ..
rm -rf temp1 temp2

# pull --union

rm -rf temp1 temp2 temp3

darcs init temp1
cd temp1
echo A > A
darcs record -lam A
echo B > B
darcs record -lam B

cd ..
darcs clone temp1 temp2

cd temp2
darcs obliterate --last 1 -a
echo C > C
darcs record -lam C
cd ..

darcs init temp3
cd temp3
darcs pull -a ../temp1 ../temp2

darcs log > out
grep A out
grep B out
grep C out

cd ..
rm -rf temp1 temp2 temp3

# pull --intersection

darcs init temp1
cd temp1
echo A > A
darcs record -lam Aismyname
echo B > B
darcs record -lam Bismyname

cd ..
darcs clone temp1 temp2
cd temp2
darcs obliterate --last 1 -a
echo C > C
darcs record -lam Cismyname

cd ..
darcs init temp3
cd temp3
darcs pull -a --intersection ../temp1 ../temp2
darcs log > out
grep Aismyname out
not grep Bismyname out
not grep Cismyname out

cd ..
rm -rf temp1 temp2 temp3


# pull --skip-conflicts
rm -rf R S
darcs init R
cd R
echo 'foo' > foo
echo 'bar' > bar
darcs rec -lam 'Add foo and bar'
cd ..

darcs clone R S

cd R
echo 'foo2' > foo
darcs rec -lam 'Change foo (2)'
echo 'bar2' > bar
darcs rec -lam 'Change bar (2)'
cd ..

cd S
echo 'foo3' > foo
darcs rec -lam 'Change foo (3)'
darcs pull --skip-conflicts -a ../R
test `darcs log --count` -eq 3
cd ..

cd S
darcs pull -a ../R
test `darcs log --count` -eq 4
cd ..
rm -rf R S

# bad pending after pull

rm -fr temp1 temp2

darcs init temp1
cd temp1
echo abc > A
echo def > B1
darcs record -lam patch1
darcs mv B1 B2
darcs record -am patch2
cd ..

darcs init temp2
cd temp2
darcs pull -a ../temp1
not darcs whatsnew
cd ..

rm -fr temp1 temp2

# issue494: note that in this test, we deliberately select filenames
# with a backwards sorting order
darcs init temp1
cd temp1
echo abc > b
darcs record -lam patch1
darcs mv b a
echo def > a
darcs record -am patch2
cd ..

darcs init temp2
cd temp2
darcs pull --all ../temp1
not darcs whatsnew
cd ..

rm -fr temp1 temp2

# pull binary

rm -rf temp1 temp2

darcs init temp1
cd temp1
printf "%01048576d" 0 > foo
darcs record -l -a -m xx
rm foo
darcs record -a -m yy
cd ..

darcs init temp2
cd temp2
echo yny | darcs pull --set-default ../temp1
rm foo
# for darcs-1 and darcs-3 this pull conflicts with unrecorded changes
# (which is correct, whereas darcs-2 is buggy)
if test "$format" != "darcs-2"; then
  echo y | darcs pull -a
else
  darcs pull -a
fi
cd ..

rm -rf temp1 temp2

# pull --matches
darcs init temp1
cd temp1
echo first > a
darcs record -lam 'first'
firsthash=`darcs log --xml | grep 'hash=' | sed -e "s/.*hash='//" -e "s/'>//"`
echo second > b
darcs record -lam 'second'
cd ..

darcs init temp2
darcs pull --repodir temp2 -a --match "hash $firsthash" temp1
test $(darcs log --count --repodir temp2) -eq 1

darcs init temp3
darcs pull --repodir temp3 -a --hash $firsthash temp1
test $(darcs log --count --repodir temp3) -eq 1

rm -rf temp1 temp2 temp3