Show More
@@ -1,441 +1,443 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 ( |
|
16 | 16 | hex, |
|
17 | 17 | short, |
|
18 | 18 | ) |
|
19 | 19 | from . import ( |
|
20 | 20 | bundle2, |
|
21 | 21 | changegroup, |
|
22 | 22 | discovery, |
|
23 | 23 | error, |
|
24 | 24 | exchange, |
|
25 | 25 | obsolete, |
|
26 | 26 | obsutil, |
|
27 | phases, | |
|
27 | 28 | pycompat, |
|
28 | 29 | util, |
|
29 | 30 | ) |
|
30 | 31 | from .utils import ( |
|
31 | 32 | stringutil, |
|
32 | 33 | ) |
|
33 | 34 | |
|
34 | 35 | def backupbundle(repo, bases, heads, node, suffix, compress=True, |
|
35 | 36 | obsolescence=True): |
|
36 | 37 | """create a bundle with the specified revisions as a backup""" |
|
37 | 38 | |
|
38 | 39 | backupdir = "strip-backup" |
|
39 | 40 | vfs = repo.vfs |
|
40 | 41 | if not vfs.isdir(backupdir): |
|
41 | 42 | vfs.mkdir(backupdir) |
|
42 | 43 | |
|
43 | 44 | # Include a hash of all the nodes in the filename for uniqueness |
|
44 | 45 | allcommits = repo.set('%ln::%ln', bases, heads) |
|
45 | 46 | allhashes = sorted(c.hex() for c in allcommits) |
|
46 | 47 | totalhash = hashlib.sha1(''.join(allhashes)).digest() |
|
47 | 48 | name = "%s/%s-%s-%s.hg" % (backupdir, short(node), |
|
48 | 49 | hex(totalhash[:4]), suffix) |
|
49 | 50 | |
|
50 | 51 | cgversion = changegroup.localversion(repo) |
|
51 | 52 | comp = None |
|
52 | 53 | if cgversion != '01': |
|
53 | 54 | bundletype = "HG20" |
|
54 | 55 | if compress: |
|
55 | 56 | comp = 'BZ' |
|
56 | 57 | elif compress: |
|
57 | 58 | bundletype = "HG10BZ" |
|
58 | 59 | else: |
|
59 | 60 | bundletype = "HG10UN" |
|
60 | 61 | |
|
61 | 62 | outgoing = discovery.outgoing(repo, missingroots=bases, missingheads=heads) |
|
62 | 63 | contentopts = { |
|
63 | 64 | 'cg.version': cgversion, |
|
64 | 65 | 'obsolescence': obsolescence, |
|
65 | 66 | 'phases': True, |
|
66 | 67 | } |
|
67 | 68 | return bundle2.writenewbundle(repo.ui, repo, 'strip', name, bundletype, |
|
68 | 69 | outgoing, contentopts, vfs, compression=comp) |
|
69 | 70 | |
|
70 | 71 | def _collectfiles(repo, striprev): |
|
71 | 72 | """find out the filelogs affected by the strip""" |
|
72 | 73 | files = set() |
|
73 | 74 | |
|
74 | 75 | for x in pycompat.xrange(striprev, len(repo)): |
|
75 | 76 | files.update(repo[x].files()) |
|
76 | 77 | |
|
77 | 78 | return sorted(files) |
|
78 | 79 | |
|
79 | 80 | def _collectrevlog(revlog, striprev): |
|
80 | 81 | _, brokenset = revlog.getstrippoint(striprev) |
|
81 | 82 | return [revlog.linkrev(r) for r in brokenset] |
|
82 | 83 | |
|
83 | 84 | def _collectmanifest(repo, striprev): |
|
84 | 85 | return _collectrevlog(repo.manifestlog.getstorage(b''), striprev) |
|
85 | 86 | |
|
86 | 87 | def _collectbrokencsets(repo, files, striprev): |
|
87 | 88 | """return the changesets which will be broken by the truncation""" |
|
88 | 89 | s = set() |
|
89 | 90 | |
|
90 | 91 | s.update(_collectmanifest(repo, striprev)) |
|
91 | 92 | for fname in files: |
|
92 | 93 | s.update(_collectrevlog(repo.file(fname), striprev)) |
|
93 | 94 | |
|
94 | 95 | return s |
|
95 | 96 | |
|
96 | 97 | def strip(ui, repo, nodelist, backup=True, topic='backup'): |
|
97 | 98 | # This function requires the caller to lock the repo, but it operates |
|
98 | 99 | # within a transaction of its own, and thus requires there to be no current |
|
99 | 100 | # transaction when it is called. |
|
100 | 101 | if repo.currenttransaction() is not None: |
|
101 | 102 | raise error.ProgrammingError('cannot strip from inside a transaction') |
|
102 | 103 | |
|
103 | 104 | # Simple way to maintain backwards compatibility for this |
|
104 | 105 | # argument. |
|
105 | 106 | if backup in ['none', 'strip']: |
|
106 | 107 | backup = False |
|
107 | 108 | |
|
108 | 109 | repo = repo.unfiltered() |
|
109 | 110 | repo.destroying() |
|
110 | 111 | |
|
111 | 112 | cl = repo.changelog |
|
112 | 113 | # TODO handle undo of merge sets |
|
113 | 114 | if isinstance(nodelist, str): |
|
114 | 115 | nodelist = [nodelist] |
|
115 | 116 | striplist = [cl.rev(node) for node in nodelist] |
|
116 | 117 | striprev = min(striplist) |
|
117 | 118 | |
|
118 | 119 | files = _collectfiles(repo, striprev) |
|
119 | 120 | saverevs = _collectbrokencsets(repo, files, striprev) |
|
120 | 121 | |
|
121 | 122 | # Some revisions with rev > striprev may not be descendants of striprev. |
|
122 | 123 | # We have to find these revisions and put them in a bundle, so that |
|
123 | 124 | # we can restore them after the truncations. |
|
124 | 125 | # To create the bundle we use repo.changegroupsubset which requires |
|
125 | 126 | # the list of heads and bases of the set of interesting revisions. |
|
126 | 127 | # (head = revision in the set that has no descendant in the set; |
|
127 | 128 | # base = revision in the set that has no ancestor in the set) |
|
128 | 129 | tostrip = set(striplist) |
|
129 | 130 | saveheads = set(saverevs) |
|
130 | 131 | for r in cl.revs(start=striprev + 1): |
|
131 | 132 | if any(p in tostrip for p in cl.parentrevs(r)): |
|
132 | 133 | tostrip.add(r) |
|
133 | 134 | |
|
134 | 135 | if r not in tostrip: |
|
135 | 136 | saverevs.add(r) |
|
136 | 137 | saveheads.difference_update(cl.parentrevs(r)) |
|
137 | 138 | saveheads.add(r) |
|
138 | 139 | saveheads = [cl.node(r) for r in saveheads] |
|
139 | 140 | |
|
140 | 141 | # compute base nodes |
|
141 | 142 | if saverevs: |
|
142 | 143 | descendants = set(cl.descendants(saverevs)) |
|
143 | 144 | saverevs.difference_update(descendants) |
|
144 | 145 | savebases = [cl.node(r) for r in saverevs] |
|
145 | 146 | stripbases = [cl.node(r) for r in tostrip] |
|
146 | 147 | |
|
147 | 148 | stripobsidx = obsmarkers = () |
|
148 | 149 | if repo.ui.configbool('devel', 'strip-obsmarkers'): |
|
149 | 150 | obsmarkers = obsutil.exclusivemarkers(repo, stripbases) |
|
150 | 151 | if obsmarkers: |
|
151 | 152 | stripobsidx = [i for i, m in enumerate(repo.obsstore) |
|
152 | 153 | if m in obsmarkers] |
|
153 | 154 | |
|
154 | 155 | # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but |
|
155 | 156 | # is much faster |
|
156 | 157 | newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) |
|
157 | 158 | if newbmtarget: |
|
158 | 159 | newbmtarget = repo[newbmtarget.first()].node() |
|
159 | 160 | else: |
|
160 | 161 | newbmtarget = '.' |
|
161 | 162 | |
|
162 | 163 | bm = repo._bookmarks |
|
163 | 164 | updatebm = [] |
|
164 | 165 | for m in bm: |
|
165 | 166 | rev = repo[bm[m]].rev() |
|
166 | 167 | if rev in tostrip: |
|
167 | 168 | updatebm.append(m) |
|
168 | 169 | |
|
169 | 170 | # create a changegroup for all the branches we need to keep |
|
170 | 171 | backupfile = None |
|
171 | 172 | vfs = repo.vfs |
|
172 | 173 | node = nodelist[-1] |
|
173 | 174 | if backup: |
|
174 | 175 | backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic) |
|
175 | 176 | repo.ui.status(_("saved backup bundle to %s\n") % |
|
176 | 177 | vfs.join(backupfile)) |
|
177 | 178 | repo.ui.log("backupbundle", "saved backup bundle to %s\n", |
|
178 | 179 | vfs.join(backupfile)) |
|
179 | 180 | tmpbundlefile = None |
|
180 | 181 | if saveheads: |
|
181 | 182 | # do not compress temporary bundle if we remove it from disk later |
|
182 | 183 | # |
|
183 | 184 | # We do not include obsolescence, it might re-introduce prune markers |
|
184 | 185 | # we are trying to strip. This is harmless since the stripped markers |
|
185 | 186 | # are already backed up and we did not touched the markers for the |
|
186 | 187 | # saved changesets. |
|
187 | 188 | tmpbundlefile = backupbundle(repo, savebases, saveheads, node, 'temp', |
|
188 | 189 | compress=False, obsolescence=False) |
|
189 | 190 | |
|
190 | 191 | with ui.uninterruptable(): |
|
191 | 192 | try: |
|
192 | 193 | with repo.transaction("strip") as tr: |
|
193 | 194 | # TODO this code violates the interface abstraction of the |
|
194 | 195 | # transaction and makes assumptions that file storage is |
|
195 | 196 | # using append-only files. We'll need some kind of storage |
|
196 | 197 | # API to handle stripping for us. |
|
197 | 198 | offset = len(tr._entries) |
|
198 | 199 | |
|
199 | 200 | tr.startgroup() |
|
200 | 201 | cl.strip(striprev, tr) |
|
201 | 202 | stripmanifest(repo, striprev, tr, files) |
|
202 | 203 | |
|
203 | 204 | for fn in files: |
|
204 | 205 | repo.file(fn).strip(striprev, tr) |
|
205 | 206 | tr.endgroup() |
|
206 | 207 | |
|
207 | 208 | for i in pycompat.xrange(offset, len(tr._entries)): |
|
208 | 209 | file, troffset, ignore = tr._entries[i] |
|
209 | 210 | with repo.svfs(file, 'a', checkambig=True) as fp: |
|
210 | 211 | fp.truncate(troffset) |
|
211 | 212 | if troffset == 0: |
|
212 | 213 | repo.store.markremoved(file) |
|
213 | 214 | |
|
214 | 215 | deleteobsmarkers(repo.obsstore, stripobsidx) |
|
215 | 216 | del repo.obsstore |
|
216 | 217 | repo.invalidatevolatilesets() |
|
217 | 218 | repo._phasecache.filterunknown(repo) |
|
218 | 219 | |
|
219 | 220 | if tmpbundlefile: |
|
220 | 221 | ui.note(_("adding branch\n")) |
|
221 | 222 | f = vfs.open(tmpbundlefile, "rb") |
|
222 | 223 | gen = exchange.readbundle(ui, f, tmpbundlefile, vfs) |
|
223 | 224 | if not repo.ui.verbose: |
|
224 | 225 | # silence internal shuffling chatter |
|
225 | 226 | repo.ui.pushbuffer() |
|
226 | 227 | tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile) |
|
227 | 228 | txnname = 'strip' |
|
228 | 229 | if not isinstance(gen, bundle2.unbundle20): |
|
229 | 230 | txnname = "strip\n%s" % util.hidepassword(tmpbundleurl) |
|
230 | 231 | with repo.transaction(txnname) as tr: |
|
231 | 232 | bundle2.applybundle(repo, gen, tr, source='strip', |
|
232 | 233 | url=tmpbundleurl) |
|
233 | 234 | if not repo.ui.verbose: |
|
234 | 235 | repo.ui.popbuffer() |
|
235 | 236 | f.close() |
|
236 | 237 | |
|
237 | 238 | with repo.transaction('repair') as tr: |
|
238 | 239 | bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm] |
|
239 | 240 | bm.applychanges(repo, tr, bmchanges) |
|
240 | 241 | |
|
241 | 242 | # remove undo files |
|
242 | 243 | for undovfs, undofile in repo.undofiles(): |
|
243 | 244 | try: |
|
244 | 245 | undovfs.unlink(undofile) |
|
245 | 246 | except OSError as e: |
|
246 | 247 | if e.errno != errno.ENOENT: |
|
247 | 248 | ui.warn(_('error removing %s: %s\n') % |
|
248 | 249 | (undovfs.join(undofile), |
|
249 | 250 | stringutil.forcebytestr(e))) |
|
250 | 251 | |
|
251 | 252 | except: # re-raises |
|
252 | 253 | if backupfile: |
|
253 | 254 | ui.warn(_("strip failed, backup bundle stored in '%s'\n") |
|
254 | 255 | % vfs.join(backupfile)) |
|
255 | 256 | if tmpbundlefile: |
|
256 | 257 | ui.warn(_("strip failed, unrecovered changes stored in '%s'\n") |
|
257 | 258 | % vfs.join(tmpbundlefile)) |
|
258 | 259 | ui.warn(_("(fix the problem, then recover the changesets with " |
|
259 | 260 | "\"hg unbundle '%s'\")\n") % vfs.join(tmpbundlefile)) |
|
260 | 261 | raise |
|
261 | 262 | else: |
|
262 | 263 | if tmpbundlefile: |
|
263 | 264 | # Remove temporary bundle only if there were no exceptions |
|
264 | 265 | vfs.unlink(tmpbundlefile) |
|
265 | 266 | |
|
266 | 267 | repo.destroyed() |
|
267 | 268 | # return the backup file path (or None if 'backup' was False) so |
|
268 | 269 | # extensions can use it |
|
269 | 270 | return backupfile |
|
270 | 271 | |
|
271 | 272 | def safestriproots(ui, repo, nodes): |
|
272 | 273 | """return list of roots of nodes where descendants are covered by nodes""" |
|
273 | 274 | torev = repo.unfiltered().changelog.rev |
|
274 | 275 | revs = set(torev(n) for n in nodes) |
|
275 | 276 | # tostrip = wanted - unsafe = wanted - ancestors(orphaned) |
|
276 | 277 | # orphaned = affected - wanted |
|
277 | 278 | # affected = descendants(roots(wanted)) |
|
278 | 279 | # wanted = revs |
|
279 | tostrip = set(repo.revs('%ld-(::((roots(%ld)::)-%ld))', revs, revs, revs)) | |
|
280 | revset = '%ld - ( ::( (roots(%ld):: and not _phase(%s)) -%ld) )' | |
|
281 | tostrip = set(repo.revs(revset, revs, revs, phases.internal, revs)) | |
|
280 | 282 | notstrip = revs - tostrip |
|
281 | 283 | if notstrip: |
|
282 | 284 | nodestr = ', '.join(sorted(short(repo[n].node()) for n in notstrip)) |
|
283 | 285 | ui.warn(_('warning: orphaned descendants detected, ' |
|
284 | 286 | 'not stripping %s\n') % nodestr) |
|
285 | 287 | return [c.node() for c in repo.set('roots(%ld)', tostrip)] |
|
286 | 288 | |
|
287 | 289 | class stripcallback(object): |
|
288 | 290 | """used as a transaction postclose callback""" |
|
289 | 291 | |
|
290 | 292 | def __init__(self, ui, repo, backup, topic): |
|
291 | 293 | self.ui = ui |
|
292 | 294 | self.repo = repo |
|
293 | 295 | self.backup = backup |
|
294 | 296 | self.topic = topic or 'backup' |
|
295 | 297 | self.nodelist = [] |
|
296 | 298 | |
|
297 | 299 | def addnodes(self, nodes): |
|
298 | 300 | self.nodelist.extend(nodes) |
|
299 | 301 | |
|
300 | 302 | def __call__(self, tr): |
|
301 | 303 | roots = safestriproots(self.ui, self.repo, self.nodelist) |
|
302 | 304 | if roots: |
|
303 | 305 | strip(self.ui, self.repo, roots, self.backup, self.topic) |
|
304 | 306 | |
|
305 | 307 | def delayedstrip(ui, repo, nodelist, topic=None, backup=True): |
|
306 | 308 | """like strip, but works inside transaction and won't strip irreverent revs |
|
307 | 309 | |
|
308 | 310 | nodelist must explicitly contain all descendants. Otherwise a warning will |
|
309 | 311 | be printed that some nodes are not stripped. |
|
310 | 312 | |
|
311 | 313 | Will do a backup if `backup` is True. The last non-None "topic" will be |
|
312 | 314 | used as the backup topic name. The default backup topic name is "backup". |
|
313 | 315 | """ |
|
314 | 316 | tr = repo.currenttransaction() |
|
315 | 317 | if not tr: |
|
316 | 318 | nodes = safestriproots(ui, repo, nodelist) |
|
317 | 319 | return strip(ui, repo, nodes, backup=backup, topic=topic) |
|
318 | 320 | # transaction postclose callbacks are called in alphabet order. |
|
319 | 321 | # use '\xff' as prefix so we are likely to be called last. |
|
320 | 322 | callback = tr.getpostclose('\xffstrip') |
|
321 | 323 | if callback is None: |
|
322 | 324 | callback = stripcallback(ui, repo, backup=backup, topic=topic) |
|
323 | 325 | tr.addpostclose('\xffstrip', callback) |
|
324 | 326 | if topic: |
|
325 | 327 | callback.topic = topic |
|
326 | 328 | callback.addnodes(nodelist) |
|
327 | 329 | |
|
328 | 330 | def stripmanifest(repo, striprev, tr, files): |
|
329 | 331 | revlog = repo.manifestlog.getstorage(b'') |
|
330 | 332 | revlog.strip(striprev, tr) |
|
331 | 333 | striptrees(repo, tr, striprev, files) |
|
332 | 334 | |
|
333 | 335 | def striptrees(repo, tr, striprev, files): |
|
334 | 336 | if 'treemanifest' in repo.requirements: # safe but unnecessary |
|
335 | 337 | # otherwise |
|
336 | 338 | for unencoded, encoded, size in repo.store.datafiles(): |
|
337 | 339 | if (unencoded.startswith('meta/') and |
|
338 | 340 | unencoded.endswith('00manifest.i')): |
|
339 | 341 | dir = unencoded[5:-12] |
|
340 | 342 | repo.manifestlog.getstorage(dir).strip(striprev, tr) |
|
341 | 343 | |
|
342 | 344 | def rebuildfncache(ui, repo): |
|
343 | 345 | """Rebuilds the fncache file from repo history. |
|
344 | 346 | |
|
345 | 347 | Missing entries will be added. Extra entries will be removed. |
|
346 | 348 | """ |
|
347 | 349 | repo = repo.unfiltered() |
|
348 | 350 | |
|
349 | 351 | if 'fncache' not in repo.requirements: |
|
350 | 352 | ui.warn(_('(not rebuilding fncache because repository does not ' |
|
351 | 353 | 'support fncache)\n')) |
|
352 | 354 | return |
|
353 | 355 | |
|
354 | 356 | with repo.lock(): |
|
355 | 357 | fnc = repo.store.fncache |
|
356 | 358 | # Trigger load of fncache. |
|
357 | 359 | if 'irrelevant' in fnc: |
|
358 | 360 | pass |
|
359 | 361 | |
|
360 | 362 | oldentries = set(fnc.entries) |
|
361 | 363 | newentries = set() |
|
362 | 364 | seenfiles = set() |
|
363 | 365 | |
|
364 | 366 | progress = ui.makeprogress(_('rebuilding'), unit=_('changesets'), |
|
365 | 367 | total=len(repo)) |
|
366 | 368 | for rev in repo: |
|
367 | 369 | progress.update(rev) |
|
368 | 370 | |
|
369 | 371 | ctx = repo[rev] |
|
370 | 372 | for f in ctx.files(): |
|
371 | 373 | # This is to minimize I/O. |
|
372 | 374 | if f in seenfiles: |
|
373 | 375 | continue |
|
374 | 376 | seenfiles.add(f) |
|
375 | 377 | |
|
376 | 378 | i = 'data/%s.i' % f |
|
377 | 379 | d = 'data/%s.d' % f |
|
378 | 380 | |
|
379 | 381 | if repo.store._exists(i): |
|
380 | 382 | newentries.add(i) |
|
381 | 383 | if repo.store._exists(d): |
|
382 | 384 | newentries.add(d) |
|
383 | 385 | |
|
384 | 386 | progress.complete() |
|
385 | 387 | |
|
386 | 388 | if 'treemanifest' in repo.requirements: # safe but unnecessary otherwise |
|
387 | 389 | for dir in util.dirs(seenfiles): |
|
388 | 390 | i = 'meta/%s/00manifest.i' % dir |
|
389 | 391 | d = 'meta/%s/00manifest.d' % dir |
|
390 | 392 | |
|
391 | 393 | if repo.store._exists(i): |
|
392 | 394 | newentries.add(i) |
|
393 | 395 | if repo.store._exists(d): |
|
394 | 396 | newentries.add(d) |
|
395 | 397 | |
|
396 | 398 | addcount = len(newentries - oldentries) |
|
397 | 399 | removecount = len(oldentries - newentries) |
|
398 | 400 | for p in sorted(oldentries - newentries): |
|
399 | 401 | ui.write(_('removing %s\n') % p) |
|
400 | 402 | for p in sorted(newentries - oldentries): |
|
401 | 403 | ui.write(_('adding %s\n') % p) |
|
402 | 404 | |
|
403 | 405 | if addcount or removecount: |
|
404 | 406 | ui.write(_('%d items added, %d removed from fncache\n') % |
|
405 | 407 | (addcount, removecount)) |
|
406 | 408 | fnc.entries = newentries |
|
407 | 409 | fnc._dirty = True |
|
408 | 410 | |
|
409 | 411 | with repo.transaction('fncache') as tr: |
|
410 | 412 | fnc.write(tr) |
|
411 | 413 | else: |
|
412 | 414 | ui.write(_('fncache already up to date\n')) |
|
413 | 415 | |
|
414 | 416 | def deleteobsmarkers(obsstore, indices): |
|
415 | 417 | """Delete some obsmarkers from obsstore and return how many were deleted |
|
416 | 418 | |
|
417 | 419 | 'indices' is a list of ints which are the indices |
|
418 | 420 | of the markers to be deleted. |
|
419 | 421 | |
|
420 | 422 | Every invocation of this function completely rewrites the obsstore file, |
|
421 | 423 | skipping the markers we want to be removed. The new temporary file is |
|
422 | 424 | created, remaining markers are written there and on .close() this file |
|
423 | 425 | gets atomically renamed to obsstore, thus guaranteeing consistency.""" |
|
424 | 426 | if not indices: |
|
425 | 427 | # we don't want to rewrite the obsstore with the same content |
|
426 | 428 | return |
|
427 | 429 | |
|
428 | 430 | left = [] |
|
429 | 431 | current = obsstore._all |
|
430 | 432 | n = 0 |
|
431 | 433 | for i, m in enumerate(current): |
|
432 | 434 | if i in indices: |
|
433 | 435 | n += 1 |
|
434 | 436 | continue |
|
435 | 437 | left.append(m) |
|
436 | 438 | |
|
437 | 439 | newobsstorefile = obsstore.svfs('obsstore', 'w', atomictemp=True) |
|
438 | 440 | for bytes in obsolete.encodemarkers(left, True, obsstore._version): |
|
439 | 441 | newobsstorefile.write(bytes) |
|
440 | 442 | newobsstorefile.close() |
|
441 | 443 | return n |
@@ -1,1875 +1,1866 b'' | |||
|
1 | 1 | #testcases stripbased phasebased |
|
2 | 2 | |
|
3 | 3 | $ cat <<EOF >> $HGRCPATH |
|
4 | 4 | > [extensions] |
|
5 | 5 | > mq = |
|
6 | 6 | > shelve = |
|
7 | 7 | > [defaults] |
|
8 | 8 | > diff = --nodates --git |
|
9 | 9 | > qnew = --date '0 0' |
|
10 | 10 | > [shelve] |
|
11 | 11 | > maxbackups = 2 |
|
12 | 12 | > EOF |
|
13 | 13 | |
|
14 | 14 | #if phasebased |
|
15 | 15 | |
|
16 | 16 | $ cat <<EOF >> $HGRCPATH |
|
17 | 17 | > [format] |
|
18 | 18 | > internal-phase = yes |
|
19 | 19 | > EOF |
|
20 | 20 | |
|
21 | 21 | #endif |
|
22 | 22 | |
|
23 | 23 | $ hg init repo |
|
24 | 24 | $ cd repo |
|
25 | 25 | $ mkdir a b |
|
26 | 26 | $ echo a > a/a |
|
27 | 27 | $ echo b > b/b |
|
28 | 28 | $ echo c > c |
|
29 | 29 | $ echo d > d |
|
30 | 30 | $ echo x > x |
|
31 | 31 | $ hg addremove -q |
|
32 | 32 | |
|
33 | 33 | shelve has a help message |
|
34 | 34 | $ hg shelve -h |
|
35 | 35 | hg shelve [OPTION]... [FILE]... |
|
36 | 36 | |
|
37 | 37 | save and set aside changes from the working directory |
|
38 | 38 | |
|
39 | 39 | Shelving takes files that "hg status" reports as not clean, saves the |
|
40 | 40 | modifications to a bundle (a shelved change), and reverts the files so |
|
41 | 41 | that their state in the working directory becomes clean. |
|
42 | 42 | |
|
43 | 43 | To restore these changes to the working directory, using "hg unshelve"; |
|
44 | 44 | this will work even if you switch to a different commit. |
|
45 | 45 | |
|
46 | 46 | When no files are specified, "hg shelve" saves all not-clean files. If |
|
47 | 47 | specific files or directories are named, only changes to those files are |
|
48 | 48 | shelved. |
|
49 | 49 | |
|
50 | 50 | In bare shelve (when no files are specified, without interactive, include |
|
51 | 51 | and exclude option), shelving remembers information if the working |
|
52 | 52 | directory was on newly created branch, in other words working directory |
|
53 | 53 | was on different branch than its first parent. In this situation |
|
54 | 54 | unshelving restores branch information to the working directory. |
|
55 | 55 | |
|
56 | 56 | Each shelved change has a name that makes it easier to find later. The |
|
57 | 57 | name of a shelved change defaults to being based on the active bookmark, |
|
58 | 58 | or if there is no active bookmark, the current named branch. To specify a |
|
59 | 59 | different name, use "--name". |
|
60 | 60 | |
|
61 | 61 | To see a list of existing shelved changes, use the "--list" option. For |
|
62 | 62 | each shelved change, this will print its name, age, and description; use " |
|
63 | 63 | --patch" or "--stat" for more details. |
|
64 | 64 | |
|
65 | 65 | To delete specific shelved changes, use "--delete". To delete all shelved |
|
66 | 66 | changes, use "--cleanup". |
|
67 | 67 | |
|
68 | 68 | (use 'hg help -e shelve' to show help for the shelve extension) |
|
69 | 69 | |
|
70 | 70 | options ([+] can be repeated): |
|
71 | 71 | |
|
72 | 72 | -A --addremove mark new/missing files as added/removed before |
|
73 | 73 | shelving |
|
74 | 74 | -u --unknown store unknown files in the shelve |
|
75 | 75 | --cleanup delete all shelved changes |
|
76 | 76 | --date DATE shelve with the specified commit date |
|
77 | 77 | -d --delete delete the named shelved change(s) |
|
78 | 78 | -e --edit invoke editor on commit messages |
|
79 | 79 | -l --list list current shelves |
|
80 | 80 | -m --message TEXT use text as shelve message |
|
81 | 81 | -n --name NAME use the given name for the shelved commit |
|
82 | 82 | -p --patch output patches for changes (provide the names of the |
|
83 | 83 | shelved changes as positional arguments) |
|
84 | 84 | -i --interactive interactive mode, only works while creating a shelve |
|
85 | 85 | --stat output diffstat-style summary of changes (provide |
|
86 | 86 | the names of the shelved changes as positional |
|
87 | 87 | arguments) |
|
88 | 88 | -I --include PATTERN [+] include names matching the given patterns |
|
89 | 89 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
90 | 90 | --mq operate on patch repository |
|
91 | 91 | |
|
92 | 92 | (some details hidden, use --verbose to show complete help) |
|
93 | 93 | |
|
94 | 94 | shelving in an empty repo should be possible |
|
95 | 95 | (this tests also that editor is not invoked, if '--edit' is not |
|
96 | 96 | specified) |
|
97 | 97 | |
|
98 | 98 | $ HGEDITOR=cat hg shelve |
|
99 | 99 | shelved as default |
|
100 | 100 | 0 files updated, 0 files merged, 5 files removed, 0 files unresolved |
|
101 | 101 | |
|
102 | 102 | $ hg unshelve |
|
103 | 103 | unshelving change 'default' |
|
104 | 104 | |
|
105 | 105 | $ hg commit -q -m 'initial commit' |
|
106 | 106 | |
|
107 | 107 | $ hg shelve |
|
108 | 108 | nothing changed |
|
109 | 109 | [1] |
|
110 | 110 | |
|
111 | 111 | make sure shelve files were backed up |
|
112 | 112 | |
|
113 | 113 | $ ls .hg/shelve-backup |
|
114 | 114 | default.hg |
|
115 | 115 | default.patch |
|
116 | 116 | default.shelve |
|
117 | 117 | |
|
118 | 118 | checks to make sure we dont create a directory or |
|
119 | 119 | hidden file while choosing a new shelve name |
|
120 | 120 | |
|
121 | 121 | when we are given a name |
|
122 | 122 | |
|
123 | 123 | $ hg shelve -n foo/bar |
|
124 | 124 | abort: shelved change names can not contain slashes |
|
125 | 125 | [255] |
|
126 | 126 | $ hg shelve -n .baz |
|
127 | 127 | abort: shelved change names can not start with '.' |
|
128 | 128 | [255] |
|
129 | 129 | $ hg shelve -n foo\\bar |
|
130 | 130 | abort: shelved change names can not contain slashes |
|
131 | 131 | [255] |
|
132 | 132 | |
|
133 | 133 | when shelve has to choose itself |
|
134 | 134 | |
|
135 | 135 | $ hg branch x/y -q |
|
136 | 136 | $ hg commit -q -m "Branch commit 0" |
|
137 | 137 | $ hg shelve |
|
138 | 138 | nothing changed |
|
139 | 139 | [1] |
|
140 | 140 | $ hg branch .x -q |
|
141 | 141 | $ hg commit -q -m "Branch commit 1" |
|
142 | 142 | $ hg shelve |
|
143 | 143 | nothing changed |
|
144 | 144 | [1] |
|
145 | 145 | $ hg branch x\\y -q |
|
146 | 146 | $ hg commit -q -m "Branch commit 2" |
|
147 | 147 | $ hg shelve |
|
148 | 148 | nothing changed |
|
149 | 149 | [1] |
|
150 | 150 | |
|
151 | 151 | cleaning the branches made for name checking tests |
|
152 | 152 | |
|
153 | 153 | $ hg up default -q |
|
154 | 154 | $ hg strip e9177275307e+6a6d231f43d+882bae7c62c2 -q |
|
155 | 155 | |
|
156 | 156 | create an mq patch - shelving should work fine with a patch applied |
|
157 | 157 | |
|
158 | 158 | $ echo n > n |
|
159 | 159 | $ hg add n |
|
160 | 160 | $ hg commit n -m second |
|
161 | 161 | $ hg qnew second.patch |
|
162 | 162 | |
|
163 | 163 | shelve a change that we will delete later |
|
164 | 164 | |
|
165 | 165 | $ echo a >> a/a |
|
166 | 166 | $ hg shelve |
|
167 | 167 | shelved as default |
|
168 | 168 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
169 | 169 | |
|
170 | 170 | set up some more complex changes to shelve |
|
171 | 171 | |
|
172 | 172 | $ echo a >> a/a |
|
173 | 173 | $ hg mv b b.rename |
|
174 | 174 | moving b/b to b.rename/b |
|
175 | 175 | $ hg cp c c.copy |
|
176 | 176 | $ hg status -C |
|
177 | 177 | M a/a |
|
178 | 178 | A b.rename/b |
|
179 | 179 | b/b |
|
180 | 180 | A c.copy |
|
181 | 181 | c |
|
182 | 182 | R b/b |
|
183 | 183 | |
|
184 | 184 | the common case - no options or filenames |
|
185 | 185 | |
|
186 | 186 | $ hg shelve |
|
187 | 187 | shelved as default-01 |
|
188 | 188 | 2 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
189 | 189 | $ hg status -C |
|
190 | 190 | |
|
191 | 191 | ensure that our shelved changes exist |
|
192 | 192 | |
|
193 | 193 | $ hg shelve -l |
|
194 | 194 | default-01 (*)* changes to: [mq]: second.patch (glob) |
|
195 | 195 | default (*)* changes to: [mq]: second.patch (glob) |
|
196 | 196 | |
|
197 | 197 | $ hg shelve -l -p default |
|
198 | 198 | default (*)* changes to: [mq]: second.patch (glob) |
|
199 | 199 | |
|
200 | 200 | diff --git a/a/a b/a/a |
|
201 | 201 | --- a/a/a |
|
202 | 202 | +++ b/a/a |
|
203 | 203 | @@ -1,1 +1,2 @@ |
|
204 | 204 | a |
|
205 | 205 | +a |
|
206 | 206 | |
|
207 | 207 | $ hg shelve --list --addremove |
|
208 | 208 | abort: options '--list' and '--addremove' may not be used together |
|
209 | 209 | [255] |
|
210 | 210 | |
|
211 | 211 | delete our older shelved change |
|
212 | 212 | |
|
213 | 213 | $ hg shelve -d default |
|
214 | 214 | $ hg qfinish -a -q |
|
215 | 215 | |
|
216 | 216 | ensure shelve backups aren't overwritten |
|
217 | 217 | |
|
218 | 218 | $ ls .hg/shelve-backup/ |
|
219 | 219 | default-1.hg |
|
220 | 220 | default-1.patch |
|
221 | 221 | default-1.shelve |
|
222 | 222 | default.hg |
|
223 | 223 | default.patch |
|
224 | 224 | default.shelve |
|
225 | 225 | |
|
226 | 226 | local edits should not prevent a shelved change from applying |
|
227 | 227 | |
|
228 | 228 | $ printf "z\na\n" > a/a |
|
229 | 229 | $ hg unshelve --keep |
|
230 | 230 | unshelving change 'default-01' |
|
231 | 231 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
232 | 232 | rebasing shelved changes |
|
233 | 233 | merging a/a |
|
234 | 234 | |
|
235 | 235 | $ hg revert --all -q |
|
236 | 236 | $ rm a/a.orig b.rename/b c.copy |
|
237 | 237 | |
|
238 | 238 | apply it and make sure our state is as expected |
|
239 | 239 | |
|
240 | 240 | (this also tests that same timestamp prevents backups from being |
|
241 | 241 | removed, even though there are more than 'maxbackups' backups) |
|
242 | 242 | |
|
243 | 243 | $ f -t .hg/shelve-backup/default.patch |
|
244 | 244 | .hg/shelve-backup/default.patch: file |
|
245 | 245 | $ touch -t 200001010000 .hg/shelve-backup/default.patch |
|
246 | 246 | $ f -t .hg/shelve-backup/default-1.patch |
|
247 | 247 | .hg/shelve-backup/default-1.patch: file |
|
248 | 248 | $ touch -t 200001010000 .hg/shelve-backup/default-1.patch |
|
249 | 249 | |
|
250 | 250 | $ hg unshelve |
|
251 | 251 | unshelving change 'default-01' |
|
252 | 252 | $ hg status -C |
|
253 | 253 | M a/a |
|
254 | 254 | A b.rename/b |
|
255 | 255 | b/b |
|
256 | 256 | A c.copy |
|
257 | 257 | c |
|
258 | 258 | R b/b |
|
259 | 259 | $ hg shelve -l |
|
260 | 260 | |
|
261 | 261 | (both of default.hg and default-1.hg should be still kept, because it |
|
262 | 262 | is difficult to decide actual order of them from same timestamp) |
|
263 | 263 | |
|
264 | 264 | $ ls .hg/shelve-backup/ |
|
265 | 265 | default-01.hg |
|
266 | 266 | default-01.patch |
|
267 | 267 | default-01.shelve |
|
268 | 268 | default-1.hg |
|
269 | 269 | default-1.patch |
|
270 | 270 | default-1.shelve |
|
271 | 271 | default.hg |
|
272 | 272 | default.patch |
|
273 | 273 | default.shelve |
|
274 | 274 | |
|
275 | 275 | $ hg unshelve |
|
276 | 276 | abort: no shelved changes to apply! |
|
277 | 277 | [255] |
|
278 | 278 | $ hg unshelve foo |
|
279 | 279 | abort: shelved change 'foo' not found |
|
280 | 280 | [255] |
|
281 | 281 | |
|
282 | 282 | named shelves, specific filenames, and "commit messages" should all work |
|
283 | 283 | (this tests also that editor is invoked, if '--edit' is specified) |
|
284 | 284 | |
|
285 | 285 | $ hg status -C |
|
286 | 286 | M a/a |
|
287 | 287 | A b.rename/b |
|
288 | 288 | b/b |
|
289 | 289 | A c.copy |
|
290 | 290 | c |
|
291 | 291 | R b/b |
|
292 | 292 | $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a |
|
293 | 293 | wat |
|
294 | 294 | |
|
295 | 295 | |
|
296 | 296 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
297 | 297 | HG: Leave message empty to abort commit. |
|
298 | 298 | HG: -- |
|
299 | 299 | HG: user: shelve@localhost |
|
300 | 300 | HG: branch 'default' |
|
301 | 301 | HG: changed a/a |
|
302 | 302 | |
|
303 | 303 | expect "a" to no longer be present, but status otherwise unchanged |
|
304 | 304 | |
|
305 | 305 | $ hg status -C |
|
306 | 306 | A b.rename/b |
|
307 | 307 | b/b |
|
308 | 308 | A c.copy |
|
309 | 309 | c |
|
310 | 310 | R b/b |
|
311 | 311 | $ hg shelve -l --stat |
|
312 | 312 | wibble (*) wat (glob) |
|
313 | 313 | a/a | 1 + |
|
314 | 314 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
315 | 315 | |
|
316 | 316 | and now "a/a" should reappear |
|
317 | 317 | |
|
318 | 318 | $ cd a |
|
319 | 319 | $ hg unshelve -q wibble |
|
320 | 320 | $ cd .. |
|
321 | 321 | $ hg status -C |
|
322 | 322 | M a/a |
|
323 | 323 | A b.rename/b |
|
324 | 324 | b/b |
|
325 | 325 | A c.copy |
|
326 | 326 | c |
|
327 | 327 | R b/b |
|
328 | 328 | |
|
329 | 329 | ensure old shelve backups are being deleted automatically |
|
330 | 330 | |
|
331 | 331 | $ ls .hg/shelve-backup/ |
|
332 | 332 | default-01.hg |
|
333 | 333 | default-01.patch |
|
334 | 334 | default-01.shelve |
|
335 | 335 | wibble.hg |
|
336 | 336 | wibble.patch |
|
337 | 337 | wibble.shelve |
|
338 | 338 | |
|
339 | 339 | cause unshelving to result in a merge with 'a' conflicting |
|
340 | 340 | |
|
341 | 341 | $ hg shelve -q |
|
342 | 342 | $ echo c>>a/a |
|
343 | 343 | $ hg commit -m second |
|
344 | 344 | $ hg tip --template '{files}\n' |
|
345 | 345 | a/a |
|
346 | 346 | |
|
347 | 347 | add an unrelated change that should be preserved |
|
348 | 348 | |
|
349 | 349 | $ mkdir foo |
|
350 | 350 | $ echo foo > foo/foo |
|
351 | 351 | $ hg add foo/foo |
|
352 | 352 | |
|
353 | 353 | force a conflicted merge to occur |
|
354 | 354 | |
|
355 | 355 | $ hg unshelve |
|
356 | 356 | unshelving change 'default' |
|
357 | 357 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
358 | 358 | rebasing shelved changes |
|
359 | 359 | merging a/a |
|
360 | 360 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
361 | 361 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
362 | 362 | [1] |
|
363 | 363 | $ hg status -v |
|
364 | 364 | M a/a |
|
365 | 365 | M b.rename/b |
|
366 | 366 | M c.copy |
|
367 | 367 | R b/b |
|
368 | 368 | ? a/a.orig |
|
369 | 369 | # The repository is in an unfinished *unshelve* state. |
|
370 | 370 | |
|
371 | 371 | # Unresolved merge conflicts: |
|
372 | 372 | # |
|
373 | 373 | # a/a |
|
374 | 374 | # |
|
375 | 375 | # To mark files as resolved: hg resolve --mark FILE |
|
376 | 376 | |
|
377 | 377 | # To continue: hg unshelve --continue |
|
378 | 378 | # To abort: hg unshelve --abort |
|
379 | 379 | |
|
380 | 380 | |
|
381 | 381 | ensure that we have a merge with unresolved conflicts |
|
382 | 382 | |
|
383 | 383 | #if phasebased |
|
384 | 384 | $ hg heads -q --template '{rev}\n' |
|
385 | 385 | 8 |
|
386 | 386 | 5 |
|
387 | 387 | $ hg parents -q --template '{rev}\n' |
|
388 | 388 | 8 |
|
389 | 389 | 5 |
|
390 | 390 | #endif |
|
391 | 391 | |
|
392 | 392 | #if stripbased |
|
393 | 393 | $ hg heads -q --template '{rev}\n' |
|
394 | 394 | 5 |
|
395 | 395 | 4 |
|
396 | 396 | $ hg parents -q --template '{rev}\n' |
|
397 | 397 | 4 |
|
398 | 398 | 5 |
|
399 | 399 | #endif |
|
400 | 400 | |
|
401 | 401 | $ hg status |
|
402 | 402 | M a/a |
|
403 | 403 | M b.rename/b |
|
404 | 404 | M c.copy |
|
405 | 405 | R b/b |
|
406 | 406 | ? a/a.orig |
|
407 | 407 | $ hg diff |
|
408 | 408 | diff --git a/a/a b/a/a |
|
409 | 409 | --- a/a/a |
|
410 | 410 | +++ b/a/a |
|
411 | 411 | @@ -1,2 +1,6 @@ |
|
412 | 412 | a |
|
413 | 413 | +<<<<<<< shelve: 2377350b6337 - shelve: pending changes temporary commit |
|
414 | 414 | c |
|
415 | 415 | +======= |
|
416 | 416 | +a |
|
417 | 417 | +>>>>>>> working-copy: a68ec3400638 - shelve: changes to: [mq]: second.patch |
|
418 | 418 | diff --git a/b/b b/b.rename/b |
|
419 | 419 | rename from b/b |
|
420 | 420 | rename to b.rename/b |
|
421 | 421 | diff --git a/c b/c.copy |
|
422 | 422 | copy from c |
|
423 | 423 | copy to c.copy |
|
424 | 424 | $ hg resolve -l |
|
425 | 425 | U a/a |
|
426 | 426 | |
|
427 | 427 | $ hg shelve |
|
428 | 428 | abort: unshelve already in progress |
|
429 | 429 | (use 'hg unshelve --continue' or 'hg unshelve --abort') |
|
430 | 430 | [255] |
|
431 | 431 | |
|
432 | 432 | abort the unshelve and be happy |
|
433 | 433 | |
|
434 | 434 | $ hg status |
|
435 | 435 | M a/a |
|
436 | 436 | M b.rename/b |
|
437 | 437 | M c.copy |
|
438 | 438 | R b/b |
|
439 | 439 | ? a/a.orig |
|
440 | 440 | $ hg unshelve -a |
|
441 | 441 | unshelve of 'default' aborted |
|
442 | 442 | $ hg heads -q |
|
443 | 443 | [37]:2e69b451d1ea (re) |
|
444 | 444 | $ hg parents |
|
445 | 445 | changeset: [37]:2e69b451d1ea (re) |
|
446 | 446 | tag: tip |
|
447 | 447 | parent: 3:509104101065 (?) |
|
448 | 448 | user: test |
|
449 | 449 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
450 | 450 | summary: second |
|
451 | 451 | |
|
452 | 452 | $ hg resolve -l |
|
453 | 453 | $ hg status |
|
454 | 454 | A foo/foo |
|
455 | 455 | ? a/a.orig |
|
456 | 456 | |
|
457 | 457 | try to continue with no unshelve underway |
|
458 | 458 | |
|
459 | 459 | $ hg unshelve -c |
|
460 | 460 | abort: no unshelve in progress |
|
461 | 461 | [255] |
|
462 | 462 | $ hg status |
|
463 | 463 | A foo/foo |
|
464 | 464 | ? a/a.orig |
|
465 | 465 | |
|
466 | 466 | redo the unshelve to get a conflict |
|
467 | 467 | |
|
468 | 468 | $ hg unshelve -q |
|
469 | 469 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
470 | 470 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
471 | 471 | [1] |
|
472 | 472 | |
|
473 | 473 | attempt to continue |
|
474 | 474 | |
|
475 | 475 | $ hg unshelve -c |
|
476 | 476 | abort: unresolved conflicts, can't continue |
|
477 | 477 | (see 'hg resolve', then 'hg unshelve --continue') |
|
478 | 478 | [255] |
|
479 | 479 | |
|
480 | 480 | $ hg revert -r . a/a |
|
481 | 481 | $ hg resolve -m a/a |
|
482 | 482 | (no more unresolved files) |
|
483 | 483 | continue: hg unshelve --continue |
|
484 | 484 | |
|
485 | 485 | $ hg commit -m 'commit while unshelve in progress' |
|
486 | 486 | abort: unshelve already in progress |
|
487 | 487 | (use 'hg unshelve --continue' or 'hg unshelve --abort') |
|
488 | 488 | [255] |
|
489 | 489 | |
|
490 | 490 | $ hg graft --continue |
|
491 | 491 | abort: no graft in progress |
|
492 | 492 | (continue: hg unshelve --continue) |
|
493 | 493 | [255] |
|
494 | 494 | $ hg unshelve -c |
|
495 | 495 | unshelve of 'default' complete |
|
496 | 496 | |
|
497 | 497 | ensure the repo is as we hope |
|
498 | 498 | |
|
499 | 499 | $ hg parents |
|
500 | 500 | changeset: [37]:2e69b451d1ea (re) |
|
501 | 501 | tag: tip |
|
502 | 502 | parent: 3:509104101065 (?) |
|
503 | 503 | user: test |
|
504 | 504 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
505 | 505 | summary: second |
|
506 | 506 | |
|
507 | 507 | $ hg heads -q |
|
508 | 508 | [37]:2e69b451d1ea (re) |
|
509 | 509 | |
|
510 | 510 | $ hg status -C |
|
511 | 511 | A b.rename/b |
|
512 | 512 | b/b |
|
513 | 513 | A c.copy |
|
514 | 514 | c |
|
515 | 515 | A foo/foo |
|
516 | 516 | R b/b |
|
517 | 517 | ? a/a.orig |
|
518 | 518 | |
|
519 | 519 | there should be no shelves left |
|
520 | 520 | |
|
521 | 521 | $ hg shelve -l |
|
522 | 522 | |
|
523 | 523 | #if execbit |
|
524 | 524 | |
|
525 | 525 | ensure that metadata-only changes are shelved |
|
526 | 526 | |
|
527 | 527 | $ chmod +x a/a |
|
528 | 528 | $ hg shelve -q -n execbit a/a |
|
529 | 529 | $ hg status a/a |
|
530 | 530 | $ hg unshelve -q execbit |
|
531 | 531 | $ hg status a/a |
|
532 | 532 | M a/a |
|
533 | 533 | $ hg revert a/a |
|
534 | 534 | |
|
535 | 535 | #endif |
|
536 | 536 | |
|
537 | 537 | #if symlink |
|
538 | 538 | |
|
539 | 539 | $ rm a/a |
|
540 | 540 | $ ln -s foo a/a |
|
541 | 541 | $ hg shelve -q -n symlink a/a |
|
542 | 542 | $ hg status a/a |
|
543 | 543 | $ hg unshelve -q -n symlink |
|
544 | 544 | $ hg status a/a |
|
545 | 545 | M a/a |
|
546 | 546 | $ hg revert a/a |
|
547 | 547 | |
|
548 | 548 | #endif |
|
549 | 549 | |
|
550 | 550 | set up another conflict between a commit and a shelved change |
|
551 | 551 | |
|
552 | 552 | $ hg revert -q -C -a |
|
553 | 553 | $ rm a/a.orig b.rename/b c.copy |
|
554 | 554 | $ echo a >> a/a |
|
555 | 555 | $ hg shelve -q |
|
556 | 556 | $ echo x >> a/a |
|
557 | 557 | $ hg ci -m 'create conflict' |
|
558 | 558 | $ hg add foo/foo |
|
559 | 559 | |
|
560 | 560 | if we resolve a conflict while unshelving, the unshelve should succeed |
|
561 | 561 | |
|
562 | 562 | $ hg unshelve --tool :merge-other --keep |
|
563 | 563 | unshelving change 'default' |
|
564 | 564 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
565 | 565 | rebasing shelved changes |
|
566 | 566 | merging a/a |
|
567 | 567 | $ hg parents -q |
|
568 | 568 | (4|13):33f7f61e6c5e (re) |
|
569 | 569 | $ hg shelve -l |
|
570 | 570 | default (*)* changes to: second (glob) |
|
571 | 571 | $ hg status |
|
572 | 572 | M a/a |
|
573 | 573 | A foo/foo |
|
574 | 574 | $ cat a/a |
|
575 | 575 | a |
|
576 | 576 | c |
|
577 | 577 | a |
|
578 | 578 | $ cat > a/a << EOF |
|
579 | 579 | > a |
|
580 | 580 | > c |
|
581 | 581 | > x |
|
582 | 582 | > EOF |
|
583 | 583 | |
|
584 | 584 | $ HGMERGE=true hg unshelve |
|
585 | 585 | unshelving change 'default' |
|
586 | 586 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
587 | 587 | rebasing shelved changes |
|
588 | 588 | merging a/a |
|
589 | 589 | note: unshelved changes already existed in the working copy |
|
590 | 590 | $ hg parents -q |
|
591 | 591 | (4|13):33f7f61e6c5e (re) |
|
592 | 592 | $ hg shelve -l |
|
593 | 593 | $ hg status |
|
594 | 594 | A foo/foo |
|
595 | 595 | $ cat a/a |
|
596 | 596 | a |
|
597 | 597 | c |
|
598 | 598 | x |
|
599 | 599 | |
|
600 | 600 | test keep and cleanup |
|
601 | 601 | |
|
602 | 602 | $ hg shelve |
|
603 | 603 | shelved as default |
|
604 | 604 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
605 | 605 | $ hg shelve --list |
|
606 | 606 | default (*)* changes to: create conflict (glob) |
|
607 | 607 | $ hg unshelve -k |
|
608 | 608 | unshelving change 'default' |
|
609 | 609 | $ hg shelve --list |
|
610 | 610 | default (*)* changes to: create conflict (glob) |
|
611 | 611 | $ hg shelve --cleanup |
|
612 | 612 | $ hg shelve --list |
|
613 | 613 | |
|
614 | 614 | $ hg shelve --cleanup --delete |
|
615 | 615 | abort: options '--cleanup' and '--delete' may not be used together |
|
616 | 616 | [255] |
|
617 | 617 | $ hg shelve --cleanup --patch |
|
618 | 618 | abort: options '--cleanup' and '--patch' may not be used together |
|
619 | 619 | [255] |
|
620 | 620 | $ hg shelve --cleanup --message MESSAGE |
|
621 | 621 | abort: options '--cleanup' and '--message' may not be used together |
|
622 | 622 | [255] |
|
623 | 623 | |
|
624 | 624 | test bookmarks |
|
625 | 625 | |
|
626 | 626 | $ hg bookmark test |
|
627 | 627 | $ hg bookmark |
|
628 | 628 | \* test (4|13):33f7f61e6c5e (re) |
|
629 | 629 | $ hg shelve |
|
630 | 630 | shelved as test |
|
631 | 631 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
632 | 632 | $ hg bookmark |
|
633 | 633 | \* test (4|13):33f7f61e6c5e (re) |
|
634 | 634 | $ hg unshelve |
|
635 | 635 | unshelving change 'test' |
|
636 | 636 | $ hg bookmark |
|
637 | 637 | \* test (4|13):33f7f61e6c5e (re) |
|
638 | 638 | |
|
639 | 639 | shelve should still work even if mq is disabled |
|
640 | 640 | |
|
641 | 641 | $ hg --config extensions.mq=! shelve |
|
642 | 642 | shelved as test |
|
643 | 643 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
644 | 644 | $ hg --config extensions.mq=! shelve --list |
|
645 | 645 | test (*)* changes to: create conflict (glob) |
|
646 | 646 | $ hg bookmark |
|
647 | 647 | \* test (4|13):33f7f61e6c5e (re) |
|
648 | 648 | $ hg --config extensions.mq=! unshelve |
|
649 | 649 | unshelving change 'test' |
|
650 | 650 | $ hg bookmark |
|
651 | 651 | \* test (4|13):33f7f61e6c5e (re) |
|
652 | 652 | |
|
653 | 653 | shelve should leave dirstate clean (issue4055) |
|
654 | 654 | |
|
655 | 655 | $ cd .. |
|
656 | 656 | $ hg init shelverebase |
|
657 | 657 | $ cd shelverebase |
|
658 | 658 | $ printf 'x\ny\n' > x |
|
659 | 659 | $ echo z > z |
|
660 | 660 | $ hg commit -Aqm xy |
|
661 | 661 | $ echo z >> x |
|
662 | 662 | $ hg commit -Aqm z |
|
663 | 663 | $ hg up 5c4c67fb7dce |
|
664 | 664 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
665 | 665 | $ printf 'a\nx\ny\nz\n' > x |
|
666 | 666 | $ hg commit -Aqm xyz |
|
667 | 667 | $ echo c >> z |
|
668 | 668 | $ hg shelve |
|
669 | 669 | shelved as default |
|
670 | 670 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
671 | 671 | |
|
672 | #if phasebased | |
|
673 | 672 | $ hg rebase -d 6c103be8f4e4 --config extensions.rebase= |
|
674 | rebasing 2:323bfa07f744 "xyz" | |
|
673 | rebasing 2:323bfa07f744 "xyz"( \(tip\))? (re) | |
|
675 | 674 | merging x |
|
676 | warning: orphaned descendants detected, not stripping 323bfa07f744 (?) | |
|
677 | #endif | |
|
678 | ||
|
679 | #if stripbased | |
|
680 | $ hg rebase -d 6c103be8f4e4 --config extensions.rebase= | |
|
681 | rebasing 2:323bfa07f744 "xyz" (tip) | |
|
682 | merging x | |
|
683 | saved backup bundle to $TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-78114325-rebase.hg | |
|
684 | #endif | |
|
675 | saved backup bundle to \$TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-(78114325|7ae538ef)-rebase.hg (re) | |
|
685 | 676 | $ hg unshelve |
|
686 | 677 | unshelving change 'default' |
|
687 | 678 | rebasing shelved changes |
|
688 | 679 | $ hg status |
|
689 | 680 | M z |
|
690 | 681 | |
|
691 | 682 | $ cd .. |
|
692 | 683 | |
|
693 | 684 | shelve should only unshelve pending changes (issue4068) |
|
694 | 685 | |
|
695 | 686 | $ hg init onlypendingchanges |
|
696 | 687 | $ cd onlypendingchanges |
|
697 | 688 | $ touch a |
|
698 | 689 | $ hg ci -Aqm a |
|
699 | 690 | $ touch b |
|
700 | 691 | $ hg ci -Aqm b |
|
701 | 692 | $ hg up -q 3903775176ed |
|
702 | 693 | $ touch c |
|
703 | 694 | $ hg ci -Aqm c |
|
704 | 695 | |
|
705 | 696 | $ touch d |
|
706 | 697 | $ hg add d |
|
707 | 698 | $ hg shelve |
|
708 | 699 | shelved as default |
|
709 | 700 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
710 | 701 | $ hg up -q 0e067c57feba |
|
711 | 702 | $ hg unshelve |
|
712 | 703 | unshelving change 'default' |
|
713 | 704 | rebasing shelved changes |
|
714 | 705 | $ hg status |
|
715 | 706 | A d |
|
716 | 707 | |
|
717 | 708 | unshelve should work on an ancestor of the original commit |
|
718 | 709 | |
|
719 | 710 | $ hg shelve |
|
720 | 711 | shelved as default |
|
721 | 712 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
722 | 713 | $ hg up 3903775176ed |
|
723 | 714 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
724 | 715 | $ hg unshelve |
|
725 | 716 | unshelving change 'default' |
|
726 | 717 | rebasing shelved changes |
|
727 | 718 | $ hg status |
|
728 | 719 | A d |
|
729 | 720 | |
|
730 | 721 | test bug 4073 we need to enable obsolete markers for it |
|
731 | 722 | |
|
732 | 723 | $ cat >> $HGRCPATH << EOF |
|
733 | 724 | > [experimental] |
|
734 | 725 | > evolution.createmarkers=True |
|
735 | 726 | > EOF |
|
736 | 727 | $ hg shelve |
|
737 | 728 | shelved as default |
|
738 | 729 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
739 | 730 | $ hg debugobsolete `hg log -r 0e067c57feba -T '{node}'` |
|
740 | 731 | obsoleted 1 changesets |
|
741 | 732 | $ hg unshelve |
|
742 | 733 | unshelving change 'default' |
|
743 | 734 | |
|
744 | 735 | unshelve should leave unknown files alone (issue4113) |
|
745 | 736 | |
|
746 | 737 | $ echo e > e |
|
747 | 738 | $ hg shelve |
|
748 | 739 | shelved as default |
|
749 | 740 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
750 | 741 | $ hg status |
|
751 | 742 | ? e |
|
752 | 743 | $ hg unshelve |
|
753 | 744 | unshelving change 'default' |
|
754 | 745 | $ hg status |
|
755 | 746 | A d |
|
756 | 747 | ? e |
|
757 | 748 | $ cat e |
|
758 | 749 | e |
|
759 | 750 | |
|
760 | 751 | unshelve should keep a copy of unknown files |
|
761 | 752 | |
|
762 | 753 | $ hg add e |
|
763 | 754 | $ hg shelve |
|
764 | 755 | shelved as default |
|
765 | 756 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
766 | 757 | $ echo z > e |
|
767 | 758 | $ hg unshelve |
|
768 | 759 | unshelving change 'default' |
|
769 | 760 | $ cat e |
|
770 | 761 | e |
|
771 | 762 | $ cat e.orig |
|
772 | 763 | z |
|
773 | 764 | |
|
774 | 765 | |
|
775 | 766 | unshelve and conflicts with tracked and untracked files |
|
776 | 767 | |
|
777 | 768 | preparing: |
|
778 | 769 | |
|
779 | 770 | $ rm *.orig |
|
780 | 771 | $ hg ci -qm 'commit stuff' |
|
781 | 772 | $ hg phase -p null: |
|
782 | 773 | |
|
783 | 774 | no other changes - no merge: |
|
784 | 775 | |
|
785 | 776 | $ echo f > f |
|
786 | 777 | $ hg add f |
|
787 | 778 | $ hg shelve |
|
788 | 779 | shelved as default |
|
789 | 780 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
790 | 781 | $ echo g > f |
|
791 | 782 | $ hg unshelve |
|
792 | 783 | unshelving change 'default' |
|
793 | 784 | $ hg st |
|
794 | 785 | A f |
|
795 | 786 | ? f.orig |
|
796 | 787 | $ cat f |
|
797 | 788 | f |
|
798 | 789 | $ cat f.orig |
|
799 | 790 | g |
|
800 | 791 | |
|
801 | 792 | other uncommitted changes - merge: |
|
802 | 793 | |
|
803 | 794 | $ hg st |
|
804 | 795 | A f |
|
805 | 796 | ? f.orig |
|
806 | 797 | $ hg shelve |
|
807 | 798 | shelved as default |
|
808 | 799 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
809 | 800 | #if repobundlerepo |
|
810 | 801 | $ hg log -G --template '{rev} {desc|firstline} {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()' --hidden |
|
811 | 802 | o [48] changes to: commit stuff shelve@localhost (re) |
|
812 | 803 | | |
|
813 | 804 | ~ |
|
814 | 805 | #endif |
|
815 | 806 | $ hg log -G --template '{rev} {desc|firstline} {author}' |
|
816 | 807 | @ [37] commit stuff test (re) |
|
817 | 808 | | |
|
818 | 809 | | o 2 c test |
|
819 | 810 | |/ |
|
820 | 811 | o 0 a test |
|
821 | 812 | |
|
822 | 813 | $ mv f.orig f |
|
823 | 814 | $ echo 1 > a |
|
824 | 815 | $ hg unshelve --date '1073741824 0' |
|
825 | 816 | unshelving change 'default' |
|
826 | 817 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
827 | 818 | rebasing shelved changes |
|
828 | 819 | merging f |
|
829 | 820 | warning: conflicts while merging f! (edit, then use 'hg resolve --mark') |
|
830 | 821 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
831 | 822 | [1] |
|
832 | 823 | |
|
833 | 824 | #if phasebased |
|
834 | 825 | $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}' |
|
835 | 826 | @ 9 pending changes temporary commit shelve@localhost 2004-01-10 13:37 +0000 |
|
836 | 827 | | |
|
837 | 828 | | @ 8 changes to: commit stuff shelve@localhost 1970-01-01 00:00 +0000 |
|
838 | 829 | |/ |
|
839 | 830 | o 7 commit stuff test 1970-01-01 00:00 +0000 |
|
840 | 831 | | |
|
841 | 832 | | o 2 c test 1970-01-01 00:00 +0000 |
|
842 | 833 | |/ |
|
843 | 834 | o 0 a test 1970-01-01 00:00 +0000 |
|
844 | 835 | |
|
845 | 836 | #endif |
|
846 | 837 | |
|
847 | 838 | #if stripbased |
|
848 | 839 | $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}' |
|
849 | 840 | @ 5 changes to: commit stuff shelve@localhost 1970-01-01 00:00 +0000 |
|
850 | 841 | | |
|
851 | 842 | | @ 4 pending changes temporary commit shelve@localhost 2004-01-10 13:37 +0000 |
|
852 | 843 | |/ |
|
853 | 844 | o 3 commit stuff test 1970-01-01 00:00 +0000 |
|
854 | 845 | | |
|
855 | 846 | | o 2 c test 1970-01-01 00:00 +0000 |
|
856 | 847 | |/ |
|
857 | 848 | o 0 a test 1970-01-01 00:00 +0000 |
|
858 | 849 | |
|
859 | 850 | #endif |
|
860 | 851 | |
|
861 | 852 | $ hg st |
|
862 | 853 | M f |
|
863 | 854 | ? f.orig |
|
864 | 855 | $ cat f |
|
865 | 856 | <<<<<<< shelve: d44eae5c3d33 - shelve: pending changes temporary commit |
|
866 | 857 | g |
|
867 | 858 | ======= |
|
868 | 859 | f |
|
869 | 860 | >>>>>>> working-copy: aef214a5229c - shelve: changes to: commit stuff |
|
870 | 861 | $ cat f.orig |
|
871 | 862 | g |
|
872 | 863 | $ hg unshelve --abort -t false |
|
873 | 864 | tool option will be ignored |
|
874 | 865 | unshelve of 'default' aborted |
|
875 | 866 | $ hg st |
|
876 | 867 | M a |
|
877 | 868 | ? f.orig |
|
878 | 869 | $ cat f.orig |
|
879 | 870 | g |
|
880 | 871 | $ hg unshelve |
|
881 | 872 | unshelving change 'default' |
|
882 | 873 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
883 | 874 | rebasing shelved changes |
|
884 | 875 | $ hg st |
|
885 | 876 | M a |
|
886 | 877 | A f |
|
887 | 878 | ? f.orig |
|
888 | 879 | |
|
889 | 880 | other committed changes - merge: |
|
890 | 881 | |
|
891 | 882 | $ hg shelve f |
|
892 | 883 | shelved as default |
|
893 | 884 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
894 | 885 | $ hg ci a -m 'intermediate other change' |
|
895 | 886 | $ mv f.orig f |
|
896 | 887 | $ hg unshelve |
|
897 | 888 | unshelving change 'default' |
|
898 | 889 | rebasing shelved changes |
|
899 | 890 | merging f |
|
900 | 891 | warning: conflicts while merging f! (edit, then use 'hg resolve --mark') |
|
901 | 892 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
902 | 893 | [1] |
|
903 | 894 | $ hg st |
|
904 | 895 | M f |
|
905 | 896 | ? f.orig |
|
906 | 897 | $ cat f |
|
907 | 898 | <<<<<<< shelve: 6b563750f973 - test: intermediate other change |
|
908 | 899 | g |
|
909 | 900 | ======= |
|
910 | 901 | f |
|
911 | 902 | >>>>>>> working-copy: aef214a5229c - shelve: changes to: commit stuff |
|
912 | 903 | $ cat f.orig |
|
913 | 904 | g |
|
914 | 905 | $ hg unshelve --abort |
|
915 | 906 | unshelve of 'default' aborted |
|
916 | 907 | $ hg st |
|
917 | 908 | ? f.orig |
|
918 | 909 | $ cat f.orig |
|
919 | 910 | g |
|
920 | 911 | $ hg shelve --delete default |
|
921 | 912 | |
|
922 | 913 | Recreate some conflict again |
|
923 | 914 | |
|
924 | 915 | $ cd ../repo |
|
925 | 916 | $ hg up -C -r 2e69b451d1ea |
|
926 | 917 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
927 | 918 | (leaving bookmark test) |
|
928 | 919 | $ echo y >> a/a |
|
929 | 920 | $ hg shelve |
|
930 | 921 | shelved as default |
|
931 | 922 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
932 | 923 | $ hg up test |
|
933 | 924 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
934 | 925 | (activating bookmark test) |
|
935 | 926 | $ hg bookmark |
|
936 | 927 | \* test (4|13):33f7f61e6c5e (re) |
|
937 | 928 | $ hg unshelve |
|
938 | 929 | unshelving change 'default' |
|
939 | 930 | rebasing shelved changes |
|
940 | 931 | merging a/a |
|
941 | 932 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
942 | 933 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
943 | 934 | [1] |
|
944 | 935 | $ hg bookmark |
|
945 | 936 | test (4|13):33f7f61e6c5e (re) |
|
946 | 937 | |
|
947 | 938 | Test that resolving all conflicts in one direction (so that the rebase |
|
948 | 939 | is a no-op), works (issue4398) |
|
949 | 940 | |
|
950 | 941 | $ hg revert -a -r . |
|
951 | 942 | reverting a/a |
|
952 | 943 | $ hg resolve -m a/a |
|
953 | 944 | (no more unresolved files) |
|
954 | 945 | continue: hg unshelve --continue |
|
955 | 946 | $ hg unshelve -c |
|
956 | 947 | note: unshelved changes already existed in the working copy |
|
957 | 948 | unshelve of 'default' complete |
|
958 | 949 | $ hg bookmark |
|
959 | 950 | \* test (4|13):33f7f61e6c5e (re) |
|
960 | 951 | $ hg diff |
|
961 | 952 | $ hg status |
|
962 | 953 | ? a/a.orig |
|
963 | 954 | ? foo/foo |
|
964 | 955 | $ hg summary |
|
965 | 956 | parent: (4|13):33f7f61e6c5e tip (re) |
|
966 | 957 | create conflict |
|
967 | 958 | branch: default |
|
968 | 959 | bookmarks: *test |
|
969 | 960 | commit: 2 unknown (clean) |
|
970 | 961 | update: (current) |
|
971 | 962 | phases: 5 draft |
|
972 | 963 | |
|
973 | 964 | $ hg shelve --delete --stat |
|
974 | 965 | abort: options '--delete' and '--stat' may not be used together |
|
975 | 966 | [255] |
|
976 | 967 | $ hg shelve --delete --name NAME |
|
977 | 968 | abort: options '--delete' and '--name' may not be used together |
|
978 | 969 | [255] |
|
979 | 970 | |
|
980 | 971 | Test interactive shelve |
|
981 | 972 | $ cat <<EOF >> $HGRCPATH |
|
982 | 973 | > [ui] |
|
983 | 974 | > interactive = true |
|
984 | 975 | > EOF |
|
985 | 976 | $ echo 'a' >> a/b |
|
986 | 977 | $ cat a/a >> a/b |
|
987 | 978 | $ echo 'x' >> a/b |
|
988 | 979 | $ mv a/b a/a |
|
989 | 980 | $ echo 'a' >> foo/foo |
|
990 | 981 | $ hg st |
|
991 | 982 | M a/a |
|
992 | 983 | ? a/a.orig |
|
993 | 984 | ? foo/foo |
|
994 | 985 | $ cat a/a |
|
995 | 986 | a |
|
996 | 987 | a |
|
997 | 988 | c |
|
998 | 989 | x |
|
999 | 990 | x |
|
1000 | 991 | $ cat foo/foo |
|
1001 | 992 | foo |
|
1002 | 993 | a |
|
1003 | 994 | $ hg shelve --interactive --config ui.interactive=false |
|
1004 | 995 | abort: running non-interactively |
|
1005 | 996 | [255] |
|
1006 | 997 | $ hg shelve --interactive << EOF |
|
1007 | 998 | > y |
|
1008 | 999 | > y |
|
1009 | 1000 | > n |
|
1010 | 1001 | > EOF |
|
1011 | 1002 | diff --git a/a/a b/a/a |
|
1012 | 1003 | 2 hunks, 2 lines changed |
|
1013 | 1004 | examine changes to 'a/a'? [Ynesfdaq?] y |
|
1014 | 1005 | |
|
1015 | 1006 | @@ -1,3 +1,4 @@ |
|
1016 | 1007 | +a |
|
1017 | 1008 | a |
|
1018 | 1009 | c |
|
1019 | 1010 | x |
|
1020 | 1011 | record change 1/2 to 'a/a'? [Ynesfdaq?] y |
|
1021 | 1012 | |
|
1022 | 1013 | @@ -1,3 +2,4 @@ |
|
1023 | 1014 | a |
|
1024 | 1015 | c |
|
1025 | 1016 | x |
|
1026 | 1017 | +x |
|
1027 | 1018 | record change 2/2 to 'a/a'? [Ynesfdaq?] n |
|
1028 | 1019 | |
|
1029 | 1020 | shelved as test |
|
1030 | 1021 | merging a/a |
|
1031 | 1022 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
1032 | 1023 | $ cat a/a |
|
1033 | 1024 | a |
|
1034 | 1025 | c |
|
1035 | 1026 | x |
|
1036 | 1027 | x |
|
1037 | 1028 | $ cat foo/foo |
|
1038 | 1029 | foo |
|
1039 | 1030 | a |
|
1040 | 1031 | $ hg st |
|
1041 | 1032 | M a/a |
|
1042 | 1033 | ? foo/foo |
|
1043 | 1034 | $ hg bookmark |
|
1044 | 1035 | \* test (4|13):33f7f61e6c5e (re) |
|
1045 | 1036 | $ hg unshelve |
|
1046 | 1037 | unshelving change 'test' |
|
1047 | 1038 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1048 | 1039 | rebasing shelved changes |
|
1049 | 1040 | merging a/a |
|
1050 | 1041 | $ hg bookmark |
|
1051 | 1042 | \* test (4|13):33f7f61e6c5e (re) |
|
1052 | 1043 | $ cat a/a |
|
1053 | 1044 | a |
|
1054 | 1045 | a |
|
1055 | 1046 | c |
|
1056 | 1047 | x |
|
1057 | 1048 | x |
|
1058 | 1049 | |
|
1059 | 1050 | shelve --patch and shelve --stat should work with valid shelfnames |
|
1060 | 1051 | |
|
1061 | 1052 | $ hg up --clean . |
|
1062 | 1053 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1063 | 1054 | (leaving bookmark test) |
|
1064 | 1055 | $ hg shelve --list |
|
1065 | 1056 | $ echo 'patch a' > shelf-patch-a |
|
1066 | 1057 | $ hg add shelf-patch-a |
|
1067 | 1058 | $ hg shelve |
|
1068 | 1059 | shelved as default |
|
1069 | 1060 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1070 | 1061 | $ echo 'patch b' > shelf-patch-b |
|
1071 | 1062 | $ hg add shelf-patch-b |
|
1072 | 1063 | $ hg shelve |
|
1073 | 1064 | shelved as default-01 |
|
1074 | 1065 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1075 | 1066 | $ hg shelve --patch default default-01 |
|
1076 | 1067 | default-01 (*)* changes to: create conflict (glob) |
|
1077 | 1068 | |
|
1078 | 1069 | diff --git a/shelf-patch-b b/shelf-patch-b |
|
1079 | 1070 | new file mode 100644 |
|
1080 | 1071 | --- /dev/null |
|
1081 | 1072 | +++ b/shelf-patch-b |
|
1082 | 1073 | @@ -0,0 +1,1 @@ |
|
1083 | 1074 | +patch b |
|
1084 | 1075 | default (*)* changes to: create conflict (glob) |
|
1085 | 1076 | |
|
1086 | 1077 | diff --git a/shelf-patch-a b/shelf-patch-a |
|
1087 | 1078 | new file mode 100644 |
|
1088 | 1079 | --- /dev/null |
|
1089 | 1080 | +++ b/shelf-patch-a |
|
1090 | 1081 | @@ -0,0 +1,1 @@ |
|
1091 | 1082 | +patch a |
|
1092 | 1083 | $ hg shelve --stat default default-01 |
|
1093 | 1084 | default-01 (*)* changes to: create conflict (glob) |
|
1094 | 1085 | shelf-patch-b | 1 + |
|
1095 | 1086 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
1096 | 1087 | default (*)* changes to: create conflict (glob) |
|
1097 | 1088 | shelf-patch-a | 1 + |
|
1098 | 1089 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
1099 | 1090 | $ hg shelve --patch default |
|
1100 | 1091 | default (*)* changes to: create conflict (glob) |
|
1101 | 1092 | |
|
1102 | 1093 | diff --git a/shelf-patch-a b/shelf-patch-a |
|
1103 | 1094 | new file mode 100644 |
|
1104 | 1095 | --- /dev/null |
|
1105 | 1096 | +++ b/shelf-patch-a |
|
1106 | 1097 | @@ -0,0 +1,1 @@ |
|
1107 | 1098 | +patch a |
|
1108 | 1099 | $ hg shelve --stat default |
|
1109 | 1100 | default (*)* changes to: create conflict (glob) |
|
1110 | 1101 | shelf-patch-a | 1 + |
|
1111 | 1102 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
1112 | 1103 | $ hg shelve --patch nonexistentshelf |
|
1113 | 1104 | abort: cannot find shelf nonexistentshelf |
|
1114 | 1105 | [255] |
|
1115 | 1106 | $ hg shelve --stat nonexistentshelf |
|
1116 | 1107 | abort: cannot find shelf nonexistentshelf |
|
1117 | 1108 | [255] |
|
1118 | 1109 | $ hg shelve --patch default nonexistentshelf |
|
1119 | 1110 | abort: cannot find shelf nonexistentshelf |
|
1120 | 1111 | [255] |
|
1121 | 1112 | |
|
1122 | 1113 | when the user asks for a patch, we assume they want the most recent shelve if |
|
1123 | 1114 | they don't provide a shelve name |
|
1124 | 1115 | |
|
1125 | 1116 | $ hg shelve --patch |
|
1126 | 1117 | default-01 (*)* changes to: create conflict (glob) |
|
1127 | 1118 | |
|
1128 | 1119 | diff --git a/shelf-patch-b b/shelf-patch-b |
|
1129 | 1120 | new file mode 100644 |
|
1130 | 1121 | --- /dev/null |
|
1131 | 1122 | +++ b/shelf-patch-b |
|
1132 | 1123 | @@ -0,0 +1,1 @@ |
|
1133 | 1124 | +patch b |
|
1134 | 1125 | |
|
1135 | 1126 | $ cd .. |
|
1136 | 1127 | |
|
1137 | 1128 | you shouldn't be able to ask for the patch/stats of the most recent shelve if |
|
1138 | 1129 | there are no shelves |
|
1139 | 1130 | |
|
1140 | 1131 | $ hg init noshelves |
|
1141 | 1132 | $ cd noshelves |
|
1142 | 1133 | |
|
1143 | 1134 | $ hg shelve --patch |
|
1144 | 1135 | abort: there are no shelves to show |
|
1145 | 1136 | [255] |
|
1146 | 1137 | $ hg shelve --stat |
|
1147 | 1138 | abort: there are no shelves to show |
|
1148 | 1139 | [255] |
|
1149 | 1140 | |
|
1150 | 1141 | $ cd .. |
|
1151 | 1142 | |
|
1152 | 1143 | Shelve from general delta repo uses bundle2 on disk |
|
1153 | 1144 | -------------------------------------------------- |
|
1154 | 1145 | |
|
1155 | 1146 | no general delta |
|
1156 | 1147 | |
|
1157 | 1148 | $ hg clone --pull repo bundle1 --config format.usegeneraldelta=0 |
|
1158 | 1149 | requesting all changes |
|
1159 | 1150 | adding changesets |
|
1160 | 1151 | adding manifests |
|
1161 | 1152 | adding file changes |
|
1162 | 1153 | added 5 changesets with 8 changes to 6 files |
|
1163 | 1154 | new changesets cc01e2b0c59f:33f7f61e6c5e |
|
1164 | 1155 | updating to branch default |
|
1165 | 1156 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1166 | 1157 | $ cd bundle1 |
|
1167 | 1158 | $ echo babar > jungle |
|
1168 | 1159 | $ hg add jungle |
|
1169 | 1160 | $ hg shelve |
|
1170 | 1161 | shelved as default |
|
1171 | 1162 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1172 | 1163 | $ hg debugbundle .hg/shelved/*.hg |
|
1173 | 1164 | 330882a04d2ce8487636b1fb292e5beea77fa1e3 |
|
1174 | 1165 | $ cd .. |
|
1175 | 1166 | |
|
1176 | 1167 | with general delta |
|
1177 | 1168 | |
|
1178 | 1169 | $ hg clone --pull repo bundle2 --config format.usegeneraldelta=1 |
|
1179 | 1170 | requesting all changes |
|
1180 | 1171 | adding changesets |
|
1181 | 1172 | adding manifests |
|
1182 | 1173 | adding file changes |
|
1183 | 1174 | added 5 changesets with 8 changes to 6 files |
|
1184 | 1175 | new changesets cc01e2b0c59f:33f7f61e6c5e |
|
1185 | 1176 | updating to branch default |
|
1186 | 1177 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1187 | 1178 | $ cd bundle2 |
|
1188 | 1179 | $ echo babar > jungle |
|
1189 | 1180 | $ hg add jungle |
|
1190 | 1181 | $ hg shelve |
|
1191 | 1182 | shelved as default |
|
1192 | 1183 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1193 | 1184 | $ hg debugbundle .hg/shelved/*.hg |
|
1194 | 1185 | Stream params: {Compression: BZ} |
|
1195 | 1186 | changegroup -- {nbchanges: 1, version: 02} (mandatory: True) |
|
1196 | 1187 | 330882a04d2ce8487636b1fb292e5beea77fa1e3 |
|
1197 | 1188 | $ cd .. |
|
1198 | 1189 | |
|
1199 | 1190 | Test visibility of in-memory changes inside transaction to external hook |
|
1200 | 1191 | ------------------------------------------------------------------------ |
|
1201 | 1192 | |
|
1202 | 1193 | $ cd repo |
|
1203 | 1194 | |
|
1204 | 1195 | $ echo xxxx >> x |
|
1205 | 1196 | $ hg commit -m "#5: changes to invoke rebase" |
|
1206 | 1197 | |
|
1207 | 1198 | $ cat > $TESTTMP/checkvisibility.sh <<EOF |
|
1208 | 1199 | > echo "==== \$1:" |
|
1209 | 1200 | > hg parents --template "VISIBLE {rev}:{node|short}\n" |
|
1210 | 1201 | > # test that pending changes are hidden |
|
1211 | 1202 | > unset HG_PENDING |
|
1212 | 1203 | > hg parents --template "ACTUAL {rev}:{node|short}\n" |
|
1213 | 1204 | > echo "====" |
|
1214 | 1205 | > EOF |
|
1215 | 1206 | |
|
1216 | 1207 | $ cat >> .hg/hgrc <<EOF |
|
1217 | 1208 | > [defaults] |
|
1218 | 1209 | > # to fix hash id of temporary revisions |
|
1219 | 1210 | > unshelve = --date '0 0' |
|
1220 | 1211 | > EOF |
|
1221 | 1212 | |
|
1222 | 1213 | "hg unshelve" at REV5 implies steps below: |
|
1223 | 1214 | |
|
1224 | 1215 | (1) commit changes in the working directory (REV6) |
|
1225 | 1216 | (2) unbundle shelved revision (REV7) |
|
1226 | 1217 | (3) rebase: merge REV7 into REV6 (REV6 => REV6, REV7) |
|
1227 | 1218 | (4) rebase: commit merged revision (REV8) |
|
1228 | 1219 | (5) rebase: update to REV6 (REV8 => REV6) |
|
1229 | 1220 | (6) update to REV5 (REV6 => REV5) |
|
1230 | 1221 | (7) abort transaction |
|
1231 | 1222 | |
|
1232 | 1223 | == test visibility to external preupdate hook |
|
1233 | 1224 | |
|
1234 | 1225 | $ cat >> .hg/hgrc <<EOF |
|
1235 | 1226 | > [hooks] |
|
1236 | 1227 | > preupdate.visibility = sh $TESTTMP/checkvisibility.sh preupdate |
|
1237 | 1228 | > EOF |
|
1238 | 1229 | |
|
1239 | 1230 | $ echo nnnn >> n |
|
1240 | 1231 | |
|
1241 | 1232 | $ sh $TESTTMP/checkvisibility.sh before-unshelving |
|
1242 | 1233 | ==== before-unshelving: |
|
1243 | 1234 | VISIBLE (5|19):703117a2acfb (re) |
|
1244 | 1235 | ACTUAL (5|19):703117a2acfb (re) |
|
1245 | 1236 | ==== |
|
1246 | 1237 | |
|
1247 | 1238 | $ hg unshelve --keep default |
|
1248 | 1239 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1249 | 1240 | rebasing shelved changes |
|
1250 | 1241 | ==== preupdate: |
|
1251 | 1242 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1252 | 1243 | ACTUAL (5|19):703117a2acfb (re) |
|
1253 | 1244 | ==== |
|
1254 | 1245 | ==== preupdate: |
|
1255 | 1246 | VISIBLE (8|21):8efe6f7537dc (re) |
|
1256 | 1247 | ACTUAL (5|19):703117a2acfb (re) |
|
1257 | 1248 | ==== |
|
1258 | 1249 | ==== preupdate: |
|
1259 | 1250 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1260 | 1251 | ACTUAL (5|19):703117a2acfb (re) |
|
1261 | 1252 | ==== |
|
1262 | 1253 | |
|
1263 | 1254 | $ cat >> .hg/hgrc <<EOF |
|
1264 | 1255 | > [hooks] |
|
1265 | 1256 | > preupdate.visibility = |
|
1266 | 1257 | > EOF |
|
1267 | 1258 | |
|
1268 | 1259 | $ sh $TESTTMP/checkvisibility.sh after-unshelving |
|
1269 | 1260 | ==== after-unshelving: |
|
1270 | 1261 | VISIBLE (5|19):703117a2acfb (re) |
|
1271 | 1262 | ACTUAL (5|19):703117a2acfb (re) |
|
1272 | 1263 | ==== |
|
1273 | 1264 | |
|
1274 | 1265 | == test visibility to external update hook |
|
1275 | 1266 | |
|
1276 | 1267 | $ hg update -q -C 703117a2acfb |
|
1277 | 1268 | |
|
1278 | 1269 | $ cat >> .hg/hgrc <<EOF |
|
1279 | 1270 | > [hooks] |
|
1280 | 1271 | > update.visibility = sh $TESTTMP/checkvisibility.sh update |
|
1281 | 1272 | > EOF |
|
1282 | 1273 | |
|
1283 | 1274 | $ echo nnnn >> n |
|
1284 | 1275 | |
|
1285 | 1276 | $ sh $TESTTMP/checkvisibility.sh before-unshelving |
|
1286 | 1277 | ==== before-unshelving: |
|
1287 | 1278 | VISIBLE (5|19):703117a2acfb (re) |
|
1288 | 1279 | ACTUAL (5|19):703117a2acfb (re) |
|
1289 | 1280 | ==== |
|
1290 | 1281 | |
|
1291 | 1282 | $ hg unshelve --keep default |
|
1292 | 1283 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1293 | 1284 | rebasing shelved changes |
|
1294 | 1285 | ==== update: |
|
1295 | 1286 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1296 | 1287 | VISIBLE 1?7:492ed9d705e5 (re) |
|
1297 | 1288 | ACTUAL (5|19):703117a2acfb (re) |
|
1298 | 1289 | ==== |
|
1299 | 1290 | ==== update: |
|
1300 | 1291 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1301 | 1292 | ACTUAL (5|19):703117a2acfb (re) |
|
1302 | 1293 | ==== |
|
1303 | 1294 | ==== update: |
|
1304 | 1295 | VISIBLE (5|19):703117a2acfb (re) |
|
1305 | 1296 | ACTUAL (5|19):703117a2acfb (re) |
|
1306 | 1297 | ==== |
|
1307 | 1298 | |
|
1308 | 1299 | $ cat >> .hg/hgrc <<EOF |
|
1309 | 1300 | > [hooks] |
|
1310 | 1301 | > update.visibility = |
|
1311 | 1302 | > EOF |
|
1312 | 1303 | |
|
1313 | 1304 | $ sh $TESTTMP/checkvisibility.sh after-unshelving |
|
1314 | 1305 | ==== after-unshelving: |
|
1315 | 1306 | VISIBLE (5|19):703117a2acfb (re) |
|
1316 | 1307 | ACTUAL (5|19):703117a2acfb (re) |
|
1317 | 1308 | ==== |
|
1318 | 1309 | |
|
1319 | 1310 | $ cd .. |
|
1320 | 1311 | |
|
1321 | 1312 | test .orig files go where the user wants them to |
|
1322 | 1313 | --------------------------------------------------------------- |
|
1323 | 1314 | $ hg init salvage |
|
1324 | 1315 | $ cd salvage |
|
1325 | 1316 | $ echo 'content' > root |
|
1326 | 1317 | $ hg commit -A -m 'root' -q |
|
1327 | 1318 | $ echo '' > root |
|
1328 | 1319 | $ hg shelve -q |
|
1329 | 1320 | $ echo 'contADDent' > root |
|
1330 | 1321 | $ hg unshelve -q --config 'ui.origbackuppath=.hg/origbackups' |
|
1331 | 1322 | warning: conflicts while merging root! (edit, then use 'hg resolve --mark') |
|
1332 | 1323 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1333 | 1324 | [1] |
|
1334 | 1325 | $ ls .hg/origbackups |
|
1335 | 1326 | root |
|
1336 | 1327 | $ rm -rf .hg/origbackups |
|
1337 | 1328 | |
|
1338 | 1329 | test Abort unshelve always gets user out of the unshelved state |
|
1339 | 1330 | --------------------------------------------------------------- |
|
1340 | 1331 | |
|
1341 | 1332 | with a corrupted shelve state file |
|
1342 | 1333 | $ sed 's/ae8c668541e8/123456789012/' .hg/shelvedstate > ../corrupt-shelvedstate |
|
1343 | 1334 | $ mv ../corrupt-shelvedstate .hg/shelvestate |
|
1344 | 1335 | $ hg unshelve --abort 2>&1 | grep 'aborted' |
|
1345 | 1336 | unshelve of 'default' aborted |
|
1346 | 1337 | $ hg summary |
|
1347 | 1338 | parent: 0:ae8c668541e8 tip |
|
1348 | 1339 | root |
|
1349 | 1340 | branch: default |
|
1350 | 1341 | commit: 1 modified |
|
1351 | 1342 | update: (current) |
|
1352 | 1343 | phases: 1 draft |
|
1353 | 1344 | $ hg up -C . |
|
1354 | 1345 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1355 | 1346 | |
|
1356 | 1347 | $ cd .. |
|
1357 | 1348 | |
|
1358 | 1349 | Keep active bookmark while (un)shelving even on shared repo (issue4940) |
|
1359 | 1350 | ----------------------------------------------------------------------- |
|
1360 | 1351 | |
|
1361 | 1352 | $ cat <<EOF >> $HGRCPATH |
|
1362 | 1353 | > [extensions] |
|
1363 | 1354 | > share = |
|
1364 | 1355 | > EOF |
|
1365 | 1356 | |
|
1366 | 1357 | $ hg bookmarks -R repo |
|
1367 | 1358 | test (4|13):33f7f61e6c5e (re) |
|
1368 | 1359 | $ hg share -B repo share |
|
1369 | 1360 | updating working directory |
|
1370 | 1361 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1371 | 1362 | $ cd share |
|
1372 | 1363 | |
|
1373 | 1364 | $ hg bookmarks |
|
1374 | 1365 | test (4|13):33f7f61e6c5e (re) |
|
1375 | 1366 | $ hg bookmarks foo |
|
1376 | 1367 | $ hg bookmarks |
|
1377 | 1368 | \* foo (5|19):703117a2acfb (re) |
|
1378 | 1369 | test (4|13):33f7f61e6c5e (re) |
|
1379 | 1370 | $ echo x >> x |
|
1380 | 1371 | $ hg shelve |
|
1381 | 1372 | shelved as foo |
|
1382 | 1373 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1383 | 1374 | $ hg bookmarks |
|
1384 | 1375 | \* foo (5|19):703117a2acfb (re) |
|
1385 | 1376 | test (4|13):33f7f61e6c5e (re) |
|
1386 | 1377 | |
|
1387 | 1378 | $ hg unshelve |
|
1388 | 1379 | unshelving change 'foo' |
|
1389 | 1380 | $ hg bookmarks |
|
1390 | 1381 | \* foo (5|19):703117a2acfb (re) |
|
1391 | 1382 | test (4|13):33f7f61e6c5e (re) |
|
1392 | 1383 | |
|
1393 | 1384 | $ cd .. |
|
1394 | 1385 | |
|
1395 | 1386 | Shelve and unshelve unknown files. For the purposes of unshelve, a shelved |
|
1396 | 1387 | unknown file is the same as a shelved added file, except that it will be in |
|
1397 | 1388 | unknown state after unshelve if and only if it was either absent or unknown |
|
1398 | 1389 | before the unshelve operation. |
|
1399 | 1390 | |
|
1400 | 1391 | $ hg init unknowns |
|
1401 | 1392 | $ cd unknowns |
|
1402 | 1393 | |
|
1403 | 1394 | The simplest case is if I simply have an unknown file that I shelve and unshelve |
|
1404 | 1395 | |
|
1405 | 1396 | $ echo unknown > unknown |
|
1406 | 1397 | $ hg status |
|
1407 | 1398 | ? unknown |
|
1408 | 1399 | $ hg shelve --unknown |
|
1409 | 1400 | shelved as default |
|
1410 | 1401 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1411 | 1402 | $ hg status |
|
1412 | 1403 | $ hg unshelve |
|
1413 | 1404 | unshelving change 'default' |
|
1414 | 1405 | $ hg status |
|
1415 | 1406 | ? unknown |
|
1416 | 1407 | $ rm unknown |
|
1417 | 1408 | |
|
1418 | 1409 | If I shelve, add the file, and unshelve, does it stay added? |
|
1419 | 1410 | |
|
1420 | 1411 | $ echo unknown > unknown |
|
1421 | 1412 | $ hg shelve -u |
|
1422 | 1413 | shelved as default |
|
1423 | 1414 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1424 | 1415 | $ hg status |
|
1425 | 1416 | $ touch unknown |
|
1426 | 1417 | $ hg add unknown |
|
1427 | 1418 | $ hg status |
|
1428 | 1419 | A unknown |
|
1429 | 1420 | $ hg unshelve |
|
1430 | 1421 | unshelving change 'default' |
|
1431 | 1422 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1432 | 1423 | rebasing shelved changes |
|
1433 | 1424 | merging unknown |
|
1434 | 1425 | $ hg status |
|
1435 | 1426 | A unknown |
|
1436 | 1427 | $ hg forget unknown |
|
1437 | 1428 | $ rm unknown |
|
1438 | 1429 | |
|
1439 | 1430 | And if I shelve, commit, then unshelve, does it become modified? |
|
1440 | 1431 | |
|
1441 | 1432 | $ echo unknown > unknown |
|
1442 | 1433 | $ hg shelve -u |
|
1443 | 1434 | shelved as default |
|
1444 | 1435 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1445 | 1436 | $ hg status |
|
1446 | 1437 | $ touch unknown |
|
1447 | 1438 | $ hg add unknown |
|
1448 | 1439 | $ hg commit -qm "Add unknown" |
|
1449 | 1440 | $ hg status |
|
1450 | 1441 | $ hg unshelve |
|
1451 | 1442 | unshelving change 'default' |
|
1452 | 1443 | rebasing shelved changes |
|
1453 | 1444 | merging unknown |
|
1454 | 1445 | $ hg status |
|
1455 | 1446 | M unknown |
|
1456 | 1447 | $ hg remove --force unknown |
|
1457 | 1448 | $ hg commit -qm "Remove unknown" |
|
1458 | 1449 | |
|
1459 | 1450 | $ cd .. |
|
1460 | 1451 | |
|
1461 | 1452 | We expects that non-bare shelve keeps newly created branch in |
|
1462 | 1453 | working directory. |
|
1463 | 1454 | |
|
1464 | 1455 | $ hg init shelve-preserve-new-branch |
|
1465 | 1456 | $ cd shelve-preserve-new-branch |
|
1466 | 1457 | $ echo "a" >> a |
|
1467 | 1458 | $ hg add a |
|
1468 | 1459 | $ echo "b" >> b |
|
1469 | 1460 | $ hg add b |
|
1470 | 1461 | $ hg commit -m "ab" |
|
1471 | 1462 | $ echo "aa" >> a |
|
1472 | 1463 | $ echo "bb" >> b |
|
1473 | 1464 | $ hg branch new-branch |
|
1474 | 1465 | marked working directory as branch new-branch |
|
1475 | 1466 | (branches are permanent and global, did you want a bookmark?) |
|
1476 | 1467 | $ hg status |
|
1477 | 1468 | M a |
|
1478 | 1469 | M b |
|
1479 | 1470 | $ hg branch |
|
1480 | 1471 | new-branch |
|
1481 | 1472 | $ hg shelve a |
|
1482 | 1473 | shelved as default |
|
1483 | 1474 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1484 | 1475 | $ hg branch |
|
1485 | 1476 | new-branch |
|
1486 | 1477 | $ hg status |
|
1487 | 1478 | M b |
|
1488 | 1479 | $ touch "c" >> c |
|
1489 | 1480 | $ hg add c |
|
1490 | 1481 | $ hg status |
|
1491 | 1482 | M b |
|
1492 | 1483 | A c |
|
1493 | 1484 | $ hg shelve --exclude c |
|
1494 | 1485 | shelved as default-01 |
|
1495 | 1486 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1496 | 1487 | $ hg branch |
|
1497 | 1488 | new-branch |
|
1498 | 1489 | $ hg status |
|
1499 | 1490 | A c |
|
1500 | 1491 | $ hg shelve --include c |
|
1501 | 1492 | shelved as default-02 |
|
1502 | 1493 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1503 | 1494 | $ hg branch |
|
1504 | 1495 | new-branch |
|
1505 | 1496 | $ hg status |
|
1506 | 1497 | $ echo "d" >> d |
|
1507 | 1498 | $ hg add d |
|
1508 | 1499 | $ hg status |
|
1509 | 1500 | A d |
|
1510 | 1501 | |
|
1511 | 1502 | We expect that bare-shelve will not keep branch in current working directory. |
|
1512 | 1503 | |
|
1513 | 1504 | $ hg shelve |
|
1514 | 1505 | shelved as default-03 |
|
1515 | 1506 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1516 | 1507 | $ hg branch |
|
1517 | 1508 | default |
|
1518 | 1509 | $ cd .. |
|
1519 | 1510 | |
|
1520 | 1511 | When i shelve commit on newly created branch i expect |
|
1521 | 1512 | that after unshelve newly created branch will be preserved. |
|
1522 | 1513 | |
|
1523 | 1514 | $ hg init shelve_on_new_branch_simple |
|
1524 | 1515 | $ cd shelve_on_new_branch_simple |
|
1525 | 1516 | $ echo "aaa" >> a |
|
1526 | 1517 | $ hg commit -A -m "a" |
|
1527 | 1518 | adding a |
|
1528 | 1519 | $ hg branch |
|
1529 | 1520 | default |
|
1530 | 1521 | $ hg branch test |
|
1531 | 1522 | marked working directory as branch test |
|
1532 | 1523 | (branches are permanent and global, did you want a bookmark?) |
|
1533 | 1524 | $ echo "bbb" >> a |
|
1534 | 1525 | $ hg status |
|
1535 | 1526 | M a |
|
1536 | 1527 | $ hg shelve |
|
1537 | 1528 | shelved as default |
|
1538 | 1529 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1539 | 1530 | $ hg branch |
|
1540 | 1531 | default |
|
1541 | 1532 | $ echo "bbb" >> b |
|
1542 | 1533 | $ hg status |
|
1543 | 1534 | ? b |
|
1544 | 1535 | $ hg unshelve |
|
1545 | 1536 | unshelving change 'default' |
|
1546 | 1537 | marked working directory as branch test |
|
1547 | 1538 | $ hg status |
|
1548 | 1539 | M a |
|
1549 | 1540 | ? b |
|
1550 | 1541 | $ hg branch |
|
1551 | 1542 | test |
|
1552 | 1543 | $ cd .. |
|
1553 | 1544 | |
|
1554 | 1545 | When i shelve commit on newly created branch, make |
|
1555 | 1546 | some changes, unshelve it and running into merge |
|
1556 | 1547 | conflicts i expect that after fixing them and |
|
1557 | 1548 | running unshelve --continue newly created branch |
|
1558 | 1549 | will be preserved. |
|
1559 | 1550 | |
|
1560 | 1551 | $ hg init shelve_on_new_branch_conflict |
|
1561 | 1552 | $ cd shelve_on_new_branch_conflict |
|
1562 | 1553 | $ echo "aaa" >> a |
|
1563 | 1554 | $ hg commit -A -m "a" |
|
1564 | 1555 | adding a |
|
1565 | 1556 | $ hg branch |
|
1566 | 1557 | default |
|
1567 | 1558 | $ hg branch test |
|
1568 | 1559 | marked working directory as branch test |
|
1569 | 1560 | (branches are permanent and global, did you want a bookmark?) |
|
1570 | 1561 | $ echo "bbb" >> a |
|
1571 | 1562 | $ hg status |
|
1572 | 1563 | M a |
|
1573 | 1564 | $ hg shelve |
|
1574 | 1565 | shelved as default |
|
1575 | 1566 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1576 | 1567 | $ hg branch |
|
1577 | 1568 | default |
|
1578 | 1569 | $ echo "ccc" >> a |
|
1579 | 1570 | $ hg status |
|
1580 | 1571 | M a |
|
1581 | 1572 | $ hg unshelve |
|
1582 | 1573 | unshelving change 'default' |
|
1583 | 1574 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1584 | 1575 | rebasing shelved changes |
|
1585 | 1576 | merging a |
|
1586 | 1577 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
1587 | 1578 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1588 | 1579 | [1] |
|
1589 | 1580 | $ echo "aaabbbccc" > a |
|
1590 | 1581 | $ rm a.orig |
|
1591 | 1582 | $ hg resolve --mark a |
|
1592 | 1583 | (no more unresolved files) |
|
1593 | 1584 | continue: hg unshelve --continue |
|
1594 | 1585 | $ hg unshelve --continue |
|
1595 | 1586 | marked working directory as branch test |
|
1596 | 1587 | unshelve of 'default' complete |
|
1597 | 1588 | $ cat a |
|
1598 | 1589 | aaabbbccc |
|
1599 | 1590 | $ hg status |
|
1600 | 1591 | M a |
|
1601 | 1592 | $ hg branch |
|
1602 | 1593 | test |
|
1603 | 1594 | $ hg commit -m "test-commit" |
|
1604 | 1595 | |
|
1605 | 1596 | When i shelve on test branch, update to default branch |
|
1606 | 1597 | and unshelve i expect that it will not preserve previous |
|
1607 | 1598 | test branch. |
|
1608 | 1599 | |
|
1609 | 1600 | $ echo "xxx" > b |
|
1610 | 1601 | $ hg add b |
|
1611 | 1602 | $ hg shelve |
|
1612 | 1603 | shelved as test |
|
1613 | 1604 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1614 | 1605 | $ hg update -r 7049e48789d7 |
|
1615 | 1606 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1616 | 1607 | $ hg unshelve |
|
1617 | 1608 | unshelving change 'test' |
|
1618 | 1609 | rebasing shelved changes |
|
1619 | 1610 | $ hg status |
|
1620 | 1611 | A b |
|
1621 | 1612 | $ hg branch |
|
1622 | 1613 | default |
|
1623 | 1614 | $ cd .. |
|
1624 | 1615 | |
|
1625 | 1616 | When i unshelve resulting in merge conflicts and makes saved |
|
1626 | 1617 | file shelvedstate looks like in previous versions in |
|
1627 | 1618 | mercurial(without restore branch information in 7th line) i |
|
1628 | 1619 | expect that after resolving conflicts and successfully |
|
1629 | 1620 | running 'shelve --continue' the branch information won't be |
|
1630 | 1621 | restored and branch will be unchanged. |
|
1631 | 1622 | |
|
1632 | 1623 | shelve on new branch, conflict with previous shelvedstate |
|
1633 | 1624 | |
|
1634 | 1625 | $ hg init conflict |
|
1635 | 1626 | $ cd conflict |
|
1636 | 1627 | $ echo "aaa" >> a |
|
1637 | 1628 | $ hg commit -A -m "a" |
|
1638 | 1629 | adding a |
|
1639 | 1630 | $ hg branch |
|
1640 | 1631 | default |
|
1641 | 1632 | $ hg branch test |
|
1642 | 1633 | marked working directory as branch test |
|
1643 | 1634 | (branches are permanent and global, did you want a bookmark?) |
|
1644 | 1635 | $ echo "bbb" >> a |
|
1645 | 1636 | $ hg status |
|
1646 | 1637 | M a |
|
1647 | 1638 | $ hg shelve |
|
1648 | 1639 | shelved as default |
|
1649 | 1640 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1650 | 1641 | $ hg branch |
|
1651 | 1642 | default |
|
1652 | 1643 | $ echo "ccc" >> a |
|
1653 | 1644 | $ hg status |
|
1654 | 1645 | M a |
|
1655 | 1646 | $ hg unshelve |
|
1656 | 1647 | unshelving change 'default' |
|
1657 | 1648 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1658 | 1649 | rebasing shelved changes |
|
1659 | 1650 | merging a |
|
1660 | 1651 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
1661 | 1652 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1662 | 1653 | [1] |
|
1663 | 1654 | |
|
1664 | 1655 | Removing restore branch information from shelvedstate file(making it looks like |
|
1665 | 1656 | in previous versions) and running unshelve --continue |
|
1666 | 1657 | |
|
1667 | 1658 | $ cp .hg/shelvedstate .hg/shelvedstate_old |
|
1668 | 1659 | $ cat .hg/shelvedstate_old | grep -v 'branchtorestore' > .hg/shelvedstate |
|
1669 | 1660 | |
|
1670 | 1661 | $ echo "aaabbbccc" > a |
|
1671 | 1662 | $ rm a.orig |
|
1672 | 1663 | $ hg resolve --mark a |
|
1673 | 1664 | (no more unresolved files) |
|
1674 | 1665 | continue: hg unshelve --continue |
|
1675 | 1666 | $ hg unshelve --continue |
|
1676 | 1667 | unshelve of 'default' complete |
|
1677 | 1668 | $ cat a |
|
1678 | 1669 | aaabbbccc |
|
1679 | 1670 | $ hg status |
|
1680 | 1671 | M a |
|
1681 | 1672 | $ hg branch |
|
1682 | 1673 | default |
|
1683 | 1674 | $ cd .. |
|
1684 | 1675 | |
|
1685 | 1676 | On non bare shelve the branch information shouldn't be restored |
|
1686 | 1677 | |
|
1687 | 1678 | $ hg init bare_shelve_on_new_branch |
|
1688 | 1679 | $ cd bare_shelve_on_new_branch |
|
1689 | 1680 | $ echo "aaa" >> a |
|
1690 | 1681 | $ hg commit -A -m "a" |
|
1691 | 1682 | adding a |
|
1692 | 1683 | $ hg branch |
|
1693 | 1684 | default |
|
1694 | 1685 | $ hg branch test |
|
1695 | 1686 | marked working directory as branch test |
|
1696 | 1687 | (branches are permanent and global, did you want a bookmark?) |
|
1697 | 1688 | $ echo "bbb" >> a |
|
1698 | 1689 | $ hg status |
|
1699 | 1690 | M a |
|
1700 | 1691 | $ hg shelve a |
|
1701 | 1692 | shelved as default |
|
1702 | 1693 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1703 | 1694 | $ hg branch |
|
1704 | 1695 | test |
|
1705 | 1696 | $ hg branch default |
|
1706 | 1697 | marked working directory as branch default |
|
1707 | 1698 | (branches are permanent and global, did you want a bookmark?) |
|
1708 | 1699 | $ echo "bbb" >> b |
|
1709 | 1700 | $ hg status |
|
1710 | 1701 | ? b |
|
1711 | 1702 | $ hg unshelve |
|
1712 | 1703 | unshelving change 'default' |
|
1713 | 1704 | $ hg status |
|
1714 | 1705 | M a |
|
1715 | 1706 | ? b |
|
1716 | 1707 | $ hg branch |
|
1717 | 1708 | default |
|
1718 | 1709 | $ cd .. |
|
1719 | 1710 | |
|
1720 | 1711 | Prepare unshelve with a corrupted shelvedstate |
|
1721 | 1712 | $ hg init r1 && cd r1 |
|
1722 | 1713 | $ echo text1 > file && hg add file |
|
1723 | 1714 | $ hg shelve |
|
1724 | 1715 | shelved as default |
|
1725 | 1716 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1726 | 1717 | $ echo text2 > file && hg ci -Am text1 |
|
1727 | 1718 | adding file |
|
1728 | 1719 | $ hg unshelve |
|
1729 | 1720 | unshelving change 'default' |
|
1730 | 1721 | rebasing shelved changes |
|
1731 | 1722 | merging file |
|
1732 | 1723 | warning: conflicts while merging file! (edit, then use 'hg resolve --mark') |
|
1733 | 1724 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1734 | 1725 | [1] |
|
1735 | 1726 | $ echo somethingsomething > .hg/shelvedstate |
|
1736 | 1727 | |
|
1737 | 1728 | Unshelve --continue fails with appropriate message if shelvedstate is corrupted |
|
1738 | 1729 | $ hg unshelve --continue |
|
1739 | 1730 | abort: corrupted shelved state file |
|
1740 | 1731 | (please run hg unshelve --abort to abort unshelve operation) |
|
1741 | 1732 | [255] |
|
1742 | 1733 | |
|
1743 | 1734 | Unshelve --abort works with a corrupted shelvedstate |
|
1744 | 1735 | $ hg unshelve --abort |
|
1745 | 1736 | could not read shelved state file, your working copy may be in an unexpected state |
|
1746 | 1737 | please update to some commit |
|
1747 | 1738 | |
|
1748 | 1739 | Unshelve --abort fails with appropriate message if there's no unshelve in |
|
1749 | 1740 | progress |
|
1750 | 1741 | $ hg unshelve --abort |
|
1751 | 1742 | abort: no unshelve in progress |
|
1752 | 1743 | [255] |
|
1753 | 1744 | $ cd .. |
|
1754 | 1745 | |
|
1755 | 1746 | Unshelve respects --keep even if user intervention is needed |
|
1756 | 1747 | $ hg init unshelvekeep && cd unshelvekeep |
|
1757 | 1748 | $ echo 1 > file && hg ci -Am 1 |
|
1758 | 1749 | adding file |
|
1759 | 1750 | $ echo 2 >> file |
|
1760 | 1751 | $ hg shelve |
|
1761 | 1752 | shelved as default |
|
1762 | 1753 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1763 | 1754 | $ echo 3 >> file && hg ci -Am 13 |
|
1764 | 1755 | $ hg shelve --list |
|
1765 | 1756 | default (*s ago) * changes to: 1 (glob) |
|
1766 | 1757 | $ hg unshelve --keep |
|
1767 | 1758 | unshelving change 'default' |
|
1768 | 1759 | rebasing shelved changes |
|
1769 | 1760 | merging file |
|
1770 | 1761 | warning: conflicts while merging file! (edit, then use 'hg resolve --mark') |
|
1771 | 1762 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1772 | 1763 | [1] |
|
1773 | 1764 | $ hg resolve --mark file |
|
1774 | 1765 | (no more unresolved files) |
|
1775 | 1766 | continue: hg unshelve --continue |
|
1776 | 1767 | $ hg unshelve --continue |
|
1777 | 1768 | unshelve of 'default' complete |
|
1778 | 1769 | $ hg shelve --list |
|
1779 | 1770 | default (*s ago) * changes to: 1 (glob) |
|
1780 | 1771 | $ cd .. |
|
1781 | 1772 | |
|
1782 | 1773 | Unshelving when there are deleted files does not crash (issue4176) |
|
1783 | 1774 | $ hg init unshelve-deleted-file && cd unshelve-deleted-file |
|
1784 | 1775 | $ echo a > a && echo b > b && hg ci -Am ab |
|
1785 | 1776 | adding a |
|
1786 | 1777 | adding b |
|
1787 | 1778 | $ echo aa > a && hg shelve |
|
1788 | 1779 | shelved as default |
|
1789 | 1780 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1790 | 1781 | $ rm b |
|
1791 | 1782 | $ hg st |
|
1792 | 1783 | ! b |
|
1793 | 1784 | $ hg unshelve |
|
1794 | 1785 | unshelving change 'default' |
|
1795 | 1786 | $ hg shelve |
|
1796 | 1787 | shelved as default |
|
1797 | 1788 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1798 | 1789 | $ rm a && echo b > b |
|
1799 | 1790 | $ hg st |
|
1800 | 1791 | ! a |
|
1801 | 1792 | $ hg unshelve |
|
1802 | 1793 | unshelving change 'default' |
|
1803 | 1794 | abort: shelved change touches missing files |
|
1804 | 1795 | (run hg status to see which files are missing) |
|
1805 | 1796 | [255] |
|
1806 | 1797 | $ hg st |
|
1807 | 1798 | ! a |
|
1808 | 1799 | $ cd .. |
|
1809 | 1800 | |
|
1810 | 1801 | New versions of Mercurial know how to read onld shelvedstate files |
|
1811 | 1802 | $ hg init oldshelvedstate |
|
1812 | 1803 | $ cd oldshelvedstate |
|
1813 | 1804 | $ echo root > root && hg ci -Am root |
|
1814 | 1805 | adding root |
|
1815 | 1806 | $ echo 1 > a |
|
1816 | 1807 | $ hg add a |
|
1817 | 1808 | $ hg shelve --name ashelve |
|
1818 | 1809 | shelved as ashelve |
|
1819 | 1810 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1820 | 1811 | $ echo 2 > a |
|
1821 | 1812 | $ hg ci -Am a |
|
1822 | 1813 | adding a |
|
1823 | 1814 | $ hg unshelve |
|
1824 | 1815 | unshelving change 'ashelve' |
|
1825 | 1816 | rebasing shelved changes |
|
1826 | 1817 | merging a |
|
1827 | 1818 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
1828 | 1819 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1829 | 1820 | [1] |
|
1830 | 1821 | putting v1 shelvedstate file in place of a created v2 |
|
1831 | 1822 | $ cat << EOF > .hg/shelvedstate |
|
1832 | 1823 | > 1 |
|
1833 | 1824 | > ashelve |
|
1834 | 1825 | > 8b058dae057a5a78f393f4535d9e363dd5efac9d |
|
1835 | 1826 | > 8b058dae057a5a78f393f4535d9e363dd5efac9d |
|
1836 | 1827 | > 8b058dae057a5a78f393f4535d9e363dd5efac9d f543b27db2cdb41737e2e0008dc524c471da1446 |
|
1837 | 1828 | > f543b27db2cdb41737e2e0008dc524c471da1446 |
|
1838 | 1829 | > |
|
1839 | 1830 | > nokeep |
|
1840 | 1831 | > :no-active-bookmark |
|
1841 | 1832 | > EOF |
|
1842 | 1833 | $ echo 1 > a |
|
1843 | 1834 | $ hg resolve --mark a |
|
1844 | 1835 | (no more unresolved files) |
|
1845 | 1836 | continue: hg unshelve --continue |
|
1846 | 1837 | mercurial does not crash |
|
1847 | 1838 | $ hg unshelve --continue |
|
1848 | 1839 | unshelve of 'ashelve' complete |
|
1849 | 1840 | |
|
1850 | 1841 | #if phasebased |
|
1851 | 1842 | |
|
1852 | 1843 | Unshelve without .shelve metadata: |
|
1853 | 1844 | |
|
1854 | 1845 | $ hg shelve |
|
1855 | 1846 | shelved as default |
|
1856 | 1847 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1857 | 1848 | $ cat .hg/shelved/default.shelve |
|
1858 | 1849 | node=82e0cb9893247d12667017593ce1e5655860f1ac |
|
1859 | 1850 | $ hg strip --hidden --rev 82e0cb989324 --no-backup |
|
1860 | 1851 | $ rm .hg/shelved/default.shelve |
|
1861 | 1852 | $ echo 3 > a |
|
1862 | 1853 | $ hg unshelve |
|
1863 | 1854 | unshelving change 'default' |
|
1864 | 1855 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1865 | 1856 | rebasing shelved changes |
|
1866 | 1857 | merging a |
|
1867 | 1858 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
1868 | 1859 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1869 | 1860 | [1] |
|
1870 | 1861 | $ cat .hg/shelved/default.shelve |
|
1871 | 1862 | node=82e0cb9893247d12667017593ce1e5655860f1ac |
|
1872 | 1863 | |
|
1873 | 1864 | #endif |
|
1874 | 1865 | |
|
1875 | 1866 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now