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
|
#!/usr/bin/env bash
##
## Copyright (C) 2010 Eric Kow
## Copyright (C) 2012 Owen Stephens
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation
## files (the "Software"), to deal in the Software without
## restriction, including without limitation the rights to use, copy,
## modify, merge, publish, distribute, sublicense, and/or sell copies
## of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
## BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
## ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
. lib # Load some portability helpers.
# issue1427: apply gzipped bundles
rm -rf temp1 temp2
darcs init temp1
darcs init temp2
cd temp1
touch foo bar
darcs record -lam add_foo_bar
darcs mv foo zig
darcs mv bar foo
darcs mv zig bar
darcs record -lam swap_foo_bar
darcs send --output=funpatch --dont-sign -a ../temp2
gzip funpatch
cd ../temp2
darcs apply ../temp1/funpatch.gz
cd ..
cmp temp1/bar temp2/bar
rm -rf temp2
darcs init temp2
cd temp2
darcs apply ../temp1/funpatch.gz
## Also test that "darcs apply" can accept a patch on stdin.
darcs obl -a
darcs apply < ../temp1/funpatch.gz
cd ..
cmp temp1/bar temp2/bar
## issue2017 - apply should gracefully handle tag missing
## from context (complain, not crash)
rm -rf R* S* T*
darcs init R
cd R
echo 'Example content.' > f
darcs record -lam 'Add f'
cd ..
# variant 0 - this passes trivially
darcs clone R R0
darcs clone R0 S0
darcs tag 's' --repo S0
darcs clone S0 T0
cd T0
echo 'More content.' > f
darcs record -lam 'Modify f'
darcs send -o foo.dpatch -a
cd ..
not darcs apply --repo R0 T0/foo.dpatch > log 2>&1
not grep bug log
grep "Cannot find tag" log
# variant 1 - tag in shared context
darcs clone R R1
darcs tag '1' --repo R1
darcs clone R1 S1
darcs tag 's1' --repo S1
darcs clone S1 T1
cd T1
echo 'More content.' > f
darcs record -lam 'Modify f'
darcs send -o foo.dpatch -a
cd ..
# sanity check: should be able to cherry pick
darcs clone R1 R1b
cd R1b
[ `darcs log --count` -eq 2 ]
darcs pull ../T1 --match 'touch f' --all
[ `darcs log --count` -eq 3 ]
cd ..
# the test: can't apply this due to incorrect context
not darcs apply --repo R1 T1/foo.dpatch > log 2>&1
not grep 'bug' log
grep "Cannot find tag" log
# variant 2 - tag created after the fact
darcs clone R R2
darcs clone R2 S2
darcs tag 's2' --repo S2
darcs clone S2 T2
cd T2
echo 'More content.' > f
darcs record -lam 'Modify f'
darcs send -o foo.dpatch -a
cd ..
darcs tag '2' --repo R2 # only tag after
not darcs apply --repo R2 T2/foo.dpatch > log 2>&1
not grep 'bug' log
grep "Cannot find tag" log
# issue1921
# Attempting to apply a patch which depends on a missing tag should not cause
# darcs to die.
rm -rf R* S* T*
darcs init R
cd R
# Setup a repo with a tagged patch, and another patch ontop, so we have a split
# inventory
touch file1
darcs rec -alm 'Add file1'
darcs tag -m 'file1 tag'
touch file2
darcs rec -alm 'Add file2'
# Take a copy of the repo at this point
darcs clone . ../S
# Add the tag which we will fail on
darcs tag -m 'file2 tag'
# Take a copy with the tag
darcs clone . ../T
# Add our patch which will depend only on the last tag.
echo 'file1' > file1
darcs rec -am 'file1 content'
# Create a patch bundle with the new patch (by sending against the repo we
# copied, with the last tag)
darcs send ../T -a -o ../patch.dpatch --no-edit-description
cd ../S
# Try to apply to the patch which depends on the missing tag (we expect darcs
# to fail gracefully here)
not darcs apply ../patch.dpatch &> apply_output.txt
# A best-attempt at ensuring darcs warns about the missing tag:
grep "Cannot find tag file2" apply_output.txt
cd ..
rm -rf R S
## issue1873 - apply should complain about the right
## patches if it says some are missing
rm -rf R S
darcs init R
cd R
echo a > a
darcs rec -lam a
echo b > a
darcs rec -lam b
echo x > x
darcs rec -lam x
echo c > a
darcs rec -lam c
echo y > y
darcs rec -lam y
echo d > a
darcs rec -lam d
cd ..
darcs clone R S
darcs unpull -p x -a --repo R
darcs send --no-minimize -p x -a --repo S -o R/x.dpatch
darcs unpull -p y -a --repo R
not darcs apply --repo R R/x.dpatch 2>&1 | tee log
not grep '^ \* d' log # does not complain about an unrelated patch
grep '^ \* y' log # complains about the offending one instead
## Test that apply --skip-conflicts filters the conflicts
## appropriately.
rm -rf R S
darcs init R
cd R
echo 'foo' > foo
echo 'bar' > bar
darcs rec -lam 'Add foo and bar'
darcs clone . ../S
echo 'foo2' > foo
darcs rec -lam 'Change foo (2)'
echo 'bar2' > bar
darcs rec -lam 'Change bar (2)'
cd ../S
echo 'foo3' > foo
darcs rec -lam 'Change foo (3)'
cd ../R
darcs send -a ../S -o ../S/applyme.dpatch
cd ../S
darcs apply --skip-conflicts applyme.dpatch
test `darcs log --count` -eq 3
cd ..
# issue2193 - "darcs apply --test runs the test twice.
rm -rf R S
darcs init R
darcs clone R S
# Create a patch bundle
cd R
echo 'Example content.' >file1
darcs rec -lam patch1
darcs send --dont-edit-description --output=./patch1 -a ../S
# Setup a test that prints a unique string, apply the patch set,
# check that the unique string occurs in the output once.
cd ../S
darcs setpref test 'echo 2a427e65f322be754dce67c829e5f8a3'
darcs apply --test ../R/patch1 > log 2>&1
[ `fgrep -c 2a427e65f322be754dce67c829e5f8a3 log` -eq 1 ]
|