update readmes
[git-darcs-import.git] / tests / pull.sh
blob7a70875619eed0b4f737f4c5d76b643708efd2e6
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 rm -rf temp1 temp2
10 mkdir temp1
11 cd temp1
12 darcs init
14 cd ..
15 mkdir temp2
16 cd temp2
17 darcs init
19 mkdir one
20 cd one
21 mkdir two
22 cd two
23 echo darcs pull should work relative to the current directory
24 darcs pull -a ../../../temp1 | grep -i 'No remote changes to pull in'
26 echo -- darcs pull should pull into repo specified with --repo
27 cd ../.. # now in temp2
28 darcs add one;
29 darcs record --patch-name uno --all
30 cd .. # now outside of any repo
31 darcs pull --repodir temp1 --all ../temp2 | grep -i 'Finished pulling.' # temp2 is relative to temp1
33 # set up server repo
34 date > temp2/one/date.t
35 darcs add --repodir ./temp2 one/date.t
36 darcs record --repodir ./temp2 -a -m foo
38 # set up client repo for failure
39 chmod a-rwx ./temp1/one # remove all permissions
40 not darcs pull --repodir ./temp1 -a 2> err
41 chmod u+rwx temp1/one # restore permission
42 cat err
43 rm -rf temp1/one
44 if echo $OS | grep -i windows; then
45 echo this test does not work on windows, so ignore it
46 else
47 if whoami | grep root; then
48 echo root never gets permission denied
49 else
50 grep 'permission denied' err
54 cd temp1
56 echo Before trying to pull from self, defaultrepo is something else
57 not grep temp1 _darcs/prefs/defaultrepo
59 #return special message when you try to pull from yourself
60 DIR=`pwd`
61 not darcs pull -a "$DIR" 2> out
62 cat out
63 grep 'Can.t pull from current repository' out
65 not darcs pull -a . 2> out
66 cat out
67 grep 'Can.t pull from current repository' out
69 # and do not update the default repo to be the current di
70 not grep temp1 _darcs/prefs/defaultrepo
72 rm -f _darcs/prefs/defaultrepo
73 not darcs pull 2> err
74 grep 'please specify one' err
75 echo . > _darcs/prefs/defaultrepo
76 not darcs pull 2> err
77 grep 'Can.t pull from current repository' err
79 not darcs pull ../* 2> out
80 cat out
81 not grep 'Can.t pull from current repository' out
82 cd .. # now outside of any repo
84 cd temp1
85 echo a > foo
86 darcs record -lam AA
87 echo b > foo
88 darcs record -lam BB
89 echo c > foo
90 darcs record -lam CC
91 darcs rollback -p CC -a -m unC
92 cd ..
93 rm -rf temp2
94 darcs get --to-patch B temp1 temp2
95 cd temp2
96 sleep 1 # So that rollback won't have same timestamp as get.
97 darcs rollback -p BB -a -m unB
98 darcs revert -a
99 darcs pull -a ../temp1 2> err
100 not grep 'Error applying patch' err
101 cd ..
103 cd temp1
104 echo -n foo > baz
105 darcs add baz
106 darcs record -am newbaz
107 cd ../temp2
108 darcs pull -a | grep Finished
109 echo -n bar > baz
110 darcs record -am bazbar
111 cd ../temp1
112 darcs pull ../temp2 -a
113 echo -n bar > correct_baz
114 diff baz correct_baz
115 cd ..
117 # my $test_name = "when a patch creating a directory is attempted to be applied
118 # while a directory with that name already exists, a warning is raised, but
119 # the pull succeeds.";
120 mkdir temp1/newdir
121 cd temp1
122 darcs add newdir
123 darcs record -am newdir
124 cd ../temp2
125 mkdir newdir
126 darcs pull -a ../temp1 &> out
127 cat out
128 grep Backing out
129 grep 'Finished pulling' out
130 grep newdir out
131 cd ..
133 rm -rf temp1 temp2
136 # A test for issue662, which triggered:
137 # darcs failed: Error applying hunk to file ./t.t
138 # Error applying patch to the working directory.
140 rm -rf tmp;
141 darcs init --hashed --repodir=tmp
142 touch tmp/t.t
143 cd tmp
144 darcs add t.t
145 echo 'content'>t.t
146 darcs record -am 'initial add' --ignore
147 echo 'content: remote change'>t.t
148 darcs record -am 'remote change' --ignore
149 darcs put tmp2
150 cd tmp2
151 darcs obliterate --last 1 --all;
152 echo 'content: local change'> t.t
153 darcs pull -a ../
154 darcs w -s
155 darcs revert -a
157 rm -rf tmp