Merge branch 'darcs' into master
[git-darcs-import.git] / tests / workingdir.sh
blob4f0b4c8f7e49eaff0688efe682ed57360a4dedf7
1 #!/usr/bin/env bash
2 set -ev
4 not () { "$@" && exit 1 || :; }
6 # test for working dir woes
8 # the setup...
9 rm -rf temp1 temp2
10 mkdir temp1
11 cd temp1
12 darcs init
13 mkdir a
14 echo temp0 > a/x
15 darcs add a
16 darcs add a/x
17 darcs record -am "aa"
18 darcs mv a/x a/y
19 darcs record -am "x to y"
20 echo temp1 > b
21 darcs add b
22 darcs record -am "bb"
23 mkdir d
24 darcs add d
25 darcs record -am "dd"
26 darcs tag 1
27 echo 1-b2 > b
28 darcs record -am "b2"
29 cd ..
31 # try to move a file that we don't have the right to do
32 darcs get temp1 temp2 --to-patch aa
33 cd temp2
34 chmod u-w a
35 darcs pull -a
36 test -e b
37 chmod u+w a
38 cd ..
39 rm -rf temp2
41 # [issue319] try to overwrite file(s) in our working dir
42 darcs get temp1 temp2 --to-patch aa
43 cd temp2
44 echo temp2 > b
45 echo temp2 > d
46 darcs pull -a -t 1
47 grep temp1 b
48 grep temp2 b-darcs-backup0
49 grep temp2 d-darcs-backup0
50 # now make sure we didn't overdo it
51 darcs pull -a
52 grep '1-b2' b
53 test -e b-darcs-backup0
54 test ! -e b-darcs-backup1
55 cd ..
56 rm -rf temp2
58 # [issue298] backup working dir files with conflicts
59 darcs get temp1 temp2 --tag 1
60 cd temp2
61 echo 2-b2 > b
62 darcs pull -a
63 grep "v v v" b
64 grep "2-b2" b-darcs-backup0
65 not grep "v v v" b-darcs-backup0
66 cd ..
67 rm -rf temp2
69 # [issue440] a) try to overwrite a file in our working dir
70 darcs get temp1 temp2 --to-patch a
71 cd temp2
72 echo temp2 > a/y
73 echo old-bak > a/y-darcs-backup0
74 darcs pull -a
75 grep temp0 a/y
76 grep old-bak a/y-darcs-backup0
77 grep temp2 a/y-darcs-backup1
78 cd ..
79 rm -rf temp2
81 # [issue440] b) try to overwrite a directory in our working dir
82 darcs get temp1 temp2 --to-patch a
83 cd temp2
84 mkdir a/y
85 echo old-bak > a/y-darcs-backup0
86 darcs pull -a
87 grep temp0 a/y
88 grep old-bak a/y-darcs-backup0
89 test -d a/y-darcs-backup1
90 cd ..
91 rm -rf temp2
93 rm -rf temp1