Follow upstream changes -- rest
[git-darcs-import.git] / tests / pull.sh
blobded70eb99b3b41437d3962dc20ba3275edde07ca
1 #!/usr/bin/env bash
3 set -ev;
5 ## I would use the builtin !, but that has the wrong semantics.
6 not () { "$@" && exit 1 || :; }
8 # darcs does not support cygwin paths (/cygdrive/c/foo), so if
9 # we want to run the test suite under Cygwin Bash, we must
10 # convert accordingly
11 portable_pwd () {
12 if uname | grep -i cygwin > /dev/null; then
13 cygpath -w `pwd`
14 else
15 pwd
20 rm -rf temp1 temp2
22 mkdir temp1
23 cd temp1
24 darcs init
26 cd ..
27 mkdir temp2
28 cd temp2
29 darcs init
31 mkdir one
32 cd one
33 mkdir two
34 cd two
35 echo darcs pull should work relative to the current directory
36 darcs pull -a ../../../temp1 | grep -i 'No remote changes to pull in'
38 echo -- darcs pull should pull into repo specified with --repo
39 cd ../.. # now in temp2
40 darcs add one;
41 darcs record --patch-name uno --all
42 cd .. # now outside of any repo
43 darcs pull --repodir temp1 --all temp2 | grep -i 'Finished pulling.' # temp2 is not relative to temp1
45 # set up server repo
46 date > temp2/one/date.t
47 darcs add --repodir ./temp2 one/date.t
48 darcs record --repodir ./temp2 -a -m foo
50 # set up client repo for failure
51 if echo $OS | grep -i windows; then
52 echo this test does not work on windows because it
53 echo is not possible to chmod -r
54 elif whoami | grep root; then
55 echo root never gets permission denied
56 else
57 chmod a-rwx ./temp1/one # remove all permissions
58 not darcs pull --repodir ./temp1 -a 2> err
59 chmod u+rwx temp1/one # restore permission
60 cat err
61 grep 'permission denied' err
62 rm -rf temp1/one
65 cd temp1
67 echo Before trying to pull from self, defaultrepo is something else
68 not grep temp1 _darcs/prefs/defaultrepo
70 #return special message when you try to pull from yourself
71 IFS=""
72 DIR=`portable_pwd`
73 not darcs pull --debug -a "$DIR" 2> out
74 cat out
75 grep 'Can.t pull from current repository' out
77 not darcs pull --debug -a . 2> out
78 cat out
79 grep 'Can.t pull from current repository' out
81 # and do not update the default repo to be the current di
82 not grep temp1 _darcs/prefs/defaultrepo
84 rm -f _darcs/prefs/defaultrepo
85 not darcs pull 2> err
86 grep 'please specify one' err
87 echo . > _darcs/prefs/defaultrepo
88 not darcs pull --debug 2> err
89 grep 'Can.t pull from current repository' err
91 not darcs pull --debug ../* 2> out
92 cat out
93 not grep 'Can.t pull from current repository' out
94 cd .. # now outside of any repo
96 cd temp1
97 echo a > foo
98 darcs record -lam AA
99 echo b > foo
100 darcs record -lam BB
101 echo c > foo
102 darcs record -lam CC
103 darcs rollback -p CC -a -m unC
104 cd ..
105 rm -rf temp2
106 darcs get --to-patch B temp1 temp2
107 cd temp2
108 sleep 1 # So that rollback won't have same timestamp as get.
109 darcs rollback -p BB -a -m unB
110 darcs revert -a
111 darcs pull -a ../temp1 2> err2
112 not grep 'Error applying patch' err2
113 cd ..
115 cd temp1
116 echo -n foo > baz
117 darcs add baz
118 darcs record -am newbaz
119 cd ../temp2
120 darcs pull -a | grep Finished
121 echo -n bar > baz
122 darcs record -am bazbar
123 cd ../temp1
124 darcs pull ../temp2 -a
125 echo -n bar > correct_baz
126 diff baz correct_baz
127 cd ..
129 # my $test_name = "when a patch creating a directory is attempted to be applied
130 # while a directory with that name already exists, a warning is raised, but
131 # the pull succeeds.";
132 mkdir temp1/newdir
133 cd temp1
134 darcs add newdir
135 darcs record -am newdir
136 cd ../temp2
137 mkdir newdir
138 darcs pull -a ../temp1 &> out2
139 cat out
140 grep Backing out2
141 grep 'Finished pulling' out2
142 grep newdir out2
143 cd ..
145 rm -rf temp1 temp2
148 # A test for issue662, which triggered:
149 # darcs failed: Error applying hunk to file ./t.t
150 # Error applying patch to the working directory.
152 rm -rf tmp;
153 darcs init --hashed --repodir=tmp
154 touch tmp/t.t
155 cd tmp
156 darcs add t.t
157 echo 'content'>t.t
158 darcs record -am 'initial add' --ignore
159 echo 'content: remote change'>t.t
160 darcs record -am 'remote change' --ignore
161 darcs put tmp2
162 cd tmp2
163 darcs obliterate --last 1 --all;
164 echo 'content: local change'> t.t
165 darcs pull -a ../
166 darcs w -s
167 darcs revert -a
169 cd ../..
170 rm -rf tmp