##// END OF EJS Templates
rev-branch-cache: schedule a write of the "v2" format if we read from "v1"...
marmoute -
r52801:16efed18 default
parent child Browse files
Show More
@@ -1,416 +1,426
1 1 # rev_cache.py - caching branch information per revision
2 2 #
3 3 # This software may be used and distributed according to the terms of the
4 4 # GNU General Public License version 2 or any later version.
5 5 from __future__ import annotations
6 6
7 7 import os
8 8 import struct
9 9
10 10 from ..node import (
11 11 nullrev,
12 12 )
13 13
14 14 from .. import (
15 15 encoding,
16 16 error,
17 17 util,
18 18 )
19 19
20 20 from ..utils import (
21 21 stringutil,
22 22 )
23 23
24 24 calcsize = struct.calcsize
25 25 pack_into = struct.pack_into
26 26 unpack_from = struct.unpack_from
27 27
28 28
29 29 # Revision branch info cache
30 30
31 31 # The "V2" version use the same format as the "V1" but garantee it won't be
32 32 # truncated, preventing SIGBUS when it is mmap-ed
33 33 _rbcversion = b'-v2'
34 34 _rbcnames = b'rbc-names' + _rbcversion
35 35 _rbcrevs = b'rbc-revs' + _rbcversion
36 36 _rbc_legacy_version = b'-v1'
37 37 _rbc_legacy_names = b'rbc-names' + _rbc_legacy_version
38 38 _rbc_legacy_revs = b'rbc-revs' + _rbc_legacy_version
39 39 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open]
40 40 _rbcrecfmt = b'>4sI'
41 41 _rbcrecsize = calcsize(_rbcrecfmt)
42 42 _rbcmininc = 64 * _rbcrecsize
43 43 _rbcnodelen = 4
44 44 _rbcbranchidxmask = 0x7FFFFFFF
45 45 _rbccloseflag = 0x80000000
46 46
47 47
48 48 # with atomic replacement.
49 49 REWRITE_RATIO = 0.2
50 50
51 51
52 52 class rbcrevs:
53 53 """a byte string consisting of an immutable prefix followed by a mutable suffix"""
54 54
55 55 def __init__(self, revs):
56 56 self._prefix = revs
57 57 self._rest = bytearray()
58 58
59 59 def __len__(self):
60 60 return len(self._prefix) + len(self._rest)
61 61
62 62 def unpack_record(self, rbcrevidx):
63 63 if rbcrevidx < len(self._prefix):
64 64 return unpack_from(_rbcrecfmt, util.buffer(self._prefix), rbcrevidx)
65 65 else:
66 66 return unpack_from(
67 67 _rbcrecfmt,
68 68 util.buffer(self._rest),
69 69 rbcrevidx - len(self._prefix),
70 70 )
71 71
72 72 def make_mutable(self):
73 73 if len(self._prefix) > 0:
74 74 entirety = bytearray()
75 75 entirety[:] = self._prefix
76 76 entirety.extend(self._rest)
77 77 self._rest = entirety
78 78 self._prefix = bytearray()
79 79
80 80 def truncate(self, pos):
81 81 self.make_mutable()
82 82 del self._rest[pos:]
83 83
84 84 def pack_into(self, rbcrevidx, node, branchidx):
85 85 if rbcrevidx < len(self._prefix):
86 86 self.make_mutable()
87 87 buf = self._rest
88 88 start_offset = rbcrevidx - len(self._prefix)
89 89 end_offset = start_offset + _rbcrecsize
90 90
91 91 if len(self._rest) < end_offset:
92 92 # bytearray doesn't allocate extra space at least in Python 3.7.
93 93 # When multiple changesets are added in a row, precise resize would
94 94 # result in quadratic complexity. Overallocate to compensate by
95 95 # using the classic doubling technique for dynamic arrays instead.
96 96 # If there was a gap in the map before, less space will be reserved.
97 97 self._rest.extend(b'\0' * end_offset)
98 98 return pack_into(
99 99 _rbcrecfmt,
100 100 buf,
101 101 start_offset,
102 102 node,
103 103 branchidx,
104 104 )
105 105
106 106 def extend(self, extension):
107 107 return self._rest.extend(extension)
108 108
109 109 def slice(self, begin, end):
110 110 if begin < len(self._prefix):
111 111 acc = bytearray()
112 112 acc[:] = self._prefix[begin:end]
113 113 acc.extend(
114 114 self._rest[begin - len(self._prefix) : end - len(self._prefix)]
115 115 )
116 116 return acc
117 117 return self._rest[begin - len(self._prefix) : end - len(self._prefix)]
118 118
119 119
120 120 class revbranchcache:
121 121 """Persistent cache, mapping from revision number to branch name and close.
122 122 This is a low level cache, independent of filtering.
123 123
124 124 Branch names are stored in rbc-names in internal encoding separated by 0.
125 125 rbc-names is append-only, and each branch name is only stored once and will
126 126 thus have a unique index.
127 127
128 128 The branch info for each revision is stored in rbc-revs as constant size
129 129 records. The whole file is read into memory, but it is only 'parsed' on
130 130 demand. The file is usually append-only but will be truncated if repo
131 131 modification is detected.
132 132 The record for each revision contains the first 4 bytes of the
133 133 corresponding node hash, and the record is only used if it still matches.
134 134 Even a completely trashed rbc-revs fill thus still give the right result
135 135 while converging towards full recovery ... assuming no incorrectly matching
136 136 node hashes.
137 137 The record also contains 4 bytes where 31 bits contains the index of the
138 138 branch and the last bit indicate that it is a branch close commit.
139 139 The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i
140 140 and will grow with it but be 1/8th of its size.
141 141 """
142 142
143 143 def __init__(self, repo, readonly=True):
144 144 assert repo.filtername is None
145 145 self._repo = repo
146 146 self._names = [] # branch names in local encoding with static index
147 147 self._rbcrevs = rbcrevs(bytearray())
148 148 self._rbcsnameslen = 0 # length of names read at _rbcsnameslen
149 self._force_overwrite = False
149 150 v1_fallback = False
150 151 try:
151 152 try:
152 153 bndata = repo.cachevfs.read(_rbcnames)
153 154 except (IOError, OSError):
154 155 # If we don't have "v2" data, we might have "v1" data worth
155 156 # using.
156 157 #
157 158 # consider stop doing this many version after hg-6.9 release
158 159 bndata = repo.cachevfs.read(_rbc_legacy_names)
159 160 v1_fallback = True
161 self._force_overwrite = True
160 162 self._rbcsnameslen = len(bndata) # for verification before writing
161 163 if bndata:
162 164 self._names = [
163 165 encoding.tolocal(bn) for bn in bndata.split(b'\0')
164 166 ]
165 167 except (IOError, OSError):
166 168 if readonly:
167 169 # don't try to use cache - fall back to the slow path
168 170 self.branchinfo = self._branchinfo
169 171
170 172 if self._names:
171 173 try:
172 174 usemmap = repo.ui.configbool(b'storage', b'revbranchcache.mmap')
173 175 if not v1_fallback:
174 176 with repo.cachevfs(_rbcrevs) as fp:
175 177 if usemmap and repo.cachevfs.is_mmap_safe(_rbcrevs):
176 178 data = util.buffer(util.mmapread(fp))
177 179 else:
178 180 data = fp.read()
179 181 else:
180 182 # If we don't have "v2" data, we might have "v1" data worth
181 183 # using.
182 184 #
183 185 # Consider stop doing this many version after hg-6.9
184 186 # release.
185 187 with repo.cachevfs(_rbc_legacy_revs) as fp:
186 188 data = fp.read()
187 189 self._rbcrevs = rbcrevs(data)
188 190 except (IOError, OSError) as inst:
189 191 repo.ui.debug(
190 192 b"couldn't read revision branch cache: %s\n"
191 193 % stringutil.forcebytestr(inst)
192 194 )
193 195 # remember number of good records on disk
194 196 self._rbcrevslen = min(
195 197 len(self._rbcrevs) // _rbcrecsize, len(repo.changelog)
196 198 )
197 199 if self._rbcrevslen == 0:
198 200 self._names = []
199 201 self._rbcnamescount = len(self._names) # number of names read at
200 202 # _rbcsnameslen
201 self._force_overwrite = False
202 203
203 204 def _clear(self):
204 205 self._rbcsnameslen = 0
205 206 del self._names[:]
206 207 self._rbcnamescount = 0
207 208 self._rbcrevslen = len(self._repo.changelog)
208 209 self._rbcrevs = rbcrevs(bytearray(self._rbcrevslen * _rbcrecsize))
209 210 util.clearcachedproperty(self, b'_namesreverse')
210 211 self._force_overwrite = True
211 212
212 213 def invalidate(self, rev=0):
213 214 self._rbcrevslen = rev
214 215 self._rbcrevs.truncate(rev)
215 216 self._force_overwrite = True
216 217
217 218 @util.propertycache
218 219 def _namesreverse(self):
219 220 return {b: r for r, b in enumerate(self._names)}
220 221
221 222 def branchinfo(self, rev):
222 223 """Return branch name and close flag for rev, using and updating
223 224 persistent cache."""
224 225 changelog = self._repo.changelog
225 226 rbcrevidx = rev * _rbcrecsize
226 227
227 228 # avoid negative index, changelog.read(nullrev) is fast without cache
228 229 if rev == nullrev:
229 230 return changelog.branchinfo(rev)
230 231
231 232 # if requested rev isn't allocated, grow and cache the rev info
232 233 if len(self._rbcrevs) < rbcrevidx + _rbcrecsize:
233 234 return self._branchinfo(rev)
234 235
235 236 # fast path: extract data from cache, use it if node is matching
236 237 reponode = changelog.node(rev)[:_rbcnodelen]
237 238 cachenode, branchidx = self._rbcrevs.unpack_record(rbcrevidx)
238 239 close = bool(branchidx & _rbccloseflag)
239 240 if close:
240 241 branchidx &= _rbcbranchidxmask
241 242 if cachenode == b'\0\0\0\0':
242 243 pass
243 244 elif cachenode == reponode:
244 245 try:
245 246 return self._names[branchidx], close
246 247 except IndexError:
247 248 # recover from invalid reference to unknown branch
248 249 self._repo.ui.debug(
249 250 b"referenced branch names not found"
250 251 b" - rebuilding revision branch cache from scratch\n"
251 252 )
252 253 self._clear()
253 254 else:
254 255 # rev/node map has changed, invalidate the cache from here up
255 256 self._repo.ui.debug(
256 257 b"history modification detected - truncating "
257 258 b"revision branch cache to revision %d\n" % rev
258 259 )
259 260 truncate = rbcrevidx + _rbcrecsize
260 261 self._rbcrevs.truncate(truncate)
261 262 self._rbcrevslen = min(self._rbcrevslen, truncate)
262 263
263 264 # fall back to slow path and make sure it will be written to disk
264 265 return self._branchinfo(rev)
265 266
266 267 def _branchinfo(self, rev):
267 268 """Retrieve branch info from changelog and update _rbcrevs"""
268 269 changelog = self._repo.changelog
269 270 b, close = changelog.branchinfo(rev)
270 271 if b in self._namesreverse:
271 272 branchidx = self._namesreverse[b]
272 273 else:
273 274 branchidx = len(self._names)
274 275 self._names.append(b)
275 276 self._namesreverse[b] = branchidx
276 277 reponode = changelog.node(rev)
277 278 if close:
278 279 branchidx |= _rbccloseflag
279 280 self._setcachedata(rev, reponode, branchidx)
280 281 return b, close
281 282
282 283 def setdata(self, rev, changelogrevision):
283 284 """add new data information to the cache"""
284 285 branch, close = changelogrevision.branchinfo
285 286
286 287 if branch in self._namesreverse:
287 288 branchidx = self._namesreverse[branch]
288 289 else:
289 290 branchidx = len(self._names)
290 291 self._names.append(branch)
291 292 self._namesreverse[branch] = branchidx
292 293 if close:
293 294 branchidx |= _rbccloseflag
294 295 self._setcachedata(rev, self._repo.changelog.node(rev), branchidx)
295 296 # If no cache data were readable (non exists, bad permission, etc)
296 297 # the cache was bypassing itself by setting:
297 298 #
298 299 # self.branchinfo = self._branchinfo
299 300 #
300 301 # Since we now have data in the cache, we need to drop this bypassing.
301 302 if 'branchinfo' in vars(self):
302 303 del self.branchinfo
303 304
304 305 def _setcachedata(self, rev, node, branchidx):
305 306 """Writes the node's branch data to the in-memory cache data."""
306 307 if rev == nullrev:
307 308 return
308 309 rbcrevidx = rev * _rbcrecsize
309 310 self._rbcrevs.pack_into(rbcrevidx, node, branchidx)
310 311 self._rbcrevslen = min(self._rbcrevslen, rev)
311 312
312 313 tr = self._repo.currenttransaction()
313 314 if tr:
314 315 tr.addfinalize(b'write-revbranchcache', self.write)
315 316
316 317 def write(self, tr=None):
317 318 """Save branch cache if it is dirty."""
318 319 repo = self._repo
319 320 wlock = None
320 321 step = b''
321 322 try:
322 323 # write the new names
323 if self._rbcnamescount < len(self._names):
324 if self._force_overwrite or self._rbcnamescount < len(self._names):
324 325 wlock = repo.wlock(wait=False)
325 326 step = b' names'
326 327 self._writenames(repo)
327 328
328 329 # write the new revs
329 330 start = self._rbcrevslen * _rbcrecsize
330 331 if self._force_overwrite or start != len(self._rbcrevs):
331 332 step = b''
332 333 if wlock is None:
333 334 wlock = repo.wlock(wait=False)
334 335 self._writerevs(repo, start)
335 336
336 337 except (IOError, OSError, error.Abort, error.LockError) as inst:
337 338 repo.ui.debug(
338 339 b"couldn't write revision branch cache%s: %s\n"
339 340 % (step, stringutil.forcebytestr(inst))
340 341 )
341 342 finally:
342 343 if wlock is not None:
343 344 wlock.release()
344 345
345 346 def _writenames(self, repo):
346 347 """write the new branch names to revbranchcache"""
347 348 f = None
349 if self._force_overwrite:
350 self._rbcsnameslen = 0
351 self._rbcnamescount = 0
348 352 try:
349 if self._rbcnamescount != 0:
353 if self._force_overwrite or self._rbcnamescount != 0:
350 354 f = repo.cachevfs.open(_rbcnames, b'ab')
351 if f.tell() == self._rbcsnameslen:
355 current_size = f.tell()
356 if current_size == self._rbcsnameslen:
352 357 f.write(b'\0')
353 358 else:
354 359 f.close()
355 f = None
356 repo.ui.debug(b"%s changed - rewriting it\n" % _rbcnames)
360 if self._force_overwrite:
361 dbg = b"resetting content of %s\n"
362 elif current_size > 0:
363 dbg = b"%s changed - rewriting it\n"
364 else:
365 dbg = b"%s is missing - rewriting it\n"
366 repo.ui.debug(dbg % _rbcnames)
357 367 self._rbcnamescount = 0
358 368 self._rbcrevslen = 0
359 369 if self._rbcnamescount == 0:
360 370 # before rewriting names, make sure references are removed
361 371 repo.cachevfs.unlinkpath(_rbcrevs, ignoremissing=True)
362 372 f = repo.cachevfs.open(_rbcnames, b'wb')
363 373 names = self._names[self._rbcnamescount :]
364 374 from_local = encoding.fromlocal
365 375 data = b'\0'.join(from_local(b) for b in names)
366 376 f.write(data)
367 377 self._rbcsnameslen = f.tell()
368 378 finally:
369 379 if f is not None:
370 380 f.close()
371 381 self._rbcnamescount = len(self._names)
372 382
373 383 def _writerevs(self, repo, start):
374 384 """write the new revs to revbranchcache"""
375 385 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize)
376 386
377 387 end = revs * _rbcrecsize
378 388 if self._force_overwrite:
379 389 start = 0
380 390
381 391 with repo.cachevfs.open(_rbcrevs, b'a+b') as f:
382 392 pass # this make sure the file exist…
383 393 with repo.cachevfs.open(_rbcrevs, b'r+b') as f:
384 394 f.seek(0, os.SEEK_END)
385 395 current_size = f.tell()
386 396 if current_size < start:
387 397 start = 0
388 398 if current_size != start:
389 399 threshold = current_size * REWRITE_RATIO
390 400 if (max(end, current_size) - start) < threshold:
391 401 # end affected, let overwrite the bad value
392 402 dbg = b"overwriting %d bytes from %d in cache/%s"
393 403 dbg %= (current_size - start, start, _rbcrevs)
394 404 if end < current_size:
395 405 extra = b" leaving (%d trailing bytes)"
396 406 extra %= current_size - end
397 407 dbg += extra
398 408 dbg += b'\n'
399 409 repo.ui.debug(dbg)
400 410 else:
401 411 start = 0
402 412 dbg = b"resetting content of cache/%s\n" % _rbcrevs
403 413 repo.ui.debug(dbg)
404 414 if start > 0:
405 415 f.seek(start)
406 416 f.write(self._rbcrevs.slice(start, end))
407 417 else:
408 418 f.close()
409 419 with repo.cachevfs.open(
410 420 _rbcrevs,
411 421 b'wb',
412 422 atomictemp=True,
413 423 ) as rev_file:
414 424 rev_file.write(self._rbcrevs.slice(start, end))
415 425 self._rbcrevslen = revs
416 426 self._force_overwrite = False
@@ -1,1447 +1,1454
1 1 #testcases mmap nommap
2 2 #testcases v2 v3
3 3
4 4 #if mmap
5 5 $ cat <<EOF >> $HGRCPATH
6 6 > [storage]
7 7 > revbranchcache.mmap=true
8 8 > EOF
9 9 #endif
10 10
11 11 #if v3
12 12 $ cat <<EOF >> $HGRCPATH
13 13 > [experimental]
14 14 > branch-cache-v3=yes
15 15 > EOF
16 16 #else
17 17 $ cat <<EOF >> $HGRCPATH
18 18 > [experimental]
19 19 > branch-cache-v3=no
20 20 > EOF
21 21 #endif
22 22
23 23 $ hg init a
24 24 $ cd a
25 25
26 26 Verify checking branch of nullrev before the cache is created doesnt crash
27 27 $ hg log -r 'branch(.)' -T '{branch}\n'
28 28
29 29 Basic test
30 30 $ echo 'root' >root
31 31 $ hg add root
32 32 $ hg commit -d '0 0' -m "Adding root node"
33 33
34 34 $ echo 'a' >a
35 35 $ hg add a
36 36 $ hg branch a
37 37 marked working directory as branch a
38 38 (branches are permanent and global, did you want a bookmark?)
39 39 $ hg commit -d '1 0' -m "Adding a branch"
40 40
41 41 $ hg branch q
42 42 marked working directory as branch q
43 43 $ echo 'aa' >a
44 44 $ hg branch -C
45 45 reset working directory to branch a
46 46 $ hg commit -d '2 0' -m "Adding to a branch"
47 47
48 48 $ hg update -C 0
49 49 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
50 50 $ echo 'b' >b
51 51 $ hg add b
52 52 $ hg branch b
53 53 marked working directory as branch b
54 54 $ hg commit -d '2 0' -m "Adding b branch"
55 55
56 56 $ echo 'bh1' >bh1
57 57 $ hg add bh1
58 58 $ hg commit -d '3 0' -m "Adding b branch head 1"
59 59
60 60 $ hg update -C 2
61 61 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
62 62 $ echo 'bh2' >bh2
63 63 $ hg add bh2
64 64 $ hg commit -d '4 0' -m "Adding b branch head 2"
65 65
66 66 $ echo 'c' >c
67 67 $ hg add c
68 68 $ hg branch c
69 69 marked working directory as branch c
70 70 $ hg commit -d '5 0' -m "Adding c branch"
71 71
72 72 reserved names
73 73
74 74 $ hg branch tip
75 75 abort: the name 'tip' is reserved
76 76 [10]
77 77 $ hg branch null
78 78 abort: the name 'null' is reserved
79 79 [10]
80 80 $ hg branch .
81 81 abort: the name '.' is reserved
82 82 [10]
83 83
84 84 invalid characters
85 85
86 86 $ hg branch 'foo:bar'
87 87 abort: ':' cannot be used in a name
88 88 [10]
89 89
90 90 $ hg branch 'foo
91 91 > bar'
92 92 abort: '\n' cannot be used in a name
93 93 [10]
94 94
95 95 trailing or leading spaces should be stripped before testing duplicates
96 96
97 97 $ hg branch 'b '
98 98 abort: a branch of the same name already exists
99 99 (use 'hg update' to switch to it)
100 100 [10]
101 101
102 102 $ hg branch ' b'
103 103 abort: a branch of the same name already exists
104 104 (use 'hg update' to switch to it)
105 105 [10]
106 106
107 107 underscores in numeric branch names (issue6737)
108 108
109 109 $ hg branch 2700_210
110 110 marked working directory as branch 2700_210
111 111
112 112 verify update will accept invalid legacy branch names
113 113
114 114 $ hg init test-invalid-branch-name
115 115 $ cd test-invalid-branch-name
116 116 $ hg unbundle -u "$TESTDIR"/bundles/test-invalid-branch-name.hg
117 117 adding changesets
118 118 adding manifests
119 119 adding file changes
120 120 added 3 changesets with 3 changes to 2 files
121 121 new changesets f0e4c7f04036:33c2ceb9310b (3 drafts)
122 122 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
123 123
124 124 $ hg update '"colon:test"'
125 125 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
126 126 $ cd ..
127 127
128 128 $ echo 'd' >d
129 129 $ hg add d
130 130 $ hg branch 'a branch name much longer than the default justification used by branches'
131 131 marked working directory as branch a branch name much longer than the default justification used by branches
132 132 $ hg commit -d '6 0' -m "Adding d branch"
133 133
134 134 $ hg branches
135 135 a branch name much longer than the default justification used by branches 7:10ff5895aa57
136 136 b 4:aee39cd168d0
137 137 c 6:589736a22561 (inactive)
138 138 a 5:d8cbc61dbaa6 (inactive)
139 139 default 0:19709c5a4e75 (inactive)
140 140
141 141 -------
142 142
143 143 $ hg branches -a
144 144 a branch name much longer than the default justification used by branches 7:10ff5895aa57
145 145 b 4:aee39cd168d0
146 146
147 147 --- Branch a
148 148
149 149 $ hg log -b a
150 150 changeset: 5:d8cbc61dbaa6
151 151 branch: a
152 152 parent: 2:881fe2b92ad0
153 153 user: test
154 154 date: Thu Jan 01 00:00:04 1970 +0000
155 155 summary: Adding b branch head 2
156 156
157 157 changeset: 2:881fe2b92ad0
158 158 branch: a
159 159 user: test
160 160 date: Thu Jan 01 00:00:02 1970 +0000
161 161 summary: Adding to a branch
162 162
163 163 changeset: 1:dd6b440dd85a
164 164 branch: a
165 165 user: test
166 166 date: Thu Jan 01 00:00:01 1970 +0000
167 167 summary: Adding a branch
168 168
169 169
170 170 ---- Branch b
171 171
172 172 $ hg log -b b
173 173 changeset: 4:aee39cd168d0
174 174 branch: b
175 175 user: test
176 176 date: Thu Jan 01 00:00:03 1970 +0000
177 177 summary: Adding b branch head 1
178 178
179 179 changeset: 3:ac22033332d1
180 180 branch: b
181 181 parent: 0:19709c5a4e75
182 182 user: test
183 183 date: Thu Jan 01 00:00:02 1970 +0000
184 184 summary: Adding b branch
185 185
186 186
187 187 ---- going to test branch listing by rev
188 188 $ hg branches -r0
189 189 default 0:19709c5a4e75 (inactive)
190 190 $ hg branches -qr0
191 191 default
192 192 --- now more than one rev
193 193 $ hg branches -r2:5
194 194 b 4:aee39cd168d0
195 195 a 5:d8cbc61dbaa6 (inactive)
196 196 $ hg branches -qr2:5
197 197 b
198 198 a
199 199 ---- going to test branch closing
200 200
201 201 $ hg branches
202 202 a branch name much longer than the default justification used by branches 7:10ff5895aa57
203 203 b 4:aee39cd168d0
204 204 c 6:589736a22561 (inactive)
205 205 a 5:d8cbc61dbaa6 (inactive)
206 206 default 0:19709c5a4e75 (inactive)
207 207 $ hg up -C b
208 208 2 files updated, 0 files merged, 4 files removed, 0 files unresolved
209 209 $ echo 'xxx1' >> b
210 210 $ hg commit -d '7 0' -m 'adding cset to branch b'
211 211 $ hg up -C aee39cd168d0
212 212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 213 $ echo 'xxx2' >> b
214 214 $ hg commit -d '8 0' -m 'adding head to branch b'
215 215 created new head
216 216 $ echo 'xxx3' >> b
217 217 $ hg commit -d '9 0' -m 'adding another cset to branch b'
218 218 $ hg branches
219 219 b 10:bfbe841b666e
220 220 a branch name much longer than the default justification used by branches 7:10ff5895aa57
221 221 c 6:589736a22561 (inactive)
222 222 a 5:d8cbc61dbaa6 (inactive)
223 223 default 0:19709c5a4e75 (inactive)
224 224 $ hg heads --closed
225 225 changeset: 10:bfbe841b666e
226 226 branch: b
227 227 tag: tip
228 228 user: test
229 229 date: Thu Jan 01 00:00:09 1970 +0000
230 230 summary: adding another cset to branch b
231 231
232 232 changeset: 8:eebb944467c9
233 233 branch: b
234 234 parent: 4:aee39cd168d0
235 235 user: test
236 236 date: Thu Jan 01 00:00:07 1970 +0000
237 237 summary: adding cset to branch b
238 238
239 239 changeset: 7:10ff5895aa57
240 240 branch: a branch name much longer than the default justification used by branches
241 241 user: test
242 242 date: Thu Jan 01 00:00:06 1970 +0000
243 243 summary: Adding d branch
244 244
245 245 changeset: 6:589736a22561
246 246 branch: c
247 247 user: test
248 248 date: Thu Jan 01 00:00:05 1970 +0000
249 249 summary: Adding c branch
250 250
251 251 changeset: 5:d8cbc61dbaa6
252 252 branch: a
253 253 parent: 2:881fe2b92ad0
254 254 user: test
255 255 date: Thu Jan 01 00:00:04 1970 +0000
256 256 summary: Adding b branch head 2
257 257
258 258 changeset: 0:19709c5a4e75
259 259 user: test
260 260 date: Thu Jan 01 00:00:00 1970 +0000
261 261 summary: Adding root node
262 262
263 263 $ hg heads
264 264 changeset: 10:bfbe841b666e
265 265 branch: b
266 266 tag: tip
267 267 user: test
268 268 date: Thu Jan 01 00:00:09 1970 +0000
269 269 summary: adding another cset to branch b
270 270
271 271 changeset: 8:eebb944467c9
272 272 branch: b
273 273 parent: 4:aee39cd168d0
274 274 user: test
275 275 date: Thu Jan 01 00:00:07 1970 +0000
276 276 summary: adding cset to branch b
277 277
278 278 changeset: 7:10ff5895aa57
279 279 branch: a branch name much longer than the default justification used by branches
280 280 user: test
281 281 date: Thu Jan 01 00:00:06 1970 +0000
282 282 summary: Adding d branch
283 283
284 284 changeset: 6:589736a22561
285 285 branch: c
286 286 user: test
287 287 date: Thu Jan 01 00:00:05 1970 +0000
288 288 summary: Adding c branch
289 289
290 290 changeset: 5:d8cbc61dbaa6
291 291 branch: a
292 292 parent: 2:881fe2b92ad0
293 293 user: test
294 294 date: Thu Jan 01 00:00:04 1970 +0000
295 295 summary: Adding b branch head 2
296 296
297 297 changeset: 0:19709c5a4e75
298 298 user: test
299 299 date: Thu Jan 01 00:00:00 1970 +0000
300 300 summary: Adding root node
301 301
302 302 $ hg commit -d '9 0' --close-branch -m 'prune bad branch'
303 303 $ hg branches -a
304 304 b 8:eebb944467c9
305 305 a branch name much longer than the default justification used by branches 7:10ff5895aa57
306 306 $ hg up -C b
307 307 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
308 308 $ hg commit -d '9 0' --close-branch -m 'close this part branch too'
309 309 $ hg commit -d '9 0' --close-branch -m 're-closing this branch'
310 310 abort: current revision is already a branch closing head
311 311 [10]
312 312
313 313 $ echo foo > b
314 314 $ hg commit -d '9 0' --close-branch -m 're-closing this branch'
315 315
316 316 $ echo bar > b
317 317 $ hg commit -d '9 0' --close-branch -m 're-closing this branch' bh1
318 318 abort: current revision is already a branch closing head
319 319 [10]
320 320 $ hg commit -d '9 0' --close-branch -m 're-closing this branch' b
321 321
322 322 $ echo baz > b
323 323 $ hg commit -d '9 0' --close-branch -m 'empty re-closing this branch' -X b
324 324 abort: current revision is already a branch closing head
325 325 [10]
326 326 $ hg revert b
327 327
328 328 $ hg debugstrip --rev 13: --no-backup
329 329 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
330 330 $ hg revert --all --no-backup
331 331
332 332 $ hg log -r tip --debug
333 333 changeset: 12:e3d49c0575d8fc2cb1cd6859c747c14f5f6d499f
334 334 branch: b
335 335 tag: tip
336 336 phase: draft
337 337 parent: 8:eebb944467c9fb9651ed232aeaf31b3c0a7fc6c1
338 338 parent: -1:0000000000000000000000000000000000000000
339 339 manifest: 8:6f9ed32d2b310e391a4f107d5f0f071df785bfee
340 340 user: test
341 341 date: Thu Jan 01 00:00:09 1970 +0000
342 342 extra: branch=b
343 343 extra: close=1
344 344 description:
345 345 close this part branch too
346 346
347 347
348 348 --- b branch should be inactive
349 349
350 350 $ hg branches
351 351 a branch name much longer than the default justification used by branches 7:10ff5895aa57
352 352 c 6:589736a22561 (inactive)
353 353 a 5:d8cbc61dbaa6 (inactive)
354 354 default 0:19709c5a4e75 (inactive)
355 355 $ hg branches -c
356 356 a branch name much longer than the default justification used by branches 7:10ff5895aa57
357 357 b 12:e3d49c0575d8 (closed)
358 358 c 6:589736a22561 (inactive)
359 359 a 5:d8cbc61dbaa6 (inactive)
360 360 default 0:19709c5a4e75 (inactive)
361 361 $ hg branches -a
362 362 a branch name much longer than the default justification used by branches 7:10ff5895aa57
363 363 $ hg branches -q
364 364 a branch name much longer than the default justification used by branches
365 365 c
366 366 a
367 367 default
368 368 $ hg heads b
369 369 no open branch heads found on branches b
370 370 [1]
371 371 $ hg heads --closed b
372 372 changeset: 12:e3d49c0575d8
373 373 branch: b
374 374 tag: tip
375 375 parent: 8:eebb944467c9
376 376 user: test
377 377 date: Thu Jan 01 00:00:09 1970 +0000
378 378 summary: close this part branch too
379 379
380 380 changeset: 11:d3f163457ebf
381 381 branch: b
382 382 user: test
383 383 date: Thu Jan 01 00:00:09 1970 +0000
384 384 summary: prune bad branch
385 385
386 386 $ echo 'xxx4' >> b
387 387 $ hg commit -d '9 0' -m 'reopen branch with a change'
388 388 reopening closed branch head 12
389 389
390 390 --- branch b is back in action
391 391
392 392 $ hg branches -a
393 393 b 13:e23b5505d1ad
394 394 a branch name much longer than the default justification used by branches 7:10ff5895aa57
395 395
396 396 ---- test heads listings
397 397
398 398 $ hg heads
399 399 changeset: 13:e23b5505d1ad
400 400 branch: b
401 401 tag: tip
402 402 user: test
403 403 date: Thu Jan 01 00:00:09 1970 +0000
404 404 summary: reopen branch with a change
405 405
406 406 changeset: 7:10ff5895aa57
407 407 branch: a branch name much longer than the default justification used by branches
408 408 user: test
409 409 date: Thu Jan 01 00:00:06 1970 +0000
410 410 summary: Adding d branch
411 411
412 412 changeset: 6:589736a22561
413 413 branch: c
414 414 user: test
415 415 date: Thu Jan 01 00:00:05 1970 +0000
416 416 summary: Adding c branch
417 417
418 418 changeset: 5:d8cbc61dbaa6
419 419 branch: a
420 420 parent: 2:881fe2b92ad0
421 421 user: test
422 422 date: Thu Jan 01 00:00:04 1970 +0000
423 423 summary: Adding b branch head 2
424 424
425 425 changeset: 0:19709c5a4e75
426 426 user: test
427 427 date: Thu Jan 01 00:00:00 1970 +0000
428 428 summary: Adding root node
429 429
430 430
431 431 branch default
432 432
433 433 $ hg heads default
434 434 changeset: 0:19709c5a4e75
435 435 user: test
436 436 date: Thu Jan 01 00:00:00 1970 +0000
437 437 summary: Adding root node
438 438
439 439
440 440 branch a
441 441
442 442 $ hg heads a
443 443 changeset: 5:d8cbc61dbaa6
444 444 branch: a
445 445 parent: 2:881fe2b92ad0
446 446 user: test
447 447 date: Thu Jan 01 00:00:04 1970 +0000
448 448 summary: Adding b branch head 2
449 449
450 450 $ hg heads --active a
451 451 no open branch heads found on branches a
452 452 [1]
453 453
454 454 branch b
455 455
456 456 $ hg heads b
457 457 changeset: 13:e23b5505d1ad
458 458 branch: b
459 459 tag: tip
460 460 user: test
461 461 date: Thu Jan 01 00:00:09 1970 +0000
462 462 summary: reopen branch with a change
463 463
464 464 $ hg heads --closed b
465 465 changeset: 13:e23b5505d1ad
466 466 branch: b
467 467 tag: tip
468 468 user: test
469 469 date: Thu Jan 01 00:00:09 1970 +0000
470 470 summary: reopen branch with a change
471 471
472 472 changeset: 11:d3f163457ebf
473 473 branch: b
474 474 user: test
475 475 date: Thu Jan 01 00:00:09 1970 +0000
476 476 summary: prune bad branch
477 477
478 478
479 479 reclose branch
480 480
481 481 $ hg up -C c
482 482 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
483 483 $ hg commit -d '9 0' --close-branch -m 'reclosing this branch'
484 484 $ hg branches
485 485 b 13:e23b5505d1ad
486 486 a branch name much longer than the default justification used by branches 7:10ff5895aa57
487 487 a 5:d8cbc61dbaa6 (inactive)
488 488 default 0:19709c5a4e75 (inactive)
489 489 $ hg branches --closed
490 490 b 13:e23b5505d1ad
491 491 a branch name much longer than the default justification used by branches 7:10ff5895aa57
492 492 c 14:f894c25619d3 (closed)
493 493 a 5:d8cbc61dbaa6 (inactive)
494 494 default 0:19709c5a4e75 (inactive)
495 495
496 496 multihead branch
497 497
498 498 $ hg up -C default
499 499 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
500 500 $ hg branch m
501 501 marked working directory as branch m
502 502 $ touch m
503 503 $ hg add m
504 504 $ hg commit -d '10 0' -m 'multihead base'
505 505 $ echo "m1" >m
506 506 $ hg commit -d '10 0' -m 'head 1'
507 507 $ hg up -C '.^'
508 508 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
509 509 $ echo "m2" >m
510 510 $ hg commit -d '10 0' -m 'head 2'
511 511 created new head
512 512 $ hg log -b m
513 513 changeset: 17:df343b0df04f
514 514 branch: m
515 515 tag: tip
516 516 parent: 15:f3447637f53e
517 517 user: test
518 518 date: Thu Jan 01 00:00:10 1970 +0000
519 519 summary: head 2
520 520
521 521 changeset: 16:a58ca5d3bdf3
522 522 branch: m
523 523 user: test
524 524 date: Thu Jan 01 00:00:10 1970 +0000
525 525 summary: head 1
526 526
527 527 changeset: 15:f3447637f53e
528 528 branch: m
529 529 parent: 0:19709c5a4e75
530 530 user: test
531 531 date: Thu Jan 01 00:00:10 1970 +0000
532 532 summary: multihead base
533 533
534 534 $ hg heads --topo m
535 535 changeset: 17:df343b0df04f
536 536 branch: m
537 537 tag: tip
538 538 parent: 15:f3447637f53e
539 539 user: test
540 540 date: Thu Jan 01 00:00:10 1970 +0000
541 541 summary: head 2
542 542
543 543 changeset: 16:a58ca5d3bdf3
544 544 branch: m
545 545 user: test
546 546 date: Thu Jan 01 00:00:10 1970 +0000
547 547 summary: head 1
548 548
549 549 $ hg branches
550 550 m 17:df343b0df04f
551 551 b 13:e23b5505d1ad
552 552 a branch name much longer than the default justification used by branches 7:10ff5895aa57
553 553 a 5:d8cbc61dbaa6 (inactive)
554 554 default 0:19709c5a4e75 (inactive)
555 555
556 556 partially merge multihead branch
557 557
558 558 $ hg up -C default
559 559 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
560 560 $ hg branch md
561 561 marked working directory as branch md
562 562 $ hg merge m
563 563 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
564 564 (branch merge, don't forget to commit)
565 565 $ hg commit -d '11 0' -m 'merge head 2'
566 566 $ hg heads --topo m
567 567 changeset: 16:a58ca5d3bdf3
568 568 branch: m
569 569 user: test
570 570 date: Thu Jan 01 00:00:10 1970 +0000
571 571 summary: head 1
572 572
573 573 $ hg branches
574 574 md 18:c914c99f1fbb
575 575 m 17:df343b0df04f
576 576 b 13:e23b5505d1ad
577 577 a branch name much longer than the default justification used by branches 7:10ff5895aa57
578 578 a 5:d8cbc61dbaa6 (inactive)
579 579 default 0:19709c5a4e75 (inactive)
580 580
581 581 partially close multihead branch
582 582
583 583 $ hg up -C a58ca5d3bdf3
584 584 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
585 585 $ hg commit -d '12 0' -m 'close head 1' --close-branch
586 586 $ hg heads --topo m
587 587 changeset: 19:cd21a80baa3d
588 588 branch: m
589 589 tag: tip
590 590 parent: 16:a58ca5d3bdf3
591 591 user: test
592 592 date: Thu Jan 01 00:00:12 1970 +0000
593 593 summary: close head 1
594 594
595 595 $ hg branches
596 596 md 18:c914c99f1fbb
597 597 b 13:e23b5505d1ad
598 598 a branch name much longer than the default justification used by branches 7:10ff5895aa57
599 599 m 17:df343b0df04f (inactive)
600 600 a 5:d8cbc61dbaa6 (inactive)
601 601 default 0:19709c5a4e75 (inactive)
602 602
603 603 default branch colors:
604 604
605 605 $ cat <<EOF >> $HGRCPATH
606 606 > [extensions]
607 607 > color =
608 608 > [color]
609 609 > mode = ansi
610 610 > EOF
611 611
612 612 $ hg up -C b
613 613 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
614 614 $ hg branches --color=always
615 615 \x1b[0;0mmd\x1b[0m\x1b[0;33m 18:c914c99f1fbb\x1b[0m (esc)
616 616 \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc)
617 617 \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc)
618 618 \x1b[0;0mm\x1b[0m\x1b[0;33m 17:df343b0df04f\x1b[0m (inactive) (esc)
619 619 \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
620 620 \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc)
621 621
622 622 default closed branch color:
623 623
624 624 $ hg branches --color=always --closed
625 625 \x1b[0;0mmd\x1b[0m\x1b[0;33m 18:c914c99f1fbb\x1b[0m (esc)
626 626 \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc)
627 627 \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc)
628 628 \x1b[0;0mm\x1b[0m\x1b[0;33m 17:df343b0df04f\x1b[0m (inactive) (esc)
629 629 \x1b[0;30;1mc\x1b[0m\x1b[0;33m 14:f894c25619d3\x1b[0m (closed) (esc)
630 630 \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
631 631 \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc)
632 632
633 633 $ cat <<EOF >> $HGRCPATH
634 634 > [extensions]
635 635 > color =
636 636 > [color]
637 637 > branches.active = green
638 638 > branches.closed = blue
639 639 > branches.current = red
640 640 > branches.inactive = magenta
641 641 > log.changeset = cyan
642 642 > EOF
643 643
644 644 custom branch colors:
645 645
646 646 $ hg branches --color=always
647 647 \x1b[0;32mmd\x1b[0m\x1b[0;36m 18:c914c99f1fbb\x1b[0m (esc)
648 648 \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc)
649 649 \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc)
650 650 \x1b[0;35mm\x1b[0m\x1b[0;36m 17:df343b0df04f\x1b[0m (inactive) (esc)
651 651 \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
652 652 \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc)
653 653
654 654 custom closed branch color:
655 655
656 656 $ hg branches --color=always --closed
657 657 \x1b[0;32mmd\x1b[0m\x1b[0;36m 18:c914c99f1fbb\x1b[0m (esc)
658 658 \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc)
659 659 \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc)
660 660 \x1b[0;35mm\x1b[0m\x1b[0;36m 17:df343b0df04f\x1b[0m (inactive) (esc)
661 661 \x1b[0;34mc\x1b[0m\x1b[0;36m 14:f894c25619d3\x1b[0m (closed) (esc)
662 662 \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc)
663 663 \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc)
664 664
665 665 template output:
666 666
667 667 $ hg branches -Tjson --closed
668 668 [
669 669 {
670 670 "active": true,
671 671 "branch": "md",
672 672 "closed": false,
673 673 "current": false,
674 674 "node": "c914c99f1fbb2b1d785a0a939ed3f67275df18e9",
675 675 "rev": 18
676 676 },
677 677 {
678 678 "active": true,
679 679 "branch": "b",
680 680 "closed": false,
681 681 "current": true,
682 682 "node": "e23b5505d1ad24aab6f84fd8c7cb8cd8e5e93be0",
683 683 "rev": 13
684 684 },
685 685 {
686 686 "active": true,
687 687 "branch": "a branch name much longer than the default justification used by branches",
688 688 "closed": false,
689 689 "current": false,
690 690 "node": "10ff5895aa5793bd378da574af8cec8ea408d831",
691 691 "rev": 7
692 692 },
693 693 {
694 694 "active": false,
695 695 "branch": "m",
696 696 "closed": false,
697 697 "current": false,
698 698 "node": "df343b0df04feb2a946cd4b6e9520e552fef14ee",
699 699 "rev": 17
700 700 },
701 701 {
702 702 "active": false,
703 703 "branch": "c",
704 704 "closed": true,
705 705 "current": false,
706 706 "node": "f894c25619d3f1484639d81be950e0a07bc6f1f6",
707 707 "rev": 14
708 708 },
709 709 {
710 710 "active": false,
711 711 "branch": "a",
712 712 "closed": false,
713 713 "current": false,
714 714 "node": "d8cbc61dbaa6dc817175d1e301eecb863f280832",
715 715 "rev": 5
716 716 },
717 717 {
718 718 "active": false,
719 719 "branch": "default",
720 720 "closed": false,
721 721 "current": false,
722 722 "node": "19709c5a4e75bf938f8e349aff97438539bb729e",
723 723 "rev": 0
724 724 }
725 725 ]
726 726
727 727 $ hg branches --closed -T '{if(closed, "{branch}\n")}'
728 728 c
729 729
730 730 $ hg branches -T '{word(0, branch)}: {desc|firstline}\n'
731 731 md: merge head 2
732 732 b: reopen branch with a change
733 733 a: Adding d branch
734 734 m: head 2
735 735 a: Adding b branch head 2
736 736 default: Adding root node
737 737
738 738 $ cat <<'EOF' > "$TESTTMP/map-myjson"
739 739 > docheader = '\{\n'
740 740 > docfooter = '\n}\n'
741 741 > separator = ',\n'
742 742 > branches = ' {dict(branch, node|short)|json}'
743 743 > EOF
744 744 $ hg branches -T "$TESTTMP/map-myjson"
745 745 {
746 746 {"branch": "md", "node": "c914c99f1fbb"},
747 747 {"branch": "b", "node": "e23b5505d1ad"},
748 748 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob)
749 749 {"branch": "m", "node": "df343b0df04f"},
750 750 {"branch": "a", "node": "d8cbc61dbaa6"},
751 751 {"branch": "default", "node": "19709c5a4e75"}
752 752 }
753 753
754 754 $ cat <<'EOF' >> .hg/hgrc
755 755 > [templates]
756 756 > myjson = ' {dict(branch, node|short)|json}'
757 757 > myjson:docheader = '\{\n'
758 758 > myjson:docfooter = '\n}\n'
759 759 > myjson:separator = ',\n'
760 760 > EOF
761 761 $ hg branches -T myjson
762 762 {
763 763 {"branch": "md", "node": "c914c99f1fbb"},
764 764 {"branch": "b", "node": "e23b5505d1ad"},
765 765 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob)
766 766 {"branch": "m", "node": "df343b0df04f"},
767 767 {"branch": "a", "node": "d8cbc61dbaa6"},
768 768 {"branch": "default", "node": "19709c5a4e75"}
769 769 }
770 770
771 771 $ cat <<'EOF' >> .hg/hgrc
772 772 > [templates]
773 773 > :docheader = 'should not be selected as a docheader for literal templates\n'
774 774 > EOF
775 775 $ hg branches -T '{branch}\n'
776 776 md
777 777 b
778 778 a branch name much longer than the default justification used by branches
779 779 m
780 780 a
781 781 default
782 782
783 783 Tests of revision branch name caching
784 784
785 785 We rev branch cache is updated automatically. In these tests we use a trick to
786 786 trigger rebuilds. We remove the branch head cache and run 'hg head' to cause a
787 787 rebuild that also will populate the rev branch cache.
788 788
789 789 revision branch cache is created when building the branch head cache
790 790 $ rm -rf .hg/cache; hg head a -T '{rev}\n'
791 791 5
792 792 $ f --hexdump --size .hg/cache/rbc-*
793 793 .hg/cache/rbc-names-v2: size=92
794 794 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a |
795 795 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much|
796 796 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the|
797 797 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi|
798 798 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b|
799 799 0050: 72 61 6e 63 68 65 73 00 6d 00 6d 64 |ranches.m.md|
800 800 .hg/cache/rbc-revs-v2: size=160
801 801 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
802 802 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....|
803 803 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................|
804 804 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....|
805 805 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....|
806 806 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....|
807 807 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....|
808 808 0070: f8 94 c2 56 80 00 00 03 f3 44 76 37 00 00 00 05 |...V.....Dv7....|
809 809 0080: a5 8c a5 d3 00 00 00 05 df 34 3b 0d 00 00 00 05 |.........4;.....|
810 810 0090: c9 14 c9 9f 00 00 00 06 cd 21 a8 0b 80 00 00 05 |.........!......|
811 811
812 812 no errors when revbranchcache is not writable
813 813
814 814 $ echo >> .hg/cache/rbc-revs-v2
815 815 $ mv .hg/cache/rbc-revs-v2 .hg/cache/rbc-revs-v2_
816 816 $ mkdir .hg/cache/rbc-revs-v2
817 817 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n'
818 818 5
819 819 $ rmdir .hg/cache/rbc-revs-v2
820 820 $ mv .hg/cache/rbc-revs-v2_ .hg/cache/rbc-revs-v2
821 821
822 822 no errors when wlock cannot be acquired
823 823
824 824 #if unix-permissions
825 825 $ mv .hg/cache/rbc-revs-v2 .hg/cache/rbc-revs-v2_
826 826 $ rm -f .hg/cache/branch*
827 827 $ chmod 555 .hg
828 828 $ hg head a -T '{rev}\n'
829 829 5
830 830 $ chmod 755 .hg
831 831 $ mv .hg/cache/rbc-revs-v2_ .hg/cache/rbc-revs-v2
832 832 #endif
833 833
834 834 recovery from invalid cache revs file with trailing data
835 835 $ echo >> .hg/cache/rbc-revs-v2
836 836 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
837 837 5
838 838 overwriting 2 bytes from 160 in cache/rbc-revs-v2 leaving (2 trailing bytes)
839 839 $ f --size .hg/cache/rbc-revs*
840 840 .hg/cache/rbc-revs-v2: size=162
841 841
842 842 recovery from invalid cache file with partial last record
843 843 $ mv .hg/cache/rbc-revs-v2 .
844 844 $ f -qDB 119 rbc-revs-v2 > .hg/cache/rbc-revs-v2
845 845 $ f --size .hg/cache/rbc-revs*
846 846 .hg/cache/rbc-revs-v2: size=119
847 847 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
848 848 5
849 849 resetting content of cache/rbc-revs-v2
850 850 $ f --size .hg/cache/rbc-revs*
851 851 .hg/cache/rbc-revs-v2: size=160
852 852
853 853 recovery from invalid cache file with missing record - no truncation
854 854 $ mv .hg/cache/rbc-revs-v2 .
855 855 $ f -qDB 112 rbc-revs-v2 > .hg/cache/rbc-revs-v2
856 856 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
857 857 5
858 858 $ f --size .hg/cache/rbc-revs*
859 859 .hg/cache/rbc-revs-v2: size=160
860 860
861 861 recovery from invalid cache file with some bad records
862 862 $ mv .hg/cache/rbc-revs-v2 .
863 863 $ f -qDB 8 rbc-revs-v2 > .hg/cache/rbc-revs-v2
864 864 $ f --size .hg/cache/rbc-revs*
865 865 .hg/cache/rbc-revs-v2: size=8
866 866 $ f -qDB 112 rbc-revs-v2 >> .hg/cache/rbc-revs-v2
867 867 $ f --size .hg/cache/rbc-revs*
868 868 .hg/cache/rbc-revs-v2: size=120
869 869 $ hg log -r 'branch(.)' -T '{rev} ' --debug
870 870 history modification detected - truncating revision branch cache to revision * (glob)
871 871 history modification detected - truncating revision branch cache to revision 1
872 872 3 4 8 9 10 11 12 13 resetting content of cache/rbc-revs-v2
873 873 $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug
874 874 5
875 875 resetting content of cache/rbc-revs-v2
876 876 $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs*
877 877 .hg/cache/rbc-revs-v2: size=160
878 878 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....|
879 879
880 880 Smoothly reuse "v1" format if no v2 exists
881 881 ------------------------------------------
882 882
883 read only operation with valid data(
884 (does not need to rewrite anything, maybe we should force it?)
883 read only operation with valid data
884 (actively rewrite data)
885 885
886 886 $ rm .hg/cache/rbc-names-v2
887 887 $ rm .hg/cache/rbc-revs-v2
888 888 $ rm .hg/cache/branch*
889 889 $ hg head a -T '{rev}\n' --debug
890 890 5
891 891 $ mv .hg/cache/rbc-names-v2 .hg/cache/rbc-names-v1
892 892 $ mv .hg/cache/rbc-revs-v2 .hg/cache/rbc-revs-v1
893 893 $ rm .hg/cache/branch*
894 894 $ hg head a -T '{rev}\n' --debug
895 895 5
896 896 $ f --size .hg/cache/rbc-*-*
897 897 .hg/cache/rbc-names-v1: size=92
898 .hg/cache/rbc-names-v2: size=92
898 899 .hg/cache/rbc-revs-v1: size=160
900 .hg/cache/rbc-revs-v2: size=160
899 901
900 902
901 903 Write operation write a full v2 files
902 904
905 $ mv .hg/cache/rbc-names-v2 .hg/cache/rbc-names-v1
906 $ mv .hg/cache/rbc-revs-v2 .hg/cache/rbc-revs-v1
907 $ f --size .hg/cache/rbc-*
908 .hg/cache/rbc-names-v1: size=92
909 .hg/cache/rbc-revs-v1: size=160
903 910 $ hg branch not-here-for-long
904 911 marked working directory as branch not-here-for-long
905 912 $ hg ci -m not-long --debug
906 913 reusing manifest from p1 (no file change)
907 914 committing changelog
908 rbc-names-v2 changed - rewriting it
909 915 updating the branch cache
910 916 committed changeset * (glob)
911 917 $ f --size .hg/cache/rbc-*
912 918 .hg/cache/rbc-names-v1: size=92
913 919 .hg/cache/rbc-names-v2: size=110
914 920 .hg/cache/rbc-revs-v1: size=160
915 921 .hg/cache/rbc-revs-v2: size=168
916 922
917 923
918 924 With invalid v1 data, we rewrite it too (as v2)
919 925
920 926 $ cp .hg/cache/rbc-names-v2 .hg/cache/rbc-names-v1
921 927 $ mv .hg/cache/rbc-names-v2 .hg/cache/rbc-revs-v1
922 928 $ rm .hg/cache/rbc-revs-v2
923 929 $ rm .hg/cache/branch*
924 930 $
925 931 $ hg head a -T '{rev}\n' --debug
926 932 history modification detected - truncating revision branch cache to revision 0
927 933 5
928 934 $ f --size .hg/cache/rbc-*-*
929 935 .hg/cache/rbc-names-v1: size=110
936 .hg/cache/rbc-names-v2: size=110
930 937 .hg/cache/rbc-revs-v1: size=110
931 938 .hg/cache/rbc-revs-v2: size=168
932 939
933 940 cleanup
934 941
935 942 $ hg up -qr '.^'
936 943 $ hg rollback -qf
937 944 $ rm .hg/cache/*
938 945 $ hg debugupdatecache
939 946 $ f --size .hg/cache/rbc-*
940 947 .hg/cache/rbc-names-v2: size=92
941 948 .hg/cache/rbc-revs-v2: size=160
942 949
943 950 cache is updated when committing
944 951 $ hg branch i-will-regret-this
945 952 marked working directory as branch i-will-regret-this
946 953 $ hg ci -m regrets
947 954 $ f --size .hg/cache/rbc-*
948 955 .hg/cache/rbc-names-v2: size=111
949 956 .hg/cache/rbc-revs-v2: size=168
950 957
951 958 update after rollback - the cache will be correct but rbc-names will will still
952 959 contain the branch name even though it no longer is used
953 960 $ hg up -qr '.^'
954 961 $ hg rollback -qf
955 962 $ f --size .hg/cache/rbc-names-*
956 963 .hg/cache/rbc-names-v2: size=111
957 964 $ grep "i-will-regret-this" .hg/cache/rbc-names-* > /dev/null
958 965 $ f --size .hg/cache/rbc-revs-*
959 966 .hg/cache/rbc-revs-v2: size=168
960 967
961 968 cache is updated/truncated when stripping - it is thus very hard to get in a
962 969 situation where the cache is out of sync and the hash check detects it
963 970 $ hg --config extensions.strip= strip -r tip --nob
964 971 $ f --size .hg/cache/rbc-revs*
965 972 .hg/cache/rbc-revs-v2: size=152
966 973
967 974 cache is rebuilt when corruption is detected
968 975 $ echo > .hg/cache/rbc-names-v2
969 976 $ hg log -r '5:&branch(.)' -T '{rev} ' --debug
970 977 referenced branch names not found - rebuilding revision branch cache from scratch
971 8 9 10 11 12 13 (no-eol)
978 8 9 10 11 12 13 resetting content of rbc-names-v2
972 979 $ f --size .hg/cache/rbc-names-*
973 980 .hg/cache/rbc-names-v2: size=84
974 981 $ grep "i-will-regret-this" .hg/cache/rbc-names-* > /dev/null
975 982 [1]
976 983 $ f --size .hg/cache/rbc-revs-*
977 984 .hg/cache/rbc-revs-v2: size=152
978 985
979 986 Test that cache files are created and grows correctly:
980 987
981 988 $ rm .hg/cache/rbc*
982 989 $ hg log -r "5 & branch(5)" -T "{rev}\n"
983 990 5
984 991
985 992 (here v3 is querying branch info for heads so it warm much more of the cache)
986 993
987 994 #if v2
988 995 $ f --size .hg/cache/rbc-*
989 996 .hg/cache/rbc-names-v2: size=1
990 997 .hg/cache/rbc-revs-v2: size=48
991 998 #else
992 999 $ f --size .hg/cache/rbc-*
993 1000 .hg/cache/rbc-names-v2: size=84
994 1001 .hg/cache/rbc-revs-v2: size=152
995 1002 #endif
996 1003
997 1004 $ cd ..
998 1005
999 1006 Test for multiple incorrect branch cache entries:
1000 1007
1001 1008 $ hg init b
1002 1009 $ cd b
1003 1010 $ touch f
1004 1011 $ hg ci -Aqmf
1005 1012 $ echo >> f
1006 1013 $ hg ci -Amf
1007 1014 $ hg branch -q branch
1008 1015 $ hg ci -Amf
1009 1016
1010 1017 #if v2
1011 1018
1012 1019 $ f --size --sha256 .hg/cache/rbc-*
1013 1020 .hg/cache/rbc-names-v2: size=14, sha256=d376f7eea9a7e28fac6470e78dae753c81a5543c9ad436e96999590e004a281c
1014 1021 .hg/cache/rbc-revs-v2: size=24, sha256=ec89032fd4e66e7282cb6e403848c681a855a9c36c6b44d19179218553b78779
1015 1022
1016 1023 $ : > .hg/cache/rbc-revs-v2
1017 1024
1018 1025 No superfluous rebuilding of cache:
1019 1026 $ hg log -r "branch(null)&branch(branch)" --debug
1020 1027 $ f --size --sha256 .hg/cache/rbc-*
1021 1028 .hg/cache/rbc-names-v2: size=14, sha256=d376f7eea9a7e28fac6470e78dae753c81a5543c9ad436e96999590e004a281c
1022 1029 .hg/cache/rbc-revs-v2: size=24, sha256=ec89032fd4e66e7282cb6e403848c681a855a9c36c6b44d19179218553b78779
1023 1030 #endif
1024 1031
1025 1032 $ cd ..
1026 1033
1027 1034 Test to make sure that `--close-branch` only works on a branch head:
1028 1035 --------------------------------------------------------------------
1029 1036 $ hg init closebranch
1030 1037 $ cd closebranch
1031 1038 $ for ch in a b c; do
1032 1039 > echo $ch > $ch
1033 1040 > hg add $ch
1034 1041 > hg ci -m "added "$ch
1035 1042 > done;
1036 1043
1037 1044 $ hg up -r "desc('added b')"
1038 1045 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1039 1046
1040 1047 trying to close branch from a cset which is not a branch head
1041 1048 it should abort:
1042 1049 $ hg ci -m "closing branch" --close-branch
1043 1050 abort: can only close branch heads
1044 1051 (use --force-close-branch to close branch from a non-head changeset)
1045 1052 [10]
1046 1053
1047 1054 $ hg up 0
1048 1055 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1049 1056 $ hg log -GT "{rev}: {node|short} {desc|firstline}\n\t{branch}\n\n"
1050 1057 o 2: 155349b645be added c
1051 1058 | default
1052 1059 |
1053 1060 o 1: 5f6d8a4bf34a added b
1054 1061 | default
1055 1062 |
1056 1063 @ 0: 9092f1db7931 added a
1057 1064 default
1058 1065
1059 1066 Test --force-close-branch to close a branch from a non-head changeset:
1060 1067 ---------------------------------------------------------------------
1061 1068
1062 1069 $ hg show stack --config extensions.show=
1063 1070 o 1553 added c
1064 1071 o 5f6d added b
1065 1072 @ 9092 added a
1066 1073
1067 1074 $ hg ci -m "branch closed" --close-branch
1068 1075 abort: can only close branch heads
1069 1076 (use --force-close-branch to close branch from a non-head changeset)
1070 1077 [10]
1071 1078
1072 1079 $ hg ci -m "branch closed" --force-close-branch
1073 1080 created new head
1074 1081 $ cd ..
1075 1082
1076 1083 Test various special cases for the branchmap
1077 1084 --------------------------------------------
1078 1085
1079 1086 Basic fork of the same branch
1080 1087
1081 1088 $ hg init branchmap-testing1
1082 1089 $ cd branchmap-testing1
1083 1090 $ hg debugbuild '@A . :base . :p1 *base /p1'
1084 1091 $ hg log -G
1085 1092 o changeset: 3:71ca9a6d524e
1086 1093 |\ branch: A
1087 1094 | | tag: tip
1088 1095 | | parent: 2:a3b807b3ff0b
1089 1096 | | parent: 1:99ba08759bc7
1090 1097 | | user: debugbuilddag
1091 1098 | | date: Thu Jan 01 00:00:03 1970 +0000
1092 1099 | | summary: r3
1093 1100 | |
1094 1101 | o changeset: 2:a3b807b3ff0b
1095 1102 | | branch: A
1096 1103 | | parent: 0:2ab8003a1750
1097 1104 | | user: debugbuilddag
1098 1105 | | date: Thu Jan 01 00:00:02 1970 +0000
1099 1106 | | summary: r2
1100 1107 | |
1101 1108 o | changeset: 1:99ba08759bc7
1102 1109 |/ branch: A
1103 1110 | tag: p1
1104 1111 | user: debugbuilddag
1105 1112 | date: Thu Jan 01 00:00:01 1970 +0000
1106 1113 | summary: r1
1107 1114 |
1108 1115 o changeset: 0:2ab8003a1750
1109 1116 branch: A
1110 1117 tag: base
1111 1118 user: debugbuilddag
1112 1119 date: Thu Jan 01 00:00:00 1970 +0000
1113 1120 summary: r0
1114 1121
1115 1122 $ hg branches
1116 1123 A 3:71ca9a6d524e
1117 1124 $ hg clone -r 1 -r 2 . ../branchmap-testing1-clone
1118 1125 adding changesets
1119 1126 adding manifests
1120 1127 adding file changes
1121 1128 added 3 changesets with 0 changes to 0 files (+1 heads)
1122 1129 new changesets 2ab8003a1750:a3b807b3ff0b
1123 1130 updating to branch A
1124 1131 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1125 1132 $ cd ../branchmap-testing1-clone
1126 1133 $ hg pull ../branchmap-testing1
1127 1134 pulling from ../branchmap-testing1
1128 1135 searching for changes
1129 1136 adding changesets
1130 1137 adding manifests
1131 1138 adding file changes
1132 1139 added 1 changesets with 0 changes to 0 files (-1 heads)
1133 1140 new changesets 71ca9a6d524e
1134 1141 (run 'hg update' to get a working copy)
1135 1142 $ hg branches
1136 1143 A 3:71ca9a6d524e
1137 1144 $ cd ..
1138 1145
1139 1146 Switching to a different branch and back
1140 1147
1141 1148 $ hg init branchmap-testing2
1142 1149 $ cd branchmap-testing2
1143 1150 $ hg debugbuild '@A . @B . @A .'
1144 1151 $ hg log -G
1145 1152 o changeset: 2:9699e9f260b5
1146 1153 | branch: A
1147 1154 | tag: tip
1148 1155 | user: debugbuilddag
1149 1156 | date: Thu Jan 01 00:00:02 1970 +0000
1150 1157 | summary: r2
1151 1158 |
1152 1159 o changeset: 1:0bc7d348d965
1153 1160 | branch: B
1154 1161 | user: debugbuilddag
1155 1162 | date: Thu Jan 01 00:00:01 1970 +0000
1156 1163 | summary: r1
1157 1164 |
1158 1165 o changeset: 0:2ab8003a1750
1159 1166 branch: A
1160 1167 user: debugbuilddag
1161 1168 date: Thu Jan 01 00:00:00 1970 +0000
1162 1169 summary: r0
1163 1170
1164 1171 $ hg branches
1165 1172 A 2:9699e9f260b5
1166 1173 B 1:0bc7d348d965 (inactive)
1167 1174 $ hg clone -r 1 . ../branchmap-testing2-clone
1168 1175 adding changesets
1169 1176 adding manifests
1170 1177 adding file changes
1171 1178 added 2 changesets with 0 changes to 0 files
1172 1179 new changesets 2ab8003a1750:0bc7d348d965
1173 1180 updating to branch B
1174 1181 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1175 1182 $ cd ../branchmap-testing2-clone
1176 1183 $ hg pull ../branchmap-testing2
1177 1184 pulling from ../branchmap-testing2
1178 1185 searching for changes
1179 1186 adding changesets
1180 1187 adding manifests
1181 1188 adding file changes
1182 1189 added 1 changesets with 0 changes to 0 files
1183 1190 new changesets 9699e9f260b5
1184 1191 (run 'hg update' to get a working copy)
1185 1192 $ hg branches
1186 1193 A 2:9699e9f260b5
1187 1194 B 1:0bc7d348d965 (inactive)
1188 1195 $ cd ..
1189 1196
1190 1197 A fork on a branch switching to a different branch and back
1191 1198 is still collecting the fork.
1192 1199
1193 1200 $ hg init branchmap-testing3
1194 1201 $ cd branchmap-testing3
1195 1202 $ hg debugbuild '@A . :base . :p1 *base @B . @A /p1'
1196 1203 $ hg log -G
1197 1204 o changeset: 4:3614a1711d23
1198 1205 |\ branch: A
1199 1206 | | tag: tip
1200 1207 | | parent: 3:e9c8abcf65aa
1201 1208 | | parent: 1:99ba08759bc7
1202 1209 | | user: debugbuilddag
1203 1210 | | date: Thu Jan 01 00:00:04 1970 +0000
1204 1211 | | summary: r4
1205 1212 | |
1206 1213 | o changeset: 3:e9c8abcf65aa
1207 1214 | | branch: B
1208 1215 | | user: debugbuilddag
1209 1216 | | date: Thu Jan 01 00:00:03 1970 +0000
1210 1217 | | summary: r3
1211 1218 | |
1212 1219 | o changeset: 2:a3b807b3ff0b
1213 1220 | | branch: A
1214 1221 | | parent: 0:2ab8003a1750
1215 1222 | | user: debugbuilddag
1216 1223 | | date: Thu Jan 01 00:00:02 1970 +0000
1217 1224 | | summary: r2
1218 1225 | |
1219 1226 o | changeset: 1:99ba08759bc7
1220 1227 |/ branch: A
1221 1228 | tag: p1
1222 1229 | user: debugbuilddag
1223 1230 | date: Thu Jan 01 00:00:01 1970 +0000
1224 1231 | summary: r1
1225 1232 |
1226 1233 o changeset: 0:2ab8003a1750
1227 1234 branch: A
1228 1235 tag: base
1229 1236 user: debugbuilddag
1230 1237 date: Thu Jan 01 00:00:00 1970 +0000
1231 1238 summary: r0
1232 1239
1233 1240 $ hg branches
1234 1241 A 4:3614a1711d23
1235 1242 B 3:e9c8abcf65aa (inactive)
1236 1243 $ hg clone -r 1 -r 3 . ../branchmap-testing3-clone
1237 1244 adding changesets
1238 1245 adding manifests
1239 1246 adding file changes
1240 1247 added 4 changesets with 0 changes to 0 files (+1 heads)
1241 1248 new changesets 2ab8003a1750:e9c8abcf65aa
1242 1249 updating to branch A
1243 1250 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1244 1251 $ cd ../branchmap-testing3-clone
1245 1252 $ hg pull ../branchmap-testing3
1246 1253 pulling from ../branchmap-testing3
1247 1254 searching for changes
1248 1255 adding changesets
1249 1256 adding manifests
1250 1257 adding file changes
1251 1258 added 1 changesets with 0 changes to 0 files (-1 heads)
1252 1259 new changesets 3614a1711d23
1253 1260 (run 'hg update' to get a working copy)
1254 1261 $ hg branches
1255 1262 A 4:3614a1711d23
1256 1263 B 3:e9c8abcf65aa (inactive)
1257 1264 $ cd ..
1258 1265
1259 1266 Intermediary parents are on different branches.
1260 1267
1261 1268 $ hg init branchmap-testing4
1262 1269 $ cd branchmap-testing4
1263 1270 $ hg debugbuild '@A . @B :base . @A :p1 *base @C . @A /p1'
1264 1271 $ hg log -G
1265 1272 o changeset: 4:4bf67499b70a
1266 1273 |\ branch: A
1267 1274 | | tag: tip
1268 1275 | | parent: 3:4a546028fa8f
1269 1276 | | parent: 1:0bc7d348d965
1270 1277 | | user: debugbuilddag
1271 1278 | | date: Thu Jan 01 00:00:04 1970 +0000
1272 1279 | | summary: r4
1273 1280 | |
1274 1281 | o changeset: 3:4a546028fa8f
1275 1282 | | branch: C
1276 1283 | | user: debugbuilddag
1277 1284 | | date: Thu Jan 01 00:00:03 1970 +0000
1278 1285 | | summary: r3
1279 1286 | |
1280 1287 | o changeset: 2:a3b807b3ff0b
1281 1288 | | branch: A
1282 1289 | | parent: 0:2ab8003a1750
1283 1290 | | user: debugbuilddag
1284 1291 | | date: Thu Jan 01 00:00:02 1970 +0000
1285 1292 | | summary: r2
1286 1293 | |
1287 1294 o | changeset: 1:0bc7d348d965
1288 1295 |/ branch: B
1289 1296 | tag: p1
1290 1297 | user: debugbuilddag
1291 1298 | date: Thu Jan 01 00:00:01 1970 +0000
1292 1299 | summary: r1
1293 1300 |
1294 1301 o changeset: 0:2ab8003a1750
1295 1302 branch: A
1296 1303 tag: base
1297 1304 user: debugbuilddag
1298 1305 date: Thu Jan 01 00:00:00 1970 +0000
1299 1306 summary: r0
1300 1307
1301 1308 $ hg branches
1302 1309 A 4:4bf67499b70a
1303 1310 C 3:4a546028fa8f (inactive)
1304 1311 B 1:0bc7d348d965 (inactive)
1305 1312 $ hg clone -r 1 -r 3 . ../branchmap-testing4-clone
1306 1313 adding changesets
1307 1314 adding manifests
1308 1315 adding file changes
1309 1316 added 4 changesets with 0 changes to 0 files (+1 heads)
1310 1317 new changesets 2ab8003a1750:4a546028fa8f
1311 1318 updating to branch B
1312 1319 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1313 1320 $ cd ../branchmap-testing4-clone
1314 1321 $ hg pull ../branchmap-testing4
1315 1322 pulling from ../branchmap-testing4
1316 1323 searching for changes
1317 1324 adding changesets
1318 1325 adding manifests
1319 1326 adding file changes
1320 1327 added 1 changesets with 0 changes to 0 files (-1 heads)
1321 1328 new changesets 4bf67499b70a
1322 1329 (run 'hg update' to get a working copy)
1323 1330 $ hg branches
1324 1331 A 4:4bf67499b70a
1325 1332 C 3:4a546028fa8f (inactive)
1326 1333 B 1:0bc7d348d965 (inactive)
1327 1334 $ cd ..
1328 1335
1329 1336 Check that the cache are not written too early
1330 1337 ----------------------------------------------
1331 1338
1332 1339 $ hg log -R branchmap-testing1 -G
1333 1340 o changeset: 3:71ca9a6d524e
1334 1341 |\ branch: A
1335 1342 | | tag: tip
1336 1343 | | parent: 2:a3b807b3ff0b
1337 1344 | | parent: 1:99ba08759bc7
1338 1345 | | user: debugbuilddag
1339 1346 | | date: Thu Jan 01 00:00:03 1970 +0000
1340 1347 | | summary: r3
1341 1348 | |
1342 1349 | o changeset: 2:a3b807b3ff0b
1343 1350 | | branch: A
1344 1351 | | parent: 0:2ab8003a1750
1345 1352 | | user: debugbuilddag
1346 1353 | | date: Thu Jan 01 00:00:02 1970 +0000
1347 1354 | | summary: r2
1348 1355 | |
1349 1356 o | changeset: 1:99ba08759bc7
1350 1357 |/ branch: A
1351 1358 | tag: p1
1352 1359 | user: debugbuilddag
1353 1360 | date: Thu Jan 01 00:00:01 1970 +0000
1354 1361 | summary: r1
1355 1362 |
1356 1363 o changeset: 0:2ab8003a1750
1357 1364 branch: A
1358 1365 tag: base
1359 1366 user: debugbuilddag
1360 1367 date: Thu Jan 01 00:00:00 1970 +0000
1361 1368 summary: r0
1362 1369
1363 1370 $ hg bundle -R branchmap-testing1 --base 1 bundle.hg --rev 'head()'
1364 1371 2 changesets found
1365 1372
1366 1373 Unbundling revision should warm the served cache
1367 1374
1368 1375 $ hg clone branchmap-testing1 --rev 1 branchmap-update-01
1369 1376 adding changesets
1370 1377 adding manifests
1371 1378 adding file changes
1372 1379 added 2 changesets with 0 changes to 0 files
1373 1380 new changesets 2ab8003a1750:99ba08759bc7
1374 1381 updating to branch A
1375 1382 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1376 1383 #if v3
1377 1384 $ cat branchmap-update-01/.hg/cache/branch3-exp-base
1378 1385 tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 topo-mode=pure
1379 1386 A
1380 1387 #else
1381 1388 $ cat branchmap-update-01/.hg/cache/branch2-base
1382 1389 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1383 1390 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1384 1391 #endif
1385 1392 $ hg -R branchmap-update-01 unbundle bundle.hg
1386 1393 adding changesets
1387 1394 adding manifests
1388 1395 adding file changes
1389 1396 added 2 changesets with 0 changes to 0 files
1390 1397 new changesets a3b807b3ff0b:71ca9a6d524e (2 drafts)
1391 1398 (run 'hg update' to get a working copy)
1392 1399 #if v3
1393 1400 $ cat branchmap-update-01/.hg/cache/branch3-exp-served
1394 1401 tip-node=71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 tip-rev=3 topo-mode=pure
1395 1402 A
1396 1403 #else
1397 1404 $ cat branchmap-update-01/.hg/cache/branch2-served
1398 1405 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 3
1399 1406 71ca9a6d524ed3c2a215119b2086ac3b8c4c8286 o A
1400 1407 #endif
1401 1408
1402 1409 aborted Unbundle should not update the on disk cache
1403 1410
1404 1411 $ cat >> simplehook.py << EOF
1405 1412 > import sys
1406 1413 > from mercurial import node
1407 1414 > from mercurial import branchmap
1408 1415 > def hook(ui, repo, *args, **kwargs):
1409 1416 > s = repo.filtered(b"served")
1410 1417 > s.branchmap()
1411 1418 > return 1
1412 1419 > EOF
1413 1420 $ hg clone branchmap-testing1 --rev 1 branchmap-update-02
1414 1421 adding changesets
1415 1422 adding manifests
1416 1423 adding file changes
1417 1424 added 2 changesets with 0 changes to 0 files
1418 1425 new changesets 2ab8003a1750:99ba08759bc7
1419 1426 updating to branch A
1420 1427 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1421 1428
1422 1429 #if v3
1423 1430 $ cat branchmap-update-02/.hg/cache/branch3-exp-base
1424 1431 tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 topo-mode=pure
1425 1432 A
1426 1433 #else
1427 1434 $ cat branchmap-update-02/.hg/cache/branch2-base
1428 1435 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1429 1436 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1430 1437 #endif
1431 1438 $ hg -R branchmap-update-02 unbundle bundle.hg --config "hooks.pretxnclose=python:$TESTTMP/simplehook.py:hook"
1432 1439 adding changesets
1433 1440 adding manifests
1434 1441 adding file changes
1435 1442 transaction abort!
1436 1443 rollback completed
1437 1444 abort: pretxnclose hook failed
1438 1445 [40]
1439 1446 #if v3
1440 1447 $ cat branchmap-update-02/.hg/cache/branch3-exp-base
1441 1448 tip-node=99ba08759bc7f6fdbe5304e83d0387f35c082479 tip-rev=1 topo-mode=pure
1442 1449 A
1443 1450 #else
1444 1451 $ cat branchmap-update-02/.hg/cache/branch2-base
1445 1452 99ba08759bc7f6fdbe5304e83d0387f35c082479 1
1446 1453 99ba08759bc7f6fdbe5304e83d0387f35c082479 o A
1447 1454 #endif
@@ -1,500 +1,500
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 > drawdag=$TESTDIR/drawdag.py
5 5 >
6 6 > [phases]
7 7 > publish=False
8 8 >
9 9 > [alias]
10 10 > tglog = log -G --template "{rev}:{phase} '{desc}' {branches} {bookmarks}\n"
11 11 > EOF
12 12
13 13 $ hg init a
14 14 $ cd a
15 15 $ echo c1 >common
16 16 $ hg add common
17 17 $ hg ci -m C1
18 18
19 19 $ echo c2 >>common
20 20 $ hg ci -m C2
21 21
22 22 $ echo c3 >>common
23 23 $ hg ci -m C3
24 24
25 25 $ hg up -q -C 1
26 26
27 27 $ echo l1 >>extra
28 28 $ hg add extra
29 29 $ hg ci -m L1
30 30 created new head
31 31
32 32 $ sed -e 's/c2/l2/' common > common.new
33 33 $ mv common.new common
34 34 $ hg ci -m L2
35 35
36 36 $ echo l3 >> extra2
37 37 $ hg add extra2
38 38 $ hg ci -m L3
39 39 $ hg bookmark mybook
40 40
41 41 $ hg phase --force --secret 4
42 42
43 43 $ hg tglog
44 44 @ 5:secret 'L3' mybook
45 45 |
46 46 o 4:secret 'L2'
47 47 |
48 48 o 3:draft 'L1'
49 49 |
50 50 | o 2:draft 'C3'
51 51 |/
52 52 o 1:draft 'C2'
53 53 |
54 54 o 0:draft 'C1'
55 55
56 56 Try to call --continue:
57 57
58 58 $ hg rebase --continue
59 59 abort: no rebase in progress
60 60 [20]
61 61
62 62 Conflicting rebase:
63 63
64 64 $ hg rebase -s 3 -d 2
65 65 rebasing 3:3163e20567cc "L1"
66 66 rebasing 4:46f0b057b5c0 "L2"
67 67 merging common
68 68 warning: conflicts while merging common! (edit, then use 'hg resolve --mark')
69 69 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
70 70 [240]
71 71
72 72 $ hg status --config commands.status.verbose=1
73 73 M common
74 74 ? common.orig
75 75 # The repository is in an unfinished *rebase* state.
76 76
77 77 # Unresolved merge conflicts:
78 78 #
79 79 # common
80 80 #
81 81 # To mark files as resolved: hg resolve --mark FILE
82 82
83 83 # To continue: hg rebase --continue
84 84 # To abort: hg rebase --abort
85 85 # To stop: hg rebase --stop
86 86
87 87
88 88 Try to continue without solving the conflict:
89 89
90 90 $ hg rebase --continue
91 91 abort: unresolved merge conflicts (see 'hg help resolve')
92 92 [20]
93 93
94 94 Conclude rebase:
95 95
96 96 $ echo 'resolved merge' >common
97 97 $ hg resolve -m common
98 98 (no more unresolved files)
99 99 continue: hg rebase --continue
100 100 $ hg rebase --continue
101 101 already rebased 3:3163e20567cc "L1" as 3e046f2ecedb
102 102 rebasing 4:46f0b057b5c0 "L2"
103 103 rebasing 5:8029388f38dc mybook "L3"
104 104 saved backup bundle to $TESTTMP/a/.hg/strip-backup/3163e20567cc-5ca4656e-rebase.hg
105 105
106 106 $ hg tglog
107 107 @ 5:secret 'L3' mybook
108 108 |
109 109 o 4:secret 'L2'
110 110 |
111 111 o 3:draft 'L1'
112 112 |
113 113 o 2:draft 'C3'
114 114 |
115 115 o 1:draft 'C2'
116 116 |
117 117 o 0:draft 'C1'
118 118
119 119 Check correctness:
120 120
121 121 $ hg cat -r 0 common
122 122 c1
123 123
124 124 $ hg cat -r 1 common
125 125 c1
126 126 c2
127 127
128 128 $ hg cat -r 2 common
129 129 c1
130 130 c2
131 131 c3
132 132
133 133 $ hg cat -r 3 common
134 134 c1
135 135 c2
136 136 c3
137 137
138 138 $ hg cat -r 4 common
139 139 resolved merge
140 140
141 141 $ hg cat -r 5 common
142 142 resolved merge
143 143
144 144 Bookmark stays active after --continue
145 145 $ hg bookmarks
146 146 * mybook 5:d67b21408fc0
147 147
148 148 $ cd ..
149 149
150 150 Check that the right ancestors is used while rebasing a merge (issue4041)
151 151
152 152 $ hg init issue4041
153 153 $ cd issue4041
154 154 $ hg unbundle "$TESTDIR/bundles/issue4041.hg"
155 155 adding changesets
156 156 adding manifests
157 157 adding file changes
158 158 added 11 changesets with 8 changes to 3 files (+1 heads)
159 159 new changesets 24797d4f68de:2f2496ddf49d (11 drafts)
160 160 (run 'hg heads' to see heads)
161 161 $ hg up default
162 162 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
163 163 $ hg log -G
164 164 o changeset: 10:2f2496ddf49d
165 165 |\ branch: f1
166 166 | | tag: tip
167 167 | | parent: 7:4c9fbe56a16f
168 168 | | parent: 9:e31216eec445
169 169 | | user: szhang
170 170 | | date: Thu Sep 05 12:59:39 2013 -0400
171 171 | | summary: merge
172 172 | |
173 173 | o changeset: 9:e31216eec445
174 174 | | branch: f1
175 175 | | user: szhang
176 176 | | date: Thu Sep 05 12:59:10 2013 -0400
177 177 | | summary: more changes to f1
178 178 | |
179 179 | o changeset: 8:8e4e2c1a07ae
180 180 | |\ branch: f1
181 181 | | | parent: 2:4bc80088dc6b
182 182 | | | parent: 6:400110238667
183 183 | | | user: szhang
184 184 | | | date: Thu Sep 05 12:57:59 2013 -0400
185 185 | | | summary: bad merge
186 186 | | |
187 187 o | | changeset: 7:4c9fbe56a16f
188 188 |/ / branch: f1
189 189 | | parent: 2:4bc80088dc6b
190 190 | | user: szhang
191 191 | | date: Thu Sep 05 12:54:00 2013 -0400
192 192 | | summary: changed f1
193 193 | |
194 194 | o changeset: 6:400110238667
195 195 | | branch: f2
196 196 | | parent: 4:12e8ec6bb010
197 197 | | user: szhang
198 198 | | date: Tue Sep 03 13:58:02 2013 -0400
199 199 | | summary: changed f2 on f2
200 200 | |
201 201 | | @ changeset: 5:d79e2059b5c0
202 202 | | | parent: 3:8a951942e016
203 203 | | | user: szhang
204 204 | | | date: Tue Sep 03 13:57:39 2013 -0400
205 205 | | | summary: changed f2 on default
206 206 | | |
207 207 | o | changeset: 4:12e8ec6bb010
208 208 | |/ branch: f2
209 209 | | user: szhang
210 210 | | date: Tue Sep 03 13:57:18 2013 -0400
211 211 | | summary: created f2 branch
212 212 | |
213 213 | o changeset: 3:8a951942e016
214 214 | | parent: 0:24797d4f68de
215 215 | | user: szhang
216 216 | | date: Tue Sep 03 13:57:11 2013 -0400
217 217 | | summary: added f2.txt
218 218 | |
219 219 o | changeset: 2:4bc80088dc6b
220 220 | | branch: f1
221 221 | | user: szhang
222 222 | | date: Tue Sep 03 13:56:20 2013 -0400
223 223 | | summary: added f1.txt
224 224 | |
225 225 o | changeset: 1:ef53c9e6b608
226 226 |/ branch: f1
227 227 | user: szhang
228 228 | date: Tue Sep 03 13:55:26 2013 -0400
229 229 | summary: created f1 branch
230 230 |
231 231 o changeset: 0:24797d4f68de
232 232 user: szhang
233 233 date: Tue Sep 03 13:55:08 2013 -0400
234 234 summary: added default.txt
235 235
236 236 $ hg rebase -s9 -d2 --debug # use debug to really check merge base used
237 237 rebase onto 4bc80088dc6b starting from e31216eec445
238 238 rebasing on disk
239 239 rebase status stored
240 240 rebasing 9:e31216eec445 "more changes to f1"
241 241 future parents are 2 and -1
242 242 update to 2:4bc80088dc6b
243 243 resolving manifests
244 244 branchmerge: False, force: True, partial: False
245 245 ancestor: d79e2059b5c0+, local: d79e2059b5c0+, remote: 4bc80088dc6b
246 246 f2.txt: other deleted -> r
247 247 removing f2.txt
248 248 f1.txt: remote created -> g
249 249 getting f1.txt
250 250 merge against 9:e31216eec445
251 251 detach base 8:8e4e2c1a07ae
252 252 resolving manifests
253 253 branchmerge: True, force: True, partial: False
254 254 ancestor: 8e4e2c1a07ae, local: 4bc80088dc6b+, remote: e31216eec445
255 255 f1.txt: remote is newer -> g
256 256 getting f1.txt
257 257 committing files:
258 258 f1.txt
259 259 committing manifest
260 260 committing changelog
261 261 updating the branch cache
262 262 rebased as 19c888675e13
263 263 rebase status stored
264 264 rebasing 10:2f2496ddf49d tip "merge"
265 265 future parents are 11 and 7
266 266 already in destination
267 267 merge against 10:2f2496ddf49d
268 268 detach base 9:e31216eec445
269 269 resolving manifests
270 270 branchmerge: True, force: True, partial: False
271 271 ancestor: e31216eec445, local: 19c888675e13+, remote: 2f2496ddf49d
272 272 f1.txt: remote is newer -> g
273 273 getting f1.txt
274 274 committing files:
275 275 f1.txt
276 276 committing manifest
277 277 committing changelog
278 278 updating the branch cache
279 279 rebased as c1ffa3b5274e
280 280 rebase status stored
281 281 rebase merging completed
282 282 update back to initial working directory parent
283 283 resolving manifests
284 284 branchmerge: False, force: False, partial: False
285 285 ancestor: c1ffa3b5274e, local: c1ffa3b5274e+, remote: d79e2059b5c0
286 286 f1.txt: other deleted -> r
287 287 removing f1.txt
288 288 f2.txt: remote created -> g
289 289 getting f2.txt
290 290 2 changesets found
291 291 list of changesets:
292 292 e31216eec445e44352c5f01588856059466a24c9
293 293 2f2496ddf49d69b5ef23ad8cf9fb2e0e4faf0ac2
294 294 bundle2-output-bundle: "HG20", (1 params) 3 parts total
295 295 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
296 296 bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
297 297 bundle2-output-part: "phase-heads" 24 bytes payload
298 298 saved backup bundle to $TESTTMP/issue4041/.hg/strip-backup/e31216eec445-15f7a814-rebase.hg
299 299 2 changesets found
300 300 list of changesets:
301 301 19c888675e133ab5dff84516926a65672eaf04d9
302 302 c1ffa3b5274e92a9388fe782854e295d2e8d0443
303 303 bundle2-output-bundle: "HG20", 3 parts total
304 304 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
305 305 bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
306 306 bundle2-output-part: "phase-heads" 24 bytes payload
307 307 adding branch
308 308 bundle2-input-bundle: with-transaction
309 309 bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
310 310 adding changesets
311 311 add changeset 19c888675e13
312 312 add changeset c1ffa3b5274e
313 313 adding manifests
314 314 adding file changes
315 315 adding f1.txt revisions
316 316 bundle2-input-part: total payload size 1255
317 317 bundle2-input-part: "cache:rev-branch-cache" (advisory) supported
318 318 bundle2-input-part: total payload size 54
319 319 bundle2-input-part: "phase-heads" supported
320 320 bundle2-input-part: total payload size 24
321 321 bundle2-input-bundle: 3 parts total
322 resetting content of cache/rbc-revs-v2
322 resetting content of rbc-names-v2
323 323 added 2 changesets with 2 changes to 1 files
324 324 updating the branch cache
325 325 invalid branch cache (served): tip differs
326 326 history modification detected - truncating revision branch cache to revision 1
327 327 invalid branch cache (served.hidden): tip differs
328 328 rebase completed
329 329 resetting content of cache/rbc-revs-v2
330 330
331 331 Test minimization of merge conflicts
332 332 $ hg up -q null
333 333 $ echo a > a
334 334 $ hg add a
335 335 $ hg commit -q -m 'a'
336 336 $ echo b >> a
337 337 $ hg commit -q -m 'ab'
338 338 $ hg bookmark ab
339 339 $ hg up -q '.^'
340 340 $ echo b >> a
341 341 $ echo c >> a
342 342 $ hg commit -q -m 'abc'
343 343 $ hg rebase -s 7bc217434fc1 -d ab --keep
344 344 rebasing 13:7bc217434fc1 tip "abc"
345 345 merging a
346 346 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
347 347 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
348 348 [240]
349 349 $ hg diff
350 350 diff -r 328e4ab1f7cc a
351 351 --- a/a Thu Jan 01 00:00:00 1970 +0000
352 352 +++ b/a * (glob)
353 353 @@ -1,2 +1,6 @@
354 354 a
355 355 b
356 356 +<<<<<<< dest: 328e4ab1f7cc ab - test: ab
357 357 +=======
358 358 +c
359 359 +>>>>>>> source: 7bc217434fc1 - test: abc
360 360 $ hg rebase --abort
361 361 rebase aborted
362 362 $ hg up -q -C 7bc217434fc1
363 363 $ hg rebase -s . -d ab --keep -t internal:merge3
364 364 rebasing 13:7bc217434fc1 tip "abc"
365 365 merging a
366 366 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
367 367 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
368 368 [240]
369 369 $ hg diff
370 370 diff -r 328e4ab1f7cc a
371 371 --- a/a Thu Jan 01 00:00:00 1970 +0000
372 372 +++ b/a * (glob)
373 373 @@ -1,2 +1,8 @@
374 374 a
375 375 +<<<<<<< dest: 328e4ab1f7cc ab - test: ab
376 376 b
377 377 +||||||| parent of source: cb9a9f314b8b - test: a
378 378 +=======
379 379 +b
380 380 +c
381 381 +>>>>>>> source: 7bc217434fc1 - test: abc
382 382
383 383 Test rebase with obsstore turned on and off (issue5606)
384 384
385 385 $ cd $TESTTMP
386 386 $ hg init b
387 387 $ cd b
388 388 $ hg debugdrawdag <<'EOS'
389 389 > D
390 390 > |
391 391 > C
392 392 > |
393 393 > B E
394 394 > |/
395 395 > A
396 396 > EOS
397 397
398 398 $ hg update E -q
399 399 $ echo 3 > B
400 400 $ hg commit --amend -m E -A B -q
401 401 $ hg rebase -r B+D -d . --config experimental.evolution=true
402 402 rebasing 1:112478962961 B "B"
403 403 merging B
404 404 warning: conflicts while merging B! (edit, then use 'hg resolve --mark')
405 405 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
406 406 [240]
407 407
408 408 $ echo 4 > B
409 409 $ hg resolve -m
410 410 (no more unresolved files)
411 411 continue: hg rebase --continue
412 412 $ hg rebase --continue --config experimental.evolution=none
413 413 rebasing 1:112478962961 B "B"
414 414 rebasing 3:f585351a92f8 D "D"
415 415 warning: orphaned descendants detected, not stripping 112478962961
416 416 saved backup bundle to $TESTTMP/b/.hg/strip-backup/f585351a92f8-e536a9e4-rebase.hg
417 417
418 418 $ rm .hg/localtags
419 419 $ hg tglog
420 420 o 5:draft 'D'
421 421 |
422 422 o 4:draft 'B'
423 423 |
424 424 @ 3:draft 'E'
425 425 |
426 426 | o 2:draft 'C'
427 427 | |
428 428 | o 1:draft 'B'
429 429 |/
430 430 o 0:draft 'A'
431 431
432 432
433 433 Test where the conflict happens when rebasing a merge commit
434 434
435 435 $ cd $TESTTMP
436 436 $ hg init conflict-in-merge
437 437 $ cd conflict-in-merge
438 438 $ hg debugdrawdag <<'EOS'
439 439 > F # F/conflict = foo\n
440 440 > |\
441 441 > D E
442 442 > |/
443 443 > C B # B/conflict = bar\n
444 444 > |/
445 445 > A
446 446 > EOS
447 447
448 448 $ hg co F
449 449 5 files updated, 0 files merged, 0 files removed, 0 files unresolved
450 450 $ hg rebase -d B
451 451 rebasing 2:dc0947a82db8 C "C"
452 452 rebasing 3:e7b3f00ed42e D "D"
453 453 rebasing 4:03ca77807e91 E "E"
454 454 rebasing 5:9a6b91dc2044 F tip "F"
455 455 merging conflict
456 456 warning: conflicts while merging conflict! (edit, then use 'hg resolve --mark')
457 457 unresolved conflicts (see 'hg resolve', then 'hg rebase --continue')
458 458 [240]
459 459 $ hg tglog
460 460 @ 8:draft 'E'
461 461 |
462 462 | @ 7:draft 'D'
463 463 |/
464 464 o 6:draft 'C'
465 465 |
466 466 | % 5:draft 'F'
467 467 | |\
468 468 | | o 4:draft 'E'
469 469 | | |
470 470 | o | 3:draft 'D'
471 471 | |/
472 472 | o 2:draft 'C'
473 473 | |
474 474 o | 1:draft 'B'
475 475 |/
476 476 o 0:draft 'A'
477 477
478 478 $ echo baz > conflict
479 479 $ hg resolve -m
480 480 (no more unresolved files)
481 481 continue: hg rebase --continue
482 482 $ hg rebase -c
483 483 already rebased 2:dc0947a82db8 C "C" as 0199610c343e
484 484 already rebased 3:e7b3f00ed42e D "D" as f0dd538aaa63
485 485 already rebased 4:03ca77807e91 E "E" as cbf25af8347d
486 486 rebasing 5:9a6b91dc2044 F "F"
487 487 saved backup bundle to $TESTTMP/conflict-in-merge/.hg/strip-backup/dc0947a82db8-ca7e7d5b-rebase.hg
488 488 $ hg tglog
489 489 @ 5:draft 'F'
490 490 |\
491 491 | o 4:draft 'E'
492 492 | |
493 493 o | 3:draft 'D'
494 494 |/
495 495 o 2:draft 'C'
496 496 |
497 497 o 1:draft 'B'
498 498 |
499 499 o 0:draft 'A'
500 500
@@ -1,1459 +1,1459
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "strip=" >> $HGRCPATH
3 3 $ echo "drawdag=$TESTDIR/drawdag.py" >> $HGRCPATH
4 4
5 5 $ restore() {
6 6 > hg unbundle -q .hg/strip-backup/*
7 7 > rm .hg/strip-backup/*
8 8 > }
9 9 $ teststrip() {
10 10 > hg up -C $1
11 11 > echo % before update $1, strip $2
12 12 > hg log -G -T '{rev}:{node}'
13 13 > hg --traceback debugstrip $2
14 14 > echo % after update $1, strip $2
15 15 > hg log -G -T '{rev}:{node}'
16 16 > restore
17 17 > }
18 18
19 19 $ hg init test
20 20 $ cd test
21 21
22 22 $ echo foo > bar
23 23 $ hg ci -Ama
24 24 adding bar
25 25
26 26 $ echo more >> bar
27 27 $ hg ci -Amb
28 28
29 29 $ echo blah >> bar
30 30 $ hg ci -Amc
31 31
32 32 $ hg up 1
33 33 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 34 $ echo blah >> bar
35 35 $ hg ci -Amd
36 36 created new head
37 37
38 38 $ echo final >> bar
39 39 $ hg ci -Ame
40 40
41 41 $ hg log
42 42 changeset: 4:443431ffac4f
43 43 tag: tip
44 44 user: test
45 45 date: Thu Jan 01 00:00:00 1970 +0000
46 46 summary: e
47 47
48 48 changeset: 3:65bd5f99a4a3
49 49 parent: 1:ef3a871183d7
50 50 user: test
51 51 date: Thu Jan 01 00:00:00 1970 +0000
52 52 summary: d
53 53
54 54 changeset: 2:264128213d29
55 55 user: test
56 56 date: Thu Jan 01 00:00:00 1970 +0000
57 57 summary: c
58 58
59 59 changeset: 1:ef3a871183d7
60 60 user: test
61 61 date: Thu Jan 01 00:00:00 1970 +0000
62 62 summary: b
63 63
64 64 changeset: 0:9ab35a2d17cb
65 65 user: test
66 66 date: Thu Jan 01 00:00:00 1970 +0000
67 67 summary: a
68 68
69 69
70 70 $ teststrip 4 4
71 71 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
72 72 % before update 4, strip 4
73 73 @ 4:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
74 74 |
75 75 o 3:65bd5f99a4a376cdea23a1153f07856b0d881d64
76 76 |
77 77 | o 2:264128213d290d868c54642d13aeaa3675551a78
78 78 |/
79 79 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
80 80 |
81 81 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
82 82
83 83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
84 84 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
85 85 % after update 4, strip 4
86 86 @ 3:65bd5f99a4a376cdea23a1153f07856b0d881d64
87 87 |
88 88 | o 2:264128213d290d868c54642d13aeaa3675551a78
89 89 |/
90 90 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
91 91 |
92 92 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
93 93
94 94 $ teststrip 4 3
95 95 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
96 96 % before update 4, strip 3
97 97 @ 4:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
98 98 |
99 99 o 3:65bd5f99a4a376cdea23a1153f07856b0d881d64
100 100 |
101 101 | o 2:264128213d290d868c54642d13aeaa3675551a78
102 102 |/
103 103 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
104 104 |
105 105 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
106 106
107 107 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 108 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
109 109 % after update 4, strip 3
110 110 o 2:264128213d290d868c54642d13aeaa3675551a78
111 111 |
112 112 @ 1:ef3a871183d7199c541cc140218298bbfcc6c28a
113 113 |
114 114 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
115 115
116 116 $ teststrip 1 4
117 117 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
118 118 % before update 1, strip 4
119 119 o 4:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
120 120 |
121 121 o 3:65bd5f99a4a376cdea23a1153f07856b0d881d64
122 122 |
123 123 | o 2:264128213d290d868c54642d13aeaa3675551a78
124 124 |/
125 125 @ 1:ef3a871183d7199c541cc140218298bbfcc6c28a
126 126 |
127 127 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
128 128
129 129 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
130 130 % after update 1, strip 4
131 131 o 3:65bd5f99a4a376cdea23a1153f07856b0d881d64
132 132 |
133 133 | o 2:264128213d290d868c54642d13aeaa3675551a78
134 134 |/
135 135 @ 1:ef3a871183d7199c541cc140218298bbfcc6c28a
136 136 |
137 137 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
138 138
139 139 $ teststrip 4 2
140 140 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 141 % before update 4, strip 2
142 142 @ 4:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
143 143 |
144 144 o 3:65bd5f99a4a376cdea23a1153f07856b0d881d64
145 145 |
146 146 | o 2:264128213d290d868c54642d13aeaa3675551a78
147 147 |/
148 148 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
149 149 |
150 150 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
151 151
152 152 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
153 153 % after update 4, strip 2
154 154 @ 3:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
155 155 |
156 156 o 2:65bd5f99a4a376cdea23a1153f07856b0d881d64
157 157 |
158 158 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
159 159 |
160 160 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
161 161
162 162 $ teststrip 4 1
163 163 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 164 % before update 4, strip 1
165 165 @ 4:264128213d290d868c54642d13aeaa3675551a78
166 166 |
167 167 | o 3:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
168 168 | |
169 169 | o 2:65bd5f99a4a376cdea23a1153f07856b0d881d64
170 170 |/
171 171 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
172 172 |
173 173 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
174 174
175 175 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
176 176 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
177 177 % after update 4, strip 1
178 178 @ 0:9ab35a2d17cb64271241ea881efcc19dd953215b
179 179
180 180 $ teststrip null 4
181 181 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
182 182 % before update null, strip 4
183 183 o 4:264128213d290d868c54642d13aeaa3675551a78
184 184 |
185 185 | o 3:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
186 186 | |
187 187 | o 2:65bd5f99a4a376cdea23a1153f07856b0d881d64
188 188 |/
189 189 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
190 190 |
191 191 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
192 192
193 193 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
194 194 % after update null, strip 4
195 195 o 3:443431ffac4f5b5a19b0b6c298a21b7ba736bcce
196 196 |
197 197 o 2:65bd5f99a4a376cdea23a1153f07856b0d881d64
198 198 |
199 199 o 1:ef3a871183d7199c541cc140218298bbfcc6c28a
200 200 |
201 201 o 0:9ab35a2d17cb64271241ea881efcc19dd953215b
202 202
203 203
204 204 $ hg log
205 205 changeset: 4:264128213d29
206 206 tag: tip
207 207 parent: 1:ef3a871183d7
208 208 user: test
209 209 date: Thu Jan 01 00:00:00 1970 +0000
210 210 summary: c
211 211
212 212 changeset: 3:443431ffac4f
213 213 user: test
214 214 date: Thu Jan 01 00:00:00 1970 +0000
215 215 summary: e
216 216
217 217 changeset: 2:65bd5f99a4a3
218 218 user: test
219 219 date: Thu Jan 01 00:00:00 1970 +0000
220 220 summary: d
221 221
222 222 changeset: 1:ef3a871183d7
223 223 user: test
224 224 date: Thu Jan 01 00:00:00 1970 +0000
225 225 summary: b
226 226
227 227 changeset: 0:9ab35a2d17cb
228 228 user: test
229 229 date: Thu Jan 01 00:00:00 1970 +0000
230 230 summary: a
231 231
232 232 $ hg up -C 4
233 233 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
234 234 $ hg parents
235 235 changeset: 4:264128213d29
236 236 tag: tip
237 237 parent: 1:ef3a871183d7
238 238 user: test
239 239 date: Thu Jan 01 00:00:00 1970 +0000
240 240 summary: c
241 241
242 242
243 243 $ hg --traceback strip 4
244 244 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
245 245 saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg
246 246 $ hg parents
247 247 changeset: 1:ef3a871183d7
248 248 user: test
249 249 date: Thu Jan 01 00:00:00 1970 +0000
250 250 summary: b
251 251
252 252 $ hg debugbundle .hg/strip-backup/*
253 253 Stream params: {Compression: BZ}
254 254 changegroup -- {nbchanges: 1, version: 03} (mandatory: True)
255 255 264128213d290d868c54642d13aeaa3675551a78
256 256 cache:rev-branch-cache -- {} (mandatory: False)
257 257 phase-heads -- {} (mandatory: True)
258 258 264128213d290d868c54642d13aeaa3675551a78 draft
259 259 $ hg unbundle .hg/strip-backup/*
260 260 adding changesets
261 261 adding manifests
262 262 adding file changes
263 263 added 1 changesets with 0 changes to 1 files (+1 heads)
264 264 new changesets 264128213d29 (1 drafts)
265 265 (run 'hg heads' to see heads, 'hg merge' to merge)
266 266 $ rm .hg/strip-backup/*
267 267 $ hg log --graph
268 268 o changeset: 4:264128213d29
269 269 | tag: tip
270 270 | parent: 1:ef3a871183d7
271 271 | user: test
272 272 | date: Thu Jan 01 00:00:00 1970 +0000
273 273 | summary: c
274 274 |
275 275 | o changeset: 3:443431ffac4f
276 276 | | user: test
277 277 | | date: Thu Jan 01 00:00:00 1970 +0000
278 278 | | summary: e
279 279 | |
280 280 | o changeset: 2:65bd5f99a4a3
281 281 |/ user: test
282 282 | date: Thu Jan 01 00:00:00 1970 +0000
283 283 | summary: d
284 284 |
285 285 @ changeset: 1:ef3a871183d7
286 286 | user: test
287 287 | date: Thu Jan 01 00:00:00 1970 +0000
288 288 | summary: b
289 289 |
290 290 o changeset: 0:9ab35a2d17cb
291 291 user: test
292 292 date: Thu Jan 01 00:00:00 1970 +0000
293 293 summary: a
294 294
295 295 $ hg up -C 2
296 296 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
297 297 $ hg merge 4
298 298 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
299 299 (branch merge, don't forget to commit)
300 300
301 301 before strip of merge parent
302 302
303 303 $ hg parents
304 304 changeset: 2:65bd5f99a4a3
305 305 user: test
306 306 date: Thu Jan 01 00:00:00 1970 +0000
307 307 summary: d
308 308
309 309 changeset: 4:264128213d29
310 310 tag: tip
311 311 parent: 1:ef3a871183d7
312 312 user: test
313 313 date: Thu Jan 01 00:00:00 1970 +0000
314 314 summary: c
315 315
316 316 ##strip not allowed with merge in progress
317 317 $ hg strip 4
318 318 abort: outstanding uncommitted merge
319 319 (use 'hg commit' or 'hg merge --abort')
320 320 [20]
321 321 ##strip allowed --force with merge in progress
322 322 $ hg strip 4 --force
323 323 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
324 324 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
325 325
326 326 after strip of merge parent
327 327
328 328 $ hg parents
329 329 changeset: 1:ef3a871183d7
330 330 user: test
331 331 date: Thu Jan 01 00:00:00 1970 +0000
332 332 summary: b
333 333
334 334 $ restore
335 335
336 336 $ hg up
337 337 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
338 338 updated to "264128213d29: c"
339 339 1 other heads for branch "default"
340 340 $ hg log -G
341 341 @ changeset: 4:264128213d29
342 342 | tag: tip
343 343 | parent: 1:ef3a871183d7
344 344 | user: test
345 345 | date: Thu Jan 01 00:00:00 1970 +0000
346 346 | summary: c
347 347 |
348 348 | o changeset: 3:443431ffac4f
349 349 | | user: test
350 350 | | date: Thu Jan 01 00:00:00 1970 +0000
351 351 | | summary: e
352 352 | |
353 353 | o changeset: 2:65bd5f99a4a3
354 354 |/ user: test
355 355 | date: Thu Jan 01 00:00:00 1970 +0000
356 356 | summary: d
357 357 |
358 358 o changeset: 1:ef3a871183d7
359 359 | user: test
360 360 | date: Thu Jan 01 00:00:00 1970 +0000
361 361 | summary: b
362 362 |
363 363 o changeset: 0:9ab35a2d17cb
364 364 user: test
365 365 date: Thu Jan 01 00:00:00 1970 +0000
366 366 summary: a
367 367
368 368
369 369 2 is parent of 3, only one strip should happen
370 370
371 371 $ hg strip "roots(2)" 3
372 372 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
373 373 $ hg log -G
374 374 @ changeset: 2:264128213d29
375 375 | tag: tip
376 376 | user: test
377 377 | date: Thu Jan 01 00:00:00 1970 +0000
378 378 | summary: c
379 379 |
380 380 o changeset: 1:ef3a871183d7
381 381 | user: test
382 382 | date: Thu Jan 01 00:00:00 1970 +0000
383 383 | summary: b
384 384 |
385 385 o changeset: 0:9ab35a2d17cb
386 386 user: test
387 387 date: Thu Jan 01 00:00:00 1970 +0000
388 388 summary: a
389 389
390 390 $ restore
391 391 $ hg log -G
392 392 o changeset: 4:443431ffac4f
393 393 | tag: tip
394 394 | user: test
395 395 | date: Thu Jan 01 00:00:00 1970 +0000
396 396 | summary: e
397 397 |
398 398 o changeset: 3:65bd5f99a4a3
399 399 | parent: 1:ef3a871183d7
400 400 | user: test
401 401 | date: Thu Jan 01 00:00:00 1970 +0000
402 402 | summary: d
403 403 |
404 404 | @ changeset: 2:264128213d29
405 405 |/ user: test
406 406 | date: Thu Jan 01 00:00:00 1970 +0000
407 407 | summary: c
408 408 |
409 409 o changeset: 1:ef3a871183d7
410 410 | user: test
411 411 | date: Thu Jan 01 00:00:00 1970 +0000
412 412 | summary: b
413 413 |
414 414 o changeset: 0:9ab35a2d17cb
415 415 user: test
416 416 date: Thu Jan 01 00:00:00 1970 +0000
417 417 summary: a
418 418
419 419 Failed hook while applying "saveheads" bundle.
420 420
421 421 $ hg strip 2 --config hooks.pretxnchangegroup.bad=false
422 422 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
423 423 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
424 424 transaction abort!
425 425 rollback completed
426 426 strip failed, backup bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob)
427 427 strip failed, unrecovered changes stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob)
428 428 (fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/test/.hg/strip-backup/*-temp.hg'") (glob)
429 429 abort: pretxnchangegroup.bad hook exited with status 1
430 430 [40]
431 431 $ restore
432 432 $ hg log -G
433 433 o changeset: 4:443431ffac4f
434 434 | tag: tip
435 435 | user: test
436 436 | date: Thu Jan 01 00:00:00 1970 +0000
437 437 | summary: e
438 438 |
439 439 o changeset: 3:65bd5f99a4a3
440 440 | parent: 1:ef3a871183d7
441 441 | user: test
442 442 | date: Thu Jan 01 00:00:00 1970 +0000
443 443 | summary: d
444 444 |
445 445 | o changeset: 2:264128213d29
446 446 |/ user: test
447 447 | date: Thu Jan 01 00:00:00 1970 +0000
448 448 | summary: c
449 449 |
450 450 @ changeset: 1:ef3a871183d7
451 451 | user: test
452 452 | date: Thu Jan 01 00:00:00 1970 +0000
453 453 | summary: b
454 454 |
455 455 o changeset: 0:9ab35a2d17cb
456 456 user: test
457 457 date: Thu Jan 01 00:00:00 1970 +0000
458 458 summary: a
459 459
460 460
461 461 2 different branches: 2 strips
462 462
463 463 $ hg strip 2 4
464 464 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
465 465 $ hg log -G
466 466 o changeset: 2:65bd5f99a4a3
467 467 | tag: tip
468 468 | user: test
469 469 | date: Thu Jan 01 00:00:00 1970 +0000
470 470 | summary: d
471 471 |
472 472 @ changeset: 1:ef3a871183d7
473 473 | user: test
474 474 | date: Thu Jan 01 00:00:00 1970 +0000
475 475 | summary: b
476 476 |
477 477 o changeset: 0:9ab35a2d17cb
478 478 user: test
479 479 date: Thu Jan 01 00:00:00 1970 +0000
480 480 summary: a
481 481
482 482 $ restore
483 483
484 484 2 different branches and a common ancestor: 1 strip
485 485
486 486 $ hg strip 1 "2|4"
487 487 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
488 488 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
489 489 $ restore
490 490
491 491 verify fncache is kept up-to-date
492 492
493 493 $ touch a
494 494 $ hg ci -qAm a
495 495 #if repofncache
496 496 $ cat .hg/store/fncache | sort
497 497 data/a.i
498 498 data/bar.i
499 499 #endif
500 500
501 501 $ hg strip tip
502 502 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
503 503 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
504 504 #if repofncache
505 505 $ cat .hg/store/fncache
506 506 data/bar.i
507 507 #endif
508 508
509 509 stripping an empty revset
510 510
511 511 $ hg strip "1 and not 1"
512 512 abort: empty revision set
513 513 [255]
514 514
515 515 remove branchy history for qimport tests
516 516
517 517 $ hg strip 3
518 518 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
519 519
520 520
521 521 strip of applied mq should cleanup status file
522 522
523 523 $ echo "mq=" >> $HGRCPATH
524 524 $ hg up -C 3
525 525 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
526 526 $ echo fooagain >> bar
527 527 $ hg ci -mf
528 528 $ hg qimport -r tip:2
529 529
530 530 applied patches before strip
531 531
532 532 $ hg qapplied
533 533 d
534 534 e
535 535 f
536 536
537 537 stripping revision in queue
538 538
539 539 $ hg strip 3
540 540 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
541 541 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
542 542
543 543 applied patches after stripping rev in queue
544 544
545 545 $ hg qapplied
546 546 d
547 547
548 548 stripping ancestor of queue
549 549
550 550 $ hg strip 1
551 551 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
552 552 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
553 553
554 554 applied patches after stripping ancestor of queue
555 555
556 556 $ hg qapplied
557 557
558 558 Verify strip protects against stripping wc parent when there are uncommitted mods
559 559
560 560 $ echo b > b
561 561 $ echo bb > bar
562 562 $ hg add b
563 563 $ hg ci -m 'b'
564 564 $ hg log --graph
565 565 @ changeset: 1:76dcf9fab855
566 566 | tag: tip
567 567 | user: test
568 568 | date: Thu Jan 01 00:00:00 1970 +0000
569 569 | summary: b
570 570 |
571 571 o changeset: 0:9ab35a2d17cb
572 572 user: test
573 573 date: Thu Jan 01 00:00:00 1970 +0000
574 574 summary: a
575 575
576 576 $ hg up 0
577 577 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
578 578 $ echo c > bar
579 579 $ hg up -t false
580 580 merging bar
581 581 merging bar failed!
582 582 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
583 583 use 'hg resolve' to retry unresolved file merges
584 584 [1]
585 585 $ hg sum
586 586 parent: 1:76dcf9fab855 tip
587 587 b
588 588 branch: default
589 589 commit: 1 modified, 1 unknown, 1 unresolved
590 590 update: (current)
591 591 phases: 2 draft
592 592 mq: 3 unapplied
593 593
594 594 $ hg log --graph
595 595 @ changeset: 1:76dcf9fab855
596 596 | tag: tip
597 597 | user: test
598 598 | date: Thu Jan 01 00:00:00 1970 +0000
599 599 | summary: b
600 600 |
601 601 % changeset: 0:9ab35a2d17cb
602 602 user: test
603 603 date: Thu Jan 01 00:00:00 1970 +0000
604 604 summary: a
605 605
606 606 $ echo c > b
607 607 $ hg strip tip
608 608 abort: uncommitted changes
609 609 [20]
610 610 $ hg strip tip --keep
611 611 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
612 612 $ hg log --graph
613 613 @ changeset: 0:9ab35a2d17cb
614 614 tag: tip
615 615 user: test
616 616 date: Thu Jan 01 00:00:00 1970 +0000
617 617 summary: a
618 618
619 619 $ hg status
620 620 M bar
621 621 ? b
622 622 ? bar.orig
623 623
624 624 $ rm bar.orig
625 625 $ hg sum
626 626 parent: 0:9ab35a2d17cb tip
627 627 a
628 628 branch: default
629 629 commit: 1 modified, 1 unknown
630 630 update: (current)
631 631 phases: 1 draft
632 632 mq: 3 unapplied
633 633
634 634 Strip adds, removes, modifies with --keep
635 635
636 636 $ touch b
637 637 $ hg add b
638 638 $ hg commit -mb
639 639 $ touch c
640 640
641 641 ... with a clean working dir
642 642
643 643 $ hg add c
644 644 $ hg rm bar
645 645 $ hg commit -mc
646 646 $ hg status
647 647 $ hg strip --keep tip
648 648 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
649 649 $ hg status
650 650 ! bar
651 651 ? c
652 652
653 653 ... with a dirty working dir
654 654
655 655 $ hg add c
656 656 $ hg rm bar
657 657 $ hg commit -mc
658 658 $ hg status
659 659 $ echo b > b
660 660 $ echo d > d
661 661 $ hg strip --keep tip
662 662 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
663 663 $ hg status
664 664 M b
665 665 ! bar
666 666 ? c
667 667 ? d
668 668
669 669 ... after updating the dirstate
670 670 $ hg add c
671 671 $ hg commit -mc
672 672 $ hg rm c
673 673 $ hg commit -mc
674 674 $ hg strip --keep '.^' -q
675 675 $ cd ..
676 676
677 677 stripping many nodes on a complex graph (issue3299)
678 678
679 679 $ hg init issue3299
680 680 $ cd issue3299
681 681 $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
682 682 $ hg strip 'not ancestors(x)'
683 683 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
684 684
685 685 test hg strip -B bookmark
686 686
687 687 $ cd ..
688 688 $ hg init bookmarks
689 689 $ cd bookmarks
690 690 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b<m+2:d<2.:e<m+1:f'
691 691 $ hg bookmark -r 'a' 'todelete'
692 692 $ hg bookmark -r 'b' 'B'
693 693 $ hg bookmark -r 'b' 'nostrip'
694 694 $ hg bookmark -r 'c' 'delete'
695 695 $ hg bookmark -r 'd' 'multipledelete1'
696 696 $ hg bookmark -r 'e' 'multipledelete2'
697 697 $ hg bookmark -r 'f' 'singlenode1'
698 698 $ hg bookmark -r 'f' 'singlenode2'
699 699 $ hg up -C todelete
700 700 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
701 701 (activating bookmark todelete)
702 702 $ hg strip -B nostrip
703 703 bookmark 'nostrip' deleted
704 704 abort: empty revision set
705 705 [255]
706 706 $ hg strip -B todelete
707 707 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
708 708 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
709 709 bookmark 'todelete' deleted
710 710 $ hg id -ir dcbb326fdec2
711 711 abort: unknown revision 'dcbb326fdec2'
712 712 [10]
713 713 $ hg id -ir d62d843c9a01
714 714 d62d843c9a01
715 715 $ hg bookmarks
716 716 B 9:ff43616e5d0f
717 717 delete 6:2702dd0c91e7
718 718 multipledelete1 11:e46a4836065c
719 719 multipledelete2 12:b4594d867745
720 720 singlenode1 13:43227190fef8
721 721 singlenode2 13:43227190fef8
722 722 $ hg strip -B multipledelete1 -B multipledelete2
723 723 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/e46a4836065c-89ec65c2-backup.hg
724 724 bookmark 'multipledelete1' deleted
725 725 bookmark 'multipledelete2' deleted
726 726 $ hg id -ir e46a4836065c
727 727 abort: unknown revision 'e46a4836065c'
728 728 [10]
729 729 $ hg id -ir b4594d867745
730 730 abort: unknown revision 'b4594d867745'
731 731 [10]
732 732 $ hg strip -B singlenode1 -B singlenode2
733 733 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg
734 734 bookmark 'singlenode1' deleted
735 735 bookmark 'singlenode2' deleted
736 736 $ hg id -ir 43227190fef8
737 737 abort: unknown revision '43227190fef8'
738 738 [10]
739 739 $ hg strip -B unknownbookmark
740 740 abort: bookmark 'unknownbookmark' not found
741 741 [255]
742 742 $ hg strip -B unknownbookmark1 -B unknownbookmark2
743 743 abort: bookmark 'unknownbookmark1,unknownbookmark2' not found
744 744 [255]
745 745 $ hg strip -B delete -B unknownbookmark
746 746 abort: bookmark 'unknownbookmark' not found
747 747 [255]
748 748 $ hg strip -B delete
749 749 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
750 750 bookmark 'delete' deleted
751 751 $ hg id -ir 6:2702dd0c91e7
752 752 abort: unknown revision '2702dd0c91e7'
753 753 [10]
754 754 $ hg update B
755 755 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
756 756 (activating bookmark B)
757 757 $ echo a > a
758 758 $ hg add a
759 759 $ hg strip -B B
760 760 abort: uncommitted changes
761 761 [20]
762 762 $ hg bookmarks
763 763 * B 6:ff43616e5d0f
764 764
765 765 Make sure no one adds back a -b option:
766 766
767 767 $ hg strip -b tip
768 768 hg debugstrip: option -b not recognized
769 769 hg debugstrip [-k] [-f] [-B bookmark] [-r] REV...
770 770
771 771 strip changesets and all their descendants from the repository
772 772
773 773 options ([+] can be repeated):
774 774
775 775 -r --rev REV [+] strip specified revision (optional, can specify
776 776 revisions without this option)
777 777 -f --force force removal of changesets, discard uncommitted
778 778 changes (no backup)
779 779 --no-backup do not save backup bundle
780 780 -k --keep do not modify working directory during strip
781 781 -B --bookmark BOOKMARK [+] remove revs only reachable from given bookmark
782 782 --mq operate on patch repository
783 783
784 784 (use 'hg debugstrip -h' to show more help)
785 785 [10]
786 786
787 787 $ cd ..
788 788
789 789 Verify bundles don't get overwritten:
790 790
791 791 $ hg init doublebundle
792 792 $ cd doublebundle
793 793 $ touch a
794 794 $ hg commit -Aqm a
795 795 $ touch b
796 796 $ hg commit -Aqm b
797 797 $ hg strip -r 0
798 798 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
799 799 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-e68910bd-backup.hg
800 800 $ ls .hg/strip-backup
801 801 3903775176ed-e68910bd-backup.hg
802 802 #if repobundlerepo
803 803 $ hg pull -q -r 3903775176ed .hg/strip-backup/3903775176ed-e68910bd-backup.hg
804 804 $ hg strip -r 0
805 805 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg
806 806 $ ls .hg/strip-backup
807 807 3903775176ed-54390173-backup.hg
808 808 3903775176ed-e68910bd-backup.hg
809 809 #endif
810 810 $ cd ..
811 811
812 812 Test that we only bundle the stripped changesets (issue4736)
813 813 ------------------------------------------------------------
814 814
815 815 initialization (previous repo is empty anyway)
816 816
817 817 $ hg init issue4736
818 818 $ cd issue4736
819 819 $ echo a > a
820 820 $ hg add a
821 821 $ hg commit -m commitA
822 822 $ echo b > b
823 823 $ hg add b
824 824 $ hg commit -m commitB
825 825 $ echo c > c
826 826 $ hg add c
827 827 $ hg commit -m commitC
828 828 $ hg up 'desc(commitB)'
829 829 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
830 830 $ echo d > d
831 831 $ hg add d
832 832 $ hg commit -m commitD
833 833 created new head
834 834 $ hg up 'desc(commitC)'
835 835 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
836 836 $ hg merge 'desc(commitD)'
837 837 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
838 838 (branch merge, don't forget to commit)
839 839 $ hg ci -m 'mergeCD'
840 840 $ hg log -G
841 841 @ changeset: 4:d8db9d137221
842 842 |\ tag: tip
843 843 | | parent: 2:5c51d8d6557d
844 844 | | parent: 3:6625a5168474
845 845 | | user: test
846 846 | | date: Thu Jan 01 00:00:00 1970 +0000
847 847 | | summary: mergeCD
848 848 | |
849 849 | o changeset: 3:6625a5168474
850 850 | | parent: 1:eca11cf91c71
851 851 | | user: test
852 852 | | date: Thu Jan 01 00:00:00 1970 +0000
853 853 | | summary: commitD
854 854 | |
855 855 o | changeset: 2:5c51d8d6557d
856 856 |/ user: test
857 857 | date: Thu Jan 01 00:00:00 1970 +0000
858 858 | summary: commitC
859 859 |
860 860 o changeset: 1:eca11cf91c71
861 861 | user: test
862 862 | date: Thu Jan 01 00:00:00 1970 +0000
863 863 | summary: commitB
864 864 |
865 865 o changeset: 0:105141ef12d0
866 866 user: test
867 867 date: Thu Jan 01 00:00:00 1970 +0000
868 868 summary: commitA
869 869
870 870
871 871 Check bundle behavior:
872 872
873 873 $ hg bundle -r 'desc(mergeCD)' --base 'desc(commitC)' ../issue4736.hg
874 874 2 changesets found
875 875 #if repobundlerepo
876 876 $ hg log -r 'bundle()' -R ../issue4736.hg
877 877 changeset: 3:6625a5168474
878 878 parent: 1:eca11cf91c71
879 879 user: test
880 880 date: Thu Jan 01 00:00:00 1970 +0000
881 881 summary: commitD
882 882
883 883 changeset: 4:d8db9d137221
884 884 tag: tip
885 885 parent: 2:5c51d8d6557d
886 886 parent: 3:6625a5168474
887 887 user: test
888 888 date: Thu Jan 01 00:00:00 1970 +0000
889 889 summary: mergeCD
890 890
891 891 #endif
892 892
893 893 check strip behavior
894 894
895 895 $ hg --config extensions.strip= strip 'desc(commitD)' --debug
896 896 resolving manifests
897 897 branchmerge: False, force: True, partial: False
898 898 ancestor: d8db9d137221+, local: d8db9d137221+, remote: eca11cf91c71
899 899 c: other deleted -> r
900 900 removing c
901 901 d: other deleted -> r
902 902 removing d
903 903 starting 4 threads for background file closing (?)
904 904 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
905 905 2 changesets found
906 906 list of changesets:
907 907 6625a516847449b6f0fa3737b9ba56e9f0f3032c
908 908 d8db9d1372214336d2b5570f20ee468d2c72fa8b
909 909 bundle2-output-bundle: "HG20", (1 params) 3 parts total
910 910 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
911 911 bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
912 912 bundle2-output-part: "phase-heads" 24 bytes payload
913 913 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg
914 914 updating the branch cache
915 915 invalid branch cache (served): tip differs
916 resetting content of cache/rbc-revs-v2
916 resetting content of rbc-names-v2
917 917 $ hg log -G
918 918 o changeset: 2:5c51d8d6557d
919 919 | tag: tip
920 920 | user: test
921 921 | date: Thu Jan 01 00:00:00 1970 +0000
922 922 | summary: commitC
923 923 |
924 924 @ changeset: 1:eca11cf91c71
925 925 | user: test
926 926 | date: Thu Jan 01 00:00:00 1970 +0000
927 927 | summary: commitB
928 928 |
929 929 o changeset: 0:105141ef12d0
930 930 user: test
931 931 date: Thu Jan 01 00:00:00 1970 +0000
932 932 summary: commitA
933 933
934 934
935 935 strip backup content
936 936
937 937 #if repobundlerepo
938 938 $ hg log -r 'bundle()' -R .hg/strip-backup/6625a5168474-*-backup.hg
939 939 changeset: 3:6625a5168474
940 940 parent: 1:eca11cf91c71
941 941 user: test
942 942 date: Thu Jan 01 00:00:00 1970 +0000
943 943 summary: commitD
944 944
945 945 changeset: 4:d8db9d137221
946 946 tag: tip
947 947 parent: 2:5c51d8d6557d
948 948 parent: 3:6625a5168474
949 949 user: test
950 950 date: Thu Jan 01 00:00:00 1970 +0000
951 951 summary: mergeCD
952 952
953 953
954 954 #endif
955 955
956 956 Check that the phase cache is properly invalidated after a strip with bookmark.
957 957
958 958 $ cat > ../stripstalephasecache.py << EOF
959 959 > from mercurial import extensions, localrepo
960 960 > def transactioncallback(orig, repo, desc, *args, **kwargs):
961 961 > def test(transaction):
962 962 > # observe cache inconsistency
963 963 > try:
964 964 > [repo.changelog.node(r) for r in repo.revs(b"not public()")]
965 965 > except IndexError:
966 966 > repo.ui.status(b"Index error!\n")
967 967 > transaction = orig(repo, desc, *args, **kwargs)
968 968 > # warm up the phase cache
969 969 > list(repo.revs(b"not public()"))
970 970 > if desc != b'strip':
971 971 > transaction.addpostclose(b"phase invalidation test", test)
972 972 > return transaction
973 973 > def extsetup(ui):
974 974 > extensions.wrapfunction(localrepo.localrepository, "transaction",
975 975 > transactioncallback)
976 976 > EOF
977 977 $ hg up -C 2
978 978 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
979 979 $ echo k > k
980 980 $ hg add k
981 981 $ hg commit -m commitK
982 982 $ echo l > l
983 983 $ hg add l
984 984 $ hg commit -m commitL
985 985 $ hg book -r tip blah
986 986 $ hg strip ".^" --config extensions.crash=$TESTTMP/stripstalephasecache.py
987 987 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
988 988 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/8f0b4384875c-4fa10deb-backup.hg
989 989 $ hg up -C 1
990 990 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
991 991
992 992 Error during post-close callback of the strip transaction
993 993 (They should be gracefully handled and reported)
994 994
995 995 $ cat > ../crashstrip.py << EOF
996 996 > from mercurial import error
997 997 > def reposetup(ui, repo):
998 998 > class crashstriprepo(repo.__class__):
999 999 > def transaction(self, desc, *args, **kwargs):
1000 1000 > tr = super(crashstriprepo, self).transaction(desc, *args, **kwargs)
1001 1001 > if desc == b'strip':
1002 1002 > def crash(tra): raise error.Abort(b'boom')
1003 1003 > tr.addpostclose(b'crash', crash)
1004 1004 > return tr
1005 1005 > repo.__class__ = crashstriprepo
1006 1006 > EOF
1007 1007 $ hg strip tip --config extensions.crash=$TESTTMP/crashstrip.py
1008 1008 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg
1009 1009 strip failed, backup bundle stored in '$TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg'
1010 1010 abort: boom
1011 1011 [255]
1012 1012
1013 1013 test stripping a working directory parent doesn't switch named branches
1014 1014
1015 1015 $ hg log -G
1016 1016 @ changeset: 1:eca11cf91c71
1017 1017 | tag: tip
1018 1018 | user: test
1019 1019 | date: Thu Jan 01 00:00:00 1970 +0000
1020 1020 | summary: commitB
1021 1021 |
1022 1022 o changeset: 0:105141ef12d0
1023 1023 user: test
1024 1024 date: Thu Jan 01 00:00:00 1970 +0000
1025 1025 summary: commitA
1026 1026
1027 1027
1028 1028 $ hg branch new-branch
1029 1029 marked working directory as branch new-branch
1030 1030 (branches are permanent and global, did you want a bookmark?)
1031 1031 $ hg ci -m "start new branch"
1032 1032 $ echo 'foo' > foo.txt
1033 1033 $ hg ci -Aqm foo
1034 1034 $ hg up default
1035 1035 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1036 1036 $ echo 'bar' > bar.txt
1037 1037 $ hg ci -Aqm bar
1038 1038 $ hg up new-branch
1039 1039 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1040 1040 $ hg merge default
1041 1041 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1042 1042 (branch merge, don't forget to commit)
1043 1043 $ hg log -G
1044 1044 @ changeset: 4:35358f982181
1045 1045 | tag: tip
1046 1046 | parent: 1:eca11cf91c71
1047 1047 | user: test
1048 1048 | date: Thu Jan 01 00:00:00 1970 +0000
1049 1049 | summary: bar
1050 1050 |
1051 1051 | @ changeset: 3:f62c6c09b707
1052 1052 | | branch: new-branch
1053 1053 | | user: test
1054 1054 | | date: Thu Jan 01 00:00:00 1970 +0000
1055 1055 | | summary: foo
1056 1056 | |
1057 1057 | o changeset: 2:b1d33a8cadd9
1058 1058 |/ branch: new-branch
1059 1059 | user: test
1060 1060 | date: Thu Jan 01 00:00:00 1970 +0000
1061 1061 | summary: start new branch
1062 1062 |
1063 1063 o changeset: 1:eca11cf91c71
1064 1064 | user: test
1065 1065 | date: Thu Jan 01 00:00:00 1970 +0000
1066 1066 | summary: commitB
1067 1067 |
1068 1068 o changeset: 0:105141ef12d0
1069 1069 user: test
1070 1070 date: Thu Jan 01 00:00:00 1970 +0000
1071 1071 summary: commitA
1072 1072
1073 1073
1074 1074 $ hg strip --force -r 35358f982181
1075 1075 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1076 1076 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/35358f982181-50d992d4-backup.hg
1077 1077 $ hg log -G
1078 1078 @ changeset: 3:f62c6c09b707
1079 1079 | branch: new-branch
1080 1080 | tag: tip
1081 1081 | user: test
1082 1082 | date: Thu Jan 01 00:00:00 1970 +0000
1083 1083 | summary: foo
1084 1084 |
1085 1085 o changeset: 2:b1d33a8cadd9
1086 1086 | branch: new-branch
1087 1087 | user: test
1088 1088 | date: Thu Jan 01 00:00:00 1970 +0000
1089 1089 | summary: start new branch
1090 1090 |
1091 1091 o changeset: 1:eca11cf91c71
1092 1092 | user: test
1093 1093 | date: Thu Jan 01 00:00:00 1970 +0000
1094 1094 | summary: commitB
1095 1095 |
1096 1096 o changeset: 0:105141ef12d0
1097 1097 user: test
1098 1098 date: Thu Jan 01 00:00:00 1970 +0000
1099 1099 summary: commitA
1100 1100
1101 1101
1102 1102 $ hg up default
1103 1103 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1104 1104 $ echo 'bar' > bar.txt
1105 1105 $ hg ci -Aqm bar
1106 1106 $ hg up new-branch
1107 1107 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1108 1108 $ hg merge default
1109 1109 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1110 1110 (branch merge, don't forget to commit)
1111 1111 $ hg ci -m merge
1112 1112 $ hg log -G
1113 1113 @ changeset: 5:4cf5e92caec2
1114 1114 |\ branch: new-branch
1115 1115 | | tag: tip
1116 1116 | | parent: 3:f62c6c09b707
1117 1117 | | parent: 4:35358f982181
1118 1118 | | user: test
1119 1119 | | date: Thu Jan 01 00:00:00 1970 +0000
1120 1120 | | summary: merge
1121 1121 | |
1122 1122 | o changeset: 4:35358f982181
1123 1123 | | parent: 1:eca11cf91c71
1124 1124 | | user: test
1125 1125 | | date: Thu Jan 01 00:00:00 1970 +0000
1126 1126 | | summary: bar
1127 1127 | |
1128 1128 o | changeset: 3:f62c6c09b707
1129 1129 | | branch: new-branch
1130 1130 | | user: test
1131 1131 | | date: Thu Jan 01 00:00:00 1970 +0000
1132 1132 | | summary: foo
1133 1133 | |
1134 1134 o | changeset: 2:b1d33a8cadd9
1135 1135 |/ branch: new-branch
1136 1136 | user: test
1137 1137 | date: Thu Jan 01 00:00:00 1970 +0000
1138 1138 | summary: start new branch
1139 1139 |
1140 1140 o changeset: 1:eca11cf91c71
1141 1141 | user: test
1142 1142 | date: Thu Jan 01 00:00:00 1970 +0000
1143 1143 | summary: commitB
1144 1144 |
1145 1145 o changeset: 0:105141ef12d0
1146 1146 user: test
1147 1147 date: Thu Jan 01 00:00:00 1970 +0000
1148 1148 summary: commitA
1149 1149
1150 1150
1151 1151 $ hg strip -r 35358f982181
1152 1152 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1153 1153 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/35358f982181-a6f020aa-backup.hg
1154 1154 $ hg log -G
1155 1155 @ changeset: 3:f62c6c09b707
1156 1156 | branch: new-branch
1157 1157 | tag: tip
1158 1158 | user: test
1159 1159 | date: Thu Jan 01 00:00:00 1970 +0000
1160 1160 | summary: foo
1161 1161 |
1162 1162 o changeset: 2:b1d33a8cadd9
1163 1163 | branch: new-branch
1164 1164 | user: test
1165 1165 | date: Thu Jan 01 00:00:00 1970 +0000
1166 1166 | summary: start new branch
1167 1167 |
1168 1168 o changeset: 1:eca11cf91c71
1169 1169 | user: test
1170 1170 | date: Thu Jan 01 00:00:00 1970 +0000
1171 1171 | summary: commitB
1172 1172 |
1173 1173 o changeset: 0:105141ef12d0
1174 1174 user: test
1175 1175 date: Thu Jan 01 00:00:00 1970 +0000
1176 1176 summary: commitA
1177 1177
1178 1178
1179 1179 stripping a set containing a merge properly reset file content, including items on other branches
1180 1180
1181 1181 The added file is moved to unknown, which is the behavior we have been seeing for other `hg strip --keep` call.
1182 1182
1183 1183 stripping a set containing a merge properly reset file content, including items on other branches
1184 1184
1185 1185 The added file is moved to unknown, which is the behavior we have been seeing for other `hg strip --keep` call.
1186 1186
1187 1187 $ hg unbundle -u $TESTTMP/issue4736/.hg/strip-backup/35358f982181-a6f020aa-backup.hg
1188 1188 adding changesets
1189 1189 adding manifests
1190 1190 adding file changes
1191 1191 added 2 changesets with 1 changes to 1 files
1192 1192 new changesets 35358f982181:4cf5e92caec2 (2 drafts)
1193 1193 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1194 1194
1195 1195 $ hg id
1196 1196 4cf5e92caec2 (new-branch) tip
1197 1197 $ hg status --rev "f62c6c09b707"
1198 1198 A bar.txt
1199 1199 $ hg diff --rev "f62c6c09b707"
1200 1200 diff -r f62c6c09b707 bar.txt
1201 1201 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1202 1202 +++ b/bar.txt Thu Jan 01 00:00:00 1970 +0000
1203 1203 @@ -0,0 +1,1 @@
1204 1204 +bar
1205 1205 $ hg log -G -v --rev 35358f982181:: --patch
1206 1206 @ changeset: 5:4cf5e92caec2
1207 1207 |\ branch: new-branch
1208 1208 | ~ tag: tip
1209 1209 | parent: 3:f62c6c09b707
1210 1210 | parent: 4:35358f982181
1211 1211 | user: test
1212 1212 | date: Thu Jan 01 00:00:00 1970 +0000
1213 1213 | description:
1214 1214 | merge
1215 1215 |
1216 1216 |
1217 1217 | diff -r f62c6c09b707 -r 4cf5e92caec2 bar.txt
1218 1218 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1219 1219 | +++ b/bar.txt Thu Jan 01 00:00:00 1970 +0000
1220 1220 | @@ -0,0 +1,1 @@
1221 1221 | +bar
1222 1222 |
1223 1223 o changeset: 4:35358f982181
1224 1224 | parent: 1:eca11cf91c71
1225 1225 ~ user: test
1226 1226 date: Thu Jan 01 00:00:00 1970 +0000
1227 1227 files: bar.txt
1228 1228 description:
1229 1229 bar
1230 1230
1231 1231
1232 1232 diff -r eca11cf91c71 -r 35358f982181 bar.txt
1233 1233 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1234 1234 +++ b/bar.txt Thu Jan 01 00:00:00 1970 +0000
1235 1235 @@ -0,0 +1,1 @@
1236 1236 +bar
1237 1237
1238 1238
1239 1239 $ hg strip -k -r 35358f982181
1240 1240 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/35358f982181-a6f020aa-backup.hg
1241 1241 $ hg log -G
1242 1242 @ changeset: 3:f62c6c09b707
1243 1243 | branch: new-branch
1244 1244 | tag: tip
1245 1245 | user: test
1246 1246 | date: Thu Jan 01 00:00:00 1970 +0000
1247 1247 | summary: foo
1248 1248 |
1249 1249 o changeset: 2:b1d33a8cadd9
1250 1250 | branch: new-branch
1251 1251 | user: test
1252 1252 | date: Thu Jan 01 00:00:00 1970 +0000
1253 1253 | summary: start new branch
1254 1254 |
1255 1255 o changeset: 1:eca11cf91c71
1256 1256 | user: test
1257 1257 | date: Thu Jan 01 00:00:00 1970 +0000
1258 1258 | summary: commitB
1259 1259 |
1260 1260 o changeset: 0:105141ef12d0
1261 1261 user: test
1262 1262 date: Thu Jan 01 00:00:00 1970 +0000
1263 1263 summary: commitA
1264 1264
1265 1265
1266 1266 $ hg status -A
1267 1267 ? bar.txt
1268 1268 C a
1269 1269 C b
1270 1270 C foo.txt
1271 1271 $ cat bar.txt
1272 1272 bar
1273 1273
1274 1274 Use delayedstrip to strip inside a transaction
1275 1275
1276 1276 $ cd $TESTTMP
1277 1277 $ hg init delayedstrip
1278 1278 $ cd delayedstrip
1279 1279 $ hg debugdrawdag <<'EOS'
1280 1280 > D
1281 1281 > |
1282 1282 > C F H # Commit on top of "I",
1283 1283 > | |/| # Strip B+D+I+E+G+H+Z
1284 1284 > I B E G
1285 1285 > \|/
1286 1286 > A Z
1287 1287 > EOS
1288 1288 $ cp -R . ../scmutilcleanup
1289 1289
1290 1290 $ hg up -C I
1291 1291 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1292 1292 $ echo 3 >> I
1293 1293 $ cat > $TESTTMP/delayedstrip.py <<EOF
1294 1294 > from mercurial import commands, registrar, repair
1295 1295 > cmdtable = {}
1296 1296 > command = registrar.command(cmdtable)
1297 1297 > @command(b'testdelayedstrip')
1298 1298 > def testdelayedstrip(ui, repo):
1299 1299 > def getnodes(expr):
1300 1300 > return [repo.changelog.node(r) for r in repo.revs(expr)]
1301 1301 > with repo.wlock():
1302 1302 > with repo.lock():
1303 1303 > with repo.transaction(b'delayedstrip'):
1304 1304 > repair.delayedstrip(ui, repo, getnodes(b'B+I+Z+D+E'), b'J')
1305 1305 > repair.delayedstrip(ui, repo, getnodes(b'G+H+Z'), b'I')
1306 1306 > commands.commit(ui, repo, message=b'J', date=b'0 0')
1307 1307 > EOF
1308 1308 $ hg testdelayedstrip --config extensions.t=$TESTTMP/delayedstrip.py
1309 1309 warning: orphaned descendants detected, not stripping 08ebfeb61bac, 112478962961, 7fb047a69f22
1310 1310 saved backup bundle to $TESTTMP/delayedstrip/.hg/strip-backup/f585351a92f8-17475721-I.hg
1311 1311
1312 1312 $ hg log -G -T '{rev}:{node|short} {desc}' -r 'sort(all(), topo)'
1313 1313 @ 6:2f2d51af6205 J
1314 1314 |
1315 1315 o 3:08ebfeb61bac I
1316 1316 |
1317 1317 | o 5:64a8289d2492 F
1318 1318 | |
1319 1319 | o 2:7fb047a69f22 E
1320 1320 |/
1321 1321 | o 4:26805aba1e60 C
1322 1322 | |
1323 1323 | o 1:112478962961 B
1324 1324 |/
1325 1325 o 0:426bada5c675 A
1326 1326
1327 1327 Test high-level scmutil.cleanupnodes API
1328 1328
1329 1329 $ cd $TESTTMP/scmutilcleanup
1330 1330 $ hg debugdrawdag <<'EOS'
1331 1331 > D2 F2 G2 # D2, F2, G2 are replacements for D, F, G
1332 1332 > | | |
1333 1333 > C H G
1334 1334 > EOS
1335 1335 $ for i in B C D F G I Z; do
1336 1336 > hg bookmark -i -r $i b-$i
1337 1337 > done
1338 1338 $ hg bookmark -i -r E 'b-F@divergent1'
1339 1339 $ hg bookmark -i -r H 'b-F@divergent2'
1340 1340 $ hg bookmark -i -r G 'b-F@divergent3'
1341 1341 $ cp -R . ../scmutilcleanup.obsstore
1342 1342
1343 1343 $ cat > $TESTTMP/scmutilcleanup.py <<EOF
1344 1344 > from mercurial import registrar, scmutil
1345 1345 > cmdtable = {}
1346 1346 > command = registrar.command(cmdtable)
1347 1347 > @command(b'testnodescleanup')
1348 1348 > def testnodescleanup(ui, repo):
1349 1349 > def nodes(expr):
1350 1350 > return [repo.changelog.node(r) for r in repo.revs(expr)]
1351 1351 > def node(expr):
1352 1352 > return nodes(expr)[0]
1353 1353 > with repo.wlock():
1354 1354 > with repo.lock():
1355 1355 > with repo.transaction(b'delayedstrip'):
1356 1356 > mapping = {node(b'F'): [node(b'F2')],
1357 1357 > node(b'D'): [node(b'D2')],
1358 1358 > node(b'G'): [node(b'G2')]}
1359 1359 > scmutil.cleanupnodes(repo, mapping, b'replace')
1360 1360 > scmutil.cleanupnodes(repo, nodes(b'((B::)+I+Z)-D2-obsolete()'),
1361 1361 > b'replace')
1362 1362 > EOF
1363 1363 $ hg testnodescleanup --config extensions.t=$TESTTMP/scmutilcleanup.py
1364 1364 warning: orphaned descendants detected, not stripping 112478962961, 1fc8102cda62, 26805aba1e60
1365 1365 saved backup bundle to $TESTTMP/scmutilcleanup/.hg/strip-backup/f585351a92f8-73fb7c03-replace.hg
1366 1366
1367 1367 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1368 1368 o 8:1473d4b996d1 G2 b-F@divergent3 b-G
1369 1369 |
1370 1370 | o 7:d11b3456a873 F2 b-F
1371 1371 | |
1372 1372 | o 5:5cb05ba470a7 H
1373 1373 |/|
1374 1374 | o 3:7fb047a69f22 E b-F@divergent1
1375 1375 | |
1376 1376 | | o 6:7c78f703e465 D2 b-D
1377 1377 | | |
1378 1378 | | o 4:26805aba1e60 C
1379 1379 | | |
1380 1380 | | o 2:112478962961 B
1381 1381 | |/
1382 1382 o | 1:1fc8102cda62 G
1383 1383 /
1384 1384 o 0:426bada5c675 A b-B b-C b-I
1385 1385
1386 1386 $ hg bookmark
1387 1387 b-B 0:426bada5c675
1388 1388 b-C 0:426bada5c675
1389 1389 b-D 6:7c78f703e465
1390 1390 b-F 7:d11b3456a873
1391 1391 b-F@divergent1 3:7fb047a69f22
1392 1392 b-F@divergent3 8:1473d4b996d1
1393 1393 b-G 8:1473d4b996d1
1394 1394 b-I 0:426bada5c675
1395 1395 b-Z -1:000000000000
1396 1396
1397 1397 Test the above using obsstore "by the way". Not directly related to strip, but
1398 1398 we have reusable code here
1399 1399
1400 1400 $ cd $TESTTMP/scmutilcleanup.obsstore
1401 1401 $ cat >> .hg/hgrc <<EOF
1402 1402 > [experimental]
1403 1403 > evolution=true
1404 1404 > evolution.track-operation=1
1405 1405 > EOF
1406 1406
1407 1407 $ hg testnodescleanup --config extensions.t=$TESTTMP/scmutilcleanup.py
1408 1408 4 new orphan changesets
1409 1409
1410 1410 $ rm .hg/localtags
1411 1411 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1412 1412 * 12:1473d4b996d1 G2 b-F@divergent3 b-G
1413 1413 |
1414 1414 | * 11:d11b3456a873 F2 b-F
1415 1415 | |
1416 1416 | * 8:5cb05ba470a7 H
1417 1417 |/|
1418 1418 | o 4:7fb047a69f22 E b-F@divergent1
1419 1419 | |
1420 1420 | | * 10:7c78f703e465 D2 b-D
1421 1421 | | |
1422 1422 | | x 6:26805aba1e60 C
1423 1423 | | |
1424 1424 | | x 3:112478962961 B
1425 1425 | |/
1426 1426 x | 1:1fc8102cda62 G
1427 1427 /
1428 1428 o 0:426bada5c675 A b-B b-C b-I
1429 1429
1430 1430 $ hg debugobsolete
1431 1431 1fc8102cda6204549f031015641606ccf5513ec3 1473d4b996d1d1b121de6b39fab6a04fbf9d873e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
1432 1432 64a8289d249234b9886244d379f15e6b650b28e3 d11b3456a873daec7c7bc53e5622e8df6d741bd2 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
1433 1433 f585351a92f85104bff7c284233c338b10eb1df7 7c78f703e465d73102cc8780667ce269c5208a40 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'replace', 'user': 'test'}
1434 1434 48b9aae0607f43ff110d84e6883c151942add5ab 0 {0000000000000000000000000000000000000000} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1435 1435 112478962961147124edd43549aedd1a335e44bf 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1436 1436 08ebfeb61bac6e3f12079de774d285a0d6689eba 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1437 1437 26805aba1e600a82e93661149f2313866a221a7b 0 {112478962961147124edd43549aedd1a335e44bf} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1438 1438 $ cd ..
1439 1439
1440 1440 Test that obsmarkers are restored even when not using generaldelta
1441 1441
1442 1442 $ hg --config format.usegeneraldelta=no init issue5678
1443 1443 $ cd issue5678
1444 1444 $ cat >> .hg/hgrc <<EOF
1445 1445 > [experimental]
1446 1446 > evolution=true
1447 1447 > EOF
1448 1448 $ echo a > a
1449 1449 $ hg ci -Aqm a
1450 1450 $ hg ci --amend -m a2
1451 1451 $ hg debugobsolete
1452 1452 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 489bac576828490c0bb8d45eac9e5e172e4ec0a8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1453 1453 $ hg strip .
1454 1454 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1455 1455 saved backup bundle to $TESTTMP/issue5678/.hg/strip-backup/489bac576828-bef27e14-backup.hg
1456 1456 $ hg unbundle -q .hg/strip-backup/*
1457 1457 $ hg debugobsolete
1458 1458 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 489bac576828490c0bb8d45eac9e5e172e4ec0a8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1459 1459 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now