Show More
@@ -1,355 +1,355 b'' | |||
|
1 | 1 | # repair.py - functions for repository repair for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Chris Mason <mason@suse.com> |
|
4 | 4 | # Copyright 2007 Matt Mackall |
|
5 | 5 | # |
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | 9 | from __future__ import absolute_import |
|
10 | 10 | |
|
11 | 11 | import errno |
|
12 | 12 | import hashlib |
|
13 | 13 | |
|
14 | 14 | from .i18n import _ |
|
15 | 15 | from .node import short |
|
16 | 16 | from . import ( |
|
17 | 17 | bundle2, |
|
18 | 18 | changegroup, |
|
19 | 19 | error, |
|
20 | 20 | exchange, |
|
21 | 21 | obsolete, |
|
22 | 22 | util, |
|
23 | 23 | ) |
|
24 | 24 | |
|
25 | 25 | def _bundle(repo, bases, heads, node, suffix, compress=True): |
|
26 | 26 | """create a bundle with the specified revisions as a backup""" |
|
27 | 27 | cgversion = changegroup.safeversion(repo) |
|
28 | 28 | |
|
29 | 29 | cg = changegroup.changegroupsubset(repo, bases, heads, 'strip', |
|
30 | 30 | version=cgversion) |
|
31 | 31 | backupdir = "strip-backup" |
|
32 | 32 | vfs = repo.vfs |
|
33 | 33 | if not vfs.isdir(backupdir): |
|
34 | 34 | vfs.mkdir(backupdir) |
|
35 | 35 | |
|
36 | 36 | # Include a hash of all the nodes in the filename for uniqueness |
|
37 | 37 | allcommits = repo.set('%ln::%ln', bases, heads) |
|
38 | 38 | allhashes = sorted(c.hex() for c in allcommits) |
|
39 | 39 | totalhash = hashlib.sha1(''.join(allhashes)).hexdigest() |
|
40 | 40 | name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) |
|
41 | 41 | |
|
42 | 42 | comp = None |
|
43 | 43 | if cgversion != '01': |
|
44 | 44 | bundletype = "HG20" |
|
45 | 45 | if compress: |
|
46 | 46 | comp = 'BZ' |
|
47 | 47 | elif compress: |
|
48 | 48 | bundletype = "HG10BZ" |
|
49 | 49 | else: |
|
50 | 50 | bundletype = "HG10UN" |
|
51 | 51 | return bundle2.writebundle(repo.ui, cg, name, bundletype, vfs, |
|
52 | 52 | compression=comp) |
|
53 | 53 | |
|
54 | 54 | def _collectfiles(repo, striprev): |
|
55 | 55 | """find out the filelogs affected by the strip""" |
|
56 | 56 | files = set() |
|
57 | 57 | |
|
58 | 58 | for x in xrange(striprev, len(repo)): |
|
59 | 59 | files.update(repo[x].files()) |
|
60 | 60 | |
|
61 | 61 | return sorted(files) |
|
62 | 62 | |
|
63 | 63 | def _collectbrokencsets(repo, files, striprev): |
|
64 | 64 | """return the changesets which will be broken by the truncation""" |
|
65 | 65 | s = set() |
|
66 | 66 | def collectone(revlog): |
|
67 | 67 | _, brokenset = revlog.getstrippoint(striprev) |
|
68 | 68 | s.update([revlog.linkrev(r) for r in brokenset]) |
|
69 | 69 | |
|
70 | 70 | collectone(repo.manifest) |
|
71 | 71 | for fname in files: |
|
72 | 72 | collectone(repo.file(fname)) |
|
73 | 73 | |
|
74 | 74 | return s |
|
75 | 75 | |
|
76 | 76 | def strip(ui, repo, nodelist, backup=True, topic='backup'): |
|
77 | 77 | # This function operates within a transaction of its own, but does |
|
78 | 78 | # not take any lock on the repo. |
|
79 | 79 | # Simple way to maintain backwards compatibility for this |
|
80 | 80 | # argument. |
|
81 | 81 | if backup in ['none', 'strip']: |
|
82 | 82 | backup = False |
|
83 | 83 | |
|
84 | 84 | repo = repo.unfiltered() |
|
85 | 85 | repo.destroying() |
|
86 | 86 | |
|
87 | 87 | cl = repo.changelog |
|
88 | 88 | # TODO handle undo of merge sets |
|
89 | 89 | if isinstance(nodelist, str): |
|
90 | 90 | nodelist = [nodelist] |
|
91 | 91 | striplist = [cl.rev(node) for node in nodelist] |
|
92 | 92 | striprev = min(striplist) |
|
93 | 93 | |
|
94 | 94 | # Some revisions with rev > striprev may not be descendants of striprev. |
|
95 | 95 | # We have to find these revisions and put them in a bundle, so that |
|
96 | 96 | # we can restore them after the truncations. |
|
97 | 97 | # To create the bundle we use repo.changegroupsubset which requires |
|
98 | 98 | # the list of heads and bases of the set of interesting revisions. |
|
99 | 99 | # (head = revision in the set that has no descendant in the set; |
|
100 | 100 | # base = revision in the set that has no ancestor in the set) |
|
101 | 101 | tostrip = set(striplist) |
|
102 | 102 | for rev in striplist: |
|
103 | 103 | for desc in cl.descendants([rev]): |
|
104 | 104 | tostrip.add(desc) |
|
105 | 105 | |
|
106 | 106 | files = _collectfiles(repo, striprev) |
|
107 | 107 | saverevs = _collectbrokencsets(repo, files, striprev) |
|
108 | 108 | |
|
109 | 109 | # compute heads |
|
110 | 110 | saveheads = set(saverevs) |
|
111 | 111 | for r in xrange(striprev + 1, len(cl)): |
|
112 | 112 | if r not in tostrip: |
|
113 | 113 | saverevs.add(r) |
|
114 | 114 | saveheads.difference_update(cl.parentrevs(r)) |
|
115 | 115 | saveheads.add(r) |
|
116 | 116 | saveheads = [cl.node(r) for r in saveheads] |
|
117 | 117 | |
|
118 | 118 | # compute base nodes |
|
119 | 119 | if saverevs: |
|
120 | 120 | descendants = set(cl.descendants(saverevs)) |
|
121 | 121 | saverevs.difference_update(descendants) |
|
122 | 122 | savebases = [cl.node(r) for r in saverevs] |
|
123 | 123 | stripbases = [cl.node(r) for r in tostrip] |
|
124 | 124 | |
|
125 | 125 | # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but |
|
126 | 126 | # is much faster |
|
127 | 127 | newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) |
|
128 | 128 | if newbmtarget: |
|
129 | 129 | newbmtarget = repo[newbmtarget.first()].node() |
|
130 | 130 | else: |
|
131 | 131 | newbmtarget = '.' |
|
132 | 132 | |
|
133 | 133 | bm = repo._bookmarks |
|
134 | 134 | updatebm = [] |
|
135 | 135 | for m in bm: |
|
136 | 136 | rev = repo[bm[m]].rev() |
|
137 | 137 | if rev in tostrip: |
|
138 | 138 | updatebm.append(m) |
|
139 | 139 | |
|
140 | 140 | # create a changegroup for all the branches we need to keep |
|
141 | 141 | backupfile = None |
|
142 | 142 | vfs = repo.vfs |
|
143 | 143 | node = nodelist[-1] |
|
144 | 144 | if backup: |
|
145 | 145 | backupfile = _bundle(repo, stripbases, cl.heads(), node, topic) |
|
146 | 146 | repo.ui.status(_("saved backup bundle to %s\n") % |
|
147 | 147 | vfs.join(backupfile)) |
|
148 | 148 | repo.ui.log("backupbundle", "saved backup bundle to %s\n", |
|
149 | 149 | vfs.join(backupfile)) |
|
150 | 150 | chgrpfile = None |
|
151 | 151 | if saveheads: |
|
152 | 152 | # do not compress partial bundle if we remove it from disk later |
|
153 | 153 | chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp', |
|
154 | 154 | compress=False) |
|
155 | 155 | |
|
156 | 156 | mfst = repo.manifest |
|
157 | 157 | |
|
158 | 158 | curtr = repo.currenttransaction() |
|
159 | 159 | if curtr is not None: |
|
160 | 160 | del curtr # avoid carrying reference to transaction for nothing |
|
161 | 161 | msg = _('programming error: cannot strip from inside a transaction') |
|
162 | 162 | raise error.Abort(msg, hint=_('contact your extension maintainer')) |
|
163 | 163 | |
|
164 | 164 | try: |
|
165 | 165 | with repo.transaction("strip") as tr: |
|
166 | 166 | offset = len(tr.entries) |
|
167 | 167 | |
|
168 | 168 | tr.startgroup() |
|
169 | 169 | cl.strip(striprev, tr) |
|
170 | 170 | mfst.strip(striprev, tr) |
|
171 | 171 | if 'treemanifest' in repo.requirements: # safe but unnecessary |
|
172 | 172 | # otherwise |
|
173 | 173 | for unencoded, encoded, size in repo.store.datafiles(): |
|
174 | 174 | if (unencoded.startswith('meta/') and |
|
175 | 175 | unencoded.endswith('00manifest.i')): |
|
176 | 176 | dir = unencoded[5:-12] |
|
177 | 177 | repo.manifest.dirlog(dir).strip(striprev, tr) |
|
178 | 178 | for fn in files: |
|
179 | 179 | repo.file(fn).strip(striprev, tr) |
|
180 | 180 | tr.endgroup() |
|
181 | 181 | |
|
182 | 182 | for i in xrange(offset, len(tr.entries)): |
|
183 | 183 | file, troffset, ignore = tr.entries[i] |
|
184 | 184 | repo.svfs(file, 'a').truncate(troffset) |
|
185 | 185 | if troffset == 0: |
|
186 | 186 | repo.store.markremoved(file) |
|
187 | 187 | |
|
188 | 188 | if chgrpfile: |
|
189 | 189 | ui.note(_("adding branch\n")) |
|
190 | 190 | f = vfs.open(chgrpfile, "rb") |
|
191 | 191 | gen = exchange.readbundle(ui, f, chgrpfile, vfs) |
|
192 | 192 | if not repo.ui.verbose: |
|
193 | 193 | # silence internal shuffling chatter |
|
194 | 194 | repo.ui.pushbuffer() |
|
195 | 195 | if isinstance(gen, bundle2.unbundle20): |
|
196 | 196 | with repo.transaction('strip') as tr: |
|
197 | 197 | tr.hookargs = {'source': 'strip', |
|
198 | 198 | 'url': 'bundle:' + vfs.join(chgrpfile)} |
|
199 | 199 | bundle2.applybundle(repo, gen, tr, source='strip', |
|
200 | 200 | url='bundle:' + vfs.join(chgrpfile)) |
|
201 | 201 | else: |
|
202 | 202 | gen.apply(repo, 'strip', 'bundle:' + vfs.join(chgrpfile), True) |
|
203 | 203 | if not repo.ui.verbose: |
|
204 | 204 | repo.ui.popbuffer() |
|
205 | 205 | f.close() |
|
206 | 206 | repo._phasecache.invalidate() |
|
207 | 207 | |
|
208 | 208 | for m in updatebm: |
|
209 | 209 | bm[m] = repo[newbmtarget].node() |
|
210 | 210 | lock = tr = None |
|
211 | 211 | try: |
|
212 | 212 | lock = repo.lock() |
|
213 | 213 | tr = repo.transaction('repair') |
|
214 | 214 | bm.recordchange(tr) |
|
215 | 215 | tr.close() |
|
216 | 216 | finally: |
|
217 | 217 | tr.release() |
|
218 | 218 | lock.release() |
|
219 | 219 | |
|
220 | 220 | # remove undo files |
|
221 | 221 | for undovfs, undofile in repo.undofiles(): |
|
222 | 222 | try: |
|
223 | 223 | undovfs.unlink(undofile) |
|
224 | 224 | except OSError as e: |
|
225 | 225 | if e.errno != errno.ENOENT: |
|
226 | 226 | ui.warn(_('error removing %s: %s\n') % |
|
227 | 227 | (undovfs.join(undofile), str(e))) |
|
228 | 228 | |
|
229 | 229 | except: # re-raises |
|
230 | 230 | if backupfile: |
|
231 | 231 | ui.warn(_("strip failed, full bundle stored in '%s'\n") |
|
232 | 232 | % vfs.join(backupfile)) |
|
233 |
|
|
|
233 | if chgrpfile: | |
|
234 | 234 | ui.warn(_("strip failed, partial bundle stored in '%s'\n") |
|
235 | 235 | % vfs.join(chgrpfile)) |
|
236 | 236 | raise |
|
237 | 237 | else: |
|
238 | 238 | if chgrpfile: |
|
239 | 239 | # Remove partial backup only if there were no exceptions |
|
240 | 240 | vfs.unlink(chgrpfile) |
|
241 | 241 | |
|
242 | 242 | repo.destroyed() |
|
243 | 243 | |
|
244 | 244 | def rebuildfncache(ui, repo): |
|
245 | 245 | """Rebuilds the fncache file from repo history. |
|
246 | 246 | |
|
247 | 247 | Missing entries will be added. Extra entries will be removed. |
|
248 | 248 | """ |
|
249 | 249 | repo = repo.unfiltered() |
|
250 | 250 | |
|
251 | 251 | if 'fncache' not in repo.requirements: |
|
252 | 252 | ui.warn(_('(not rebuilding fncache because repository does not ' |
|
253 | 253 | 'support fncache)\n')) |
|
254 | 254 | return |
|
255 | 255 | |
|
256 | 256 | with repo.lock(): |
|
257 | 257 | fnc = repo.store.fncache |
|
258 | 258 | # Trigger load of fncache. |
|
259 | 259 | if 'irrelevant' in fnc: |
|
260 | 260 | pass |
|
261 | 261 | |
|
262 | 262 | oldentries = set(fnc.entries) |
|
263 | 263 | newentries = set() |
|
264 | 264 | seenfiles = set() |
|
265 | 265 | |
|
266 | 266 | repolen = len(repo) |
|
267 | 267 | for rev in repo: |
|
268 | 268 | ui.progress(_('rebuilding'), rev, total=repolen, |
|
269 | 269 | unit=_('changesets')) |
|
270 | 270 | |
|
271 | 271 | ctx = repo[rev] |
|
272 | 272 | for f in ctx.files(): |
|
273 | 273 | # This is to minimize I/O. |
|
274 | 274 | if f in seenfiles: |
|
275 | 275 | continue |
|
276 | 276 | seenfiles.add(f) |
|
277 | 277 | |
|
278 | 278 | i = 'data/%s.i' % f |
|
279 | 279 | d = 'data/%s.d' % f |
|
280 | 280 | |
|
281 | 281 | if repo.store._exists(i): |
|
282 | 282 | newentries.add(i) |
|
283 | 283 | if repo.store._exists(d): |
|
284 | 284 | newentries.add(d) |
|
285 | 285 | |
|
286 | 286 | ui.progress(_('rebuilding'), None) |
|
287 | 287 | |
|
288 | 288 | if 'treemanifest' in repo.requirements: # safe but unnecessary otherwise |
|
289 | 289 | for dir in util.dirs(seenfiles): |
|
290 | 290 | i = 'meta/%s/00manifest.i' % dir |
|
291 | 291 | d = 'meta/%s/00manifest.d' % dir |
|
292 | 292 | |
|
293 | 293 | if repo.store._exists(i): |
|
294 | 294 | newentries.add(i) |
|
295 | 295 | if repo.store._exists(d): |
|
296 | 296 | newentries.add(d) |
|
297 | 297 | |
|
298 | 298 | addcount = len(newentries - oldentries) |
|
299 | 299 | removecount = len(oldentries - newentries) |
|
300 | 300 | for p in sorted(oldentries - newentries): |
|
301 | 301 | ui.write(_('removing %s\n') % p) |
|
302 | 302 | for p in sorted(newentries - oldentries): |
|
303 | 303 | ui.write(_('adding %s\n') % p) |
|
304 | 304 | |
|
305 | 305 | if addcount or removecount: |
|
306 | 306 | ui.write(_('%d items added, %d removed from fncache\n') % |
|
307 | 307 | (addcount, removecount)) |
|
308 | 308 | fnc.entries = newentries |
|
309 | 309 | fnc._dirty = True |
|
310 | 310 | |
|
311 | 311 | with repo.transaction('fncache') as tr: |
|
312 | 312 | fnc.write(tr) |
|
313 | 313 | else: |
|
314 | 314 | ui.write(_('fncache already up to date\n')) |
|
315 | 315 | |
|
316 | 316 | def stripbmrevset(repo, mark): |
|
317 | 317 | """ |
|
318 | 318 | The revset to strip when strip is called with -B mark |
|
319 | 319 | |
|
320 | 320 | Needs to live here so extensions can use it and wrap it even when strip is |
|
321 | 321 | not enabled or not present on a box. |
|
322 | 322 | """ |
|
323 | 323 | return repo.revs("ancestors(bookmark(%s)) - " |
|
324 | 324 | "ancestors(head() and not bookmark(%s)) - " |
|
325 | 325 | "ancestors(bookmark() and not bookmark(%s))", |
|
326 | 326 | mark, mark, mark) |
|
327 | 327 | |
|
328 | 328 | def deleteobsmarkers(obsstore, indices): |
|
329 | 329 | """Delete some obsmarkers from obsstore and return how many were deleted |
|
330 | 330 | |
|
331 | 331 | 'indices' is a list of ints which are the indices |
|
332 | 332 | of the markers to be deleted. |
|
333 | 333 | |
|
334 | 334 | Every invocation of this function completely rewrites the obsstore file, |
|
335 | 335 | skipping the markers we want to be removed. The new temporary file is |
|
336 | 336 | created, remaining markers are written there and on .close() this file |
|
337 | 337 | gets atomically renamed to obsstore, thus guaranteeing consistency.""" |
|
338 | 338 | if not indices: |
|
339 | 339 | # we don't want to rewrite the obsstore with the same content |
|
340 | 340 | return |
|
341 | 341 | |
|
342 | 342 | left = [] |
|
343 | 343 | current = obsstore._all |
|
344 | 344 | n = 0 |
|
345 | 345 | for i, m in enumerate(current): |
|
346 | 346 | if i in indices: |
|
347 | 347 | n += 1 |
|
348 | 348 | continue |
|
349 | 349 | left.append(m) |
|
350 | 350 | |
|
351 | 351 | newobsstorefile = obsstore.svfs('obsstore', 'w', atomictemp=True) |
|
352 | 352 | for bytes in obsolete.encodemarkers(left, True, obsstore._version): |
|
353 | 353 | newobsstorefile.write(bytes) |
|
354 | 354 | newobsstorefile.close() |
|
355 | 355 | return n |
@@ -1,898 +1,937 b'' | |||
|
1 | 1 | $ echo "[format]" >> $HGRCPATH |
|
2 | 2 | $ echo "usegeneraldelta=yes" >> $HGRCPATH |
|
3 | 3 | $ echo "[extensions]" >> $HGRCPATH |
|
4 | 4 | $ echo "strip=" >> $HGRCPATH |
|
5 | 5 | |
|
6 | 6 | $ restore() { |
|
7 | 7 | > hg unbundle -q .hg/strip-backup/* |
|
8 | 8 | > rm .hg/strip-backup/* |
|
9 | 9 | > } |
|
10 | 10 | $ teststrip() { |
|
11 | 11 | > hg up -C $1 |
|
12 | 12 | > echo % before update $1, strip $2 |
|
13 | 13 | > hg parents |
|
14 | 14 | > hg --traceback strip $2 |
|
15 | 15 | > echo % after update $1, strip $2 |
|
16 | 16 | > hg parents |
|
17 | 17 | > restore |
|
18 | 18 | > } |
|
19 | 19 | |
|
20 | 20 | $ hg init test |
|
21 | 21 | $ cd test |
|
22 | 22 | |
|
23 | 23 | $ echo foo > bar |
|
24 | 24 | $ hg ci -Ama |
|
25 | 25 | adding bar |
|
26 | 26 | |
|
27 | 27 | $ echo more >> bar |
|
28 | 28 | $ hg ci -Amb |
|
29 | 29 | |
|
30 | 30 | $ echo blah >> bar |
|
31 | 31 | $ hg ci -Amc |
|
32 | 32 | |
|
33 | 33 | $ hg up 1 |
|
34 | 34 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
35 | 35 | $ echo blah >> bar |
|
36 | 36 | $ hg ci -Amd |
|
37 | 37 | created new head |
|
38 | 38 | |
|
39 | 39 | $ echo final >> bar |
|
40 | 40 | $ hg ci -Ame |
|
41 | 41 | |
|
42 | 42 | $ hg log |
|
43 | 43 | changeset: 4:443431ffac4f |
|
44 | 44 | tag: tip |
|
45 | 45 | user: test |
|
46 | 46 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
47 | 47 | summary: e |
|
48 | 48 | |
|
49 | 49 | changeset: 3:65bd5f99a4a3 |
|
50 | 50 | parent: 1:ef3a871183d7 |
|
51 | 51 | user: test |
|
52 | 52 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
53 | 53 | summary: d |
|
54 | 54 | |
|
55 | 55 | changeset: 2:264128213d29 |
|
56 | 56 | user: test |
|
57 | 57 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
58 | 58 | summary: c |
|
59 | 59 | |
|
60 | 60 | changeset: 1:ef3a871183d7 |
|
61 | 61 | user: test |
|
62 | 62 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
63 | 63 | summary: b |
|
64 | 64 | |
|
65 | 65 | changeset: 0:9ab35a2d17cb |
|
66 | 66 | user: test |
|
67 | 67 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
68 | 68 | summary: a |
|
69 | 69 | |
|
70 | 70 | |
|
71 | 71 | $ teststrip 4 4 |
|
72 | 72 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
73 | 73 | % before update 4, strip 4 |
|
74 | 74 | changeset: 4:443431ffac4f |
|
75 | 75 | tag: tip |
|
76 | 76 | user: test |
|
77 | 77 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
78 | 78 | summary: e |
|
79 | 79 | |
|
80 | 80 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
81 | 81 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
82 | 82 | % after update 4, strip 4 |
|
83 | 83 | changeset: 3:65bd5f99a4a3 |
|
84 | 84 | tag: tip |
|
85 | 85 | parent: 1:ef3a871183d7 |
|
86 | 86 | user: test |
|
87 | 87 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
88 | 88 | summary: d |
|
89 | 89 | |
|
90 | 90 | $ teststrip 4 3 |
|
91 | 91 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
92 | 92 | % before update 4, strip 3 |
|
93 | 93 | changeset: 4:443431ffac4f |
|
94 | 94 | tag: tip |
|
95 | 95 | user: test |
|
96 | 96 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
97 | 97 | summary: e |
|
98 | 98 | |
|
99 | 99 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
100 | 100 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
101 | 101 | % after update 4, strip 3 |
|
102 | 102 | changeset: 1:ef3a871183d7 |
|
103 | 103 | user: test |
|
104 | 104 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
105 | 105 | summary: b |
|
106 | 106 | |
|
107 | 107 | $ teststrip 1 4 |
|
108 | 108 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
109 | 109 | % before update 1, strip 4 |
|
110 | 110 | changeset: 1:ef3a871183d7 |
|
111 | 111 | user: test |
|
112 | 112 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
113 | 113 | summary: b |
|
114 | 114 | |
|
115 | 115 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
116 | 116 | % after update 1, strip 4 |
|
117 | 117 | changeset: 1:ef3a871183d7 |
|
118 | 118 | user: test |
|
119 | 119 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
120 | 120 | summary: b |
|
121 | 121 | |
|
122 | 122 | $ teststrip 4 2 |
|
123 | 123 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
124 | 124 | % before update 4, strip 2 |
|
125 | 125 | changeset: 4:443431ffac4f |
|
126 | 126 | tag: tip |
|
127 | 127 | user: test |
|
128 | 128 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
129 | 129 | summary: e |
|
130 | 130 | |
|
131 | 131 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
132 | 132 | % after update 4, strip 2 |
|
133 | 133 | changeset: 3:443431ffac4f |
|
134 | 134 | tag: tip |
|
135 | 135 | user: test |
|
136 | 136 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
137 | 137 | summary: e |
|
138 | 138 | |
|
139 | 139 | $ teststrip 4 1 |
|
140 | 140 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
141 | 141 | % before update 4, strip 1 |
|
142 | 142 | changeset: 4:264128213d29 |
|
143 | 143 | tag: tip |
|
144 | 144 | parent: 1:ef3a871183d7 |
|
145 | 145 | user: test |
|
146 | 146 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
147 | 147 | summary: c |
|
148 | 148 | |
|
149 | 149 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
150 | 150 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
151 | 151 | % after update 4, strip 1 |
|
152 | 152 | changeset: 0:9ab35a2d17cb |
|
153 | 153 | tag: tip |
|
154 | 154 | user: test |
|
155 | 155 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
156 | 156 | summary: a |
|
157 | 157 | |
|
158 | 158 | $ teststrip null 4 |
|
159 | 159 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
160 | 160 | % before update null, strip 4 |
|
161 | 161 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
162 | 162 | % after update null, strip 4 |
|
163 | 163 | |
|
164 | 164 | $ hg log |
|
165 | 165 | changeset: 4:264128213d29 |
|
166 | 166 | tag: tip |
|
167 | 167 | parent: 1:ef3a871183d7 |
|
168 | 168 | user: test |
|
169 | 169 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
170 | 170 | summary: c |
|
171 | 171 | |
|
172 | 172 | changeset: 3:443431ffac4f |
|
173 | 173 | user: test |
|
174 | 174 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
175 | 175 | summary: e |
|
176 | 176 | |
|
177 | 177 | changeset: 2:65bd5f99a4a3 |
|
178 | 178 | user: test |
|
179 | 179 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
180 | 180 | summary: d |
|
181 | 181 | |
|
182 | 182 | changeset: 1:ef3a871183d7 |
|
183 | 183 | user: test |
|
184 | 184 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
185 | 185 | summary: b |
|
186 | 186 | |
|
187 | 187 | changeset: 0:9ab35a2d17cb |
|
188 | 188 | user: test |
|
189 | 189 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
190 | 190 | summary: a |
|
191 | 191 | |
|
192 | 192 | $ hg up -C 4 |
|
193 | 193 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
194 | 194 | $ hg parents |
|
195 | 195 | changeset: 4:264128213d29 |
|
196 | 196 | tag: tip |
|
197 | 197 | parent: 1:ef3a871183d7 |
|
198 | 198 | user: test |
|
199 | 199 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
200 | 200 | summary: c |
|
201 | 201 | |
|
202 | 202 | |
|
203 | 203 | $ hg --traceback strip 4 |
|
204 | 204 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
205 | 205 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob) |
|
206 | 206 | $ hg parents |
|
207 | 207 | changeset: 1:ef3a871183d7 |
|
208 | 208 | user: test |
|
209 | 209 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
210 | 210 | summary: b |
|
211 | 211 | |
|
212 | 212 | $ hg debugbundle .hg/strip-backup/* |
|
213 | 213 | Stream params: sortdict([('Compression', 'BZ')]) |
|
214 | 214 | changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])" |
|
215 | 215 | 264128213d290d868c54642d13aeaa3675551a78 |
|
216 | 216 | $ hg pull .hg/strip-backup/* |
|
217 | 217 | pulling from .hg/strip-backup/264128213d29-0b39d6bf-backup.hg |
|
218 | 218 | searching for changes |
|
219 | 219 | adding changesets |
|
220 | 220 | adding manifests |
|
221 | 221 | adding file changes |
|
222 | 222 | added 1 changesets with 0 changes to 0 files (+1 heads) |
|
223 | 223 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
224 | 224 | $ rm .hg/strip-backup/* |
|
225 | 225 | $ hg log --graph |
|
226 | 226 | o changeset: 4:264128213d29 |
|
227 | 227 | | tag: tip |
|
228 | 228 | | parent: 1:ef3a871183d7 |
|
229 | 229 | | user: test |
|
230 | 230 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
231 | 231 | | summary: c |
|
232 | 232 | | |
|
233 | 233 | | o changeset: 3:443431ffac4f |
|
234 | 234 | | | user: test |
|
235 | 235 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
236 | 236 | | | summary: e |
|
237 | 237 | | | |
|
238 | 238 | | o changeset: 2:65bd5f99a4a3 |
|
239 | 239 | |/ user: test |
|
240 | 240 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
241 | 241 | | summary: d |
|
242 | 242 | | |
|
243 | 243 | @ changeset: 1:ef3a871183d7 |
|
244 | 244 | | user: test |
|
245 | 245 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
246 | 246 | | summary: b |
|
247 | 247 | | |
|
248 | 248 | o changeset: 0:9ab35a2d17cb |
|
249 | 249 | user: test |
|
250 | 250 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
251 | 251 | summary: a |
|
252 | 252 | |
|
253 | 253 | $ hg up -C 2 |
|
254 | 254 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
255 | 255 | $ hg merge 4 |
|
256 | 256 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
257 | 257 | (branch merge, don't forget to commit) |
|
258 | 258 | |
|
259 | 259 | before strip of merge parent |
|
260 | 260 | |
|
261 | 261 | $ hg parents |
|
262 | 262 | changeset: 2:65bd5f99a4a3 |
|
263 | 263 | user: test |
|
264 | 264 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
265 | 265 | summary: d |
|
266 | 266 | |
|
267 | 267 | changeset: 4:264128213d29 |
|
268 | 268 | tag: tip |
|
269 | 269 | parent: 1:ef3a871183d7 |
|
270 | 270 | user: test |
|
271 | 271 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
272 | 272 | summary: c |
|
273 | 273 | |
|
274 | 274 | $ hg strip 4 |
|
275 | 275 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
276 | 276 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
277 | 277 | |
|
278 | 278 | after strip of merge parent |
|
279 | 279 | |
|
280 | 280 | $ hg parents |
|
281 | 281 | changeset: 1:ef3a871183d7 |
|
282 | 282 | user: test |
|
283 | 283 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
284 | 284 | summary: b |
|
285 | 285 | |
|
286 | 286 | $ restore |
|
287 | 287 | |
|
288 | 288 | $ hg up |
|
289 | 289 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
290 | 290 | 1 other heads for branch "default" |
|
291 | 291 | $ hg log -G |
|
292 | 292 | @ changeset: 4:264128213d29 |
|
293 | 293 | | tag: tip |
|
294 | 294 | | parent: 1:ef3a871183d7 |
|
295 | 295 | | user: test |
|
296 | 296 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
297 | 297 | | summary: c |
|
298 | 298 | | |
|
299 | 299 | | o changeset: 3:443431ffac4f |
|
300 | 300 | | | user: test |
|
301 | 301 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
302 | 302 | | | summary: e |
|
303 | 303 | | | |
|
304 | 304 | | o 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 | o changeset: 1:ef3a871183d7 |
|
310 | 310 | | user: test |
|
311 | 311 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
312 | 312 | | summary: b |
|
313 | 313 | | |
|
314 | 314 | o changeset: 0:9ab35a2d17cb |
|
315 | 315 | user: test |
|
316 | 316 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
317 | 317 | summary: a |
|
318 | 318 | |
|
319 | 319 | |
|
320 | 320 | 2 is parent of 3, only one strip should happen |
|
321 | 321 | |
|
322 | 322 | $ hg strip "roots(2)" 3 |
|
323 | 323 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
324 | 324 | $ hg log -G |
|
325 | 325 | @ changeset: 2:264128213d29 |
|
326 | 326 | | tag: tip |
|
327 | 327 | | user: test |
|
328 | 328 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
329 | 329 | | summary: c |
|
330 | 330 | | |
|
331 | 331 | o changeset: 1:ef3a871183d7 |
|
332 | 332 | | user: test |
|
333 | 333 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
334 | 334 | | summary: b |
|
335 | 335 | | |
|
336 | 336 | o changeset: 0:9ab35a2d17cb |
|
337 | 337 | user: test |
|
338 | 338 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
339 | 339 | summary: a |
|
340 | 340 | |
|
341 | 341 | $ restore |
|
342 | 342 | $ hg log -G |
|
343 | 343 | o changeset: 4:443431ffac4f |
|
344 | 344 | | tag: tip |
|
345 | 345 | | user: test |
|
346 | 346 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
347 | 347 | | summary: e |
|
348 | 348 | | |
|
349 | 349 | o changeset: 3:65bd5f99a4a3 |
|
350 | 350 | | parent: 1:ef3a871183d7 |
|
351 | 351 | | user: test |
|
352 | 352 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
353 | 353 | | summary: d |
|
354 | 354 | | |
|
355 | 355 | | @ changeset: 2:264128213d29 |
|
356 | 356 | |/ user: test |
|
357 | 357 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
358 | 358 | | summary: c |
|
359 | 359 | | |
|
360 | 360 | o changeset: 1:ef3a871183d7 |
|
361 | 361 | | user: test |
|
362 | 362 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
363 | 363 | | summary: b |
|
364 | 364 | | |
|
365 | 365 | o changeset: 0:9ab35a2d17cb |
|
366 | 366 | user: test |
|
367 | 367 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
368 | 368 | summary: a |
|
369 | 369 | |
|
370 | Failed hook while applying "saveheads" bundle. | |
|
371 | ||
|
372 | $ hg strip 2 --config hooks.pretxnchangegroup.bad=false | |
|
373 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
374 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) | |
|
375 | transaction abort! | |
|
376 | rollback completed | |
|
377 | strip failed, full bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob) | |
|
378 | strip failed, partial bundle stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob) | |
|
379 | abort: pretxnchangegroup.bad hook exited with status 1 | |
|
380 | [255] | |
|
381 | $ restore | |
|
382 | $ hg log -G | |
|
383 | o changeset: 4:443431ffac4f | |
|
384 | | tag: tip | |
|
385 | | user: test | |
|
386 | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
387 | | summary: e | |
|
388 | | | |
|
389 | o changeset: 3:65bd5f99a4a3 | |
|
390 | | parent: 1:ef3a871183d7 | |
|
391 | | user: test | |
|
392 | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
393 | | summary: d | |
|
394 | | | |
|
395 | | o changeset: 2:264128213d29 | |
|
396 | |/ user: test | |
|
397 | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
398 | | summary: c | |
|
399 | | | |
|
400 | @ changeset: 1:ef3a871183d7 | |
|
401 | | user: test | |
|
402 | | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
403 | | summary: b | |
|
404 | | | |
|
405 | o changeset: 0:9ab35a2d17cb | |
|
406 | user: test | |
|
407 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
408 | summary: a | |
|
409 | ||
|
370 | 410 | |
|
371 | 411 | 2 different branches: 2 strips |
|
372 | 412 | |
|
373 | 413 | $ hg strip 2 4 |
|
374 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
375 | 414 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
376 | 415 | $ hg log -G |
|
377 | 416 | o changeset: 2:65bd5f99a4a3 |
|
378 | 417 | | tag: tip |
|
379 | 418 | | user: test |
|
380 | 419 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
381 | 420 | | summary: d |
|
382 | 421 | | |
|
383 | 422 | @ changeset: 1:ef3a871183d7 |
|
384 | 423 | | user: test |
|
385 | 424 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
386 | 425 | | summary: b |
|
387 | 426 | | |
|
388 | 427 | o changeset: 0:9ab35a2d17cb |
|
389 | 428 | user: test |
|
390 | 429 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
391 | 430 | summary: a |
|
392 | 431 | |
|
393 | 432 | $ restore |
|
394 | 433 | |
|
395 | 434 | 2 different branches and a common ancestor: 1 strip |
|
396 | 435 | |
|
397 | 436 | $ hg strip 1 "2|4" |
|
398 | 437 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
399 | 438 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
400 | 439 | $ restore |
|
401 | 440 | |
|
402 | 441 | verify fncache is kept up-to-date |
|
403 | 442 | |
|
404 | 443 | $ touch a |
|
405 | 444 | $ hg ci -qAm a |
|
406 | 445 | $ cat .hg/store/fncache | sort |
|
407 | 446 | data/a.i |
|
408 | 447 | data/bar.i |
|
409 | 448 | $ hg strip tip |
|
410 | 449 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
411 | 450 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
412 | 451 | $ cat .hg/store/fncache |
|
413 | 452 | data/bar.i |
|
414 | 453 | |
|
415 | 454 | stripping an empty revset |
|
416 | 455 | |
|
417 | 456 | $ hg strip "1 and not 1" |
|
418 | 457 | abort: empty revision set |
|
419 | 458 | [255] |
|
420 | 459 | |
|
421 | 460 | remove branchy history for qimport tests |
|
422 | 461 | |
|
423 | 462 | $ hg strip 3 |
|
424 | 463 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
425 | 464 | |
|
426 | 465 | |
|
427 | 466 | strip of applied mq should cleanup status file |
|
428 | 467 | |
|
429 | 468 | $ echo "mq=" >> $HGRCPATH |
|
430 | 469 | $ hg up -C 3 |
|
431 | 470 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
432 | 471 | $ echo fooagain >> bar |
|
433 | 472 | $ hg ci -mf |
|
434 | 473 | $ hg qimport -r tip:2 |
|
435 | 474 | |
|
436 | 475 | applied patches before strip |
|
437 | 476 | |
|
438 | 477 | $ hg qapplied |
|
439 | 478 | d |
|
440 | 479 | e |
|
441 | 480 | f |
|
442 | 481 | |
|
443 | 482 | stripping revision in queue |
|
444 | 483 | |
|
445 | 484 | $ hg strip 3 |
|
446 | 485 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
447 | 486 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
448 | 487 | |
|
449 | 488 | applied patches after stripping rev in queue |
|
450 | 489 | |
|
451 | 490 | $ hg qapplied |
|
452 | 491 | d |
|
453 | 492 | |
|
454 | 493 | stripping ancestor of queue |
|
455 | 494 | |
|
456 | 495 | $ hg strip 1 |
|
457 | 496 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
458 | 497 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
459 | 498 | |
|
460 | 499 | applied patches after stripping ancestor of queue |
|
461 | 500 | |
|
462 | 501 | $ hg qapplied |
|
463 | 502 | |
|
464 | 503 | Verify strip protects against stripping wc parent when there are uncommitted mods |
|
465 | 504 | |
|
466 | 505 | $ echo b > b |
|
467 | 506 | $ echo bb > bar |
|
468 | 507 | $ hg add b |
|
469 | 508 | $ hg ci -m 'b' |
|
470 | 509 | $ hg log --graph |
|
471 | 510 | @ changeset: 1:76dcf9fab855 |
|
472 | 511 | | tag: tip |
|
473 | 512 | | user: test |
|
474 | 513 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
475 | 514 | | summary: b |
|
476 | 515 | | |
|
477 | 516 | o changeset: 0:9ab35a2d17cb |
|
478 | 517 | user: test |
|
479 | 518 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
480 | 519 | summary: a |
|
481 | 520 | |
|
482 | 521 | $ hg up 0 |
|
483 | 522 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
484 | 523 | $ echo c > bar |
|
485 | 524 | $ hg up -t false |
|
486 | 525 | merging bar |
|
487 | 526 | merging bar failed! |
|
488 | 527 | 1 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
489 | 528 | use 'hg resolve' to retry unresolved file merges |
|
490 | 529 | [1] |
|
491 | 530 | $ hg sum |
|
492 | 531 | parent: 1:76dcf9fab855 tip |
|
493 | 532 | b |
|
494 | 533 | branch: default |
|
495 | 534 | commit: 1 modified, 1 unknown, 1 unresolved |
|
496 | 535 | update: (current) |
|
497 | 536 | phases: 2 draft |
|
498 | 537 | mq: 3 unapplied |
|
499 | 538 | |
|
500 | 539 | $ echo c > b |
|
501 | 540 | $ hg strip tip |
|
502 | 541 | abort: local changes found |
|
503 | 542 | [255] |
|
504 | 543 | $ hg strip tip --keep |
|
505 | 544 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
506 | 545 | $ hg log --graph |
|
507 | 546 | @ changeset: 0:9ab35a2d17cb |
|
508 | 547 | tag: tip |
|
509 | 548 | user: test |
|
510 | 549 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
511 | 550 | summary: a |
|
512 | 551 | |
|
513 | 552 | $ hg status |
|
514 | 553 | M bar |
|
515 | 554 | ? b |
|
516 | 555 | ? bar.orig |
|
517 | 556 | |
|
518 | 557 | $ rm bar.orig |
|
519 | 558 | $ hg sum |
|
520 | 559 | parent: 0:9ab35a2d17cb tip |
|
521 | 560 | a |
|
522 | 561 | branch: default |
|
523 | 562 | commit: 1 modified, 1 unknown |
|
524 | 563 | update: (current) |
|
525 | 564 | phases: 1 draft |
|
526 | 565 | mq: 3 unapplied |
|
527 | 566 | |
|
528 | 567 | Strip adds, removes, modifies with --keep |
|
529 | 568 | |
|
530 | 569 | $ touch b |
|
531 | 570 | $ hg add b |
|
532 | 571 | $ hg commit -mb |
|
533 | 572 | $ touch c |
|
534 | 573 | |
|
535 | 574 | ... with a clean working dir |
|
536 | 575 | |
|
537 | 576 | $ hg add c |
|
538 | 577 | $ hg rm bar |
|
539 | 578 | $ hg commit -mc |
|
540 | 579 | $ hg status |
|
541 | 580 | $ hg strip --keep tip |
|
542 | 581 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
543 | 582 | $ hg status |
|
544 | 583 | ! bar |
|
545 | 584 | ? c |
|
546 | 585 | |
|
547 | 586 | ... with a dirty working dir |
|
548 | 587 | |
|
549 | 588 | $ hg add c |
|
550 | 589 | $ hg rm bar |
|
551 | 590 | $ hg commit -mc |
|
552 | 591 | $ hg status |
|
553 | 592 | $ echo b > b |
|
554 | 593 | $ echo d > d |
|
555 | 594 | $ hg strip --keep tip |
|
556 | 595 | saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob) |
|
557 | 596 | $ hg status |
|
558 | 597 | M b |
|
559 | 598 | ! bar |
|
560 | 599 | ? c |
|
561 | 600 | ? d |
|
562 | 601 | |
|
563 | 602 | ... after updating the dirstate |
|
564 | 603 | $ hg add c |
|
565 | 604 | $ hg commit -mc |
|
566 | 605 | $ hg rm c |
|
567 | 606 | $ hg commit -mc |
|
568 | 607 | $ hg strip --keep '.^' -q |
|
569 | 608 | $ cd .. |
|
570 | 609 | |
|
571 | 610 | stripping many nodes on a complex graph (issue3299) |
|
572 | 611 | |
|
573 | 612 | $ hg init issue3299 |
|
574 | 613 | $ cd issue3299 |
|
575 | 614 | $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a' |
|
576 | 615 | $ hg strip 'not ancestors(x)' |
|
577 | 616 | saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob) |
|
578 | 617 | |
|
579 | 618 | test hg strip -B bookmark |
|
580 | 619 | |
|
581 | 620 | $ cd .. |
|
582 | 621 | $ hg init bookmarks |
|
583 | 622 | $ cd bookmarks |
|
584 | 623 | $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b<m+2:d<2.:e<m+1:f' |
|
585 | 624 | $ hg bookmark -r 'a' 'todelete' |
|
586 | 625 | $ hg bookmark -r 'b' 'B' |
|
587 | 626 | $ hg bookmark -r 'b' 'nostrip' |
|
588 | 627 | $ hg bookmark -r 'c' 'delete' |
|
589 | 628 | $ hg bookmark -r 'd' 'multipledelete1' |
|
590 | 629 | $ hg bookmark -r 'e' 'multipledelete2' |
|
591 | 630 | $ hg bookmark -r 'f' 'singlenode1' |
|
592 | 631 | $ hg bookmark -r 'f' 'singlenode2' |
|
593 | 632 | $ hg up -C todelete |
|
594 | 633 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
595 | 634 | (activating bookmark todelete) |
|
596 | 635 | $ hg strip -B nostrip |
|
597 | 636 | bookmark 'nostrip' deleted |
|
598 | 637 | abort: empty revision set |
|
599 | 638 | [255] |
|
600 | 639 | $ hg strip -B todelete |
|
601 | 640 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
602 | 641 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) |
|
603 | 642 | bookmark 'todelete' deleted |
|
604 | 643 | $ hg id -ir dcbb326fdec2 |
|
605 | 644 | abort: unknown revision 'dcbb326fdec2'! |
|
606 | 645 | [255] |
|
607 | 646 | $ hg id -ir d62d843c9a01 |
|
608 | 647 | d62d843c9a01 |
|
609 | 648 | $ hg bookmarks |
|
610 | 649 | B 9:ff43616e5d0f |
|
611 | 650 | delete 6:2702dd0c91e7 |
|
612 | 651 | multipledelete1 11:e46a4836065c |
|
613 | 652 | multipledelete2 12:b4594d867745 |
|
614 | 653 | singlenode1 13:43227190fef8 |
|
615 | 654 | singlenode2 13:43227190fef8 |
|
616 | 655 | $ hg strip -B multipledelete1 -B multipledelete2 |
|
617 | 656 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/e46a4836065c-89ec65c2-backup.hg (glob) |
|
618 | 657 | bookmark 'multipledelete1' deleted |
|
619 | 658 | bookmark 'multipledelete2' deleted |
|
620 | 659 | $ hg id -ir e46a4836065c |
|
621 | 660 | abort: unknown revision 'e46a4836065c'! |
|
622 | 661 | [255] |
|
623 | 662 | $ hg id -ir b4594d867745 |
|
624 | 663 | abort: unknown revision 'b4594d867745'! |
|
625 | 664 | [255] |
|
626 | 665 | $ hg strip -B singlenode1 -B singlenode2 |
|
627 | 666 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg (glob) |
|
628 | 667 | bookmark 'singlenode1' deleted |
|
629 | 668 | bookmark 'singlenode2' deleted |
|
630 | 669 | $ hg id -ir 43227190fef8 |
|
631 | 670 | abort: unknown revision '43227190fef8'! |
|
632 | 671 | [255] |
|
633 | 672 | $ hg strip -B unknownbookmark |
|
634 | 673 | abort: bookmark 'unknownbookmark' not found |
|
635 | 674 | [255] |
|
636 | 675 | $ hg strip -B unknownbookmark1 -B unknownbookmark2 |
|
637 | 676 | abort: bookmark 'unknownbookmark1,unknownbookmark2' not found |
|
638 | 677 | [255] |
|
639 | 678 | $ hg strip -B delete -B unknownbookmark |
|
640 | 679 | abort: bookmark 'unknownbookmark' not found |
|
641 | 680 | [255] |
|
642 | 681 | $ hg strip -B delete |
|
643 | 682 | saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob) |
|
644 | 683 | bookmark 'delete' deleted |
|
645 | 684 | $ hg id -ir 6:2702dd0c91e7 |
|
646 | 685 | abort: unknown revision '2702dd0c91e7'! |
|
647 | 686 | [255] |
|
648 | 687 | $ hg update B |
|
649 | 688 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
650 | 689 | (activating bookmark B) |
|
651 | 690 | $ echo a > a |
|
652 | 691 | $ hg add a |
|
653 | 692 | $ hg strip -B B |
|
654 | 693 | abort: local changes found |
|
655 | 694 | [255] |
|
656 | 695 | $ hg bookmarks |
|
657 | 696 | * B 6:ff43616e5d0f |
|
658 | 697 | |
|
659 | 698 | Make sure no one adds back a -b option: |
|
660 | 699 | |
|
661 | 700 | $ hg strip -b tip |
|
662 | 701 | hg strip: option -b not recognized |
|
663 | 702 | hg strip [-k] [-f] [-B bookmark] [-r] REV... |
|
664 | 703 | |
|
665 | 704 | strip changesets and all their descendants from the repository |
|
666 | 705 | |
|
667 | 706 | (use "hg help -e strip" to show help for the strip extension) |
|
668 | 707 | |
|
669 | 708 | options ([+] can be repeated): |
|
670 | 709 | |
|
671 | 710 | -r --rev REV [+] strip specified revision (optional, can specify |
|
672 | 711 | revisions without this option) |
|
673 | 712 | -f --force force removal of changesets, discard uncommitted |
|
674 | 713 | changes (no backup) |
|
675 | 714 | --no-backup no backups |
|
676 | 715 | -k --keep do not modify working directory during strip |
|
677 | 716 | -B --bookmark VALUE [+] remove revs only reachable from given bookmark |
|
678 | 717 | --mq operate on patch repository |
|
679 | 718 | |
|
680 | 719 | (use "hg strip -h" to show more help) |
|
681 | 720 | [255] |
|
682 | 721 | |
|
683 | 722 | $ cd .. |
|
684 | 723 | |
|
685 | 724 | Verify bundles don't get overwritten: |
|
686 | 725 | |
|
687 | 726 | $ hg init doublebundle |
|
688 | 727 | $ cd doublebundle |
|
689 | 728 | $ touch a |
|
690 | 729 | $ hg commit -Aqm a |
|
691 | 730 | $ touch b |
|
692 | 731 | $ hg commit -Aqm b |
|
693 | 732 | $ hg strip -r 0 |
|
694 | 733 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
695 | 734 | saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-e68910bd-backup.hg (glob) |
|
696 | 735 | $ ls .hg/strip-backup |
|
697 | 736 | 3903775176ed-e68910bd-backup.hg |
|
698 | 737 | $ hg pull -q -r 3903775176ed .hg/strip-backup/3903775176ed-e68910bd-backup.hg |
|
699 | 738 | $ hg strip -r 0 |
|
700 | 739 | saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg (glob) |
|
701 | 740 | $ ls .hg/strip-backup |
|
702 | 741 | 3903775176ed-54390173-backup.hg |
|
703 | 742 | 3903775176ed-e68910bd-backup.hg |
|
704 | 743 | $ cd .. |
|
705 | 744 | |
|
706 | 745 | Test that we only bundle the stripped changesets (issue4736) |
|
707 | 746 | ------------------------------------------------------------ |
|
708 | 747 | |
|
709 | 748 | initialization (previous repo is empty anyway) |
|
710 | 749 | |
|
711 | 750 | $ hg init issue4736 |
|
712 | 751 | $ cd issue4736 |
|
713 | 752 | $ echo a > a |
|
714 | 753 | $ hg add a |
|
715 | 754 | $ hg commit -m commitA |
|
716 | 755 | $ echo b > b |
|
717 | 756 | $ hg add b |
|
718 | 757 | $ hg commit -m commitB |
|
719 | 758 | $ echo c > c |
|
720 | 759 | $ hg add c |
|
721 | 760 | $ hg commit -m commitC |
|
722 | 761 | $ hg up 'desc(commitB)' |
|
723 | 762 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
724 | 763 | $ echo d > d |
|
725 | 764 | $ hg add d |
|
726 | 765 | $ hg commit -m commitD |
|
727 | 766 | created new head |
|
728 | 767 | $ hg up 'desc(commitC)' |
|
729 | 768 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
730 | 769 | $ hg merge 'desc(commitD)' |
|
731 | 770 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
732 | 771 | (branch merge, don't forget to commit) |
|
733 | 772 | $ hg ci -m 'mergeCD' |
|
734 | 773 | $ hg log -G |
|
735 | 774 | @ changeset: 4:d8db9d137221 |
|
736 | 775 | |\ tag: tip |
|
737 | 776 | | | parent: 2:5c51d8d6557d |
|
738 | 777 | | | parent: 3:6625a5168474 |
|
739 | 778 | | | user: test |
|
740 | 779 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
741 | 780 | | | summary: mergeCD |
|
742 | 781 | | | |
|
743 | 782 | | o changeset: 3:6625a5168474 |
|
744 | 783 | | | parent: 1:eca11cf91c71 |
|
745 | 784 | | | user: test |
|
746 | 785 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
747 | 786 | | | summary: commitD |
|
748 | 787 | | | |
|
749 | 788 | o | changeset: 2:5c51d8d6557d |
|
750 | 789 | |/ user: test |
|
751 | 790 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
752 | 791 | | summary: commitC |
|
753 | 792 | | |
|
754 | 793 | o changeset: 1:eca11cf91c71 |
|
755 | 794 | | user: test |
|
756 | 795 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
757 | 796 | | summary: commitB |
|
758 | 797 | | |
|
759 | 798 | o changeset: 0:105141ef12d0 |
|
760 | 799 | user: test |
|
761 | 800 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
762 | 801 | summary: commitA |
|
763 | 802 | |
|
764 | 803 | |
|
765 | 804 | Check bundle behavior: |
|
766 | 805 | |
|
767 | 806 | $ hg bundle -r 'desc(mergeCD)' --base 'desc(commitC)' ../issue4736.hg |
|
768 | 807 | 2 changesets found |
|
769 | 808 | $ hg log -r 'bundle()' -R ../issue4736.hg |
|
770 | 809 | changeset: 3:6625a5168474 |
|
771 | 810 | parent: 1:eca11cf91c71 |
|
772 | 811 | user: test |
|
773 | 812 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
774 | 813 | summary: commitD |
|
775 | 814 | |
|
776 | 815 | changeset: 4:d8db9d137221 |
|
777 | 816 | tag: tip |
|
778 | 817 | parent: 2:5c51d8d6557d |
|
779 | 818 | parent: 3:6625a5168474 |
|
780 | 819 | user: test |
|
781 | 820 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
782 | 821 | summary: mergeCD |
|
783 | 822 | |
|
784 | 823 | |
|
785 | 824 | check strip behavior |
|
786 | 825 | |
|
787 | 826 | $ hg --config extensions.strip= strip 'desc(commitD)' --debug |
|
788 | 827 | resolving manifests |
|
789 | 828 | branchmerge: False, force: True, partial: False |
|
790 | 829 | ancestor: d8db9d137221+, local: d8db9d137221+, remote: eca11cf91c71 |
|
791 | 830 | c: other deleted -> r |
|
792 | 831 | removing c |
|
793 | 832 | d: other deleted -> r |
|
794 | 833 | removing d |
|
795 | 834 | starting 4 threads for background file closing (?) |
|
796 | 835 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
797 | 836 | 2 changesets found |
|
798 | 837 | list of changesets: |
|
799 | 838 | 6625a516847449b6f0fa3737b9ba56e9f0f3032c |
|
800 | 839 | d8db9d1372214336d2b5570f20ee468d2c72fa8b |
|
801 | 840 | bundle2-output-bundle: "HG20", (1 params) 1 parts total |
|
802 | 841 | bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload |
|
803 | 842 | saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg (glob) |
|
804 | 843 | invalid branchheads cache (served): tip differs |
|
805 | 844 | truncating cache/rbc-revs-v1 to 24 |
|
806 | 845 | $ hg log -G |
|
807 | 846 | o changeset: 2:5c51d8d6557d |
|
808 | 847 | | tag: tip |
|
809 | 848 | | user: test |
|
810 | 849 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
811 | 850 | | summary: commitC |
|
812 | 851 | | |
|
813 | 852 | @ changeset: 1:eca11cf91c71 |
|
814 | 853 | | user: test |
|
815 | 854 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
816 | 855 | | summary: commitB |
|
817 | 856 | | |
|
818 | 857 | o changeset: 0:105141ef12d0 |
|
819 | 858 | user: test |
|
820 | 859 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
821 | 860 | summary: commitA |
|
822 | 861 | |
|
823 | 862 | |
|
824 | 863 | strip backup content |
|
825 | 864 | |
|
826 | 865 | $ hg log -r 'bundle()' -R .hg/strip-backup/6625a5168474-*-backup.hg |
|
827 | 866 | changeset: 3:6625a5168474 |
|
828 | 867 | parent: 1:eca11cf91c71 |
|
829 | 868 | user: test |
|
830 | 869 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
831 | 870 | summary: commitD |
|
832 | 871 | |
|
833 | 872 | changeset: 4:d8db9d137221 |
|
834 | 873 | tag: tip |
|
835 | 874 | parent: 2:5c51d8d6557d |
|
836 | 875 | parent: 3:6625a5168474 |
|
837 | 876 | user: test |
|
838 | 877 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
839 | 878 | summary: mergeCD |
|
840 | 879 | |
|
841 | 880 | Check that the phase cache is properly invalidated after a strip with bookmark. |
|
842 | 881 | |
|
843 | 882 | $ cat > ../stripstalephasecache.py << EOF |
|
844 | 883 | > from mercurial import extensions, localrepo |
|
845 | 884 | > def transactioncallback(orig, repo, desc, *args, **kwargs): |
|
846 | 885 | > def test(transaction): |
|
847 | 886 | > # observe cache inconsistency |
|
848 | 887 | > try: |
|
849 | 888 | > [repo.changelog.node(r) for r in repo.revs("not public()")] |
|
850 | 889 | > except IndexError: |
|
851 | 890 | > repo.ui.status("Index error!\n") |
|
852 | 891 | > transaction = orig(repo, desc, *args, **kwargs) |
|
853 | 892 | > # warm up the phase cache |
|
854 | 893 | > list(repo.revs("not public()")) |
|
855 | 894 | > if desc != 'strip': |
|
856 | 895 | > transaction.addpostclose("phase invalidation test", test) |
|
857 | 896 | > return transaction |
|
858 | 897 | > def extsetup(ui): |
|
859 | 898 | > extensions.wrapfunction(localrepo.localrepository, "transaction", |
|
860 | 899 | > transactioncallback) |
|
861 | 900 | > EOF |
|
862 | 901 | $ hg up -C 2 |
|
863 | 902 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
864 | 903 | $ echo k > k |
|
865 | 904 | $ hg add k |
|
866 | 905 | $ hg commit -m commitK |
|
867 | 906 | $ echo l > l |
|
868 | 907 | $ hg add l |
|
869 | 908 | $ hg commit -m commitL |
|
870 | 909 | $ hg book -r tip blah |
|
871 | 910 | $ hg strip ".^" --config extensions.crash=$TESTTMP/stripstalephasecache.py |
|
872 | 911 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
873 | 912 | saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/8f0b4384875c-4fa10deb-backup.hg (glob) |
|
874 | 913 | $ hg up -C 1 |
|
875 | 914 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
876 | 915 | |
|
877 | 916 | Error during post-close callback of the strip transaction |
|
878 | 917 | (They should be gracefully handled and reported) |
|
879 | 918 | |
|
880 | 919 | $ cat > ../crashstrip.py << EOF |
|
881 | 920 | > from mercurial import error |
|
882 | 921 | > def reposetup(ui, repo): |
|
883 | 922 | > class crashstriprepo(repo.__class__): |
|
884 | 923 | > def transaction(self, desc, *args, **kwargs): |
|
885 | 924 | > tr = super(crashstriprepo, self).transaction(self, desc, *args, **kwargs) |
|
886 | 925 | > if desc == 'strip': |
|
887 | 926 | > def crash(tra): raise error.Abort('boom') |
|
888 | 927 | > tr.addpostclose('crash', crash) |
|
889 | 928 | > return tr |
|
890 | 929 | > repo.__class__ = crashstriprepo |
|
891 | 930 | > EOF |
|
892 | 931 | $ hg strip tip --config extensions.crash=$TESTTMP/crashstrip.py |
|
893 | 932 | saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg (glob) |
|
894 | 933 | strip failed, full bundle stored in '$TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg' (glob) |
|
895 | 934 | abort: boom |
|
896 | 935 | [255] |
|
897 | 936 | |
|
898 | 937 |
General Comments 0
You need to be logged in to leave comments.
Login now