Follow upstream changes -- rest
[git-darcs-import.git] / tests / hashed_inventory.sh
blob83e18546fc9c6302ca59cb32b69dc85fc323b5a5
1 #!/usr/bin/env bash
3 set -ev
5 # We'd just use `diff -x _darcs -r' if -x was portable.
6 diffx () {
7 { find $1 -type f; find $2 -type f; } |
8 sed -e '/.*\/_darcs\//d' -e 's;^[^/]*;;' | grep -v darcs.tix | sort | uniq |
10 while read part; do
11 diff -c $1$part $2$part
12 done
16 makepristine () {
17 rm -rf pristine
18 mkdir pristine
19 for i in `darcs show files --no-files --no-pending`; do
20 echo mkdir -p pristine/$i;
21 mkdir -p pristine/$i;
22 done
23 for i in `darcs show files --no-directories --no-pending`; do
24 echo darcs show contents $i ">" pristine/$i;
25 darcs show contents $i > pristine/$i;
26 cat pristine/$i;
27 done
32 rm -rf temp1 temp2 temp3 temp4 temp5
33 mkdir temp1
34 cd temp1
35 darcs init --hashed
36 touch foo
37 darcs add foo
38 darcs rec -m t1 -a -A tester
39 echo 1 >> foo
40 darcs what -s | grep -v No\ changes
41 darcs what -l | grep -v No\ changes
42 darcs what -sl | grep -v No\ changes
43 makepristine
44 cd ..
46 darcs get temp1 temp2
47 cd temp2
48 darcs changes
49 makepristine
50 cd ..
52 darcs get --hashed temp1 temp3
53 cd temp3
54 darcs changes
55 cp _darcs/hashed_inventory inv
56 darcs optimize
57 diff -c inv _darcs/hashed_inventory
58 rm inv
59 makepristine
60 cd ..
61 cat temp3/pristine/foo
63 diffx temp2 temp3
64 diff -rc temp1/pristine temp3/pristine
65 diff -rc temp2/pristine temp3/pristine
67 cd temp1
68 darcs record -a -A tester -m t2
69 darcs push ../temp2 -a
70 darcs push ../temp3 -a
71 makepristine
72 cd ..
74 cd temp3
75 makepristine
76 cd ..
77 cd temp2
78 makepristine
79 cd ..
81 diffx temp2 temp3
82 diff -rc temp1/pristine temp3/pristine
83 diff -rc temp2/pristine temp3/pristine
85 cd temp1
86 date > foo
87 darcs record -a -A tester -m t3
88 makepristine
89 cd ../temp2
90 darcs pull -a
91 makepristine
92 cd ../temp3
93 darcs pull -a
94 darcs check
95 makepristine
96 cd ..
98 diffx temp2 temp3
99 diff -rc temp1/pristine temp3/pristine
100 diff -rc temp2/pristine temp3/pristine
102 cd temp1
103 darcs put --hashed ../temp4
104 cd ..
105 cd temp4
106 makepristine
107 cd ..
109 diffx temp2 temp4
110 diff -rc temp2/pristine temp4/pristine
112 cd temp1
113 darcs tag -A tagger -m atag
114 darcs check
115 darcs optimize
116 darcs check
117 darcs changes | grep t1
118 cd ..
120 cd temp3
121 date > foobarpatch
122 darcs add foobarpatch
123 darcs record -a -A silly -m foobarpatch
124 darcs check
125 darcs optimize
126 darcs check
127 darcs pull -a ../temp1
128 darcs check
129 darcs optimize --reorder-patches
130 darcs check
131 grep 'Starting with inventory' _darcs/hashed_inventory
132 cd ..
134 cd temp1
135 darcs pull -a ../temp3
136 cd ..
138 diff -c temp1/_darcs/hashed_inventory temp3/_darcs/hashed_inventory
140 cd temp4
141 darcs pull -p foobarpatch -a ../temp3
142 darcs pull -a ../temp1
143 darcs optimize --reorder
144 darcs check
145 darcs push ../temp1
146 cd ..
148 diff temp1/_darcs/hashed_inventory temp4/_darcs/hashed_inventory
150 rm -rf temp3
151 darcs get --old-fashioned temp1 temp3
153 rm -rf "$HOME"/.darcs/sources
154 echo cache:"$HOME"/.darcs/cache > "$HOME"/.darcs/sources
155 darcs get --hashed temp3 temp5
156 rm -rf temp5
157 # check that sources directory was created:
158 cd "$HOME"/.darcs/sources && cd -
160 darcs get temp1 temp5 --hashed --old-fashioned
161 cd temp5
162 darcs obliterate --last 3 -a
163 darcs pull ../temp1 -a
164 darcs obliterate --last 3 -a
165 darcs pull ../temp2 -a
166 darcs check
167 darcs obliterate --last 3 -a
168 darcs pull ../temp3 -a
169 darcs obliterate --last 3 -a
170 darcs pull ../temp4 -a
171 cd ..
173 cd temp4
174 darcs obliterate --last 3 -a
175 darcs pull ../temp5 -a
176 cd ..
178 cd temp3
179 darcs obliterate --last 3 -a
180 darcs pull ../temp5 -a
181 cd ..
183 cd temp2
184 darcs obliterate --last 3 -a
185 darcs pull ../temp5 -a
186 cd ..
188 cd temp1
189 darcs obliterate --last 3 -a
190 darcs pull ../temp5 -a
191 cd ..
193 rm -rf temp1 temp2 temp3 temp4 temp5