##// END OF EJS Templates
strip: improve full backup message
Matt Mackall -
r11200:12e5149c default
parent child Browse files
Show More
@@ -1,154 +1,154 b''
1 1 # repair.py - functions for repository repair for mercurial
2 2 #
3 3 # Copyright 2005, 2006 Chris Mason <mason@suse.com>
4 4 # Copyright 2007 Matt Mackall
5 5 #
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 9 import changegroup
10 10 from node import nullrev, short
11 11 from i18n import _
12 12 import os
13 13
14 14 def _bundle(repo, bases, heads, node, suffix, extranodes=None):
15 15 """create a bundle with the specified revisions as a backup"""
16 16 cg = repo.changegroupsubset(bases, heads, 'strip', extranodes)
17 17 backupdir = repo.join("strip-backup")
18 18 if not os.path.isdir(backupdir):
19 19 os.mkdir(backupdir)
20 20 name = os.path.join(backupdir, "%s-%s" % (short(node), suffix))
21 21 return changegroup.writebundle(cg, name, "HG10BZ")
22 22
23 23 def _collectfiles(repo, striprev):
24 24 """find out the filelogs affected by the strip"""
25 25 files = set()
26 26
27 27 for x in xrange(striprev, len(repo)):
28 28 files.update(repo[x].files())
29 29
30 30 return sorted(files)
31 31
32 32 def _collectextranodes(repo, files, link):
33 33 """return the nodes that have to be saved before the strip"""
34 34 def collectone(revlog):
35 35 extra = []
36 36 startrev = count = len(revlog)
37 37 # find the truncation point of the revlog
38 38 for i in xrange(count):
39 39 lrev = revlog.linkrev(i)
40 40 if lrev >= link:
41 41 startrev = i + 1
42 42 break
43 43
44 44 # see if any revision after that point has a linkrev less than link
45 45 # (we have to manually save these guys)
46 46 for i in xrange(startrev, count):
47 47 node = revlog.node(i)
48 48 lrev = revlog.linkrev(i)
49 49 if lrev < link:
50 50 extra.append((node, cl.node(lrev)))
51 51
52 52 return extra
53 53
54 54 extranodes = {}
55 55 cl = repo.changelog
56 56 extra = collectone(repo.manifest)
57 57 if extra:
58 58 extranodes[1] = extra
59 59 for fname in files:
60 60 f = repo.file(fname)
61 61 extra = collectone(f)
62 62 if extra:
63 63 extranodes[fname] = extra
64 64
65 65 return extranodes
66 66
67 67 def strip(ui, repo, node, backup="all"):
68 68 cl = repo.changelog
69 69 # TODO delete the undo files, and handle undo of merge sets
70 70 striprev = cl.rev(node)
71 71
72 72 # Some revisions with rev > striprev may not be descendants of striprev.
73 73 # We have to find these revisions and put them in a bundle, so that
74 74 # we can restore them after the truncations.
75 75 # To create the bundle we use repo.changegroupsubset which requires
76 76 # the list of heads and bases of the set of interesting revisions.
77 77 # (head = revision in the set that has no descendant in the set;
78 78 # base = revision in the set that has no ancestor in the set)
79 79 tostrip = set((striprev,))
80 80 saveheads = set()
81 81 savebases = []
82 82 for r in xrange(striprev + 1, len(cl)):
83 83 parents = cl.parentrevs(r)
84 84 if parents[0] in tostrip or parents[1] in tostrip:
85 85 # r is a descendant of striprev
86 86 tostrip.add(r)
87 87 # if this is a merge and one of the parents does not descend
88 88 # from striprev, mark that parent as a savehead.
89 89 if parents[1] != nullrev:
90 90 for p in parents:
91 91 if p not in tostrip and p > striprev:
92 92 saveheads.add(p)
93 93 else:
94 94 # if no parents of this revision will be stripped, mark it as
95 95 # a savebase
96 96 if parents[0] < striprev and parents[1] < striprev:
97 97 savebases.append(cl.node(r))
98 98
99 99 saveheads.difference_update(parents)
100 100 saveheads.add(r)
101 101
102 102 saveheads = [cl.node(r) for r in saveheads]
103 103 files = _collectfiles(repo, striprev)
104 104
105 105 extranodes = _collectextranodes(repo, files, striprev)
106 106
107 107 # create a changegroup for all the branches we need to keep
108 108 backupfile = None
109 109 if backup == "all":
110 110 backupfile = _bundle(repo, [node], cl.heads(), node, 'backup')
111 repo.ui.status(_("saving bundle to %s\n") % backupfile)
111 repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
112 112 if saveheads or extranodes:
113 113 chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
114 114 extranodes)
115 115
116 116 mfst = repo.manifest
117 117
118 118 tr = repo.transaction("strip")
119 119 offset = len(tr.entries)
120 120
121 121 try:
122 122 tr.startgroup()
123 123 cl.strip(striprev, tr)
124 124 mfst.strip(striprev, tr)
125 125 for fn in files:
126 126 repo.file(fn).strip(striprev, tr)
127 127 tr.endgroup()
128 128
129 129 try:
130 130 for i in xrange(offset, len(tr.entries)):
131 131 file, troffset, ignore = tr.entries[i]
132 132 repo.sopener(file, 'a').truncate(troffset)
133 133 tr.close()
134 134 except:
135 135 tr.abort()
136 136 raise
137 137
138 138 if saveheads or extranodes:
139 139 ui.status(_("adding branch\n"))
140 140 f = open(chgrpfile, "rb")
141 141 gen = changegroup.readbundle(f, chgrpfile)
142 142 repo.addchangegroup(gen, 'strip', 'bundle:' + chgrpfile, True)
143 143 f.close()
144 144 if backup != "strip":
145 145 os.unlink(chgrpfile)
146 146 except:
147 147 if backupfile:
148 148 ui.warn("strip failed, full bundle stored in '%s'\n" % backupfile)
149 149 elif saveheads:
150 150 ui.warn("strip failed, partial bundle stored in '%s'\n"
151 151 % chgrpfile)
152 152 raise
153 153
154 154 repo.destroyed()
@@ -1,17 +1,17 b''
1 1 #/bin/sh
2 2
3 3 hideport() { sed "s/localhost:$HGPORT/localhost:\$HGPORT/"; }
4 4
5 5 repr() { python -c "import sys; print repr(sys.stdin.read()).replace('\\n', '\n')"; }
6 6
7 7 hidehex() { python -c 'import sys, re; print re.replace("\b[0-9A-Fa-f]{12,40}", "X" * 12)'; }
8 8
9 9 hidetmp() { sed "s/$HGTMP/\$HGTMP/"; }
10 10
11 hidebackup() { sed 's/\(saving bundle to \).*/\1/'; }
11 hidebackup() { sed 's/\(saved backup bundle to \).*/\1/'; }
12 12
13 13 cleanrebase() {
14 14 sed -e 's/\(Rebase status stored to\).*/\1/' \
15 15 -e 's/\(Rebase status restored from\).*/\1/' \
16 -e 's/\(saving bundle to \).*/\1/';
16 -e 's/\(saved backup bundle to \).*/\1/';
17 17 }
@@ -1,44 +1,45 b''
1 1 #!/bin/sh
2 2
3 source $TESTDIR/helpers.sh
3 4 echo "[extensions]" >> $HGRCPATH
4 5 echo "bookmarks=" >> $HGRCPATH
5 6 echo "mq=" >> $HGRCPATH
6 7
7 8 hg init
8 9
9 10 echo qqq>qqq.txt
10 11
11 12 echo % add file
12 13 hg add
13 14
14 15 echo % commit first revision
15 16 hg ci -m 1 -u user -d "1 0"
16 17
17 18 echo % set bookmark
18 19 hg book test
19 20
20 21 echo www>>qqq.txt
21 22
22 23 echo % commit second revision
23 24 hg ci -m 2 -u usr -d "1 0"
24 25
25 26 echo % set bookmark
26 27 hg book test2
27 28
28 29 echo % update to -2
29 30 hg update -r -2
30 31
31 32 echo eee>>qqq.txt
32 33
33 34 echo % commit new head
34 35 hg ci -m 3 -u user -d "1 0"
35 36
36 37 echo % bookmarks updated?
37 38 hg book
38 39
39 40 echo % strip to revision 1
40 hg strip 1 2>&1 | sed 's/\(saving bundle to \).*/\1/'
41 hg strip 1 | hidebackup
41 42
42 43 echo % list bookmarks
43 44 hg book
44 45
@@ -1,23 +1,23 b''
1 1 % add file
2 2 adding qqq.txt
3 3 % commit first revision
4 4 % set bookmark
5 5 % commit second revision
6 6 % set bookmark
7 7 % update to -2
8 8 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
9 9 % commit new head
10 10 created new head
11 11 % bookmarks updated?
12 12 test 1:16b24da7e457
13 13 test2 1:16b24da7e457
14 14 % strip to revision 1
15 saving bundle to
15 saved backup bundle to
16 16 adding branch
17 17 adding changesets
18 18 adding manifests
19 19 adding file changes
20 20 added 1 changesets with 1 changes to 1 files
21 21 % list bookmarks
22 22 * test 1:9f1b7e78eff8
23 23 * test2 1:9f1b7e78eff8
@@ -1,620 +1,622 b''
1 1 #!/bin/sh
2 2
3 source $TESTDIR/helpers.sh
4
3 5 checkundo()
4 6 {
5 7 if [ -f .hg/store/undo ]; then
6 8 echo ".hg/store/undo still exists after $1"
7 9 fi
8 10 }
9 11
10 12 echo "[extensions]" >> $HGRCPATH
11 13 echo "mq=" >> $HGRCPATH
12 14
13 15 echo "[mq]" >> $HGRCPATH
14 16 echo "plain=true" >> $HGRCPATH
15 17
16 18 echo % help
17 19 hg help mq
18 20
19 21 hg init a
20 22 cd a
21 23 echo a > a
22 24 hg ci -Ama
23 25
24 26 hg clone . ../k
25 27
26 28 mkdir b
27 29 echo z > b/z
28 30 hg ci -Ama
29 31
30 32 echo % qinit
31 33
32 34 hg qinit
33 35
34 36 cd ..
35 37 hg init b
36 38
37 39 echo % -R qinit
38 40
39 41 hg -R b qinit
40 42
41 43 hg init c
42 44
43 45 echo % qinit -c
44 46
45 47 hg --cwd c qinit -c
46 48 hg -R c/.hg/patches st
47 49
48 50 echo '% qinit; qinit -c'
49 51 hg init d
50 52 cd d
51 53 hg qinit
52 54 hg qinit -c
53 55 # qinit -c should create both files if they don't exist
54 56 echo ' .hgignore:'
55 57 cat .hg/patches/.hgignore
56 58 echo ' series:'
57 59 cat .hg/patches/series
58 60 hg qinit -c 2>&1 | sed -e 's/repository.*already/repository already/'
59 61 cd ..
60 62
61 63 echo '% qinit; <stuff>; qinit -c'
62 64 hg init e
63 65 cd e
64 66 hg qnew A
65 67 checkundo qnew
66 68 echo foo > foo
67 69 hg add foo
68 70 hg qrefresh
69 71 hg qnew B
70 72 echo >> foo
71 73 hg qrefresh
72 74 echo status >> .hg/patches/.hgignore
73 75 echo bleh >> .hg/patches/.hgignore
74 76 hg qinit -c
75 77 hg -R .hg/patches status
76 78 # qinit -c shouldn't touch these files if they already exist
77 79 echo ' .hgignore:'
78 80 cat .hg/patches/.hgignore
79 81 echo ' series:'
80 82 cat .hg/patches/series
81 83 cd ..
82 84
83 85 echo '% init --mq without repo'
84 86 mkdir f
85 87 cd f
86 88 hg init --mq
87 89 cd ..
88 90
89 91 echo '% init --mq with repo path'
90 92 hg init g
91 93 hg init --mq g
92 94 test -d g/.hg/patches/.hg && echo "ok" || echo "failed"
93 95
94 96 echo '% init --mq with nonexistent directory'
95 97 hg init --mq nonexistentdir
96 98
97 99 echo '% init --mq with bundle (non "local")'
98 100 hg -R a bundle --all a.bundle >/dev/null
99 101 hg init --mq a.bundle
100 102
101 103 cd a
102 104
103 105 hg qnew -m 'foo bar' test.patch
104 106
105 107 echo % qrefresh
106 108
107 109 echo a >> a
108 110 hg qrefresh
109 111 sed -e "s/^\(diff -r \)\([a-f0-9]* \)/\1 x/" \
110 112 -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
111 113 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/test.patch
112 114
113 115 echo % empty qrefresh
114 116
115 117 hg qrefresh -X a
116 118 echo 'revision:'
117 119 hg diff -r -2 -r -1
118 120 echo 'patch:'
119 121 cat .hg/patches/test.patch
120 122 echo 'working dir diff:'
121 123 hg diff --nodates -q
122 124 # restore things
123 125 hg qrefresh
124 126 checkundo qrefresh
125 127
126 128 echo % qpop
127 129
128 130 hg qpop
129 131 checkundo qpop
130 132
131 133 echo % qpush with dump of tag cache
132 134
133 135 # Dump the tag cache to ensure that it has exactly one head after qpush.
134 136 rm -f .hg/tags.cache
135 137 hg tags > /dev/null
136 138 echo ".hg/tags.cache (pre qpush):"
137 139 sed 's/ [0-9a-f]*//' .hg/tags.cache
138 140 hg qpush
139 141 hg tags > /dev/null
140 142 echo ".hg/tags.cache (post qpush):"
141 143 sed 's/ [0-9a-f]*//' .hg/tags.cache
142 144
143 145 checkundo qpush
144 146
145 147 cd ..
146 148
147 149 echo % pop/push outside repo
148 150
149 151 hg -R a qpop
150 152 hg -R a qpush
151 153
152 154 cd a
153 155 hg qnew test2.patch
154 156
155 157 echo % qrefresh in subdir
156 158
157 159 cd b
158 160 echo a > a
159 161 hg add a
160 162 hg qrefresh
161 163
162 164 echo % pop/push -a in subdir
163 165
164 166 hg qpop -a
165 167 hg --traceback qpush -a
166 168
167 169 # setting columns & interactive tests truncating (issue1912)
168 170 echo % qseries
169 171 COLUMNS=4 hg qseries --config ui.interactive=true
170 172 COLUMNS=20 hg qseries --config ui.interactive=true -vs
171 173 hg qpop
172 174 hg qseries -vs
173 175 hg sum | grep mq
174 176 hg qpush
175 177 hg sum | grep mq
176 178
177 179 echo % qapplied
178 180 hg qapplied
179 181
180 182 echo % qtop
181 183 hg qtop
182 184
183 185 echo % prev
184 186 hg qapp -1
185 187
186 188 echo % next
187 189 hg qunapp -1
188 190
189 191 hg qpop
190 192 echo % commit should fail
191 193 hg commit
192 194
193 195 echo % push should fail
194 196 hg push ../../k
195 197
196 198 echo % import should fail
197 199 hg st .
198 200 echo foo >> ../a
199 201 hg diff > ../../import.diff
200 202 hg revert --no-backup ../a
201 203 hg import ../../import.diff
202 204 hg st
203 205 echo % import --no-commit should succeed
204 206 hg import --no-commit ../../import.diff
205 207 hg st
206 208 hg revert --no-backup ../a
207 209
208 210 echo % qunapplied
209 211 hg qunapplied
210 212
211 213 echo % qpush/qpop with index
212 214 hg qnew test1b.patch
213 215 echo 1b > 1b
214 216 hg add 1b
215 217 hg qrefresh
216 218 hg qpush 2
217 219 hg qpop 0
218 220 hg qpush test.patch+1
219 221 hg qpush test.patch+2
220 222 hg qpop test2.patch-1
221 223 hg qpop test2.patch-2
222 224 hg qpush test1b.patch+1
223 225
224 226 echo % qpush --move
225 227 hg qpop -a
226 228 hg qpush --move test2.patch # move to front
227 229 hg qpush --move test1b.patch
228 230 hg qpush --move test.patch # noop move
229 231 hg qseries -v
230 232 hg qpop -a
231 233 hg qpush --move test.patch # cleaning up
232 234 hg qpush --move test1b.patch
233 235 hg qpush --move bogus # nonexistent patch
234 236 hg qpush --move test.patch # already applied
235 237 hg qpush
236 238
237 239 echo % pop, qapplied, qunapplied
238 240 hg qseries -v
239 241 echo % qapplied -1 test.patch
240 242 hg qapplied -1 test.patch
241 243 echo % qapplied -1 test1b.patch
242 244 hg qapplied -1 test1b.patch
243 245 echo % qapplied -1 test2.patch
244 246 hg qapplied -1 test2.patch
245 247 echo % qapplied -1
246 248 hg qapplied -1
247 249 echo % qapplied
248 250 hg qapplied
249 251 echo % qapplied test1b.patch
250 252 hg qapplied test1b.patch
251 253 echo % qunapplied -1
252 254 hg qunapplied -1
253 255 echo % qunapplied
254 256 hg qunapplied
255 257 echo % popping
256 258 hg qpop
257 259 echo % qunapplied -1
258 260 hg qunapplied -1
259 261 echo % qunapplied
260 262 hg qunapplied
261 263 echo % qunapplied test2.patch
262 264 hg qunapplied test2.patch
263 265 echo % qunapplied -1 test2.patch
264 266 hg qunapplied -1 test2.patch
265 267 echo % popping -a
266 268 hg qpop -a
267 269 echo % qapplied
268 270 hg qapplied
269 271 echo % qapplied -1
270 272 hg qapplied -1
271 273 hg qpush
272 274
273 275 echo % push should succeed
274 276 hg qpop -a
275 277 hg push ../../k
276 278
277 279 echo % qpush/qpop error codes
278 280 errorcode()
279 281 {
280 282 hg "$@" && echo " $@ succeeds" || echo " $@ fails"
281 283 }
282 284
283 285 # we want to start with some patches applied
284 286 hg qpush -a
285 287 echo " % pops all patches and succeeds"
286 288 errorcode qpop -a
287 289 echo " % does nothing and succeeds"
288 290 errorcode qpop -a
289 291 echo " % fails - nothing else to pop"
290 292 errorcode qpop
291 293 echo " % pushes a patch and succeeds"
292 294 errorcode qpush
293 295 echo " % pops a patch and succeeds"
294 296 errorcode qpop
295 297 echo " % pushes up to test1b.patch and succeeds"
296 298 errorcode qpush test1b.patch
297 299 echo " % does nothing and succeeds"
298 300 errorcode qpush test1b.patch
299 301 echo " % does nothing and succeeds"
300 302 errorcode qpop test1b.patch
301 303 echo " % fails - can't push to this patch"
302 304 errorcode qpush test.patch
303 305 echo " % fails - can't pop to this patch"
304 306 errorcode qpop test2.patch
305 307 echo " % pops up to test.patch and succeeds"
306 308 errorcode qpop test.patch
307 309 echo " % pushes all patches and succeeds"
308 310 errorcode qpush -a
309 311 echo " % does nothing and succeeds"
310 312 errorcode qpush -a
311 313 echo " % fails - nothing else to push"
312 314 errorcode qpush
313 315 echo " % does nothing and succeeds"
314 316 errorcode qpush test2.patch
315 317
316 318
317 319 echo % strip
318 320 cd ../../b
319 321 echo x>x
320 322 hg ci -Ama
321 hg strip tip 2>&1 | sed 's/\(saving bundle to \).*/\1/'
323 hg strip tip | hidebackup
322 324 hg unbundle .hg/strip-backup/*
323 325
324 326 echo % strip with local changes, should complain
325 327 hg up
326 328 echo y>y
327 329 hg add y
328 hg strip tip | sed 's/\(saving bundle to \).*/\1/'
330 hg strip tip | hidebackup
329 331 echo % --force strip with local changes
330 hg strip -f tip 2>&1 | sed 's/\(saving bundle to \).*/\1/'
332 hg strip -f tip | hidebackup
331 333
332 334 echo '% cd b; hg qrefresh'
333 335 hg init refresh
334 336 cd refresh
335 337 echo a > a
336 338 hg ci -Ama
337 339 hg qnew -mfoo foo
338 340 echo a >> a
339 341 hg qrefresh
340 342 mkdir b
341 343 cd b
342 344 echo f > f
343 345 hg add f
344 346 hg qrefresh
345 347 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
346 348 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" ../.hg/patches/foo
347 349 echo % hg qrefresh .
348 350 hg qrefresh .
349 351 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
350 352 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" ../.hg/patches/foo
351 353 hg status
352 354
353 355 echo % qpush failure
354 356 cd ..
355 357 hg qrefresh
356 358 hg qnew -mbar bar
357 359 echo foo > foo
358 360 echo bar > bar
359 361 hg add foo bar
360 362 hg qrefresh
361 363 hg qpop -a
362 364 echo bar > foo
363 365 hg qpush -a
364 366 hg st
365 367
366 368 echo % mq tags
367 369 hg log --template '{rev} {tags}\n' -r qparent:qtip
368 370
369 371 echo % bad node in status
370 372 hg qpop
371 373 hg strip -qn tip
372 374 hg tip 2>&1 | sed -e 's/unknown node .*/unknown node/'
373 375 hg branches 2>&1 | sed -e 's/unknown node .*/unknown node/'
374 376 hg qpop 2>&1 | sed -e 's/unknown node .*/unknown node/'
375 377
376 378 cat >>$HGRCPATH <<EOF
377 379 [diff]
378 380 git = True
379 381 EOF
380 382 cd ..
381 383 hg init git
382 384 cd git
383 385 hg qinit
384 386
385 387 hg qnew -m'new file' new
386 388 echo foo > new
387 389 chmod +x new
388 390 hg add new
389 391 hg qrefresh
390 392 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
391 393 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/new
392 394
393 395 hg qnew -m'copy file' copy
394 396 hg cp new copy
395 397 hg qrefresh
396 398 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
397 399 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/copy
398 400
399 401 hg qpop
400 402 hg qpush
401 403 hg qdiff
402 404 cat >>$HGRCPATH <<EOF
403 405 [diff]
404 406 git = False
405 407 EOF
406 408 hg qdiff --git
407 409 cd ..
408 410
409 411 echo % test file addition in slow path
410 412 hg init slow
411 413 cd slow
412 414 hg qinit
413 415 echo foo > foo
414 416 hg add foo
415 417 hg ci -m 'add foo'
416 418 hg qnew bar
417 419 echo bar > bar
418 420 hg add bar
419 421 hg mv foo baz
420 422 hg qrefresh --git
421 423 hg up -C 0
422 424 echo >> foo
423 425 hg ci -m 'change foo'
424 426 hg up -C 1
425 427 hg qrefresh --git 2>&1 | grep -v 'saving bundle'
426 428 cat .hg/patches/bar
427 429 hg log -v --template '{rev} {file_copies}\n' -r .
428 430 hg qrefresh --git
429 431 cat .hg/patches/bar
430 432 hg log -v --template '{rev} {file_copies}\n' -r .
431 433 hg qrefresh
432 434 grep 'diff --git' .hg/patches/bar
433 435
434 436 echo % test file move chains in the slow path
435 437 hg up -C 1
436 438 echo >> foo
437 439 hg ci -m 'change foo again'
438 440 hg up -C 2
439 441 hg mv bar quux
440 442 hg mv baz bleh
441 443 hg qrefresh --git 2>&1 | grep -v 'saving bundle'
442 444 cat .hg/patches/bar
443 445 hg log -v --template '{rev} {file_copies}\n' -r .
444 446 hg mv quux fred
445 447 hg mv bleh barney
446 448 hg qrefresh --git
447 449 cat .hg/patches/bar
448 450 hg log -v --template '{rev} {file_copies}\n' -r .
449 451
450 452 echo % refresh omitting an added file
451 453 hg qnew baz
452 454 echo newfile > newfile
453 455 hg add newfile
454 456 hg qrefresh
455 457 hg st -A newfile
456 458 hg qrefresh -X newfile
457 459 hg st -A newfile
458 460 hg revert newfile
459 461 rm newfile
460 462 hg qpop
461 463 hg qdel baz
462 464
463 465 echo % create a git patch
464 466 echo a > alexander
465 467 hg add alexander
466 468 hg qnew -f --git addalexander
467 469 grep diff .hg/patches/addalexander
468 470
469 471 echo % create a git binary patch
470 472 cat > writebin.py <<EOF
471 473 import sys
472 474 path = sys.argv[1]
473 475 open(path, 'wb').write('BIN\x00ARY')
474 476 EOF
475 477 python writebin.py bucephalus
476 478
477 479 python "$TESTDIR/md5sum.py" bucephalus
478 480 hg add bucephalus
479 481 hg qnew -f --git addbucephalus
480 482 grep diff .hg/patches/addbucephalus
481 483
482 484 echo % check binary patches can be popped and pushed
483 485 hg qpop
484 486 test -f bucephalus && echo % bucephalus should not be there
485 487 hg qpush
486 488 test -f bucephalus || echo % bucephalus should be there
487 489 python "$TESTDIR/md5sum.py" bucephalus
488 490
489 491
490 492 echo '% strip again'
491 493 cd ..
492 494 hg init strip
493 495 cd strip
494 496 touch foo
495 497 hg add foo
496 498 hg ci -m 'add foo'
497 499 echo >> foo
498 500 hg ci -m 'change foo 1'
499 501 hg up -C 0
500 502 echo 1 >> foo
501 503 hg ci -m 'change foo 2'
502 504 HGMERGE=true hg merge
503 505 hg ci -m merge
504 506 hg log
505 hg strip 1 2>&1 | sed 's/\(saving bundle to \).*/\1/'
507 hg strip 1 | hidebackup
506 508 checkundo strip
507 509 hg log
508 510 cd ..
509 511
510 512 echo '% qclone'
511 513 qlog()
512 514 {
513 515 echo 'main repo:'
514 516 hg log --template ' rev {rev}: {desc}\n'
515 517 echo 'patch repo:'
516 518 hg -R .hg/patches log --template ' rev {rev}: {desc}\n'
517 519 }
518 520 hg init qclonesource
519 521 cd qclonesource
520 522 echo foo > foo
521 523 hg add foo
522 524 hg ci -m 'add foo'
523 525 hg qinit
524 526 hg qnew patch1
525 527 echo bar >> foo
526 528 hg qrefresh -m 'change foo'
527 529 cd ..
528 530
529 531 # repo with unversioned patch dir
530 532 hg qclone qclonesource failure
531 533
532 534 cd qclonesource
533 535 hg qinit -c
534 536 hg qci -m checkpoint
535 537 qlog
536 538 cd ..
537 539
538 540 # repo with patches applied
539 541 hg qclone qclonesource qclonedest
540 542 cd qclonedest
541 543 qlog
542 544 cd ..
543 545
544 546 # repo with patches unapplied
545 547 cd qclonesource
546 548 hg qpop -a
547 549 qlog
548 550 cd ..
549 551 hg qclone qclonesource qclonedest2
550 552 cd qclonedest2
551 553 qlog
552 554 cd ..
553 555
554 556 echo % 'test applying on an empty file (issue 1033)'
555 557 hg init empty
556 558 cd empty
557 559 touch a
558 560 hg ci -Am addempty
559 561 echo a > a
560 562 hg qnew -f -e changea
561 563 hg qpop
562 564 hg qpush
563 565 cd ..
564 566
565 567 echo % test qpush with --force, issue1087
566 568 hg init forcepush
567 569 cd forcepush
568 570 echo hello > hello.txt
569 571 echo bye > bye.txt
570 572 hg ci -Ama
571 573 hg qnew -d '0 0' empty
572 574 hg qpop
573 575 echo world >> hello.txt
574 576
575 577 echo % qpush should fail, local changes
576 578 hg qpush
577 579
578 580 echo % apply force, should not discard changes with empty patch
579 581 hg qpush -f 2>&1 | sed 's,^.*/patch,patch,g'
580 582 hg diff --config diff.nodates=True
581 583 hg qdiff --config diff.nodates=True
582 584 hg log -l1 -p
583 585 hg qref -d '0 0'
584 586 hg qpop
585 587 echo universe >> hello.txt
586 588 echo universe >> bye.txt
587 589
588 590 echo % qpush should fail, local changes
589 591 hg qpush
590 592
591 593 echo % apply force, should discard changes in hello, but not bye
592 594 hg qpush -f
593 595 hg st
594 596 hg diff --config diff.nodates=True
595 597 hg qdiff --config diff.nodates=True
596 598
597 599 echo % test popping revisions not in working dir ancestry
598 600 hg qseries -v
599 601 hg up qparent
600 602 hg qpop
601 603
602 604 cd ..
603 605 hg init deletion-order
604 606 cd deletion-order
605 607
606 608 touch a
607 609 hg ci -Aqm0
608 610
609 611 hg qnew rename-dir
610 612 hg rm a
611 613 hg qrefresh
612 614
613 615 mkdir a b
614 616 touch a/a b/b
615 617 hg add -q a b
616 618 hg qrefresh
617 619
618 620 echo % test popping must remove files added in subdirectories first
619 621 hg qpop
620 622 cd ..
@@ -1,53 +1,55 b''
1 1 #!/bin/sh
2 2
3 source $TESTDIR/helpers.sh
4
3 5 echo "[extensions]" >> $HGRCPATH
4 6 echo "mq=" >> $HGRCPATH
5 7
6 8 teststrip() {
7 9 hg up -C $1
8 10 echo % before update $1, strip $2
9 11 hg parents
10 hg strip $2 2>&1 | sed 's/\(saving bundle to \).*/\1/'
12 hg strip $2 | hidebackup
11 13 echo % after update $1, strip $2
12 14 hg parents
13 15 hg unbundle -q .hg/strip-backup/*
14 16 rm .hg/strip-backup/*
15 17 }
16 18
17 19 hg init test
18 20 cd test
19 21
20 22 echo foo > bar
21 23 hg ci -Ama
22 24
23 25 echo more >> bar
24 26 hg ci -Amb
25 27
26 28 echo blah >> bar
27 29 hg ci -Amc
28 30
29 31 hg up 1
30 32 echo blah >> bar
31 33 hg ci -Amd
32 34
33 35 echo final >> bar
34 36 hg ci -Ame
35 37
36 38 hg log
37 39
38 40 teststrip 4 4
39 41 teststrip 4 3
40 42 teststrip 1 4
41 43 teststrip 4 2
42 44 teststrip 4 1
43 45 teststrip null 4
44 46
45 47 hg log
46 48
47 49 hg up -C 2
48 50 hg merge 4
49 51 echo % before strip of merge parent
50 52 hg parents
51 hg strip 4 2>&1 | sed 's/\(saving bundle to \).*/\1/'
53 hg strip 4 2>&1 | hidebackup
52 54 echo % after strip of merge parent
53 55 hg parents
@@ -1,172 +1,172 b''
1 1 adding bar
2 2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
3 3 created new head
4 4 changeset: 4:443431ffac4f
5 5 tag: tip
6 6 user: test
7 7 date: Thu Jan 01 00:00:00 1970 +0000
8 8 summary: e
9 9
10 10 changeset: 3:65bd5f99a4a3
11 11 parent: 1:ef3a871183d7
12 12 user: test
13 13 date: Thu Jan 01 00:00:00 1970 +0000
14 14 summary: d
15 15
16 16 changeset: 2:264128213d29
17 17 user: test
18 18 date: Thu Jan 01 00:00:00 1970 +0000
19 19 summary: c
20 20
21 21 changeset: 1:ef3a871183d7
22 22 user: test
23 23 date: Thu Jan 01 00:00:00 1970 +0000
24 24 summary: b
25 25
26 26 changeset: 0:9ab35a2d17cb
27 27 user: test
28 28 date: Thu Jan 01 00:00:00 1970 +0000
29 29 summary: a
30 30
31 31 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 32 % before update 4, strip 4
33 33 changeset: 4:443431ffac4f
34 34 tag: tip
35 35 user: test
36 36 date: Thu Jan 01 00:00:00 1970 +0000
37 37 summary: e
38 38
39 39 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 saving bundle to
40 saved backup bundle to
41 41 % after update 4, strip 4
42 42 changeset: 3:65bd5f99a4a3
43 43 tag: tip
44 44 parent: 1:ef3a871183d7
45 45 user: test
46 46 date: Thu Jan 01 00:00:00 1970 +0000
47 47 summary: d
48 48
49 49 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 50 % before update 4, strip 3
51 51 changeset: 4:443431ffac4f
52 52 tag: tip
53 53 user: test
54 54 date: Thu Jan 01 00:00:00 1970 +0000
55 55 summary: e
56 56
57 57 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
58 saving bundle to
58 saved backup bundle to
59 59 % after update 4, strip 3
60 60 changeset: 1:ef3a871183d7
61 61 user: test
62 62 date: Thu Jan 01 00:00:00 1970 +0000
63 63 summary: b
64 64
65 65 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
66 66 % before update 1, strip 4
67 67 changeset: 1:ef3a871183d7
68 68 user: test
69 69 date: Thu Jan 01 00:00:00 1970 +0000
70 70 summary: b
71 71
72 saving bundle to
72 saved backup bundle to
73 73 % after update 1, strip 4
74 74 changeset: 1:ef3a871183d7
75 75 user: test
76 76 date: Thu Jan 01 00:00:00 1970 +0000
77 77 summary: b
78 78
79 79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 80 % before update 4, strip 2
81 81 changeset: 4:443431ffac4f
82 82 tag: tip
83 83 user: test
84 84 date: Thu Jan 01 00:00:00 1970 +0000
85 85 summary: e
86 86
87 saving bundle to
87 saved backup bundle to
88 88 adding branch
89 89 adding changesets
90 90 adding manifests
91 91 adding file changes
92 92 added 2 changesets with 2 changes to 1 files
93 93 % after update 4, strip 2
94 94 changeset: 3:443431ffac4f
95 95 tag: tip
96 96 user: test
97 97 date: Thu Jan 01 00:00:00 1970 +0000
98 98 summary: e
99 99
100 100 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 101 % before update 4, strip 1
102 102 changeset: 4:264128213d29
103 103 tag: tip
104 104 parent: 1:ef3a871183d7
105 105 user: test
106 106 date: Thu Jan 01 00:00:00 1970 +0000
107 107 summary: c
108 108
109 109 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 saving bundle to
110 saved backup bundle to
111 111 % after update 4, strip 1
112 112 changeset: 0:9ab35a2d17cb
113 113 tag: tip
114 114 user: test
115 115 date: Thu Jan 01 00:00:00 1970 +0000
116 116 summary: a
117 117
118 118 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
119 119 % before update null, strip 4
120 saving bundle to
120 saved backup bundle to
121 121 % after update null, strip 4
122 122 changeset: 4:264128213d29
123 123 tag: tip
124 124 parent: 1:ef3a871183d7
125 125 user: test
126 126 date: Thu Jan 01 00:00:00 1970 +0000
127 127 summary: c
128 128
129 129 changeset: 3:443431ffac4f
130 130 user: test
131 131 date: Thu Jan 01 00:00:00 1970 +0000
132 132 summary: e
133 133
134 134 changeset: 2:65bd5f99a4a3
135 135 user: test
136 136 date: Thu Jan 01 00:00:00 1970 +0000
137 137 summary: d
138 138
139 139 changeset: 1:ef3a871183d7
140 140 user: test
141 141 date: Thu Jan 01 00:00:00 1970 +0000
142 142 summary: b
143 143
144 144 changeset: 0:9ab35a2d17cb
145 145 user: test
146 146 date: Thu Jan 01 00:00:00 1970 +0000
147 147 summary: a
148 148
149 149 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
150 150 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
151 151 (branch merge, don't forget to commit)
152 152 % before strip of merge parent
153 153 changeset: 2:65bd5f99a4a3
154 154 user: test
155 155 date: Thu Jan 01 00:00:00 1970 +0000
156 156 summary: d
157 157
158 158 changeset: 4:264128213d29
159 159 tag: tip
160 160 parent: 1:ef3a871183d7
161 161 user: test
162 162 date: Thu Jan 01 00:00:00 1970 +0000
163 163 summary: c
164 164
165 165 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
166 saving bundle to
166 saved backup bundle to
167 167 % after strip of merge parent
168 168 changeset: 1:ef3a871183d7
169 169 user: test
170 170 date: Thu Jan 01 00:00:00 1970 +0000
171 171 summary: b
172 172
@@ -1,650 +1,650 b''
1 1 % help
2 2 mq extension - manage a stack of patches
3 3
4 4 This extension lets you work with a stack of patches in a Mercurial
5 5 repository. It manages two stacks of patches - all known patches, and applied
6 6 patches (subset of known patches).
7 7
8 8 Known patches are represented as patch files in the .hg/patches directory.
9 9 Applied patches are both patch files and changesets.
10 10
11 11 Common tasks (use "hg help command" for more details):
12 12
13 13 create new patch qnew
14 14 import existing patch qimport
15 15
16 16 print patch series qseries
17 17 print applied patches qapplied
18 18
19 19 add known patch to applied stack qpush
20 20 remove patch from applied stack qpop
21 21 refresh contents of top applied patch qrefresh
22 22
23 23 By default, mq will automatically use git patches when required to avoid
24 24 losing file mode changes, copy records, binary files or empty files creations
25 25 or deletions. This behaviour can be configured with:
26 26
27 27 [mq]
28 28 git = auto/keep/yes/no
29 29
30 30 If set to 'keep', mq will obey the [diff] section configuration while
31 31 preserving existing git patches upon qrefresh. If set to 'yes' or 'no', mq
32 32 will override the [diff] section and always generate git or regular patches,
33 33 possibly losing data in the second case.
34 34
35 35 list of commands:
36 36
37 37 qapplied print the patches already applied
38 38 qclone clone main and patch repository at same time
39 39 qdelete remove patches from queue
40 40 qdiff diff of the current patch and subsequent modifications
41 41 qfinish move applied patches into repository history
42 42 qfold fold the named patches into the current patch
43 43 qgoto push or pop patches until named patch is at top of stack
44 44 qguard set or print guards for a patch
45 45 qheader print the header of the topmost or specified patch
46 46 qimport import a patch
47 47 qnew create a new patch
48 48 qnext print the name of the next patch
49 49 qpop pop the current patch off the stack
50 50 qprev print the name of the previous patch
51 51 qpush push the next patch onto the stack
52 52 qrefresh update the current patch
53 53 qrename rename a patch
54 54 qselect set or print guarded patches to push
55 55 qseries print the entire series file
56 56 qtop print the name of the current patch
57 57 qunapplied print the patches not yet applied
58 58 strip strip a changeset and all its descendants from the repository
59 59
60 60 use "hg -v help mq" to show aliases and global options
61 61 adding a
62 62 updating to branch default
63 63 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 64 adding b/z
65 65 % qinit
66 66 % -R qinit
67 67 % qinit -c
68 68 A .hgignore
69 69 A series
70 70 % qinit; qinit -c
71 71 .hgignore:
72 72 ^\.hg
73 73 ^\.mq
74 74 syntax: glob
75 75 status
76 76 guards
77 77 series:
78 78 abort: repository already exists!
79 79 % qinit; <stuff>; qinit -c
80 80 adding .hg/patches/A
81 81 adding .hg/patches/B
82 82 A .hgignore
83 83 A A
84 84 A B
85 85 A series
86 86 .hgignore:
87 87 status
88 88 bleh
89 89 series:
90 90 A
91 91 B
92 92 % init --mq without repo
93 93 abort: There is no Mercurial repository here (.hg not found)
94 94 % init --mq with repo path
95 95 ok
96 96 % init --mq with nonexistent directory
97 97 abort: repository nonexistentdir not found!
98 98 % init --mq with bundle (non "local")
99 99 abort: only a local queue repository may be initialized
100 100 % qrefresh
101 101 foo bar
102 102
103 103 diff -r xa
104 104 --- a/a
105 105 +++ b/a
106 106 @@ -1,1 +1,2 @@
107 107 a
108 108 +a
109 109 % empty qrefresh
110 110 revision:
111 111 patch:
112 112 foo bar
113 113
114 114 working dir diff:
115 115 --- a/a
116 116 +++ b/a
117 117 @@ -1,1 +1,2 @@
118 118 a
119 119 +a
120 120 % qpop
121 121 popping test.patch
122 122 patch queue now empty
123 123 % qpush with dump of tag cache
124 124 .hg/tags.cache (pre qpush):
125 125 1
126 126
127 127 applying test.patch
128 128 now at: test.patch
129 129 .hg/tags.cache (post qpush):
130 130 2
131 131
132 132 % pop/push outside repo
133 133 popping test.patch
134 134 patch queue now empty
135 135 applying test.patch
136 136 now at: test.patch
137 137 % qrefresh in subdir
138 138 % pop/push -a in subdir
139 139 popping test2.patch
140 140 popping test.patch
141 141 patch queue now empty
142 142 applying test.patch
143 143 applying test2.patch
144 144 now at: test2.patch
145 145 % qseries
146 146 test.patch
147 147 test2.patch
148 148 0 A test.patch: f...
149 149 1 A test2.patch:
150 150 popping test2.patch
151 151 now at: test.patch
152 152 0 A test.patch: foo bar
153 153 1 U test2.patch:
154 154 mq: 1 applied, 1 unapplied
155 155 applying test2.patch
156 156 now at: test2.patch
157 157 mq: 2 applied
158 158 % qapplied
159 159 test.patch
160 160 test2.patch
161 161 % qtop
162 162 test2.patch
163 163 % prev
164 164 test.patch
165 165 % next
166 166 all patches applied
167 167 popping test2.patch
168 168 now at: test.patch
169 169 % commit should fail
170 170 abort: cannot commit over an applied mq patch
171 171 % push should fail
172 172 pushing to ../../k
173 173 abort: source has mq patches applied
174 174 % import should fail
175 175 abort: cannot import over an applied patch
176 176 % import --no-commit should succeed
177 177 applying ../../import.diff
178 178 M a
179 179 % qunapplied
180 180 test2.patch
181 181 % qpush/qpop with index
182 182 applying test2.patch
183 183 now at: test2.patch
184 184 popping test2.patch
185 185 popping test1b.patch
186 186 now at: test.patch
187 187 applying test1b.patch
188 188 now at: test1b.patch
189 189 applying test2.patch
190 190 now at: test2.patch
191 191 popping test2.patch
192 192 now at: test1b.patch
193 193 popping test1b.patch
194 194 now at: test.patch
195 195 applying test1b.patch
196 196 applying test2.patch
197 197 now at: test2.patch
198 198 % qpush --move
199 199 popping test2.patch
200 200 popping test1b.patch
201 201 popping test.patch
202 202 patch queue now empty
203 203 applying test2.patch
204 204 now at: test2.patch
205 205 applying test1b.patch
206 206 now at: test1b.patch
207 207 applying test.patch
208 208 now at: test.patch
209 209 0 A test2.patch
210 210 1 A test1b.patch
211 211 2 A test.patch
212 212 popping test.patch
213 213 popping test1b.patch
214 214 popping test2.patch
215 215 patch queue now empty
216 216 applying test.patch
217 217 now at: test.patch
218 218 applying test1b.patch
219 219 now at: test1b.patch
220 220 abort: patch bogus not in series
221 221 abort: cannot push to a previous patch: test.patch
222 222 applying test2.patch
223 223 now at: test2.patch
224 224 % pop, qapplied, qunapplied
225 225 0 A test.patch
226 226 1 A test1b.patch
227 227 2 A test2.patch
228 228 % qapplied -1 test.patch
229 229 only one patch applied
230 230 % qapplied -1 test1b.patch
231 231 test.patch
232 232 % qapplied -1 test2.patch
233 233 test1b.patch
234 234 % qapplied -1
235 235 test1b.patch
236 236 % qapplied
237 237 test.patch
238 238 test1b.patch
239 239 test2.patch
240 240 % qapplied test1b.patch
241 241 test.patch
242 242 test1b.patch
243 243 % qunapplied -1
244 244 all patches applied
245 245 % qunapplied
246 246 % popping
247 247 popping test2.patch
248 248 now at: test1b.patch
249 249 % qunapplied -1
250 250 test2.patch
251 251 % qunapplied
252 252 test2.patch
253 253 % qunapplied test2.patch
254 254 % qunapplied -1 test2.patch
255 255 all patches applied
256 256 % popping -a
257 257 popping test1b.patch
258 258 popping test.patch
259 259 patch queue now empty
260 260 % qapplied
261 261 % qapplied -1
262 262 no patches applied
263 263 applying test.patch
264 264 now at: test.patch
265 265 % push should succeed
266 266 popping test.patch
267 267 patch queue now empty
268 268 pushing to ../../k
269 269 searching for changes
270 270 adding changesets
271 271 adding manifests
272 272 adding file changes
273 273 added 1 changesets with 1 changes to 1 files
274 274 % qpush/qpop error codes
275 275 applying test.patch
276 276 applying test1b.patch
277 277 applying test2.patch
278 278 now at: test2.patch
279 279 % pops all patches and succeeds
280 280 popping test2.patch
281 281 popping test1b.patch
282 282 popping test.patch
283 283 patch queue now empty
284 284 qpop -a succeeds
285 285 % does nothing and succeeds
286 286 no patches applied
287 287 qpop -a succeeds
288 288 % fails - nothing else to pop
289 289 no patches applied
290 290 qpop fails
291 291 % pushes a patch and succeeds
292 292 applying test.patch
293 293 now at: test.patch
294 294 qpush succeeds
295 295 % pops a patch and succeeds
296 296 popping test.patch
297 297 patch queue now empty
298 298 qpop succeeds
299 299 % pushes up to test1b.patch and succeeds
300 300 applying test.patch
301 301 applying test1b.patch
302 302 now at: test1b.patch
303 303 qpush test1b.patch succeeds
304 304 % does nothing and succeeds
305 305 qpush: test1b.patch is already at the top
306 306 qpush test1b.patch succeeds
307 307 % does nothing and succeeds
308 308 qpop: test1b.patch is already at the top
309 309 qpop test1b.patch succeeds
310 310 % fails - can't push to this patch
311 311 abort: cannot push to a previous patch: test.patch
312 312 qpush test.patch fails
313 313 % fails - can't pop to this patch
314 314 abort: patch test2.patch is not applied
315 315 qpop test2.patch fails
316 316 % pops up to test.patch and succeeds
317 317 popping test1b.patch
318 318 now at: test.patch
319 319 qpop test.patch succeeds
320 320 % pushes all patches and succeeds
321 321 applying test1b.patch
322 322 applying test2.patch
323 323 now at: test2.patch
324 324 qpush -a succeeds
325 325 % does nothing and succeeds
326 326 all patches are currently applied
327 327 qpush -a succeeds
328 328 % fails - nothing else to push
329 329 patch series already fully applied
330 330 qpush fails
331 331 % does nothing and succeeds
332 332 qpush: test2.patch is already at the top
333 333 qpush test2.patch succeeds
334 334 % strip
335 335 adding x
336 336 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
337 saving bundle to
337 saved backup bundle to
338 338 adding changesets
339 339 adding manifests
340 340 adding file changes
341 341 added 1 changesets with 1 changes to 1 files
342 342 (run 'hg update' to get a working copy)
343 343 % strip with local changes, should complain
344 344 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
345 345 abort: local changes found
346 346 % --force strip with local changes
347 347 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
348 saving bundle to
348 saved backup bundle to
349 349 % cd b; hg qrefresh
350 350 adding a
351 351 foo
352 352
353 353 diff -r cb9a9f314b8b a
354 354 --- a/a
355 355 +++ b/a
356 356 @@ -1,1 +1,2 @@
357 357 a
358 358 +a
359 359 diff -r cb9a9f314b8b b/f
360 360 --- /dev/null
361 361 +++ b/b/f
362 362 @@ -0,0 +1,1 @@
363 363 +f
364 364 % hg qrefresh .
365 365 foo
366 366
367 367 diff -r cb9a9f314b8b b/f
368 368 --- /dev/null
369 369 +++ b/b/f
370 370 @@ -0,0 +1,1 @@
371 371 +f
372 372 M a
373 373 % qpush failure
374 374 popping bar
375 375 popping foo
376 376 patch queue now empty
377 377 applying foo
378 378 applying bar
379 379 file foo already exists
380 380 1 out of 1 hunks FAILED -- saving rejects to file foo.rej
381 381 patch failed, unable to continue (try -v)
382 382 patch failed, rejects left in working dir
383 383 errors during apply, please fix and refresh bar
384 384 ? foo
385 385 ? foo.rej
386 386 % mq tags
387 387 0 qparent
388 388 1 foo qbase
389 389 2 bar qtip tip
390 390 % bad node in status
391 391 popping bar
392 392 now at: foo
393 393 changeset: 0:cb9a9f314b8b
394 394 mq status file refers to unknown node
395 395 tag: tip
396 396 user: test
397 397 date: Thu Jan 01 00:00:00 1970 +0000
398 398 summary: a
399 399
400 400 mq status file refers to unknown node
401 401 default 0:cb9a9f314b8b
402 402 abort: trying to pop unknown node
403 403 new file
404 404
405 405 diff --git a/new b/new
406 406 new file mode 100755
407 407 --- /dev/null
408 408 +++ b/new
409 409 @@ -0,0 +1,1 @@
410 410 +foo
411 411 copy file
412 412
413 413 diff --git a/new b/copy
414 414 copy from new
415 415 copy to copy
416 416 popping copy
417 417 now at: new
418 418 applying copy
419 419 now at: copy
420 420 diff --git a/new b/copy
421 421 copy from new
422 422 copy to copy
423 423 diff --git a/new b/copy
424 424 copy from new
425 425 copy to copy
426 426 % test file addition in slow path
427 427 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
428 428 created new head
429 429 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
430 430 adding branch
431 431 adding changesets
432 432 adding manifests
433 433 adding file changes
434 434 added 1 changesets with 1 changes to 1 files
435 435 diff --git a/bar b/bar
436 436 new file mode 100644
437 437 --- /dev/null
438 438 +++ b/bar
439 439 @@ -0,0 +1,1 @@
440 440 +bar
441 441 diff --git a/foo b/baz
442 442 rename from foo
443 443 rename to baz
444 444 2 baz (foo)
445 445 diff --git a/bar b/bar
446 446 new file mode 100644
447 447 --- /dev/null
448 448 +++ b/bar
449 449 @@ -0,0 +1,1 @@
450 450 +bar
451 451 diff --git a/foo b/baz
452 452 rename from foo
453 453 rename to baz
454 454 2 baz (foo)
455 455 diff --git a/bar b/bar
456 456 diff --git a/foo b/baz
457 457 % test file move chains in the slow path
458 458 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
459 459 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
460 460 adding branch
461 461 adding changesets
462 462 adding manifests
463 463 adding file changes
464 464 added 1 changesets with 1 changes to 1 files
465 465 diff --git a/foo b/bleh
466 466 rename from foo
467 467 rename to bleh
468 468 diff --git a/quux b/quux
469 469 new file mode 100644
470 470 --- /dev/null
471 471 +++ b/quux
472 472 @@ -0,0 +1,1 @@
473 473 +bar
474 474 3 bleh (foo)
475 475 diff --git a/foo b/barney
476 476 rename from foo
477 477 rename to barney
478 478 diff --git a/fred b/fred
479 479 new file mode 100644
480 480 --- /dev/null
481 481 +++ b/fred
482 482 @@ -0,0 +1,1 @@
483 483 +bar
484 484 3 barney (foo)
485 485 % refresh omitting an added file
486 486 C newfile
487 487 A newfile
488 488 popping baz
489 489 now at: bar
490 490 % create a git patch
491 491 diff --git a/alexander b/alexander
492 492 % create a git binary patch
493 493 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus
494 494 diff --git a/bucephalus b/bucephalus
495 495 % check binary patches can be popped and pushed
496 496 popping addbucephalus
497 497 now at: addalexander
498 498 applying addbucephalus
499 499 now at: addbucephalus
500 500 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus
501 501 % strip again
502 502 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
503 503 created new head
504 504 merging foo
505 505 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
506 506 (branch merge, don't forget to commit)
507 507 changeset: 3:99615015637b
508 508 tag: tip
509 509 parent: 2:20cbbe65cff7
510 510 parent: 1:d2871fc282d4
511 511 user: test
512 512 date: Thu Jan 01 00:00:00 1970 +0000
513 513 summary: merge
514 514
515 515 changeset: 2:20cbbe65cff7
516 516 parent: 0:53245c60e682
517 517 user: test
518 518 date: Thu Jan 01 00:00:00 1970 +0000
519 519 summary: change foo 2
520 520
521 521 changeset: 1:d2871fc282d4
522 522 user: test
523 523 date: Thu Jan 01 00:00:00 1970 +0000
524 524 summary: change foo 1
525 525
526 526 changeset: 0:53245c60e682
527 527 user: test
528 528 date: Thu Jan 01 00:00:00 1970 +0000
529 529 summary: add foo
530 530
531 531 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
532 saving bundle to
532 saved backup bundle to
533 533 adding branch
534 534 adding changesets
535 535 adding manifests
536 536 adding file changes
537 537 added 1 changesets with 1 changes to 1 files
538 538 changeset: 1:20cbbe65cff7
539 539 tag: tip
540 540 user: test
541 541 date: Thu Jan 01 00:00:00 1970 +0000
542 542 summary: change foo 2
543 543
544 544 changeset: 0:53245c60e682
545 545 user: test
546 546 date: Thu Jan 01 00:00:00 1970 +0000
547 547 summary: add foo
548 548
549 549 % qclone
550 550 abort: versioned patch repository not found (see init --mq)
551 551 adding .hg/patches/patch1
552 552 main repo:
553 553 rev 1: change foo
554 554 rev 0: add foo
555 555 patch repo:
556 556 rev 0: checkpoint
557 557 updating to branch default
558 558 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
559 559 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
560 560 main repo:
561 561 rev 0: add foo
562 562 patch repo:
563 563 rev 0: checkpoint
564 564 popping patch1
565 565 patch queue now empty
566 566 main repo:
567 567 rev 0: add foo
568 568 patch repo:
569 569 rev 0: checkpoint
570 570 updating to branch default
571 571 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
572 572 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
573 573 main repo:
574 574 rev 0: add foo
575 575 patch repo:
576 576 rev 0: checkpoint
577 577 % test applying on an empty file (issue 1033)
578 578 adding a
579 579 popping changea
580 580 patch queue now empty
581 581 applying changea
582 582 now at: changea
583 583 % test qpush with --force, issue1087
584 584 adding bye.txt
585 585 adding hello.txt
586 586 popping empty
587 587 patch queue now empty
588 588 % qpush should fail, local changes
589 589 abort: local changes found, refresh first
590 590 % apply force, should not discard changes with empty patch
591 591 applying empty
592 592 patch empty is empty
593 593 now at: empty
594 594 diff -r bf5fc3f07a0a hello.txt
595 595 --- a/hello.txt
596 596 +++ b/hello.txt
597 597 @@ -1,1 +1,2 @@
598 598 hello
599 599 +world
600 600 diff -r 9ecee4f634e3 hello.txt
601 601 --- a/hello.txt
602 602 +++ b/hello.txt
603 603 @@ -1,1 +1,2 @@
604 604 hello
605 605 +world
606 606 changeset: 1:bf5fc3f07a0a
607 607 tag: empty
608 608 tag: qbase
609 609 tag: qtip
610 610 tag: tip
611 611 user: test
612 612 date: Thu Jan 01 00:00:00 1970 +0000
613 613 summary: imported patch empty
614 614
615 615
616 616 popping empty
617 617 patch queue now empty
618 618 % qpush should fail, local changes
619 619 abort: local changes found, refresh first
620 620 % apply force, should discard changes in hello, but not bye
621 621 applying empty
622 622 now at: empty
623 623 M bye.txt
624 624 diff -r ba252371dbc1 bye.txt
625 625 --- a/bye.txt
626 626 +++ b/bye.txt
627 627 @@ -1,1 +1,2 @@
628 628 bye
629 629 +universe
630 630 diff -r 9ecee4f634e3 bye.txt
631 631 --- a/bye.txt
632 632 +++ b/bye.txt
633 633 @@ -1,1 +1,2 @@
634 634 bye
635 635 +universe
636 636 diff -r 9ecee4f634e3 hello.txt
637 637 --- a/hello.txt
638 638 +++ b/hello.txt
639 639 @@ -1,1 +1,3 @@
640 640 hello
641 641 +world
642 642 +universe
643 643 % test popping revisions not in working dir ancestry
644 644 0 A empty
645 645 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
646 646 popping empty
647 647 patch queue now empty
648 648 % test popping must remove files added in subdirectories first
649 649 popping rename-dir
650 650 patch queue now empty
@@ -1,92 +1,92 b''
1 1 % before update 0, strip 2
2 2 changeset: 0:cb9a9f314b8b
3 3 user: test
4 4 date: Thu Jan 01 00:00:00 1970 +0000
5 5 summary: a
6 6
7 saving bundle
7 saved backup bundle
8 8 transaction abort!
9 9 failed to truncate data/b.i
10 10 rollback failed - please run hg recover
11 11 strip failed, full bundle
12 12 abort: Permission denied .hg/store/data/b.i
13 13 % after update 0, strip 2
14 14 abandoned transaction found - run hg recover
15 15 checking changesets
16 16 checking manifests
17 17 crosschecking files in changesets and manifests
18 18 checking files
19 19 b@?: rev 1 points to nonexistent changeset 2
20 20 (expected 1)
21 21 b@?: 736c29771fba not in manifests
22 22 warning: orphan revlog 'data/c.i'
23 23 2 files, 2 changesets, 3 total revisions
24 24 2 warnings encountered!
25 25 2 integrity errors encountered!
26 26 % journal contents
27 27 00changelog.i
28 28 00manifest.i
29 29 data/b.i
30 30 data/c.i
31 31 rolling back interrupted transaction
32 32 checking changesets
33 33 checking manifests
34 34 crosschecking files in changesets and manifests
35 35 checking files
36 36 2 files, 2 changesets, 2 total revisions
37 37 % before update 0, strip 2
38 38 changeset: 0:cb9a9f314b8b
39 39 user: test
40 40 date: Thu Jan 01 00:00:00 1970 +0000
41 41 summary: a
42 42
43 43 abort: Permission denied .hg/store/data/b.i
44 44 % after update 0, strip 2
45 45 checking changesets
46 46 checking manifests
47 47 crosschecking files in changesets and manifests
48 48 checking files
49 49 3 files, 4 changesets, 4 total revisions
50 50 % journal contents
51 51 (no journal)
52 52 % before update 0, strip 2
53 53 changeset: 0:cb9a9f314b8b
54 54 user: test
55 55 date: Thu Jan 01 00:00:00 1970 +0000
56 56 summary: a
57 57
58 saving bundle
58 saved backup bundle
59 59 transaction abort!
60 60 failed to truncate 00manifest.i
61 61 rollback failed - please run hg recover
62 62 strip failed, full bundle
63 63 abort: Permission denied .hg/store/00manifest.i
64 64 % after update 0, strip 2
65 65 abandoned transaction found - run hg recover
66 66 checking changesets
67 67 checking manifests
68 68 manifest@?: rev 2 points to nonexistent changeset 2
69 69 manifest@?: 3362547cdf64 not in changesets
70 70 manifest@?: rev 3 points to nonexistent changeset 3
71 71 manifest@?: 265a85892ecb not in changesets
72 72 crosschecking files in changesets and manifests
73 73 c@3: in manifest but not in changeset
74 74 checking files
75 75 b@?: rev 1 points to nonexistent changeset 2
76 76 (expected 1)
77 77 c@?: rev 0 points to nonexistent changeset 3
78 78 3 files, 2 changesets, 4 total revisions
79 79 1 warnings encountered!
80 80 7 integrity errors encountered!
81 81 (first damaged changeset appears to be 3)
82 82 % journal contents
83 83 00changelog.i
84 84 00manifest.i
85 85 data/b.i
86 86 data/c.i
87 87 rolling back interrupted transaction
88 88 checking changesets
89 89 checking manifests
90 90 crosschecking files in changesets and manifests
91 91 checking files
92 92 2 files, 2 changesets, 2 total revisions
@@ -1,68 +1,64 b''
1 1 #!/bin/sh
2 2
3 3 # test stripping of filelogs where the linkrev doesn't always increase
4 4
5 source $TESTDIR/helpers.sh
5 6 echo '[extensions]' >> $HGRCPATH
6 7 echo 'hgext.mq =' >> $HGRCPATH
7 8
8 9 hg init orig
9 10 cd orig
10 11
11 hidefilename()
12 {
13 sed -e 's/saving bundle to .*strip-backup/saving bundle to strip-backup/'
14 }
15
16 12 commit()
17 13 {
18 14 hg up -qC null
19 15 count=1
20 16 for i in "$@"; do
21 17 for f in $i; do
22 18 echo $count > $f
23 19 done
24 20 count=`expr $count + 1`
25 21 done
26 22 hg commit -qAm "$*"
27 23 }
28 24
29 25 # 2 1 0 2 0 1 2
30 26 commit '201 210'
31 27
32 28 commit '102 120' '210'
33 29
34 30 commit '021'
35 31
36 32 commit '201' '021 120'
37 33
38 34 commit '012 021' '102 201' '120 210'
39 35
40 36 commit 'manifest-file'
41 37
42 38 commit '102 120' '012 210' '021 201'
43 39
44 40 commit '201 210' '021 120' '012 102'
45 41
46 42 HGUSER=another-user; export HGUSER
47 43 commit 'manifest-file'
48 44
49 45 commit '012' 'manifest-file'
50 46
51 47 cd ..
52 48 hg clone -q -U -r -1 -r -2 -r -3 -r -4 -r -6 orig crossed
53 49
54 50 for i in crossed/.hg/store/00manifest.i crossed/.hg/store/data/*.i; do
55 51 echo $i
56 52 hg debugindex $i
57 53 echo
58 54 done
59 55
60 56 for i in 0 1 2 3 4; do
61 57 hg clone -q -U --pull crossed $i
62 58 echo "% Trying to strip revision $i"
63 hg --cwd $i strip $i 2>&1 | hidefilename
59 hg --cwd $i strip $i | hidebackup
64 60 echo "% Verifying"
65 61 hg --cwd $i verify
66 62 echo
67 63 done
68 64
@@ -1,114 +1,114 b''
1 1 crossed/.hg/store/00manifest.i
2 2 rev offset length base linkrev nodeid p1 p2
3 3 0 0 112 0 0 6f105cbb914d 000000000000 000000000000
4 4 1 112 56 1 3 1b55917b3699 000000000000 000000000000
5 5 2 168 123 1 1 8f3d04e263e5 000000000000 000000000000
6 6 3 291 122 1 2 f0ef8726ac4f 000000000000 000000000000
7 7 4 413 87 4 4 0b76e38b4070 000000000000 000000000000
8 8
9 9 crossed/.hg/store/data/012.i
10 10 rev offset length base linkrev nodeid p1 p2
11 11 0 0 3 0 0 b8e02f643373 000000000000 000000000000
12 12 1 3 3 1 1 5d9299349fc0 000000000000 000000000000
13 13 2 6 3 2 2 2661d26c6496 000000000000 000000000000
14 14
15 15 crossed/.hg/store/data/021.i
16 16 rev offset length base linkrev nodeid p1 p2
17 17 0 0 3 0 0 b8e02f643373 000000000000 000000000000
18 18 1 3 3 1 2 5d9299349fc0 000000000000 000000000000
19 19 2 6 3 2 1 2661d26c6496 000000000000 000000000000
20 20
21 21 crossed/.hg/store/data/102.i
22 22 rev offset length base linkrev nodeid p1 p2
23 23 0 0 3 0 1 b8e02f643373 000000000000 000000000000
24 24 1 3 3 1 0 5d9299349fc0 000000000000 000000000000
25 25 2 6 3 2 2 2661d26c6496 000000000000 000000000000
26 26
27 27 crossed/.hg/store/data/120.i
28 28 rev offset length base linkrev nodeid p1 p2
29 29 0 0 3 0 1 b8e02f643373 000000000000 000000000000
30 30 1 3 3 1 2 5d9299349fc0 000000000000 000000000000
31 31 2 6 3 2 0 2661d26c6496 000000000000 000000000000
32 32
33 33 crossed/.hg/store/data/201.i
34 34 rev offset length base linkrev nodeid p1 p2
35 35 0 0 3 0 2 b8e02f643373 000000000000 000000000000
36 36 1 3 3 1 0 5d9299349fc0 000000000000 000000000000
37 37 2 6 3 2 1 2661d26c6496 000000000000 000000000000
38 38
39 39 crossed/.hg/store/data/210.i
40 40 rev offset length base linkrev nodeid p1 p2
41 41 0 0 3 0 2 b8e02f643373 000000000000 000000000000
42 42 1 3 3 1 1 5d9299349fc0 000000000000 000000000000
43 43 2 6 3 2 0 2661d26c6496 000000000000 000000000000
44 44
45 45 crossed/.hg/store/data/manifest-file.i
46 46 rev offset length base linkrev nodeid p1 p2
47 47 0 0 3 0 3 b8e02f643373 000000000000 000000000000
48 48 1 3 3 1 4 5d9299349fc0 000000000000 000000000000
49 49
50 50 % Trying to strip revision 0
51 saving bundle to strip-backup/cbb8c2f0a2e3-backup
51 saved backup bundle to
52 52 adding branch
53 53 adding changesets
54 54 adding manifests
55 55 adding file changes
56 56 added 4 changesets with 15 changes to 7 files (+3 heads)
57 57 % Verifying
58 58 checking changesets
59 59 checking manifests
60 60 crosschecking files in changesets and manifests
61 61 checking files
62 62 7 files, 4 changesets, 15 total revisions
63 63
64 64 % Trying to strip revision 1
65 saving bundle to strip-backup/124ecc0cbec9-backup
65 saved backup bundle to
66 66 adding branch
67 67 adding changesets
68 68 adding manifests
69 69 adding file changes
70 70 added 3 changesets with 12 changes to 7 files (+3 heads)
71 71 % Verifying
72 72 checking changesets
73 73 checking manifests
74 74 crosschecking files in changesets and manifests
75 75 checking files
76 76 7 files, 4 changesets, 14 total revisions
77 77
78 78 % Trying to strip revision 2
79 saving bundle to strip-backup/f6439b304a1a-backup
79 saved backup bundle to
80 80 adding branch
81 81 adding changesets
82 82 adding manifests
83 83 adding file changes
84 84 added 2 changesets with 8 changes to 6 files (+2 heads)
85 85 % Verifying
86 86 checking changesets
87 87 checking manifests
88 88 crosschecking files in changesets and manifests
89 89 checking files
90 90 7 files, 4 changesets, 14 total revisions
91 91
92 92 % Trying to strip revision 3
93 saving bundle to strip-backup/6e54ec5db740-backup
93 saved backup bundle to
94 94 adding branch
95 95 adding changesets
96 96 adding manifests
97 97 adding file changes
98 98 added 1 changesets with 1 changes to 2 files (+1 heads)
99 99 % Verifying
100 100 checking changesets
101 101 checking manifests
102 102 crosschecking files in changesets and manifests
103 103 checking files
104 104 7 files, 4 changesets, 19 total revisions
105 105
106 106 % Trying to strip revision 4
107 saving bundle to strip-backup/9147ea23c156-backup
107 saved backup bundle to
108 108 % Verifying
109 109 checking changesets
110 110 checking manifests
111 111 crosschecking files in changesets and manifests
112 112 checking files
113 113 7 files, 4 changesets, 19 total revisions
114 114
General Comments 0
You need to be logged in to leave comments. Login now