Show More
@@ -1,1183 +1,1183 b'' | |||
|
1 | 1 | # shelve.py - save/restore working directory state |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2013 Facebook, Inc. |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | """save and restore changes to the working directory |
|
9 | 9 | |
|
10 | 10 | The "hg shelve" command saves changes made to the working directory |
|
11 | 11 | and reverts those changes, resetting the working directory to a clean |
|
12 | 12 | state. |
|
13 | 13 | |
|
14 | 14 | Later on, the "hg unshelve" command restores the changes saved by "hg |
|
15 | 15 | shelve". Changes can be restored even after updating to a different |
|
16 | 16 | parent, in which case Mercurial's merge machinery will resolve any |
|
17 | 17 | conflicts if necessary. |
|
18 | 18 | |
|
19 | 19 | You can have more than one shelved change outstanding at a time; each |
|
20 | 20 | shelved change has a distinct name. For details, see the help for "hg |
|
21 | 21 | shelve". |
|
22 | 22 | """ |
|
23 | 23 | from __future__ import absolute_import |
|
24 | 24 | |
|
25 | 25 | import collections |
|
26 | 26 | import errno |
|
27 | 27 | import itertools |
|
28 | 28 | import stat |
|
29 | 29 | |
|
30 | 30 | from .i18n import _ |
|
31 | 31 | from .pycompat import open |
|
32 | 32 | from . import ( |
|
33 | 33 | bookmarks, |
|
34 | 34 | bundle2, |
|
35 | 35 | bundlerepo, |
|
36 | 36 | changegroup, |
|
37 | 37 | cmdutil, |
|
38 | 38 | discovery, |
|
39 | 39 | error, |
|
40 | 40 | exchange, |
|
41 | 41 | hg, |
|
42 | 42 | lock as lockmod, |
|
43 | 43 | mdiff, |
|
44 | 44 | merge, |
|
45 | 45 | node as nodemod, |
|
46 | 46 | patch, |
|
47 | 47 | phases, |
|
48 | 48 | pycompat, |
|
49 | 49 | repair, |
|
50 | 50 | scmutil, |
|
51 | 51 | templatefilters, |
|
52 | 52 | util, |
|
53 | 53 | vfs as vfsmod, |
|
54 | 54 | ) |
|
55 | 55 | from .utils import ( |
|
56 | 56 | dateutil, |
|
57 | 57 | stringutil, |
|
58 | 58 | ) |
|
59 | 59 | |
|
60 | 60 | backupdir = b'shelve-backup' |
|
61 | 61 | shelvedir = b'shelved' |
|
62 | 62 | shelvefileextensions = [b'hg', b'patch', b'shelve'] |
|
63 | 63 | # universal extension is present in all types of shelves |
|
64 | 64 | patchextension = b'patch' |
|
65 | 65 | |
|
66 | 66 | # we never need the user, so we use a |
|
67 | 67 | # generic user for all shelve operations |
|
68 | 68 | shelveuser = b'shelve@localhost' |
|
69 | 69 | |
|
70 | 70 | |
|
71 | 71 | class shelvedfile(object): |
|
72 | 72 | """Helper for the file storing a single shelve |
|
73 | 73 | |
|
74 | 74 | Handles common functions on shelve files (.hg/.patch) using |
|
75 | 75 | the vfs layer""" |
|
76 | 76 | |
|
77 | 77 | def __init__(self, repo, name, filetype=None): |
|
78 | 78 | self.repo = repo |
|
79 | 79 | self.name = name |
|
80 | 80 | self.vfs = vfsmod.vfs(repo.vfs.join(shelvedir)) |
|
81 | 81 | self.backupvfs = vfsmod.vfs(repo.vfs.join(backupdir)) |
|
82 | 82 | self.ui = self.repo.ui |
|
83 | 83 | if filetype: |
|
84 | 84 | self.fname = name + b'.' + filetype |
|
85 | 85 | else: |
|
86 | 86 | self.fname = name |
|
87 | 87 | |
|
88 | 88 | def exists(self): |
|
89 | 89 | return self.vfs.exists(self.fname) |
|
90 | 90 | |
|
91 | 91 | def filename(self): |
|
92 | 92 | return self.vfs.join(self.fname) |
|
93 | 93 | |
|
94 | 94 | def backupfilename(self): |
|
95 | 95 | def gennames(base): |
|
96 | 96 | yield base |
|
97 | 97 | base, ext = base.rsplit(b'.', 1) |
|
98 | 98 | for i in itertools.count(1): |
|
99 | 99 | yield b'%s-%d.%s' % (base, i, ext) |
|
100 | 100 | |
|
101 | 101 | name = self.backupvfs.join(self.fname) |
|
102 | 102 | for n in gennames(name): |
|
103 | 103 | if not self.backupvfs.exists(n): |
|
104 | 104 | return n |
|
105 | 105 | |
|
106 | 106 | def movetobackup(self): |
|
107 | 107 | if not self.backupvfs.isdir(): |
|
108 | 108 | self.backupvfs.makedir() |
|
109 | 109 | util.rename(self.filename(), self.backupfilename()) |
|
110 | 110 | |
|
111 | 111 | def stat(self): |
|
112 | 112 | return self.vfs.stat(self.fname) |
|
113 | 113 | |
|
114 | 114 | def opener(self, mode=b'rb'): |
|
115 | 115 | try: |
|
116 | 116 | return self.vfs(self.fname, mode) |
|
117 | 117 | except IOError as err: |
|
118 | 118 | if err.errno != errno.ENOENT: |
|
119 | 119 | raise |
|
120 | 120 | raise error.Abort(_(b"shelved change '%s' not found") % self.name) |
|
121 | 121 | |
|
122 | 122 | def applybundle(self, tr): |
|
123 | 123 | fp = self.opener() |
|
124 | 124 | try: |
|
125 | 125 | targetphase = phases.internal |
|
126 | 126 | if not phases.supportinternal(self.repo): |
|
127 | 127 | targetphase = phases.secret |
|
128 | 128 | gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs) |
|
129 | 129 | pretip = self.repo[b'tip'] |
|
130 | 130 | bundle2.applybundle( |
|
131 | 131 | self.repo, |
|
132 | 132 | gen, |
|
133 | 133 | tr, |
|
134 | 134 | source=b'unshelve', |
|
135 | 135 | url=b'bundle:' + self.vfs.join(self.fname), |
|
136 | 136 | targetphase=targetphase, |
|
137 | 137 | ) |
|
138 | 138 | shelvectx = self.repo[b'tip'] |
|
139 | 139 | if pretip == shelvectx: |
|
140 | 140 | shelverev = tr.changes[b'revduplicates'][-1] |
|
141 | 141 | shelvectx = self.repo[shelverev] |
|
142 | 142 | return shelvectx |
|
143 | 143 | finally: |
|
144 | 144 | fp.close() |
|
145 | 145 | |
|
146 | 146 | def bundlerepo(self): |
|
147 | 147 | path = self.vfs.join(self.fname) |
|
148 | 148 | return bundlerepo.instance( |
|
149 | 149 | self.repo.baseui, b'bundle://%s+%s' % (self.repo.root, path), False |
|
150 | 150 | ) |
|
151 | 151 | |
|
152 | 152 | def writebundle(self, bases, node): |
|
153 | 153 | cgversion = changegroup.safeversion(self.repo) |
|
154 | 154 | if cgversion == b'01': |
|
155 | 155 | btype = b'HG10BZ' |
|
156 | 156 | compression = None |
|
157 | 157 | else: |
|
158 | 158 | btype = b'HG20' |
|
159 | 159 | compression = b'BZ' |
|
160 | 160 | |
|
161 | 161 | repo = self.repo.unfiltered() |
|
162 | 162 | |
|
163 | 163 | outgoing = discovery.outgoing( |
|
164 | 164 | repo, missingroots=bases, missingheads=[node] |
|
165 | 165 | ) |
|
166 | 166 | cg = changegroup.makechangegroup(repo, outgoing, cgversion, b'shelve') |
|
167 | 167 | |
|
168 | 168 | bundle2.writebundle( |
|
169 | 169 | self.ui, cg, self.fname, btype, self.vfs, compression=compression |
|
170 | 170 | ) |
|
171 | 171 | |
|
172 | 172 | def writeinfo(self, info): |
|
173 | 173 | scmutil.simplekeyvaluefile(self.vfs, self.fname).write(info) |
|
174 | 174 | |
|
175 | 175 | def readinfo(self): |
|
176 | 176 | return scmutil.simplekeyvaluefile(self.vfs, self.fname).read() |
|
177 | 177 | |
|
178 | 178 | |
|
179 | 179 | class shelvedstate(object): |
|
180 | 180 | """Handle persistence during unshelving operations. |
|
181 | 181 | |
|
182 | 182 | Handles saving and restoring a shelved state. Ensures that different |
|
183 | 183 | versions of a shelved state are possible and handles them appropriately. |
|
184 | 184 | """ |
|
185 | 185 | |
|
186 | 186 | _version = 2 |
|
187 | 187 | _filename = b'shelvedstate' |
|
188 | 188 | _keep = b'keep' |
|
189 | 189 | _nokeep = b'nokeep' |
|
190 | 190 | # colon is essential to differentiate from a real bookmark name |
|
191 | 191 | _noactivebook = b':no-active-bookmark' |
|
192 | 192 | _interactive = b'interactive' |
|
193 | 193 | |
|
194 | 194 | @classmethod |
|
195 | 195 | def _verifyandtransform(cls, d): |
|
196 | 196 | """Some basic shelvestate syntactic verification and transformation""" |
|
197 | 197 | try: |
|
198 | 198 | d[b'originalwctx'] = nodemod.bin(d[b'originalwctx']) |
|
199 | 199 | d[b'pendingctx'] = nodemod.bin(d[b'pendingctx']) |
|
200 | 200 | d[b'parents'] = [nodemod.bin(h) for h in d[b'parents'].split(b' ')] |
|
201 | 201 | d[b'nodestoremove'] = [ |
|
202 | 202 | nodemod.bin(h) for h in d[b'nodestoremove'].split(b' ') |
|
203 | 203 | ] |
|
204 | 204 | except (ValueError, TypeError, KeyError) as err: |
|
205 | 205 | raise error.CorruptedState(pycompat.bytestr(err)) |
|
206 | 206 | |
|
207 | 207 | @classmethod |
|
208 | 208 | def _getversion(cls, repo): |
|
209 | 209 | """Read version information from shelvestate file""" |
|
210 | 210 | fp = repo.vfs(cls._filename) |
|
211 | 211 | try: |
|
212 | 212 | version = int(fp.readline().strip()) |
|
213 | 213 | except ValueError as err: |
|
214 | 214 | raise error.CorruptedState(pycompat.bytestr(err)) |
|
215 | 215 | finally: |
|
216 | 216 | fp.close() |
|
217 | 217 | return version |
|
218 | 218 | |
|
219 | 219 | @classmethod |
|
220 | 220 | def _readold(cls, repo): |
|
221 | 221 | """Read the old position-based version of a shelvestate file""" |
|
222 | 222 | # Order is important, because old shelvestate file uses it |
|
223 | 223 | # to detemine values of fields (i.g. name is on the second line, |
|
224 | 224 | # originalwctx is on the third and so forth). Please do not change. |
|
225 | 225 | keys = [ |
|
226 | 226 | b'version', |
|
227 | 227 | b'name', |
|
228 | 228 | b'originalwctx', |
|
229 | 229 | b'pendingctx', |
|
230 | 230 | b'parents', |
|
231 | 231 | b'nodestoremove', |
|
232 | 232 | b'branchtorestore', |
|
233 | 233 | b'keep', |
|
234 | 234 | b'activebook', |
|
235 | 235 | ] |
|
236 | 236 | # this is executed only seldomly, so it is not a big deal |
|
237 | 237 | # that we open this file twice |
|
238 | 238 | fp = repo.vfs(cls._filename) |
|
239 | 239 | d = {} |
|
240 | 240 | try: |
|
241 | 241 | for key in keys: |
|
242 | 242 | d[key] = fp.readline().strip() |
|
243 | 243 | finally: |
|
244 | 244 | fp.close() |
|
245 | 245 | return d |
|
246 | 246 | |
|
247 | 247 | @classmethod |
|
248 | 248 | def load(cls, repo): |
|
249 | 249 | version = cls._getversion(repo) |
|
250 | 250 | if version < cls._version: |
|
251 | 251 | d = cls._readold(repo) |
|
252 | 252 | elif version == cls._version: |
|
253 | 253 | d = scmutil.simplekeyvaluefile(repo.vfs, cls._filename).read( |
|
254 | 254 | firstlinenonkeyval=True |
|
255 | 255 | ) |
|
256 | 256 | else: |
|
257 | 257 | raise error.Abort( |
|
258 | 258 | _( |
|
259 | 259 | b'this version of shelve is incompatible ' |
|
260 | 260 | b'with the version used in this repo' |
|
261 | 261 | ) |
|
262 | 262 | ) |
|
263 | 263 | |
|
264 | 264 | cls._verifyandtransform(d) |
|
265 | 265 | try: |
|
266 | 266 | obj = cls() |
|
267 | 267 | obj.name = d[b'name'] |
|
268 | 268 | obj.wctx = repo[d[b'originalwctx']] |
|
269 | 269 | obj.pendingctx = repo[d[b'pendingctx']] |
|
270 | 270 | obj.parents = d[b'parents'] |
|
271 | 271 | obj.nodestoremove = d[b'nodestoremove'] |
|
272 | 272 | obj.branchtorestore = d.get(b'branchtorestore', b'') |
|
273 | 273 | obj.keep = d.get(b'keep') == cls._keep |
|
274 | 274 | obj.activebookmark = b'' |
|
275 | 275 | if d.get(b'activebook', b'') != cls._noactivebook: |
|
276 | 276 | obj.activebookmark = d.get(b'activebook', b'') |
|
277 | 277 | obj.interactive = d.get(b'interactive') == cls._interactive |
|
278 | 278 | except (error.RepoLookupError, KeyError) as err: |
|
279 | 279 | raise error.CorruptedState(pycompat.bytestr(err)) |
|
280 | 280 | |
|
281 | 281 | return obj |
|
282 | 282 | |
|
283 | 283 | @classmethod |
|
284 | 284 | def save( |
|
285 | 285 | cls, |
|
286 | 286 | repo, |
|
287 | 287 | name, |
|
288 | 288 | originalwctx, |
|
289 | 289 | pendingctx, |
|
290 | 290 | nodestoremove, |
|
291 | 291 | branchtorestore, |
|
292 | 292 | keep=False, |
|
293 | 293 | activebook=b'', |
|
294 | 294 | interactive=False, |
|
295 | 295 | ): |
|
296 | 296 | info = { |
|
297 | 297 | b"name": name, |
|
298 | 298 | b"originalwctx": nodemod.hex(originalwctx.node()), |
|
299 | 299 | b"pendingctx": nodemod.hex(pendingctx.node()), |
|
300 | 300 | b"parents": b' '.join( |
|
301 | 301 | [nodemod.hex(p) for p in repo.dirstate.parents()] |
|
302 | 302 | ), |
|
303 | 303 | b"nodestoremove": b' '.join( |
|
304 | 304 | [nodemod.hex(n) for n in nodestoremove] |
|
305 | 305 | ), |
|
306 | 306 | b"branchtorestore": branchtorestore, |
|
307 | 307 | b"keep": cls._keep if keep else cls._nokeep, |
|
308 | 308 | b"activebook": activebook or cls._noactivebook, |
|
309 | 309 | } |
|
310 | 310 | if interactive: |
|
311 | 311 | info[b'interactive'] = cls._interactive |
|
312 | 312 | scmutil.simplekeyvaluefile(repo.vfs, cls._filename).write( |
|
313 | 313 | info, firstline=(b"%d" % cls._version) |
|
314 | 314 | ) |
|
315 | 315 | |
|
316 | 316 | @classmethod |
|
317 | 317 | def clear(cls, repo): |
|
318 | 318 | repo.vfs.unlinkpath(cls._filename, ignoremissing=True) |
|
319 | 319 | |
|
320 | 320 | |
|
321 | 321 | def cleanupoldbackups(repo): |
|
322 | 322 | vfs = vfsmod.vfs(repo.vfs.join(backupdir)) |
|
323 | 323 | maxbackups = repo.ui.configint(b'shelve', b'maxbackups') |
|
324 | 324 | hgfiles = [f for f in vfs.listdir() if f.endswith(b'.' + patchextension)] |
|
325 | 325 | hgfiles = sorted([(vfs.stat(f)[stat.ST_MTIME], f) for f in hgfiles]) |
|
326 | 326 | if maxbackups > 0 and maxbackups < len(hgfiles): |
|
327 | 327 | bordermtime = hgfiles[-maxbackups][0] |
|
328 | 328 | else: |
|
329 | 329 | bordermtime = None |
|
330 | 330 | for mtime, f in hgfiles[: len(hgfiles) - maxbackups]: |
|
331 | 331 | if mtime == bordermtime: |
|
332 | 332 | # keep it, because timestamp can't decide exact order of backups |
|
333 | 333 | continue |
|
334 | 334 | base = f[: -(1 + len(patchextension))] |
|
335 | 335 | for ext in shelvefileextensions: |
|
336 | 336 | vfs.tryunlink(base + b'.' + ext) |
|
337 | 337 | |
|
338 | 338 | |
|
339 | 339 | def _backupactivebookmark(repo): |
|
340 | 340 | activebookmark = repo._activebookmark |
|
341 | 341 | if activebookmark: |
|
342 | 342 | bookmarks.deactivate(repo) |
|
343 | 343 | return activebookmark |
|
344 | 344 | |
|
345 | 345 | |
|
346 | 346 | def _restoreactivebookmark(repo, mark): |
|
347 | 347 | if mark: |
|
348 | 348 | bookmarks.activate(repo, mark) |
|
349 | 349 | |
|
350 | 350 | |
|
351 | 351 | def _aborttransaction(repo, tr): |
|
352 | 352 | '''Abort current transaction for shelve/unshelve, but keep dirstate |
|
353 | 353 | ''' |
|
354 | 354 | dirstatebackupname = b'dirstate.shelve' |
|
355 | 355 | repo.dirstate.savebackup(tr, dirstatebackupname) |
|
356 | 356 | tr.abort() |
|
357 | 357 | repo.dirstate.restorebackup(None, dirstatebackupname) |
|
358 | 358 | |
|
359 | 359 | |
|
360 | 360 | def getshelvename(repo, parent, opts): |
|
361 | 361 | """Decide on the name this shelve is going to have""" |
|
362 | 362 | |
|
363 | 363 | def gennames(): |
|
364 | 364 | yield label |
|
365 | 365 | for i in itertools.count(1): |
|
366 | 366 | yield b'%s-%02d' % (label, i) |
|
367 | 367 | |
|
368 | 368 | name = opts.get(b'name') |
|
369 | 369 | label = repo._activebookmark or parent.branch() or b'default' |
|
370 | 370 | # slashes aren't allowed in filenames, therefore we rename it |
|
371 | 371 | label = label.replace(b'/', b'_') |
|
372 | 372 | label = label.replace(b'\\', b'_') |
|
373 | 373 | # filenames must not start with '.' as it should not be hidden |
|
374 | 374 | if label.startswith(b'.'): |
|
375 | 375 | label = label.replace(b'.', b'_', 1) |
|
376 | 376 | |
|
377 | 377 | if name: |
|
378 | 378 | if shelvedfile(repo, name, patchextension).exists(): |
|
379 | 379 | e = _(b"a shelved change named '%s' already exists") % name |
|
380 | 380 | raise error.Abort(e) |
|
381 | 381 | |
|
382 | 382 | # ensure we are not creating a subdirectory or a hidden file |
|
383 | 383 | if b'/' in name or b'\\' in name: |
|
384 | 384 | raise error.Abort( |
|
385 | 385 | _(b'shelved change names can not contain slashes') |
|
386 | 386 | ) |
|
387 | 387 | if name.startswith(b'.'): |
|
388 | 388 | raise error.Abort(_(b"shelved change names can not start with '.'")) |
|
389 | 389 | |
|
390 | 390 | else: |
|
391 | 391 | for n in gennames(): |
|
392 | 392 | if not shelvedfile(repo, n, patchextension).exists(): |
|
393 | 393 | name = n |
|
394 | 394 | break |
|
395 | 395 | |
|
396 | 396 | return name |
|
397 | 397 | |
|
398 | 398 | |
|
399 | 399 | def mutableancestors(ctx): |
|
400 | 400 | """return all mutable ancestors for ctx (included) |
|
401 | 401 | |
|
402 | 402 | Much faster than the revset ancestors(ctx) & draft()""" |
|
403 | 403 | seen = {nodemod.nullrev} |
|
404 | 404 | visit = collections.deque() |
|
405 | 405 | visit.append(ctx) |
|
406 | 406 | while visit: |
|
407 | 407 | ctx = visit.popleft() |
|
408 | 408 | yield ctx.node() |
|
409 | 409 | for parent in ctx.parents(): |
|
410 | 410 | rev = parent.rev() |
|
411 | 411 | if rev not in seen: |
|
412 | 412 | seen.add(rev) |
|
413 | 413 | if parent.mutable(): |
|
414 | 414 | visit.append(parent) |
|
415 | 415 | |
|
416 | 416 | |
|
417 | 417 | def getcommitfunc(extra, interactive, editor=False): |
|
418 | 418 | def commitfunc(ui, repo, message, match, opts): |
|
419 | 419 | hasmq = util.safehasattr(repo, b'mq') |
|
420 | 420 | if hasmq: |
|
421 | 421 | saved, repo.mq.checkapplied = repo.mq.checkapplied, False |
|
422 | 422 | |
|
423 | 423 | targetphase = phases.internal |
|
424 | 424 | if not phases.supportinternal(repo): |
|
425 | 425 | targetphase = phases.secret |
|
426 | 426 | overrides = {(b'phases', b'new-commit'): targetphase} |
|
427 | 427 | try: |
|
428 | 428 | editor_ = False |
|
429 | 429 | if editor: |
|
430 | 430 | editor_ = cmdutil.getcommiteditor( |
|
431 | 431 | editform=b'shelve.shelve', **pycompat.strkwargs(opts) |
|
432 | 432 | ) |
|
433 | 433 | with repo.ui.configoverride(overrides): |
|
434 | 434 | return repo.commit( |
|
435 | 435 | message, |
|
436 | 436 | shelveuser, |
|
437 | 437 | opts.get(b'date'), |
|
438 | 438 | match, |
|
439 | 439 | editor=editor_, |
|
440 | 440 | extra=extra, |
|
441 | 441 | ) |
|
442 | 442 | finally: |
|
443 | 443 | if hasmq: |
|
444 | 444 | repo.mq.checkapplied = saved |
|
445 | 445 | |
|
446 | 446 | def interactivecommitfunc(ui, repo, *pats, **opts): |
|
447 | 447 | opts = pycompat.byteskwargs(opts) |
|
448 | 448 | match = scmutil.match(repo[b'.'], pats, {}) |
|
449 | 449 | message = opts[b'message'] |
|
450 | 450 | return commitfunc(ui, repo, message, match, opts) |
|
451 | 451 | |
|
452 | 452 | return interactivecommitfunc if interactive else commitfunc |
|
453 | 453 | |
|
454 | 454 | |
|
455 | 455 | def _nothingtoshelvemessaging(ui, repo, pats, opts): |
|
456 | 456 | stat = repo.status(match=scmutil.match(repo[None], pats, opts)) |
|
457 | 457 | if stat.deleted: |
|
458 | 458 | ui.status( |
|
459 | 459 | _(b"nothing changed (%d missing files, see 'hg status')\n") |
|
460 | 460 | % len(stat.deleted) |
|
461 | 461 | ) |
|
462 | 462 | else: |
|
463 | 463 | ui.status(_(b"nothing changed\n")) |
|
464 | 464 | |
|
465 | 465 | |
|
466 | 466 | def _shelvecreatedcommit(repo, node, name, match): |
|
467 | 467 | info = {b'node': nodemod.hex(node)} |
|
468 | 468 | shelvedfile(repo, name, b'shelve').writeinfo(info) |
|
469 | 469 | bases = list(mutableancestors(repo[node])) |
|
470 | 470 | shelvedfile(repo, name, b'hg').writebundle(bases, node) |
|
471 | 471 | with shelvedfile(repo, name, patchextension).opener(b'wb') as fp: |
|
472 | 472 | cmdutil.exportfile( |
|
473 | 473 | repo, [node], fp, opts=mdiff.diffopts(git=True), match=match |
|
474 | 474 | ) |
|
475 | 475 | |
|
476 | 476 | |
|
477 | 477 | def _includeunknownfiles(repo, pats, opts, extra): |
|
478 | 478 | s = repo.status(match=scmutil.match(repo[None], pats, opts), unknown=True) |
|
479 | 479 | if s.unknown: |
|
480 | 480 | extra[b'shelve_unknown'] = b'\0'.join(s.unknown) |
|
481 | 481 | repo[None].add(s.unknown) |
|
482 | 482 | |
|
483 | 483 | |
|
484 | 484 | def _finishshelve(repo, tr): |
|
485 | 485 | if phases.supportinternal(repo): |
|
486 | 486 | tr.close() |
|
487 | 487 | else: |
|
488 | 488 | _aborttransaction(repo, tr) |
|
489 | 489 | |
|
490 | 490 | |
|
491 | 491 | def createcmd(ui, repo, pats, opts): |
|
492 | 492 | """subcommand that creates a new shelve""" |
|
493 | 493 | with repo.wlock(): |
|
494 | 494 | cmdutil.checkunfinished(repo) |
|
495 | 495 | return _docreatecmd(ui, repo, pats, opts) |
|
496 | 496 | |
|
497 | 497 | |
|
498 | 498 | def _docreatecmd(ui, repo, pats, opts): |
|
499 | 499 | wctx = repo[None] |
|
500 | 500 | parents = wctx.parents() |
|
501 | 501 | parent = parents[0] |
|
502 | 502 | origbranch = wctx.branch() |
|
503 | 503 | |
|
504 | 504 | if parent.node() != nodemod.nullid: |
|
505 | 505 | desc = b"changes to: %s" % parent.description().split(b'\n', 1)[0] |
|
506 | 506 | else: |
|
507 | 507 | desc = b'(changes in empty repository)' |
|
508 | 508 | |
|
509 | 509 | if not opts.get(b'message'): |
|
510 | 510 | opts[b'message'] = desc |
|
511 | 511 | |
|
512 | 512 | lock = tr = activebookmark = None |
|
513 | 513 | try: |
|
514 | 514 | lock = repo.lock() |
|
515 | 515 | |
|
516 | 516 | # use an uncommitted transaction to generate the bundle to avoid |
|
517 | 517 | # pull races. ensure we don't print the abort message to stderr. |
|
518 | 518 | tr = repo.transaction(b'shelve', report=lambda x: None) |
|
519 | 519 | |
|
520 | 520 | interactive = opts.get(b'interactive', False) |
|
521 | 521 | includeunknown = opts.get(b'unknown', False) and not opts.get( |
|
522 | 522 | b'addremove', False |
|
523 | 523 | ) |
|
524 | 524 | |
|
525 | 525 | name = getshelvename(repo, parent, opts) |
|
526 | 526 | activebookmark = _backupactivebookmark(repo) |
|
527 | 527 | extra = {b'internal': b'shelve'} |
|
528 | 528 | if includeunknown: |
|
529 | 529 | _includeunknownfiles(repo, pats, opts, extra) |
|
530 | 530 | |
|
531 | 531 | if _iswctxonnewbranch(repo) and not _isbareshelve(pats, opts): |
|
532 | 532 | # In non-bare shelve we don't store newly created branch |
|
533 | 533 | # at bundled commit |
|
534 | 534 | repo.dirstate.setbranch(repo[b'.'].branch()) |
|
535 | 535 | |
|
536 | 536 | commitfunc = getcommitfunc(extra, interactive, editor=True) |
|
537 | 537 | if not interactive: |
|
538 | 538 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
|
539 | 539 | else: |
|
540 | 540 | node = cmdutil.dorecord( |
|
541 | 541 | ui, |
|
542 | 542 | repo, |
|
543 | 543 | commitfunc, |
|
544 | 544 | None, |
|
545 | 545 | False, |
|
546 | 546 | cmdutil.recordfilter, |
|
547 | 547 | *pats, |
|
548 | 548 | **pycompat.strkwargs(opts) |
|
549 | 549 | ) |
|
550 | 550 | if not node: |
|
551 | 551 | _nothingtoshelvemessaging(ui, repo, pats, opts) |
|
552 | 552 | return 1 |
|
553 | 553 | |
|
554 | 554 | # Create a matcher so that prefetch doesn't attempt to fetch |
|
555 | 555 | # the entire repository pointlessly, and as an optimisation |
|
556 | 556 | # for movedirstate, if needed. |
|
557 | 557 | match = scmutil.matchfiles(repo, repo[node].files()) |
|
558 | 558 | _shelvecreatedcommit(repo, node, name, match) |
|
559 | 559 | |
|
560 | 560 | ui.status(_(b'shelved as %s\n') % name) |
|
561 | 561 | if opts[b'keep']: |
|
562 | 562 | with repo.dirstate.parentchange(): |
|
563 | 563 | scmutil.movedirstate(repo, parent, match) |
|
564 | 564 | else: |
|
565 | 565 | hg.update(repo, parent.node()) |
|
566 | 566 | if origbranch != repo[b'.'].branch() and not _isbareshelve(pats, opts): |
|
567 | 567 | repo.dirstate.setbranch(origbranch) |
|
568 | 568 | |
|
569 | 569 | _finishshelve(repo, tr) |
|
570 | 570 | finally: |
|
571 | 571 | _restoreactivebookmark(repo, activebookmark) |
|
572 | 572 | lockmod.release(tr, lock) |
|
573 | 573 | |
|
574 | 574 | |
|
575 | 575 | def _isbareshelve(pats, opts): |
|
576 | 576 | return ( |
|
577 | 577 | not pats |
|
578 | 578 | and not opts.get(b'interactive', False) |
|
579 | 579 | and not opts.get(b'include', False) |
|
580 | 580 | and not opts.get(b'exclude', False) |
|
581 | 581 | ) |
|
582 | 582 | |
|
583 | 583 | |
|
584 | 584 | def _iswctxonnewbranch(repo): |
|
585 | 585 | return repo[None].branch() != repo[b'.'].branch() |
|
586 | 586 | |
|
587 | 587 | |
|
588 | 588 | def cleanupcmd(ui, repo): |
|
589 | 589 | """subcommand that deletes all shelves""" |
|
590 | 590 | |
|
591 | 591 | with repo.wlock(): |
|
592 | 592 | for (name, _type) in repo.vfs.readdir(shelvedir): |
|
593 | 593 | suffix = name.rsplit(b'.', 1)[-1] |
|
594 | 594 | if suffix in shelvefileextensions: |
|
595 | 595 | shelvedfile(repo, name).movetobackup() |
|
596 | 596 | cleanupoldbackups(repo) |
|
597 | 597 | |
|
598 | 598 | |
|
599 | 599 | def deletecmd(ui, repo, pats): |
|
600 | 600 | """subcommand that deletes a specific shelve""" |
|
601 | 601 | if not pats: |
|
602 | 602 | raise error.Abort(_(b'no shelved changes specified!')) |
|
603 | 603 | with repo.wlock(): |
|
604 | 604 | for name in pats: |
|
605 | 605 | try: |
|
606 | 606 | for suffix in shelvefileextensions: |
|
607 | 607 | shfile = shelvedfile(repo, name, suffix) |
|
608 | 608 | # patch file is necessary, as it should |
|
609 | 609 | # be present for any kind of shelve, |
|
610 | 610 | # but the .hg file is optional as in future we |
|
611 | 611 | # will add obsolete shelve with does not create a |
|
612 | 612 | # bundle |
|
613 | 613 | if shfile.exists() or suffix == patchextension: |
|
614 | 614 | shfile.movetobackup() |
|
615 | 615 | except OSError as err: |
|
616 | 616 | if err.errno != errno.ENOENT: |
|
617 | 617 | raise |
|
618 | 618 | raise error.Abort(_(b"shelved change '%s' not found") % name) |
|
619 | 619 | cleanupoldbackups(repo) |
|
620 | 620 | |
|
621 | 621 | |
|
622 | 622 | def listshelves(repo): |
|
623 | 623 | """return all shelves in repo as list of (time, filename)""" |
|
624 | 624 | try: |
|
625 | 625 | names = repo.vfs.readdir(shelvedir) |
|
626 | 626 | except OSError as err: |
|
627 | 627 | if err.errno != errno.ENOENT: |
|
628 | 628 | raise |
|
629 | 629 | return [] |
|
630 | 630 | info = [] |
|
631 | 631 | for (name, _type) in names: |
|
632 | 632 | pfx, sfx = name.rsplit(b'.', 1) |
|
633 | 633 | if not pfx or sfx != patchextension: |
|
634 | 634 | continue |
|
635 | 635 | st = shelvedfile(repo, name).stat() |
|
636 | 636 | info.append((st[stat.ST_MTIME], shelvedfile(repo, pfx).filename())) |
|
637 | 637 | return sorted(info, reverse=True) |
|
638 | 638 | |
|
639 | 639 | |
|
640 | 640 | def listcmd(ui, repo, pats, opts): |
|
641 | 641 | """subcommand that displays the list of shelves""" |
|
642 | 642 | pats = set(pats) |
|
643 | 643 | width = 80 |
|
644 | 644 | if not ui.plain(): |
|
645 | 645 | width = ui.termwidth() |
|
646 | 646 | namelabel = b'shelve.newest' |
|
647 | 647 | ui.pager(b'shelve') |
|
648 | 648 | for mtime, name in listshelves(repo): |
|
649 | 649 | sname = util.split(name)[1] |
|
650 | 650 | if pats and sname not in pats: |
|
651 | 651 | continue |
|
652 | 652 | ui.write(sname, label=namelabel) |
|
653 | 653 | namelabel = b'shelve.name' |
|
654 | 654 | if ui.quiet: |
|
655 | 655 | ui.write(b'\n') |
|
656 | 656 | continue |
|
657 | 657 | ui.write(b' ' * (16 - len(sname))) |
|
658 | 658 | used = 16 |
|
659 | 659 | date = dateutil.makedate(mtime) |
|
660 | 660 | age = b'(%s)' % templatefilters.age(date, abbrev=True) |
|
661 | 661 | ui.write(age, label=b'shelve.age') |
|
662 | 662 | ui.write(b' ' * (12 - len(age))) |
|
663 | 663 | used += 12 |
|
664 | 664 | with open(name + b'.' + patchextension, b'rb') as fp: |
|
665 | 665 | while True: |
|
666 | 666 | line = fp.readline() |
|
667 | 667 | if not line: |
|
668 | 668 | break |
|
669 | 669 | if not line.startswith(b'#'): |
|
670 | 670 | desc = line.rstrip() |
|
671 | 671 | if ui.formatted(): |
|
672 | 672 | desc = stringutil.ellipsis(desc, width - used) |
|
673 | 673 | ui.write(desc) |
|
674 | 674 | break |
|
675 | 675 | ui.write(b'\n') |
|
676 | 676 | if not (opts[b'patch'] or opts[b'stat']): |
|
677 | 677 | continue |
|
678 | 678 | difflines = fp.readlines() |
|
679 | 679 | if opts[b'patch']: |
|
680 | 680 | for chunk, label in patch.difflabel(iter, difflines): |
|
681 | 681 | ui.write(chunk, label=label) |
|
682 | 682 | if opts[b'stat']: |
|
683 | 683 | for chunk, label in patch.diffstatui(difflines, width=width): |
|
684 | 684 | ui.write(chunk, label=label) |
|
685 | 685 | |
|
686 | 686 | |
|
687 | 687 | def patchcmds(ui, repo, pats, opts): |
|
688 | 688 | """subcommand that displays shelves""" |
|
689 | 689 | if len(pats) == 0: |
|
690 | 690 | shelves = listshelves(repo) |
|
691 | 691 | if not shelves: |
|
692 | 692 | raise error.Abort(_(b"there are no shelves to show")) |
|
693 | 693 | mtime, name = shelves[0] |
|
694 | 694 | sname = util.split(name)[1] |
|
695 | 695 | pats = [sname] |
|
696 | 696 | |
|
697 | 697 | for shelfname in pats: |
|
698 | 698 | if not shelvedfile(repo, shelfname, patchextension).exists(): |
|
699 | 699 | raise error.Abort(_(b"cannot find shelf %s") % shelfname) |
|
700 | 700 | |
|
701 | 701 | listcmd(ui, repo, pats, opts) |
|
702 | 702 | |
|
703 | 703 | |
|
704 | 704 | def checkparents(repo, state): |
|
705 | 705 | """check parent while resuming an unshelve""" |
|
706 | 706 | if state.parents != repo.dirstate.parents(): |
|
707 | 707 | raise error.Abort( |
|
708 | 708 | _(b'working directory parents do not match unshelve state') |
|
709 | 709 | ) |
|
710 | 710 | |
|
711 | 711 | |
|
712 | 712 | def _loadshelvedstate(ui, repo, opts): |
|
713 | 713 | try: |
|
714 | 714 | state = shelvedstate.load(repo) |
|
715 | 715 | if opts.get(b'keep') is None: |
|
716 | 716 | opts[b'keep'] = state.keep |
|
717 | 717 | except IOError as err: |
|
718 | 718 | if err.errno != errno.ENOENT: |
|
719 | 719 | raise |
|
720 | 720 | cmdutil.wrongtooltocontinue(repo, _(b'unshelve')) |
|
721 | 721 | except error.CorruptedState as err: |
|
722 | 722 | ui.debug(pycompat.bytestr(err) + b'\n') |
|
723 | 723 | if opts.get(b'continue'): |
|
724 | 724 | msg = _(b'corrupted shelved state file') |
|
725 | 725 | hint = _( |
|
726 | 726 | b'please run hg unshelve --abort to abort unshelve ' |
|
727 | 727 | b'operation' |
|
728 | 728 | ) |
|
729 | 729 | raise error.Abort(msg, hint=hint) |
|
730 | 730 | elif opts.get(b'abort'): |
|
731 | 731 | shelvedstate.clear(repo) |
|
732 | 732 | raise error.Abort( |
|
733 | 733 | _( |
|
734 | 734 | b'could not read shelved state file, your ' |
|
735 | 735 | b'working copy may be in an unexpected state\n' |
|
736 | 736 | b'please update to some commit\n' |
|
737 | 737 | ) |
|
738 | 738 | ) |
|
739 | 739 | return state |
|
740 | 740 | |
|
741 | 741 | |
|
742 | 742 | def unshelveabort(ui, repo, state): |
|
743 | 743 | """subcommand that abort an in-progress unshelve""" |
|
744 | 744 | with repo.lock(): |
|
745 | 745 | try: |
|
746 | 746 | checkparents(repo, state) |
|
747 | 747 | |
|
748 | 748 | merge.update(repo, state.pendingctx, branchmerge=False, force=True) |
|
749 | 749 | if state.activebookmark and state.activebookmark in repo._bookmarks: |
|
750 | 750 | bookmarks.activate(repo, state.activebookmark) |
|
751 | 751 | mergefiles(ui, repo, state.wctx, state.pendingctx) |
|
752 | 752 | if not phases.supportinternal(repo): |
|
753 | 753 | repair.strip( |
|
754 | 754 | ui, repo, state.nodestoremove, backup=False, topic=b'shelve' |
|
755 | 755 | ) |
|
756 | 756 | finally: |
|
757 | 757 | shelvedstate.clear(repo) |
|
758 | 758 | ui.warn(_(b"unshelve of '%s' aborted\n") % state.name) |
|
759 | 759 | |
|
760 | 760 | |
|
761 | 761 | def hgabortunshelve(ui, repo): |
|
762 | 762 | """logic to abort unshelve using 'hg abort""" |
|
763 | 763 | with repo.wlock(): |
|
764 | 764 | state = _loadshelvedstate(ui, repo, {b'abort': True}) |
|
765 | 765 | return unshelveabort(ui, repo, state) |
|
766 | 766 | |
|
767 | 767 | |
|
768 | 768 | def mergefiles(ui, repo, wctx, shelvectx): |
|
769 | 769 | """updates to wctx and merges the changes from shelvectx into the |
|
770 | 770 | dirstate.""" |
|
771 | 771 | with ui.configoverride({(b'ui', b'quiet'): True}): |
|
772 | 772 | hg.update(repo, wctx.node()) |
|
773 | 773 | ui.pushbuffer(True) |
|
774 | 774 | cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents()) |
|
775 | 775 | ui.popbuffer() |
|
776 | 776 | |
|
777 | 777 | |
|
778 | 778 | def restorebranch(ui, repo, branchtorestore): |
|
779 | 779 | if branchtorestore and branchtorestore != repo.dirstate.branch(): |
|
780 | 780 | repo.dirstate.setbranch(branchtorestore) |
|
781 | 781 | ui.status( |
|
782 | 782 | _(b'marked working directory as branch %s\n') % branchtorestore |
|
783 | 783 | ) |
|
784 | 784 | |
|
785 | 785 | |
|
786 | 786 | def unshelvecleanup(ui, repo, name, opts): |
|
787 | 787 | """remove related files after an unshelve""" |
|
788 | 788 | if not opts.get(b'keep'): |
|
789 | 789 | for filetype in shelvefileextensions: |
|
790 | 790 | shfile = shelvedfile(repo, name, filetype) |
|
791 | 791 | if shfile.exists(): |
|
792 | 792 | shfile.movetobackup() |
|
793 | 793 | cleanupoldbackups(repo) |
|
794 | 794 | |
|
795 | 795 | |
|
796 | 796 | def unshelvecontinue(ui, repo, state, opts): |
|
797 | 797 | """subcommand to continue an in-progress unshelve""" |
|
798 | 798 | # We're finishing off a merge. First parent is our original |
|
799 | 799 | # parent, second is the temporary "fake" commit we're unshelving. |
|
800 | 800 | interactive = state.interactive |
|
801 | 801 | basename = state.name |
|
802 | 802 | with repo.lock(): |
|
803 | 803 | checkparents(repo, state) |
|
804 | 804 | ms = merge.mergestate.read(repo) |
|
805 | 805 | if list(ms.unresolved()): |
|
806 | 806 | raise error.Abort( |
|
807 | 807 | _(b"unresolved conflicts, can't continue"), |
|
808 | 808 | hint=_(b"see 'hg resolve', then 'hg unshelve --continue'"), |
|
809 | 809 | ) |
|
810 | 810 | |
|
811 | 811 | shelvectx = repo[state.parents[1]] |
|
812 | 812 | pendingctx = state.pendingctx |
|
813 | 813 | |
|
814 | 814 | with repo.dirstate.parentchange(): |
|
815 | 815 | repo.setparents(state.pendingctx.node(), nodemod.nullid) |
|
816 | 816 | repo.dirstate.write(repo.currenttransaction()) |
|
817 | 817 | |
|
818 | 818 | targetphase = phases.internal |
|
819 | 819 | if not phases.supportinternal(repo): |
|
820 | 820 | targetphase = phases.secret |
|
821 | 821 | overrides = {(b'phases', b'new-commit'): targetphase} |
|
822 | 822 | with repo.ui.configoverride(overrides, b'unshelve'): |
|
823 | 823 | with repo.dirstate.parentchange(): |
|
824 | 824 | repo.setparents(state.parents[0], nodemod.nullid) |
|
825 | 825 | newnode, ispartialunshelve = _createunshelvectx( |
|
826 | 826 | ui, repo, shelvectx, basename, interactive, opts |
|
827 | 827 | ) |
|
828 | 828 | |
|
829 | 829 | if newnode is None: |
|
830 | 830 | # If it ended up being a no-op commit, then the normal |
|
831 | 831 | # merge state clean-up path doesn't happen, so do it |
|
832 | 832 | # here. Fix issue5494 |
|
833 | 833 | merge.mergestate.clean(repo) |
|
834 | 834 | shelvectx = state.pendingctx |
|
835 | 835 | msg = _( |
|
836 | 836 | b'note: unshelved changes already existed ' |
|
837 | 837 | b'in the working copy\n' |
|
838 | 838 | ) |
|
839 | 839 | ui.status(msg) |
|
840 | 840 | else: |
|
841 | 841 | # only strip the shelvectx if we produced one |
|
842 | 842 | state.nodestoremove.append(newnode) |
|
843 | 843 | shelvectx = repo[newnode] |
|
844 | 844 | |
|
845 | 845 | hg.updaterepo(repo, pendingctx.node(), overwrite=False) |
|
846 | 846 | mergefiles(ui, repo, state.wctx, shelvectx) |
|
847 | 847 | restorebranch(ui, repo, state.branchtorestore) |
|
848 | 848 | |
|
849 | 849 | if not phases.supportinternal(repo): |
|
850 | 850 | repair.strip( |
|
851 | 851 | ui, repo, state.nodestoremove, backup=False, topic=b'shelve' |
|
852 | 852 | ) |
|
853 | 853 | shelvedstate.clear(repo) |
|
854 | 854 | if not ispartialunshelve: |
|
855 | 855 | unshelvecleanup(ui, repo, state.name, opts) |
|
856 | 856 | _restoreactivebookmark(repo, state.activebookmark) |
|
857 | 857 | ui.status(_(b"unshelve of '%s' complete\n") % state.name) |
|
858 | 858 | |
|
859 | 859 | |
|
860 | 860 | def hgcontinueunshelve(ui, repo): |
|
861 | 861 | """logic to resume unshelve using 'hg continue'""" |
|
862 | 862 | with repo.wlock(): |
|
863 | 863 | state = _loadshelvedstate(ui, repo, {b'continue': True}) |
|
864 | 864 | return unshelvecontinue(ui, repo, state, {b'keep': state.keep}) |
|
865 | 865 | |
|
866 | 866 | |
|
867 | 867 | def _commitworkingcopychanges(ui, repo, opts, tmpwctx): |
|
868 | 868 | """Temporarily commit working copy changes before moving unshelve commit""" |
|
869 | 869 | # Store pending changes in a commit and remember added in case a shelve |
|
870 | 870 | # contains unknown files that are part of the pending change |
|
871 | 871 | s = repo.status() |
|
872 | 872 | addedbefore = frozenset(s.added) |
|
873 | 873 | if not (s.modified or s.added or s.removed): |
|
874 | 874 | return tmpwctx, addedbefore |
|
875 | 875 | ui.status( |
|
876 | 876 | _( |
|
877 | 877 | b"temporarily committing pending changes " |
|
878 | 878 | b"(restore with 'hg unshelve --abort')\n" |
|
879 | 879 | ) |
|
880 | 880 | ) |
|
881 | 881 | extra = {b'internal': b'shelve'} |
|
882 | 882 | commitfunc = getcommitfunc(extra=extra, interactive=False, editor=False) |
|
883 | 883 | tempopts = {} |
|
884 | 884 | tempopts[b'message'] = b"pending changes temporary commit" |
|
885 | 885 | tempopts[b'date'] = opts.get(b'date') |
|
886 | 886 | with ui.configoverride({(b'ui', b'quiet'): True}): |
|
887 | 887 | node = cmdutil.commit(ui, repo, commitfunc, [], tempopts) |
|
888 | 888 | tmpwctx = repo[node] |
|
889 | 889 | return tmpwctx, addedbefore |
|
890 | 890 | |
|
891 | 891 | |
|
892 | 892 | def _unshelverestorecommit(ui, repo, tr, basename): |
|
893 | 893 | """Recreate commit in the repository during the unshelve""" |
|
894 | 894 | repo = repo.unfiltered() |
|
895 | 895 | node = None |
|
896 | 896 | if shelvedfile(repo, basename, b'shelve').exists(): |
|
897 | 897 | node = shelvedfile(repo, basename, b'shelve').readinfo()[b'node'] |
|
898 | 898 | if node is None or node not in repo: |
|
899 | 899 | with ui.configoverride({(b'ui', b'quiet'): True}): |
|
900 | 900 | shelvectx = shelvedfile(repo, basename, b'hg').applybundle(tr) |
|
901 | 901 | # We might not strip the unbundled changeset, so we should keep track of |
|
902 | 902 | # the unshelve node in case we need to reuse it (eg: unshelve --keep) |
|
903 | 903 | if node is None: |
|
904 | 904 | info = {b'node': nodemod.hex(shelvectx.node())} |
|
905 | 905 | shelvedfile(repo, basename, b'shelve').writeinfo(info) |
|
906 | 906 | else: |
|
907 | 907 | shelvectx = repo[node] |
|
908 | 908 | |
|
909 | 909 | return repo, shelvectx |
|
910 | 910 | |
|
911 | 911 | |
|
912 | 912 | def _createunshelvectx(ui, repo, shelvectx, basename, interactive, opts): |
|
913 | 913 | """Handles the creation of unshelve commit and updates the shelve if it |
|
914 | 914 | was partially unshelved. |
|
915 | 915 | |
|
916 | 916 | If interactive is: |
|
917 | 917 | |
|
918 | 918 | * False: Commits all the changes in the working directory. |
|
919 | 919 | * True: Prompts the user to select changes to unshelve and commit them. |
|
920 | 920 | Update the shelve with remaining changes. |
|
921 | 921 | |
|
922 | 922 | Returns the node of the new commit formed and a bool indicating whether |
|
923 | 923 | the shelve was partially unshelved.Creates a commit ctx to unshelve |
|
924 | 924 | interactively or non-interactively. |
|
925 | 925 | |
|
926 | 926 | The user might want to unshelve certain changes only from the stored |
|
927 | 927 | shelve in interactive. So, we would create two commits. One with requested |
|
928 | 928 | changes to unshelve at that time and the latter is shelved for future. |
|
929 | 929 | |
|
930 | 930 | Here, we return both the newnode which is created interactively and a |
|
931 | 931 | bool to know whether the shelve is partly done or completely done. |
|
932 | 932 | """ |
|
933 | 933 | opts[b'message'] = shelvectx.description() |
|
934 | 934 | opts[b'interactive-unshelve'] = True |
|
935 | 935 | pats = [] |
|
936 | 936 | if not interactive: |
|
937 | 937 | newnode = repo.commit( |
|
938 | 938 | text=shelvectx.description(), |
|
939 | 939 | extra=shelvectx.extra(), |
|
940 | 940 | user=shelvectx.user(), |
|
941 | 941 | date=shelvectx.date(), |
|
942 | 942 | ) |
|
943 | 943 | return newnode, False |
|
944 | 944 | |
|
945 | 945 | commitfunc = getcommitfunc(shelvectx.extra(), interactive=True, editor=True) |
|
946 | 946 | newnode = cmdutil.dorecord( |
|
947 | 947 | ui, |
|
948 | 948 | repo, |
|
949 | 949 | commitfunc, |
|
950 | 950 | None, |
|
951 | 951 | False, |
|
952 | 952 | cmdutil.recordfilter, |
|
953 | 953 | *pats, |
|
954 | 954 | **pycompat.strkwargs(opts) |
|
955 | 955 | ) |
|
956 | 956 | snode = repo.commit( |
|
957 | 957 | text=shelvectx.description(), |
|
958 | 958 | extra=shelvectx.extra(), |
|
959 | 959 | user=shelvectx.user(), |
|
960 | 960 | ) |
|
961 | 961 | if snode: |
|
962 | 962 | m = scmutil.matchfiles(repo, repo[snode].files()) |
|
963 | 963 | _shelvecreatedcommit(repo, snode, basename, m) |
|
964 | 964 | |
|
965 | 965 | return newnode, bool(snode) |
|
966 | 966 | |
|
967 | 967 | |
|
968 | 968 | def _rebaserestoredcommit( |
|
969 | 969 | ui, |
|
970 | 970 | repo, |
|
971 | 971 | opts, |
|
972 | 972 | tr, |
|
973 | 973 | oldtiprev, |
|
974 | 974 | basename, |
|
975 | 975 | pctx, |
|
976 | 976 | tmpwctx, |
|
977 | 977 | shelvectx, |
|
978 | 978 | branchtorestore, |
|
979 | 979 | activebookmark, |
|
980 | 980 | ): |
|
981 | 981 | """Rebase restored commit from its original location to a destination""" |
|
982 | 982 | # If the shelve is not immediately on top of the commit |
|
983 | 983 | # we'll be merging with, rebase it to be on top. |
|
984 | 984 | interactive = opts.get(b'interactive') |
|
985 | 985 | if tmpwctx.node() == shelvectx.p1().node() and not interactive: |
|
986 | 986 | # We won't skip on interactive mode because, the user might want to |
|
987 | 987 | # unshelve certain changes only. |
|
988 | 988 | return shelvectx, False |
|
989 | 989 | |
|
990 | 990 | overrides = { |
|
991 | 991 | (b'ui', b'forcemerge'): opts.get(b'tool', b''), |
|
992 | 992 | (b'phases', b'new-commit'): phases.secret, |
|
993 | 993 | } |
|
994 | 994 | with repo.ui.configoverride(overrides, b'unshelve'): |
|
995 | 995 | ui.status(_(b'rebasing shelved changes\n')) |
|
996 | 996 | stats = merge.graft( |
|
997 | 997 | repo, |
|
998 | 998 | shelvectx, |
|
999 | 999 | shelvectx.p1(), |
|
1000 |
labels=[b' |
|
|
1000 | labels=[b'working-copy', b'shelve'], | |
|
1001 | 1001 | keepconflictparent=True, |
|
1002 | 1002 | ) |
|
1003 | 1003 | if stats.unresolvedcount: |
|
1004 | 1004 | tr.close() |
|
1005 | 1005 | |
|
1006 | 1006 | nodestoremove = [ |
|
1007 | 1007 | repo.changelog.node(rev) |
|
1008 | 1008 | for rev in pycompat.xrange(oldtiprev, len(repo)) |
|
1009 | 1009 | ] |
|
1010 | 1010 | shelvedstate.save( |
|
1011 | 1011 | repo, |
|
1012 | 1012 | basename, |
|
1013 | 1013 | pctx, |
|
1014 | 1014 | tmpwctx, |
|
1015 | 1015 | nodestoremove, |
|
1016 | 1016 | branchtorestore, |
|
1017 | 1017 | opts.get(b'keep'), |
|
1018 | 1018 | activebookmark, |
|
1019 | 1019 | interactive, |
|
1020 | 1020 | ) |
|
1021 | 1021 | raise error.InterventionRequired( |
|
1022 | 1022 | _( |
|
1023 | 1023 | b"unresolved conflicts (see 'hg resolve', then " |
|
1024 | 1024 | b"'hg unshelve --continue')" |
|
1025 | 1025 | ) |
|
1026 | 1026 | ) |
|
1027 | 1027 | |
|
1028 | 1028 | with repo.dirstate.parentchange(): |
|
1029 | 1029 | repo.setparents(tmpwctx.node(), nodemod.nullid) |
|
1030 | 1030 | newnode, ispartialunshelve = _createunshelvectx( |
|
1031 | 1031 | ui, repo, shelvectx, basename, interactive, opts |
|
1032 | 1032 | ) |
|
1033 | 1033 | |
|
1034 | 1034 | if newnode is None: |
|
1035 | 1035 | # If it ended up being a no-op commit, then the normal |
|
1036 | 1036 | # merge state clean-up path doesn't happen, so do it |
|
1037 | 1037 | # here. Fix issue5494 |
|
1038 | 1038 | merge.mergestate.clean(repo) |
|
1039 | 1039 | shelvectx = tmpwctx |
|
1040 | 1040 | msg = _( |
|
1041 | 1041 | b'note: unshelved changes already existed ' |
|
1042 | 1042 | b'in the working copy\n' |
|
1043 | 1043 | ) |
|
1044 | 1044 | ui.status(msg) |
|
1045 | 1045 | else: |
|
1046 | 1046 | shelvectx = repo[newnode] |
|
1047 | 1047 | hg.updaterepo(repo, tmpwctx.node(), False) |
|
1048 | 1048 | |
|
1049 | 1049 | return shelvectx, ispartialunshelve |
|
1050 | 1050 | |
|
1051 | 1051 | |
|
1052 | 1052 | def _forgetunknownfiles(repo, shelvectx, addedbefore): |
|
1053 | 1053 | # Forget any files that were unknown before the shelve, unknown before |
|
1054 | 1054 | # unshelve started, but are now added. |
|
1055 | 1055 | shelveunknown = shelvectx.extra().get(b'shelve_unknown') |
|
1056 | 1056 | if not shelveunknown: |
|
1057 | 1057 | return |
|
1058 | 1058 | shelveunknown = frozenset(shelveunknown.split(b'\0')) |
|
1059 | 1059 | addedafter = frozenset(repo.status().added) |
|
1060 | 1060 | toforget = (addedafter & shelveunknown) - addedbefore |
|
1061 | 1061 | repo[None].forget(toforget) |
|
1062 | 1062 | |
|
1063 | 1063 | |
|
1064 | 1064 | def _finishunshelve(repo, oldtiprev, tr, activebookmark): |
|
1065 | 1065 | _restoreactivebookmark(repo, activebookmark) |
|
1066 | 1066 | # The transaction aborting will strip all the commits for us, |
|
1067 | 1067 | # but it doesn't update the inmemory structures, so addchangegroup |
|
1068 | 1068 | # hooks still fire and try to operate on the missing commits. |
|
1069 | 1069 | # Clean up manually to prevent this. |
|
1070 | 1070 | repo.unfiltered().changelog.strip(oldtiprev, tr) |
|
1071 | 1071 | _aborttransaction(repo, tr) |
|
1072 | 1072 | |
|
1073 | 1073 | |
|
1074 | 1074 | def _checkunshelveuntrackedproblems(ui, repo, shelvectx): |
|
1075 | 1075 | """Check potential problems which may result from working |
|
1076 | 1076 | copy having untracked changes.""" |
|
1077 | 1077 | wcdeleted = set(repo.status().deleted) |
|
1078 | 1078 | shelvetouched = set(shelvectx.files()) |
|
1079 | 1079 | intersection = wcdeleted.intersection(shelvetouched) |
|
1080 | 1080 | if intersection: |
|
1081 | 1081 | m = _(b"shelved change touches missing files") |
|
1082 | 1082 | hint = _(b"run hg status to see which files are missing") |
|
1083 | 1083 | raise error.Abort(m, hint=hint) |
|
1084 | 1084 | |
|
1085 | 1085 | |
|
1086 | 1086 | def dounshelve(ui, repo, *shelved, **opts): |
|
1087 | 1087 | opts = pycompat.byteskwargs(opts) |
|
1088 | 1088 | abortf = opts.get(b'abort') |
|
1089 | 1089 | continuef = opts.get(b'continue') |
|
1090 | 1090 | interactive = opts.get(b'interactive') |
|
1091 | 1091 | if not abortf and not continuef: |
|
1092 | 1092 | cmdutil.checkunfinished(repo) |
|
1093 | 1093 | shelved = list(shelved) |
|
1094 | 1094 | if opts.get(b"name"): |
|
1095 | 1095 | shelved.append(opts[b"name"]) |
|
1096 | 1096 | |
|
1097 | 1097 | if interactive and opts.get(b'keep'): |
|
1098 | 1098 | raise error.Abort(_(b'--keep on --interactive is not yet supported')) |
|
1099 | 1099 | if abortf or continuef: |
|
1100 | 1100 | if abortf and continuef: |
|
1101 | 1101 | raise error.Abort(_(b'cannot use both abort and continue')) |
|
1102 | 1102 | if shelved: |
|
1103 | 1103 | raise error.Abort( |
|
1104 | 1104 | _( |
|
1105 | 1105 | b'cannot combine abort/continue with ' |
|
1106 | 1106 | b'naming a shelved change' |
|
1107 | 1107 | ) |
|
1108 | 1108 | ) |
|
1109 | 1109 | if abortf and opts.get(b'tool', False): |
|
1110 | 1110 | ui.warn(_(b'tool option will be ignored\n')) |
|
1111 | 1111 | |
|
1112 | 1112 | state = _loadshelvedstate(ui, repo, opts) |
|
1113 | 1113 | if abortf: |
|
1114 | 1114 | return unshelveabort(ui, repo, state) |
|
1115 | 1115 | elif continuef and interactive: |
|
1116 | 1116 | raise error.Abort(_(b'cannot use both continue and interactive')) |
|
1117 | 1117 | elif continuef: |
|
1118 | 1118 | return unshelvecontinue(ui, repo, state, opts) |
|
1119 | 1119 | elif len(shelved) > 1: |
|
1120 | 1120 | raise error.Abort(_(b'can only unshelve one change at a time')) |
|
1121 | 1121 | elif not shelved: |
|
1122 | 1122 | shelved = listshelves(repo) |
|
1123 | 1123 | if not shelved: |
|
1124 | 1124 | raise error.Abort(_(b'no shelved changes to apply!')) |
|
1125 | 1125 | basename = util.split(shelved[0][1])[1] |
|
1126 | 1126 | ui.status(_(b"unshelving change '%s'\n") % basename) |
|
1127 | 1127 | else: |
|
1128 | 1128 | basename = shelved[0] |
|
1129 | 1129 | |
|
1130 | 1130 | if not shelvedfile(repo, basename, patchextension).exists(): |
|
1131 | 1131 | raise error.Abort(_(b"shelved change '%s' not found") % basename) |
|
1132 | 1132 | |
|
1133 | 1133 | repo = repo.unfiltered() |
|
1134 | 1134 | lock = tr = None |
|
1135 | 1135 | try: |
|
1136 | 1136 | lock = repo.lock() |
|
1137 | 1137 | tr = repo.transaction(b'unshelve', report=lambda x: None) |
|
1138 | 1138 | oldtiprev = len(repo) |
|
1139 | 1139 | |
|
1140 | 1140 | pctx = repo[b'.'] |
|
1141 | 1141 | tmpwctx = pctx |
|
1142 | 1142 | # The goal is to have a commit structure like so: |
|
1143 | 1143 | # ...-> pctx -> tmpwctx -> shelvectx |
|
1144 | 1144 | # where tmpwctx is an optional commit with the user's pending changes |
|
1145 | 1145 | # and shelvectx is the unshelved changes. Then we merge it all down |
|
1146 | 1146 | # to the original pctx. |
|
1147 | 1147 | |
|
1148 | 1148 | activebookmark = _backupactivebookmark(repo) |
|
1149 | 1149 | tmpwctx, addedbefore = _commitworkingcopychanges( |
|
1150 | 1150 | ui, repo, opts, tmpwctx |
|
1151 | 1151 | ) |
|
1152 | 1152 | repo, shelvectx = _unshelverestorecommit(ui, repo, tr, basename) |
|
1153 | 1153 | _checkunshelveuntrackedproblems(ui, repo, shelvectx) |
|
1154 | 1154 | branchtorestore = b'' |
|
1155 | 1155 | if shelvectx.branch() != shelvectx.p1().branch(): |
|
1156 | 1156 | branchtorestore = shelvectx.branch() |
|
1157 | 1157 | |
|
1158 | 1158 | shelvectx, ispartialunshelve = _rebaserestoredcommit( |
|
1159 | 1159 | ui, |
|
1160 | 1160 | repo, |
|
1161 | 1161 | opts, |
|
1162 | 1162 | tr, |
|
1163 | 1163 | oldtiprev, |
|
1164 | 1164 | basename, |
|
1165 | 1165 | pctx, |
|
1166 | 1166 | tmpwctx, |
|
1167 | 1167 | shelvectx, |
|
1168 | 1168 | branchtorestore, |
|
1169 | 1169 | activebookmark, |
|
1170 | 1170 | ) |
|
1171 | 1171 | overrides = {(b'ui', b'forcemerge'): opts.get(b'tool', b'')} |
|
1172 | 1172 | with ui.configoverride(overrides, b'unshelve'): |
|
1173 | 1173 | mergefiles(ui, repo, pctx, shelvectx) |
|
1174 | 1174 | restorebranch(ui, repo, branchtorestore) |
|
1175 | 1175 | shelvedstate.clear(repo) |
|
1176 | 1176 | _finishunshelve(repo, oldtiprev, tr, activebookmark) |
|
1177 | 1177 | _forgetunknownfiles(repo, shelvectx, addedbefore) |
|
1178 | 1178 | if not ispartialunshelve: |
|
1179 | 1179 | unshelvecleanup(ui, repo, basename, opts) |
|
1180 | 1180 | finally: |
|
1181 | 1181 | if tr: |
|
1182 | 1182 | tr.release() |
|
1183 | 1183 | lockmod.release(lock) |
@@ -1,1491 +1,1491 b'' | |||
|
1 | 1 | #testcases stripbased phasebased |
|
2 | 2 | |
|
3 | 3 | $ cat <<EOF >> $HGRCPATH |
|
4 | 4 | > [extensions] |
|
5 | 5 | > mq = |
|
6 | 6 | > [defaults] |
|
7 | 7 | > diff = --nodates --git |
|
8 | 8 | > qnew = --date '0 0' |
|
9 | 9 | > [shelve] |
|
10 | 10 | > maxbackups = 2 |
|
11 | 11 | > EOF |
|
12 | 12 | |
|
13 | 13 | #if phasebased |
|
14 | 14 | |
|
15 | 15 | $ cat <<EOF >> $HGRCPATH |
|
16 | 16 | > [format] |
|
17 | 17 | > internal-phase = yes |
|
18 | 18 | > EOF |
|
19 | 19 | |
|
20 | 20 | #endif |
|
21 | 21 | |
|
22 | 22 | $ hg init repo |
|
23 | 23 | $ cd repo |
|
24 | 24 | $ mkdir a b |
|
25 | 25 | $ echo a > a/a |
|
26 | 26 | $ echo b > b/b |
|
27 | 27 | $ echo c > c |
|
28 | 28 | $ echo d > d |
|
29 | 29 | $ echo x > x |
|
30 | 30 | $ hg addremove -q |
|
31 | 31 | |
|
32 | 32 | shelve has a help message |
|
33 | 33 | $ hg shelve -h |
|
34 | 34 | hg shelve [OPTION]... [FILE]... |
|
35 | 35 | |
|
36 | 36 | save and set aside changes from the working directory |
|
37 | 37 | |
|
38 | 38 | Shelving takes files that "hg status" reports as not clean, saves the |
|
39 | 39 | modifications to a bundle (a shelved change), and reverts the files so |
|
40 | 40 | that their state in the working directory becomes clean. |
|
41 | 41 | |
|
42 | 42 | To restore these changes to the working directory, using "hg unshelve"; |
|
43 | 43 | this will work even if you switch to a different commit. |
|
44 | 44 | |
|
45 | 45 | When no files are specified, "hg shelve" saves all not-clean files. If |
|
46 | 46 | specific files or directories are named, only changes to those files are |
|
47 | 47 | shelved. |
|
48 | 48 | |
|
49 | 49 | In bare shelve (when no files are specified, without interactive, include |
|
50 | 50 | and exclude option), shelving remembers information if the working |
|
51 | 51 | directory was on newly created branch, in other words working directory |
|
52 | 52 | was on different branch than its first parent. In this situation |
|
53 | 53 | unshelving restores branch information to the working directory. |
|
54 | 54 | |
|
55 | 55 | Each shelved change has a name that makes it easier to find later. The |
|
56 | 56 | name of a shelved change defaults to being based on the active bookmark, |
|
57 | 57 | or if there is no active bookmark, the current named branch. To specify a |
|
58 | 58 | different name, use "--name". |
|
59 | 59 | |
|
60 | 60 | To see a list of existing shelved changes, use the "--list" option. For |
|
61 | 61 | each shelved change, this will print its name, age, and description; use " |
|
62 | 62 | --patch" or "--stat" for more details. |
|
63 | 63 | |
|
64 | 64 | To delete specific shelved changes, use "--delete". To delete all shelved |
|
65 | 65 | changes, use "--cleanup". |
|
66 | 66 | |
|
67 | 67 | options ([+] can be repeated): |
|
68 | 68 | |
|
69 | 69 | -A --addremove mark new/missing files as added/removed before |
|
70 | 70 | shelving |
|
71 | 71 | -u --unknown store unknown files in the shelve |
|
72 | 72 | --cleanup delete all shelved changes |
|
73 | 73 | --date DATE shelve with the specified commit date |
|
74 | 74 | -d --delete delete the named shelved change(s) |
|
75 | 75 | -e --edit invoke editor on commit messages |
|
76 | 76 | -k --keep shelve, but keep changes in the working directory |
|
77 | 77 | -l --list list current shelves |
|
78 | 78 | -m --message TEXT use text as shelve message |
|
79 | 79 | -n --name NAME use the given name for the shelved commit |
|
80 | 80 | -p --patch output patches for changes (provide the names of the |
|
81 | 81 | shelved changes as positional arguments) |
|
82 | 82 | -i --interactive interactive mode |
|
83 | 83 | --stat output diffstat-style summary of changes (provide |
|
84 | 84 | the names of the shelved changes as positional |
|
85 | 85 | arguments) |
|
86 | 86 | -I --include PATTERN [+] include names matching the given patterns |
|
87 | 87 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
88 | 88 | --mq operate on patch repository |
|
89 | 89 | |
|
90 | 90 | (some details hidden, use --verbose to show complete help) |
|
91 | 91 | |
|
92 | 92 | shelving in an empty repo should be possible |
|
93 | 93 | (this tests also that editor is not invoked, if '--edit' is not |
|
94 | 94 | specified) |
|
95 | 95 | |
|
96 | 96 | $ HGEDITOR=cat hg shelve |
|
97 | 97 | shelved as default |
|
98 | 98 | 0 files updated, 0 files merged, 5 files removed, 0 files unresolved |
|
99 | 99 | |
|
100 | 100 | $ hg unshelve |
|
101 | 101 | unshelving change 'default' |
|
102 | 102 | |
|
103 | 103 | $ hg commit -q -m 'initial commit' |
|
104 | 104 | |
|
105 | 105 | $ hg shelve |
|
106 | 106 | nothing changed |
|
107 | 107 | [1] |
|
108 | 108 | |
|
109 | 109 | make sure shelve files were backed up |
|
110 | 110 | |
|
111 | 111 | $ ls .hg/shelve-backup |
|
112 | 112 | default.hg |
|
113 | 113 | default.patch |
|
114 | 114 | default.shelve |
|
115 | 115 | |
|
116 | 116 | checks to make sure we dont create a directory or |
|
117 | 117 | hidden file while choosing a new shelve name |
|
118 | 118 | |
|
119 | 119 | when we are given a name |
|
120 | 120 | |
|
121 | 121 | $ hg shelve -n foo/bar |
|
122 | 122 | abort: shelved change names can not contain slashes |
|
123 | 123 | [255] |
|
124 | 124 | $ hg shelve -n .baz |
|
125 | 125 | abort: shelved change names can not start with '.' |
|
126 | 126 | [255] |
|
127 | 127 | $ hg shelve -n foo\\bar |
|
128 | 128 | abort: shelved change names can not contain slashes |
|
129 | 129 | [255] |
|
130 | 130 | |
|
131 | 131 | when shelve has to choose itself |
|
132 | 132 | |
|
133 | 133 | $ hg branch x/y -q |
|
134 | 134 | $ hg commit -q -m "Branch commit 0" |
|
135 | 135 | $ hg shelve |
|
136 | 136 | nothing changed |
|
137 | 137 | [1] |
|
138 | 138 | $ hg branch .x -q |
|
139 | 139 | $ hg commit -q -m "Branch commit 1" |
|
140 | 140 | $ hg shelve |
|
141 | 141 | nothing changed |
|
142 | 142 | [1] |
|
143 | 143 | $ hg branch x\\y -q |
|
144 | 144 | $ hg commit -q -m "Branch commit 2" |
|
145 | 145 | $ hg shelve |
|
146 | 146 | nothing changed |
|
147 | 147 | [1] |
|
148 | 148 | |
|
149 | 149 | cleaning the branches made for name checking tests |
|
150 | 150 | |
|
151 | 151 | $ hg up default -q |
|
152 | 152 | $ hg strip e9177275307e+6a6d231f43d+882bae7c62c2 -q |
|
153 | 153 | |
|
154 | 154 | create an mq patch - shelving should work fine with a patch applied |
|
155 | 155 | |
|
156 | 156 | $ echo n > n |
|
157 | 157 | $ hg add n |
|
158 | 158 | $ hg commit n -m second |
|
159 | 159 | $ hg qnew second.patch |
|
160 | 160 | |
|
161 | 161 | shelve a change that we will delete later |
|
162 | 162 | |
|
163 | 163 | $ echo a >> a/a |
|
164 | 164 | $ hg shelve |
|
165 | 165 | shelved as default |
|
166 | 166 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
167 | 167 | |
|
168 | 168 | set up some more complex changes to shelve |
|
169 | 169 | |
|
170 | 170 | $ echo a >> a/a |
|
171 | 171 | $ hg mv b b.rename |
|
172 | 172 | moving b/b to b.rename/b |
|
173 | 173 | $ hg cp c c.copy |
|
174 | 174 | $ hg status -C |
|
175 | 175 | M a/a |
|
176 | 176 | A b.rename/b |
|
177 | 177 | b/b |
|
178 | 178 | A c.copy |
|
179 | 179 | c |
|
180 | 180 | R b/b |
|
181 | 181 | |
|
182 | 182 | the common case - no options or filenames |
|
183 | 183 | |
|
184 | 184 | $ hg shelve |
|
185 | 185 | shelved as default-01 |
|
186 | 186 | 2 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
187 | 187 | $ hg status -C |
|
188 | 188 | |
|
189 | 189 | ensure that our shelved changes exist |
|
190 | 190 | |
|
191 | 191 | $ hg shelve -l |
|
192 | 192 | default-01 (*)* changes to: [mq]: second.patch (glob) |
|
193 | 193 | default (*)* changes to: [mq]: second.patch (glob) |
|
194 | 194 | |
|
195 | 195 | $ hg shelve -l -p default |
|
196 | 196 | default (*)* changes to: [mq]: second.patch (glob) |
|
197 | 197 | |
|
198 | 198 | diff --git a/a/a b/a/a |
|
199 | 199 | --- a/a/a |
|
200 | 200 | +++ b/a/a |
|
201 | 201 | @@ -1,1 +1,2 @@ |
|
202 | 202 | a |
|
203 | 203 | +a |
|
204 | 204 | |
|
205 | 205 | $ hg shelve --list --addremove |
|
206 | 206 | abort: options '--list' and '--addremove' may not be used together |
|
207 | 207 | [255] |
|
208 | 208 | |
|
209 | 209 | delete our older shelved change |
|
210 | 210 | |
|
211 | 211 | $ hg shelve -d default |
|
212 | 212 | $ hg qfinish -a -q |
|
213 | 213 | |
|
214 | 214 | ensure shelve backups aren't overwritten |
|
215 | 215 | |
|
216 | 216 | $ ls .hg/shelve-backup/ |
|
217 | 217 | default-1.hg |
|
218 | 218 | default-1.patch |
|
219 | 219 | default-1.shelve |
|
220 | 220 | default.hg |
|
221 | 221 | default.patch |
|
222 | 222 | default.shelve |
|
223 | 223 | |
|
224 | 224 | local edits should not prevent a shelved change from applying |
|
225 | 225 | |
|
226 | 226 | $ printf "z\na\n" > a/a |
|
227 | 227 | $ hg unshelve --keep |
|
228 | 228 | unshelving change 'default-01' |
|
229 | 229 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
230 | 230 | rebasing shelved changes |
|
231 | 231 | merging a/a |
|
232 | 232 | |
|
233 | 233 | $ hg revert --all -q |
|
234 | 234 | $ rm a/a.orig b.rename/b c.copy |
|
235 | 235 | |
|
236 | 236 | apply it and make sure our state is as expected |
|
237 | 237 | |
|
238 | 238 | (this also tests that same timestamp prevents backups from being |
|
239 | 239 | removed, even though there are more than 'maxbackups' backups) |
|
240 | 240 | |
|
241 | 241 | $ f -t .hg/shelve-backup/default.patch |
|
242 | 242 | .hg/shelve-backup/default.patch: file |
|
243 | 243 | $ touch -t 200001010000 .hg/shelve-backup/default.patch |
|
244 | 244 | $ f -t .hg/shelve-backup/default-1.patch |
|
245 | 245 | .hg/shelve-backup/default-1.patch: file |
|
246 | 246 | $ touch -t 200001010000 .hg/shelve-backup/default-1.patch |
|
247 | 247 | |
|
248 | 248 | $ hg unshelve |
|
249 | 249 | unshelving change 'default-01' |
|
250 | 250 | $ hg status -C |
|
251 | 251 | M a/a |
|
252 | 252 | A b.rename/b |
|
253 | 253 | b/b |
|
254 | 254 | A c.copy |
|
255 | 255 | c |
|
256 | 256 | R b/b |
|
257 | 257 | $ hg shelve -l |
|
258 | 258 | |
|
259 | 259 | (both of default.hg and default-1.hg should be still kept, because it |
|
260 | 260 | is difficult to decide actual order of them from same timestamp) |
|
261 | 261 | |
|
262 | 262 | $ ls .hg/shelve-backup/ |
|
263 | 263 | default-01.hg |
|
264 | 264 | default-01.patch |
|
265 | 265 | default-01.shelve |
|
266 | 266 | default-1.hg |
|
267 | 267 | default-1.patch |
|
268 | 268 | default-1.shelve |
|
269 | 269 | default.hg |
|
270 | 270 | default.patch |
|
271 | 271 | default.shelve |
|
272 | 272 | |
|
273 | 273 | $ hg unshelve |
|
274 | 274 | abort: no shelved changes to apply! |
|
275 | 275 | [255] |
|
276 | 276 | $ hg unshelve foo |
|
277 | 277 | abort: shelved change 'foo' not found |
|
278 | 278 | [255] |
|
279 | 279 | |
|
280 | 280 | named shelves, specific filenames, and "commit messages" should all work |
|
281 | 281 | (this tests also that editor is invoked, if '--edit' is specified) |
|
282 | 282 | |
|
283 | 283 | $ hg status -C |
|
284 | 284 | M a/a |
|
285 | 285 | A b.rename/b |
|
286 | 286 | b/b |
|
287 | 287 | A c.copy |
|
288 | 288 | c |
|
289 | 289 | R b/b |
|
290 | 290 | $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a |
|
291 | 291 | wat |
|
292 | 292 | |
|
293 | 293 | |
|
294 | 294 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
295 | 295 | HG: Leave message empty to abort commit. |
|
296 | 296 | HG: -- |
|
297 | 297 | HG: user: shelve@localhost |
|
298 | 298 | HG: branch 'default' |
|
299 | 299 | HG: changed a/a |
|
300 | 300 | |
|
301 | 301 | expect "a" to no longer be present, but status otherwise unchanged |
|
302 | 302 | |
|
303 | 303 | $ hg status -C |
|
304 | 304 | A b.rename/b |
|
305 | 305 | b/b |
|
306 | 306 | A c.copy |
|
307 | 307 | c |
|
308 | 308 | R b/b |
|
309 | 309 | $ hg shelve -l --stat |
|
310 | 310 | wibble (*) wat (glob) |
|
311 | 311 | a/a | 1 + |
|
312 | 312 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
313 | 313 | |
|
314 | 314 | and now "a/a" should reappear |
|
315 | 315 | |
|
316 | 316 | $ cd a |
|
317 | 317 | $ hg unshelve -q wibble |
|
318 | 318 | $ cd .. |
|
319 | 319 | $ hg status -C |
|
320 | 320 | M a/a |
|
321 | 321 | A b.rename/b |
|
322 | 322 | b/b |
|
323 | 323 | A c.copy |
|
324 | 324 | c |
|
325 | 325 | R b/b |
|
326 | 326 | |
|
327 | 327 | ensure old shelve backups are being deleted automatically |
|
328 | 328 | |
|
329 | 329 | $ ls .hg/shelve-backup/ |
|
330 | 330 | default-01.hg |
|
331 | 331 | default-01.patch |
|
332 | 332 | default-01.shelve |
|
333 | 333 | wibble.hg |
|
334 | 334 | wibble.patch |
|
335 | 335 | wibble.shelve |
|
336 | 336 | |
|
337 | 337 | cause unshelving to result in a merge with 'a' conflicting |
|
338 | 338 | |
|
339 | 339 | $ hg shelve -q |
|
340 | 340 | $ echo c>>a/a |
|
341 | 341 | $ hg commit -m second |
|
342 | 342 | $ hg tip --template '{files}\n' |
|
343 | 343 | a/a |
|
344 | 344 | |
|
345 | 345 | add an unrelated change that should be preserved |
|
346 | 346 | |
|
347 | 347 | $ mkdir foo |
|
348 | 348 | $ echo foo > foo/foo |
|
349 | 349 | $ hg add foo/foo |
|
350 | 350 | |
|
351 | 351 | force a conflicted merge to occur |
|
352 | 352 | |
|
353 | 353 | $ hg unshelve |
|
354 | 354 | unshelving change 'default' |
|
355 | 355 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
356 | 356 | rebasing shelved changes |
|
357 | 357 | merging a/a |
|
358 | 358 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
359 | 359 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
360 | 360 | [1] |
|
361 | 361 | $ hg status -v |
|
362 | 362 | M a/a |
|
363 | 363 | M b.rename/b |
|
364 | 364 | M c.copy |
|
365 | 365 | R b/b |
|
366 | 366 | ? a/a.orig |
|
367 | 367 | # The repository is in an unfinished *unshelve* state. |
|
368 | 368 | |
|
369 | 369 | # Unresolved merge conflicts: |
|
370 | 370 | # |
|
371 | 371 | # a/a |
|
372 | 372 | # |
|
373 | 373 | # To mark files as resolved: hg resolve --mark FILE |
|
374 | 374 | |
|
375 | 375 | # To continue: hg unshelve --continue |
|
376 | 376 | # To abort: hg unshelve --abort |
|
377 | 377 | |
|
378 | 378 | |
|
379 | 379 | ensure that we have a merge with unresolved conflicts |
|
380 | 380 | |
|
381 | 381 | #if phasebased |
|
382 | 382 | $ hg heads -q --template '{rev}\n' |
|
383 | 383 | 8 |
|
384 | 384 | 5 |
|
385 | 385 | $ hg parents -q --template '{rev}\n' |
|
386 | 386 | 8 |
|
387 | 387 | 5 |
|
388 | 388 | #endif |
|
389 | 389 | |
|
390 | 390 | #if stripbased |
|
391 | 391 | $ hg heads -q --template '{rev}\n' |
|
392 | 392 | 5 |
|
393 | 393 | 4 |
|
394 | 394 | $ hg parents -q --template '{rev}\n' |
|
395 | 395 | 4 |
|
396 | 396 | 5 |
|
397 | 397 | #endif |
|
398 | 398 | |
|
399 | 399 | $ hg status |
|
400 | 400 | M a/a |
|
401 | 401 | M b.rename/b |
|
402 | 402 | M c.copy |
|
403 | 403 | R b/b |
|
404 | 404 | ? a/a.orig |
|
405 | 405 | $ hg diff |
|
406 | 406 | diff --git a/a/a b/a/a |
|
407 | 407 | --- a/a/a |
|
408 | 408 | +++ b/a/a |
|
409 | 409 | @@ -1,2 +1,6 @@ |
|
410 | 410 | a |
|
411 |
+<<<<<<< |
|
|
411 | +<<<<<<< working-copy: 2377350b6337 - shelve: pending changes temporary commit | |
|
412 | 412 | c |
|
413 | 413 | +======= |
|
414 | 414 | +a |
|
415 |
+>>>>>>> |
|
|
415 | +>>>>>>> shelve: a68ec3400638 - shelve: changes to: [mq]: second.patch | |
|
416 | 416 | diff --git a/b/b b/b.rename/b |
|
417 | 417 | rename from b/b |
|
418 | 418 | rename to b.rename/b |
|
419 | 419 | diff --git a/c b/c.copy |
|
420 | 420 | copy from c |
|
421 | 421 | copy to c.copy |
|
422 | 422 | $ hg resolve -l |
|
423 | 423 | U a/a |
|
424 | 424 | |
|
425 | 425 | $ hg shelve |
|
426 | 426 | abort: unshelve already in progress |
|
427 | 427 | (use 'hg unshelve --continue' or 'hg unshelve --abort') |
|
428 | 428 | [255] |
|
429 | 429 | |
|
430 | 430 | abort the unshelve and be happy |
|
431 | 431 | |
|
432 | 432 | $ hg status |
|
433 | 433 | M a/a |
|
434 | 434 | M b.rename/b |
|
435 | 435 | M c.copy |
|
436 | 436 | R b/b |
|
437 | 437 | ? a/a.orig |
|
438 | 438 | $ hg unshelve -a |
|
439 | 439 | unshelve of 'default' aborted |
|
440 | 440 | $ hg heads -q |
|
441 | 441 | [37]:2e69b451d1ea (re) |
|
442 | 442 | $ hg parents |
|
443 | 443 | changeset: [37]:2e69b451d1ea (re) |
|
444 | 444 | tag: tip |
|
445 | 445 | parent: 3:509104101065 (?) |
|
446 | 446 | user: test |
|
447 | 447 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
448 | 448 | summary: second |
|
449 | 449 | |
|
450 | 450 | $ hg resolve -l |
|
451 | 451 | $ hg status |
|
452 | 452 | A foo/foo |
|
453 | 453 | ? a/a.orig |
|
454 | 454 | |
|
455 | 455 | try to continue with no unshelve underway |
|
456 | 456 | |
|
457 | 457 | $ hg unshelve -c |
|
458 | 458 | abort: no unshelve in progress |
|
459 | 459 | [255] |
|
460 | 460 | $ hg status |
|
461 | 461 | A foo/foo |
|
462 | 462 | ? a/a.orig |
|
463 | 463 | |
|
464 | 464 | redo the unshelve to get a conflict |
|
465 | 465 | |
|
466 | 466 | $ hg unshelve -q |
|
467 | 467 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
468 | 468 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
469 | 469 | [1] |
|
470 | 470 | |
|
471 | 471 | attempt to continue |
|
472 | 472 | |
|
473 | 473 | $ hg unshelve -c |
|
474 | 474 | abort: unresolved conflicts, can't continue |
|
475 | 475 | (see 'hg resolve', then 'hg unshelve --continue') |
|
476 | 476 | [255] |
|
477 | 477 | |
|
478 | 478 | $ hg revert -r . a/a |
|
479 | 479 | $ hg resolve -m a/a |
|
480 | 480 | (no more unresolved files) |
|
481 | 481 | continue: hg unshelve --continue |
|
482 | 482 | |
|
483 | 483 | $ hg commit -m 'commit while unshelve in progress' |
|
484 | 484 | abort: unshelve already in progress |
|
485 | 485 | (use 'hg unshelve --continue' or 'hg unshelve --abort') |
|
486 | 486 | [255] |
|
487 | 487 | |
|
488 | 488 | $ hg graft --continue |
|
489 | 489 | abort: no graft in progress |
|
490 | 490 | (continue: hg unshelve --continue) |
|
491 | 491 | [255] |
|
492 | 492 | $ hg unshelve -c |
|
493 | 493 | unshelve of 'default' complete |
|
494 | 494 | |
|
495 | 495 | ensure the repo is as we hope |
|
496 | 496 | |
|
497 | 497 | $ hg parents |
|
498 | 498 | changeset: [37]:2e69b451d1ea (re) |
|
499 | 499 | tag: tip |
|
500 | 500 | parent: 3:509104101065 (?) |
|
501 | 501 | user: test |
|
502 | 502 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
503 | 503 | summary: second |
|
504 | 504 | |
|
505 | 505 | $ hg heads -q |
|
506 | 506 | [37]:2e69b451d1ea (re) |
|
507 | 507 | |
|
508 | 508 | $ hg status -C |
|
509 | 509 | A b.rename/b |
|
510 | 510 | b/b |
|
511 | 511 | A c.copy |
|
512 | 512 | c |
|
513 | 513 | A foo/foo |
|
514 | 514 | R b/b |
|
515 | 515 | ? a/a.orig |
|
516 | 516 | |
|
517 | 517 | there should be no shelves left |
|
518 | 518 | |
|
519 | 519 | $ hg shelve -l |
|
520 | 520 | |
|
521 | 521 | #if execbit |
|
522 | 522 | |
|
523 | 523 | ensure that metadata-only changes are shelved |
|
524 | 524 | |
|
525 | 525 | $ chmod +x a/a |
|
526 | 526 | $ hg shelve -q -n execbit a/a |
|
527 | 527 | $ hg status a/a |
|
528 | 528 | $ hg unshelve -q execbit |
|
529 | 529 | $ hg status a/a |
|
530 | 530 | M a/a |
|
531 | 531 | $ hg revert a/a |
|
532 | 532 | |
|
533 | 533 | #else |
|
534 | 534 | |
|
535 | 535 | Dummy shelve op, to keep rev numbers aligned |
|
536 | 536 | |
|
537 | 537 | $ echo foo > a/a |
|
538 | 538 | $ hg shelve -q -n dummy a/a |
|
539 | 539 | $ hg unshelve -q dummy |
|
540 | 540 | $ hg revert a/a |
|
541 | 541 | |
|
542 | 542 | #endif |
|
543 | 543 | |
|
544 | 544 | #if symlink |
|
545 | 545 | |
|
546 | 546 | $ rm a/a |
|
547 | 547 | $ ln -s foo a/a |
|
548 | 548 | $ hg shelve -q -n symlink a/a |
|
549 | 549 | $ hg status a/a |
|
550 | 550 | $ hg unshelve -q -n symlink |
|
551 | 551 | $ hg status a/a |
|
552 | 552 | M a/a |
|
553 | 553 | $ hg revert a/a |
|
554 | 554 | |
|
555 | 555 | #else |
|
556 | 556 | |
|
557 | 557 | Dummy shelve op, to keep rev numbers aligned |
|
558 | 558 | |
|
559 | 559 | $ echo bar > a/a |
|
560 | 560 | $ hg shelve -q -n dummy a/a |
|
561 | 561 | $ hg unshelve -q dummy |
|
562 | 562 | $ hg revert a/a |
|
563 | 563 | |
|
564 | 564 | #endif |
|
565 | 565 | |
|
566 | 566 | set up another conflict between a commit and a shelved change |
|
567 | 567 | |
|
568 | 568 | $ hg revert -q -C -a |
|
569 | 569 | $ rm a/a.orig b.rename/b c.copy |
|
570 | 570 | $ echo a >> a/a |
|
571 | 571 | $ hg shelve -q |
|
572 | 572 | $ echo x >> a/a |
|
573 | 573 | $ hg ci -m 'create conflict' |
|
574 | 574 | $ hg add foo/foo |
|
575 | 575 | |
|
576 | 576 | if we resolve a conflict while unshelving, the unshelve should succeed |
|
577 | 577 | |
|
578 | 578 | $ hg unshelve --tool :merge-other --keep |
|
579 | 579 | unshelving change 'default' |
|
580 | 580 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
581 | 581 | rebasing shelved changes |
|
582 | 582 | merging a/a |
|
583 | 583 | $ hg parents -q |
|
584 | 584 | (4|13):33f7f61e6c5e (re) |
|
585 | 585 | $ hg shelve -l |
|
586 | 586 | default (*)* changes to: second (glob) |
|
587 | 587 | $ hg status |
|
588 | 588 | M a/a |
|
589 | 589 | A foo/foo |
|
590 | 590 | $ cat a/a |
|
591 | 591 | a |
|
592 | 592 | c |
|
593 | 593 | a |
|
594 | 594 | $ cat > a/a << EOF |
|
595 | 595 | > a |
|
596 | 596 | > c |
|
597 | 597 | > x |
|
598 | 598 | > EOF |
|
599 | 599 | |
|
600 | 600 | $ HGMERGE=true hg unshelve |
|
601 | 601 | unshelving change 'default' |
|
602 | 602 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
603 | 603 | rebasing shelved changes |
|
604 | 604 | merging a/a |
|
605 | 605 | note: unshelved changes already existed in the working copy |
|
606 | 606 | $ hg parents -q |
|
607 | 607 | (4|13):33f7f61e6c5e (re) |
|
608 | 608 | $ hg shelve -l |
|
609 | 609 | $ hg status |
|
610 | 610 | A foo/foo |
|
611 | 611 | $ cat a/a |
|
612 | 612 | a |
|
613 | 613 | c |
|
614 | 614 | x |
|
615 | 615 | |
|
616 | 616 | test keep and cleanup |
|
617 | 617 | |
|
618 | 618 | $ hg shelve |
|
619 | 619 | shelved as default |
|
620 | 620 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
621 | 621 | $ hg shelve --list |
|
622 | 622 | default (*)* changes to: create conflict (glob) |
|
623 | 623 | $ hg unshelve -k |
|
624 | 624 | unshelving change 'default' |
|
625 | 625 | $ hg shelve --list |
|
626 | 626 | default (*)* changes to: create conflict (glob) |
|
627 | 627 | $ hg shelve --cleanup |
|
628 | 628 | $ hg shelve --list |
|
629 | 629 | |
|
630 | 630 | $ hg shelve --cleanup --delete |
|
631 | 631 | abort: options '--cleanup' and '--delete' may not be used together |
|
632 | 632 | [255] |
|
633 | 633 | $ hg shelve --cleanup --patch |
|
634 | 634 | abort: options '--cleanup' and '--patch' may not be used together |
|
635 | 635 | [255] |
|
636 | 636 | $ hg shelve --cleanup --message MESSAGE |
|
637 | 637 | abort: options '--cleanup' and '--message' may not be used together |
|
638 | 638 | [255] |
|
639 | 639 | |
|
640 | 640 | test bookmarks |
|
641 | 641 | |
|
642 | 642 | $ hg bookmark test |
|
643 | 643 | $ hg bookmark |
|
644 | 644 | \* test (4|13):33f7f61e6c5e (re) |
|
645 | 645 | $ hg shelve |
|
646 | 646 | shelved as test |
|
647 | 647 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
648 | 648 | $ hg bookmark |
|
649 | 649 | \* test (4|13):33f7f61e6c5e (re) |
|
650 | 650 | $ hg unshelve |
|
651 | 651 | unshelving change 'test' |
|
652 | 652 | $ hg bookmark |
|
653 | 653 | \* test (4|13):33f7f61e6c5e (re) |
|
654 | 654 | |
|
655 | 655 | shelve should still work even if mq is disabled |
|
656 | 656 | |
|
657 | 657 | $ hg --config extensions.mq=! shelve |
|
658 | 658 | shelved as test |
|
659 | 659 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
660 | 660 | $ hg --config extensions.mq=! shelve --list |
|
661 | 661 | test (*)* changes to: create conflict (glob) |
|
662 | 662 | $ hg bookmark |
|
663 | 663 | \* test (4|13):33f7f61e6c5e (re) |
|
664 | 664 | $ hg --config extensions.mq=! unshelve |
|
665 | 665 | unshelving change 'test' |
|
666 | 666 | $ hg bookmark |
|
667 | 667 | \* test (4|13):33f7f61e6c5e (re) |
|
668 | 668 | |
|
669 | 669 | Recreate some conflict again |
|
670 | 670 | |
|
671 | 671 | $ hg up -C -r 2e69b451d1ea |
|
672 | 672 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
673 | 673 | (leaving bookmark test) |
|
674 | 674 | $ echo y >> a/a |
|
675 | 675 | $ hg shelve |
|
676 | 676 | shelved as default |
|
677 | 677 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
678 | 678 | $ hg up test |
|
679 | 679 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
680 | 680 | (activating bookmark test) |
|
681 | 681 | $ hg bookmark |
|
682 | 682 | \* test (4|13):33f7f61e6c5e (re) |
|
683 | 683 | $ hg unshelve |
|
684 | 684 | unshelving change 'default' |
|
685 | 685 | rebasing shelved changes |
|
686 | 686 | merging a/a |
|
687 | 687 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
688 | 688 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
689 | 689 | [1] |
|
690 | 690 | $ hg bookmark |
|
691 | 691 | test (4|13):33f7f61e6c5e (re) |
|
692 | 692 | |
|
693 | 693 | Test that resolving all conflicts in one direction (so that the rebase |
|
694 | 694 | is a no-op), works (issue4398) |
|
695 | 695 | |
|
696 | 696 | $ hg revert -a -r . |
|
697 | 697 | reverting a/a |
|
698 | 698 | $ hg resolve -m a/a |
|
699 | 699 | (no more unresolved files) |
|
700 | 700 | continue: hg unshelve --continue |
|
701 | 701 | $ hg unshelve -c |
|
702 | 702 | note: unshelved changes already existed in the working copy |
|
703 | 703 | unshelve of 'default' complete |
|
704 | 704 | $ hg bookmark |
|
705 | 705 | \* test (4|13):33f7f61e6c5e (re) |
|
706 | 706 | $ hg diff |
|
707 | 707 | $ hg status |
|
708 | 708 | ? a/a.orig |
|
709 | 709 | ? foo/foo |
|
710 | 710 | $ hg summary |
|
711 | 711 | parent: (4|13):33f7f61e6c5e tip (re) |
|
712 | 712 | create conflict |
|
713 | 713 | branch: default |
|
714 | 714 | bookmarks: *test |
|
715 | 715 | commit: 2 unknown (clean) |
|
716 | 716 | update: (current) |
|
717 | 717 | phases: 5 draft |
|
718 | 718 | |
|
719 | 719 | $ hg shelve --delete --stat |
|
720 | 720 | abort: options '--delete' and '--stat' may not be used together |
|
721 | 721 | [255] |
|
722 | 722 | $ hg shelve --delete --name NAME |
|
723 | 723 | abort: options '--delete' and '--name' may not be used together |
|
724 | 724 | [255] |
|
725 | 725 | |
|
726 | 726 | Test interactive shelve |
|
727 | 727 | $ cat <<EOF >> $HGRCPATH |
|
728 | 728 | > [ui] |
|
729 | 729 | > interactive = true |
|
730 | 730 | > EOF |
|
731 | 731 | $ echo 'a' >> a/b |
|
732 | 732 | $ cat a/a >> a/b |
|
733 | 733 | $ echo 'x' >> a/b |
|
734 | 734 | $ mv a/b a/a |
|
735 | 735 | $ echo 'a' >> foo/foo |
|
736 | 736 | $ hg st |
|
737 | 737 | M a/a |
|
738 | 738 | ? a/a.orig |
|
739 | 739 | ? foo/foo |
|
740 | 740 | $ cat a/a |
|
741 | 741 | a |
|
742 | 742 | a |
|
743 | 743 | c |
|
744 | 744 | x |
|
745 | 745 | x |
|
746 | 746 | $ cat foo/foo |
|
747 | 747 | foo |
|
748 | 748 | a |
|
749 | 749 | $ hg shelve --interactive --config ui.interactive=false |
|
750 | 750 | abort: running non-interactively |
|
751 | 751 | [255] |
|
752 | 752 | $ hg shelve --interactive << EOF |
|
753 | 753 | > y |
|
754 | 754 | > y |
|
755 | 755 | > n |
|
756 | 756 | > EOF |
|
757 | 757 | diff --git a/a/a b/a/a |
|
758 | 758 | 2 hunks, 2 lines changed |
|
759 | 759 | examine changes to 'a/a'? |
|
760 | 760 | (enter ? for help) [Ynesfdaq?] y |
|
761 | 761 | |
|
762 | 762 | @@ -1,3 +1,4 @@ |
|
763 | 763 | +a |
|
764 | 764 | a |
|
765 | 765 | c |
|
766 | 766 | x |
|
767 | 767 | record change 1/2 to 'a/a'? |
|
768 | 768 | (enter ? for help) [Ynesfdaq?] y |
|
769 | 769 | |
|
770 | 770 | @@ -1,3 +2,4 @@ |
|
771 | 771 | a |
|
772 | 772 | c |
|
773 | 773 | x |
|
774 | 774 | +x |
|
775 | 775 | record change 2/2 to 'a/a'? |
|
776 | 776 | (enter ? for help) [Ynesfdaq?] n |
|
777 | 777 | |
|
778 | 778 | shelved as test |
|
779 | 779 | merging a/a |
|
780 | 780 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
781 | 781 | $ cat a/a |
|
782 | 782 | a |
|
783 | 783 | c |
|
784 | 784 | x |
|
785 | 785 | x |
|
786 | 786 | $ cat foo/foo |
|
787 | 787 | foo |
|
788 | 788 | a |
|
789 | 789 | $ hg st |
|
790 | 790 | M a/a |
|
791 | 791 | ? foo/foo |
|
792 | 792 | $ hg bookmark |
|
793 | 793 | \* test (4|13):33f7f61e6c5e (re) |
|
794 | 794 | $ hg unshelve |
|
795 | 795 | unshelving change 'test' |
|
796 | 796 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
797 | 797 | rebasing shelved changes |
|
798 | 798 | merging a/a |
|
799 | 799 | $ hg bookmark |
|
800 | 800 | \* test (4|13):33f7f61e6c5e (re) |
|
801 | 801 | $ cat a/a |
|
802 | 802 | a |
|
803 | 803 | a |
|
804 | 804 | c |
|
805 | 805 | x |
|
806 | 806 | x |
|
807 | 807 | |
|
808 | 808 | shelve --patch and shelve --stat should work with valid shelfnames |
|
809 | 809 | |
|
810 | 810 | $ hg up --clean . |
|
811 | 811 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
812 | 812 | (leaving bookmark test) |
|
813 | 813 | $ hg shelve --list |
|
814 | 814 | $ echo 'patch a' > shelf-patch-a |
|
815 | 815 | $ hg add shelf-patch-a |
|
816 | 816 | $ hg shelve |
|
817 | 817 | shelved as default |
|
818 | 818 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
819 | 819 | $ echo 'patch b' > shelf-patch-b |
|
820 | 820 | $ hg add shelf-patch-b |
|
821 | 821 | $ hg shelve |
|
822 | 822 | shelved as default-01 |
|
823 | 823 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
824 | 824 | $ hg shelve --patch default default-01 |
|
825 | 825 | default-01 (*)* changes to: create conflict (glob) |
|
826 | 826 | |
|
827 | 827 | diff --git a/shelf-patch-b b/shelf-patch-b |
|
828 | 828 | new file mode 100644 |
|
829 | 829 | --- /dev/null |
|
830 | 830 | +++ b/shelf-patch-b |
|
831 | 831 | @@ -0,0 +1,1 @@ |
|
832 | 832 | +patch b |
|
833 | 833 | default (*)* changes to: create conflict (glob) |
|
834 | 834 | |
|
835 | 835 | diff --git a/shelf-patch-a b/shelf-patch-a |
|
836 | 836 | new file mode 100644 |
|
837 | 837 | --- /dev/null |
|
838 | 838 | +++ b/shelf-patch-a |
|
839 | 839 | @@ -0,0 +1,1 @@ |
|
840 | 840 | +patch a |
|
841 | 841 | $ hg shelve --stat default default-01 |
|
842 | 842 | default-01 (*)* changes to: create conflict (glob) |
|
843 | 843 | shelf-patch-b | 1 + |
|
844 | 844 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
845 | 845 | default (*)* changes to: create conflict (glob) |
|
846 | 846 | shelf-patch-a | 1 + |
|
847 | 847 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
848 | 848 | $ hg shelve --patch default |
|
849 | 849 | default (*)* changes to: create conflict (glob) |
|
850 | 850 | |
|
851 | 851 | diff --git a/shelf-patch-a b/shelf-patch-a |
|
852 | 852 | new file mode 100644 |
|
853 | 853 | --- /dev/null |
|
854 | 854 | +++ b/shelf-patch-a |
|
855 | 855 | @@ -0,0 +1,1 @@ |
|
856 | 856 | +patch a |
|
857 | 857 | $ hg shelve --stat default |
|
858 | 858 | default (*)* changes to: create conflict (glob) |
|
859 | 859 | shelf-patch-a | 1 + |
|
860 | 860 | 1 files changed, 1 insertions(+), 0 deletions(-) |
|
861 | 861 | $ hg shelve --patch nonexistentshelf |
|
862 | 862 | abort: cannot find shelf nonexistentshelf |
|
863 | 863 | [255] |
|
864 | 864 | $ hg shelve --stat nonexistentshelf |
|
865 | 865 | abort: cannot find shelf nonexistentshelf |
|
866 | 866 | [255] |
|
867 | 867 | $ hg shelve --patch default nonexistentshelf |
|
868 | 868 | abort: cannot find shelf nonexistentshelf |
|
869 | 869 | [255] |
|
870 | 870 | |
|
871 | 871 | when the user asks for a patch, we assume they want the most recent shelve if |
|
872 | 872 | they don't provide a shelve name |
|
873 | 873 | |
|
874 | 874 | $ hg shelve --patch |
|
875 | 875 | default-01 (*)* changes to: create conflict (glob) |
|
876 | 876 | |
|
877 | 877 | diff --git a/shelf-patch-b b/shelf-patch-b |
|
878 | 878 | new file mode 100644 |
|
879 | 879 | --- /dev/null |
|
880 | 880 | +++ b/shelf-patch-b |
|
881 | 881 | @@ -0,0 +1,1 @@ |
|
882 | 882 | +patch b |
|
883 | 883 | |
|
884 | 884 | $ cd .. |
|
885 | 885 | |
|
886 | 886 | Shelve from general delta repo uses bundle2 on disk |
|
887 | 887 | -------------------------------------------------- |
|
888 | 888 | |
|
889 | 889 | no general delta |
|
890 | 890 | |
|
891 | 891 | $ hg clone --pull repo bundle1 --config format.usegeneraldelta=0 |
|
892 | 892 | requesting all changes |
|
893 | 893 | adding changesets |
|
894 | 894 | adding manifests |
|
895 | 895 | adding file changes |
|
896 | 896 | added 5 changesets with 8 changes to 6 files |
|
897 | 897 | new changesets cc01e2b0c59f:33f7f61e6c5e |
|
898 | 898 | updating to branch default |
|
899 | 899 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
900 | 900 | $ cd bundle1 |
|
901 | 901 | $ echo babar > jungle |
|
902 | 902 | $ hg add jungle |
|
903 | 903 | $ hg shelve |
|
904 | 904 | shelved as default |
|
905 | 905 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
906 | 906 | $ hg debugbundle .hg/shelved/*.hg |
|
907 | 907 | 330882a04d2ce8487636b1fb292e5beea77fa1e3 |
|
908 | 908 | $ cd .. |
|
909 | 909 | |
|
910 | 910 | with general delta |
|
911 | 911 | |
|
912 | 912 | $ hg clone --pull repo bundle2 --config format.usegeneraldelta=1 |
|
913 | 913 | requesting all changes |
|
914 | 914 | adding changesets |
|
915 | 915 | adding manifests |
|
916 | 916 | adding file changes |
|
917 | 917 | added 5 changesets with 8 changes to 6 files |
|
918 | 918 | new changesets cc01e2b0c59f:33f7f61e6c5e |
|
919 | 919 | updating to branch default |
|
920 | 920 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
921 | 921 | $ cd bundle2 |
|
922 | 922 | $ echo babar > jungle |
|
923 | 923 | $ hg add jungle |
|
924 | 924 | $ hg shelve |
|
925 | 925 | shelved as default |
|
926 | 926 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
927 | 927 | $ hg debugbundle .hg/shelved/*.hg |
|
928 | 928 | Stream params: {Compression: BZ} |
|
929 | 929 | changegroup -- {nbchanges: 1, version: 02} (mandatory: True) |
|
930 | 930 | 330882a04d2ce8487636b1fb292e5beea77fa1e3 |
|
931 | 931 | |
|
932 | 932 | Test shelve --keep |
|
933 | 933 | |
|
934 | 934 | $ hg unshelve |
|
935 | 935 | unshelving change 'default' |
|
936 | 936 | $ hg shelve --keep --list |
|
937 | 937 | abort: options '--list' and '--keep' may not be used together |
|
938 | 938 | [255] |
|
939 | 939 | $ hg shelve --keep --patch |
|
940 | 940 | abort: options '--patch' and '--keep' may not be used together |
|
941 | 941 | [255] |
|
942 | 942 | $ hg shelve --keep --delete |
|
943 | 943 | abort: options '--delete' and '--keep' may not be used together |
|
944 | 944 | [255] |
|
945 | 945 | $ hg shelve --keep |
|
946 | 946 | shelved as default |
|
947 | 947 | $ hg diff |
|
948 | 948 | diff --git a/jungle b/jungle |
|
949 | 949 | new file mode 100644 |
|
950 | 950 | --- /dev/null |
|
951 | 951 | +++ b/jungle |
|
952 | 952 | @@ -0,0 +1,1 @@ |
|
953 | 953 | +babar |
|
954 | 954 | |
|
955 | 955 | Test shelve --delete |
|
956 | 956 | |
|
957 | 957 | $ hg shelve --list |
|
958 | 958 | default (*s ago) changes to: create conflict (glob) |
|
959 | 959 | $ hg shelve --delete doesnotexist |
|
960 | 960 | abort: shelved change 'doesnotexist' not found |
|
961 | 961 | [255] |
|
962 | 962 | $ hg shelve --delete default |
|
963 | 963 | |
|
964 | 964 | $ cd .. |
|
965 | 965 | |
|
966 | 966 | Test visibility of in-memory changes inside transaction to external hook |
|
967 | 967 | ------------------------------------------------------------------------ |
|
968 | 968 | |
|
969 | 969 | $ cd repo |
|
970 | 970 | |
|
971 | 971 | $ echo xxxx >> x |
|
972 | 972 | $ hg commit -m "#5: changes to invoke rebase" |
|
973 | 973 | |
|
974 | 974 | $ cat > $TESTTMP/checkvisibility.sh <<EOF |
|
975 | 975 | > echo "==== \$1:" |
|
976 | 976 | > hg parents --template "VISIBLE {rev}:{node|short}\n" |
|
977 | 977 | > # test that pending changes are hidden |
|
978 | 978 | > unset HG_PENDING |
|
979 | 979 | > hg parents --template "ACTUAL {rev}:{node|short}\n" |
|
980 | 980 | > echo "====" |
|
981 | 981 | > EOF |
|
982 | 982 | |
|
983 | 983 | $ cat >> .hg/hgrc <<EOF |
|
984 | 984 | > [defaults] |
|
985 | 985 | > # to fix hash id of temporary revisions |
|
986 | 986 | > unshelve = --date '0 0' |
|
987 | 987 | > EOF |
|
988 | 988 | |
|
989 | 989 | "hg unshelve" at REV5 implies steps below: |
|
990 | 990 | |
|
991 | 991 | (1) commit changes in the working directory (REV6) |
|
992 | 992 | (2) unbundle shelved revision (REV7) |
|
993 | 993 | (3) rebase: merge REV7 into REV6 (REV6 => REV6, REV7) |
|
994 | 994 | (4) rebase: commit merged revision (REV8) |
|
995 | 995 | (5) rebase: update to REV6 (REV8 => REV6) |
|
996 | 996 | (6) update to REV5 (REV6 => REV5) |
|
997 | 997 | (7) abort transaction |
|
998 | 998 | |
|
999 | 999 | == test visibility to external preupdate hook |
|
1000 | 1000 | |
|
1001 | 1001 | $ cat >> .hg/hgrc <<EOF |
|
1002 | 1002 | > [hooks] |
|
1003 | 1003 | > preupdate.visibility = sh $TESTTMP/checkvisibility.sh preupdate |
|
1004 | 1004 | > EOF |
|
1005 | 1005 | |
|
1006 | 1006 | $ echo nnnn >> n |
|
1007 | 1007 | |
|
1008 | 1008 | $ sh $TESTTMP/checkvisibility.sh before-unshelving |
|
1009 | 1009 | ==== before-unshelving: |
|
1010 | 1010 | VISIBLE (5|19):703117a2acfb (re) |
|
1011 | 1011 | ACTUAL (5|19):703117a2acfb (re) |
|
1012 | 1012 | ==== |
|
1013 | 1013 | |
|
1014 | 1014 | $ hg unshelve --keep default |
|
1015 | 1015 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1016 | 1016 | rebasing shelved changes |
|
1017 | 1017 | ==== preupdate: |
|
1018 | 1018 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1019 | 1019 | ACTUAL (5|19):703117a2acfb (re) |
|
1020 | 1020 | ==== |
|
1021 | 1021 | ==== preupdate: |
|
1022 | 1022 | VISIBLE (8|21):8efe6f7537dc (re) |
|
1023 | 1023 | ACTUAL (5|19):703117a2acfb (re) |
|
1024 | 1024 | ==== |
|
1025 | 1025 | ==== preupdate: |
|
1026 | 1026 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1027 | 1027 | ACTUAL (5|19):703117a2acfb (re) |
|
1028 | 1028 | ==== |
|
1029 | 1029 | |
|
1030 | 1030 | $ cat >> .hg/hgrc <<EOF |
|
1031 | 1031 | > [hooks] |
|
1032 | 1032 | > preupdate.visibility = |
|
1033 | 1033 | > EOF |
|
1034 | 1034 | |
|
1035 | 1035 | $ sh $TESTTMP/checkvisibility.sh after-unshelving |
|
1036 | 1036 | ==== after-unshelving: |
|
1037 | 1037 | VISIBLE (5|19):703117a2acfb (re) |
|
1038 | 1038 | ACTUAL (5|19):703117a2acfb (re) |
|
1039 | 1039 | ==== |
|
1040 | 1040 | |
|
1041 | 1041 | == test visibility to external update hook |
|
1042 | 1042 | |
|
1043 | 1043 | $ hg update -q -C 703117a2acfb |
|
1044 | 1044 | |
|
1045 | 1045 | $ cat >> .hg/hgrc <<EOF |
|
1046 | 1046 | > [hooks] |
|
1047 | 1047 | > update.visibility = sh $TESTTMP/checkvisibility.sh update |
|
1048 | 1048 | > EOF |
|
1049 | 1049 | |
|
1050 | 1050 | $ echo nnnn >> n |
|
1051 | 1051 | |
|
1052 | 1052 | $ sh $TESTTMP/checkvisibility.sh before-unshelving |
|
1053 | 1053 | ==== before-unshelving: |
|
1054 | 1054 | VISIBLE (5|19):703117a2acfb (re) |
|
1055 | 1055 | ACTUAL (5|19):703117a2acfb (re) |
|
1056 | 1056 | ==== |
|
1057 | 1057 | |
|
1058 | 1058 | $ hg unshelve --keep default |
|
1059 | 1059 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1060 | 1060 | rebasing shelved changes |
|
1061 | 1061 | ==== update: |
|
1062 | 1062 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1063 | 1063 | VISIBLE 1?7:492ed9d705e5 (re) |
|
1064 | 1064 | ACTUAL (5|19):703117a2acfb (re) |
|
1065 | 1065 | ==== |
|
1066 | 1066 | ==== update: |
|
1067 | 1067 | VISIBLE (6|20):54c00d20fb3f (re) |
|
1068 | 1068 | ACTUAL (5|19):703117a2acfb (re) |
|
1069 | 1069 | ==== |
|
1070 | 1070 | ==== update: |
|
1071 | 1071 | VISIBLE (5|19):703117a2acfb (re) |
|
1072 | 1072 | ACTUAL (5|19):703117a2acfb (re) |
|
1073 | 1073 | ==== |
|
1074 | 1074 | |
|
1075 | 1075 | $ cat >> .hg/hgrc <<EOF |
|
1076 | 1076 | > [hooks] |
|
1077 | 1077 | > update.visibility = |
|
1078 | 1078 | > EOF |
|
1079 | 1079 | |
|
1080 | 1080 | $ sh $TESTTMP/checkvisibility.sh after-unshelving |
|
1081 | 1081 | ==== after-unshelving: |
|
1082 | 1082 | VISIBLE (5|19):703117a2acfb (re) |
|
1083 | 1083 | ACTUAL (5|19):703117a2acfb (re) |
|
1084 | 1084 | ==== |
|
1085 | 1085 | |
|
1086 | 1086 | $ cd .. |
|
1087 | 1087 | |
|
1088 | 1088 | Keep active bookmark while (un)shelving even on shared repo (issue4940) |
|
1089 | 1089 | ----------------------------------------------------------------------- |
|
1090 | 1090 | |
|
1091 | 1091 | $ cat <<EOF >> $HGRCPATH |
|
1092 | 1092 | > [extensions] |
|
1093 | 1093 | > share = |
|
1094 | 1094 | > EOF |
|
1095 | 1095 | |
|
1096 | 1096 | $ hg bookmarks -R repo |
|
1097 | 1097 | test (4|13):33f7f61e6c5e (re) |
|
1098 | 1098 | $ hg share -B repo share |
|
1099 | 1099 | updating working directory |
|
1100 | 1100 | 6 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1101 | 1101 | $ cd share |
|
1102 | 1102 | |
|
1103 | 1103 | $ hg bookmarks |
|
1104 | 1104 | test (4|13):33f7f61e6c5e (re) |
|
1105 | 1105 | $ hg bookmarks foo |
|
1106 | 1106 | $ hg bookmarks |
|
1107 | 1107 | \* foo (5|19):703117a2acfb (re) |
|
1108 | 1108 | test (4|13):33f7f61e6c5e (re) |
|
1109 | 1109 | $ echo x >> x |
|
1110 | 1110 | $ hg shelve |
|
1111 | 1111 | shelved as foo |
|
1112 | 1112 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1113 | 1113 | $ hg bookmarks |
|
1114 | 1114 | \* foo (5|19):703117a2acfb (re) |
|
1115 | 1115 | test (4|13):33f7f61e6c5e (re) |
|
1116 | 1116 | |
|
1117 | 1117 | $ hg unshelve |
|
1118 | 1118 | unshelving change 'foo' |
|
1119 | 1119 | $ hg bookmarks |
|
1120 | 1120 | \* foo (5|19):703117a2acfb (re) |
|
1121 | 1121 | test (4|13):33f7f61e6c5e (re) |
|
1122 | 1122 | |
|
1123 | 1123 | $ cd .. |
|
1124 | 1124 | |
|
1125 | 1125 | Abort unshelve while merging (issue5123) |
|
1126 | 1126 | ---------------------------------------- |
|
1127 | 1127 | |
|
1128 | 1128 | $ hg init issue5123 |
|
1129 | 1129 | $ cd issue5123 |
|
1130 | 1130 | $ echo > a |
|
1131 | 1131 | $ hg ci -Am a |
|
1132 | 1132 | adding a |
|
1133 | 1133 | $ hg co null |
|
1134 | 1134 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1135 | 1135 | $ echo > b |
|
1136 | 1136 | $ hg ci -Am b |
|
1137 | 1137 | adding b |
|
1138 | 1138 | created new head |
|
1139 | 1139 | $ echo > c |
|
1140 | 1140 | $ hg add c |
|
1141 | 1141 | $ hg shelve |
|
1142 | 1142 | shelved as default |
|
1143 | 1143 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1144 | 1144 | $ hg co 1 |
|
1145 | 1145 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1146 | 1146 | $ hg merge 0 |
|
1147 | 1147 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1148 | 1148 | (branch merge, don't forget to commit) |
|
1149 | 1149 | -- successful merge with two parents |
|
1150 | 1150 | $ hg log -G |
|
1151 | 1151 | @ changeset: 1:406bf70c274f |
|
1152 | 1152 | tag: tip |
|
1153 | 1153 | parent: -1:000000000000 |
|
1154 | 1154 | user: test |
|
1155 | 1155 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1156 | 1156 | summary: b |
|
1157 | 1157 | |
|
1158 | 1158 | @ changeset: 0:ada8c9eb8252 |
|
1159 | 1159 | user: test |
|
1160 | 1160 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1161 | 1161 | summary: a |
|
1162 | 1162 | |
|
1163 | 1163 | -- trying to pull in the shelve bits |
|
1164 | 1164 | -- unshelve should abort otherwise, it'll eat my second parent. |
|
1165 | 1165 | $ hg unshelve |
|
1166 | 1166 | abort: outstanding uncommitted merge |
|
1167 | 1167 | (use 'hg commit' or 'hg merge --abort') |
|
1168 | 1168 | [255] |
|
1169 | 1169 | |
|
1170 | 1170 | $ cd .. |
|
1171 | 1171 | |
|
1172 | 1172 | -- test for interactive mode on unshelve |
|
1173 | 1173 | |
|
1174 | 1174 | $ hg init a |
|
1175 | 1175 | $ cd a |
|
1176 | 1176 | $ echo > b |
|
1177 | 1177 | $ hg ci -Am b |
|
1178 | 1178 | adding b |
|
1179 | 1179 | $ echo > c |
|
1180 | 1180 | $ echo > d |
|
1181 | 1181 | $ hg add . |
|
1182 | 1182 | adding c |
|
1183 | 1183 | adding d |
|
1184 | 1184 | $ hg shelve |
|
1185 | 1185 | shelved as default |
|
1186 | 1186 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
1187 | 1187 | $ echo > e |
|
1188 | 1188 | $ hg add e |
|
1189 | 1189 | $ hg ci -m e |
|
1190 | 1190 | $ hg shelve --patch |
|
1191 | 1191 | default (*s ago) changes to: b (glob) |
|
1192 | 1192 | |
|
1193 | 1193 | diff --git a/c b/c |
|
1194 | 1194 | new file mode 100644 |
|
1195 | 1195 | --- /dev/null |
|
1196 | 1196 | +++ b/c |
|
1197 | 1197 | @@ -0,0 +1,1 @@ |
|
1198 | 1198 | + |
|
1199 | 1199 | diff --git a/d b/d |
|
1200 | 1200 | new file mode 100644 |
|
1201 | 1201 | --- /dev/null |
|
1202 | 1202 | +++ b/d |
|
1203 | 1203 | @@ -0,0 +1,1 @@ |
|
1204 | 1204 | + |
|
1205 | 1205 | $ hg unshelve -i <<EOF |
|
1206 | 1206 | > y |
|
1207 | 1207 | > y |
|
1208 | 1208 | > y |
|
1209 | 1209 | > n |
|
1210 | 1210 | > EOF |
|
1211 | 1211 | unshelving change 'default' |
|
1212 | 1212 | rebasing shelved changes |
|
1213 | 1213 | diff --git a/c b/c |
|
1214 | 1214 | new file mode 100644 |
|
1215 | 1215 | examine changes to 'c'? |
|
1216 | 1216 | (enter ? for help) [Ynesfdaq?] y |
|
1217 | 1217 | |
|
1218 | 1218 | @@ -0,0 +1,1 @@ |
|
1219 | 1219 | + |
|
1220 | 1220 | record change 1/2 to 'c'? |
|
1221 | 1221 | (enter ? for help) [Ynesfdaq?] y |
|
1222 | 1222 | |
|
1223 | 1223 | diff --git a/d b/d |
|
1224 | 1224 | new file mode 100644 |
|
1225 | 1225 | examine changes to 'd'? |
|
1226 | 1226 | (enter ? for help) [Ynesfdaq?] y |
|
1227 | 1227 | |
|
1228 | 1228 | @@ -0,0 +1,1 @@ |
|
1229 | 1229 | + |
|
1230 | 1230 | record change 2/2 to 'd'? |
|
1231 | 1231 | (enter ? for help) [Ynesfdaq?] n |
|
1232 | 1232 | |
|
1233 | 1233 | $ ls |
|
1234 | 1234 | b |
|
1235 | 1235 | c |
|
1236 | 1236 | e |
|
1237 | 1237 | -- shelve should not contain `c` now |
|
1238 | 1238 | $ hg shelve --patch |
|
1239 | 1239 | default (*s ago) changes to: b (glob) |
|
1240 | 1240 | |
|
1241 | 1241 | diff --git a/d b/d |
|
1242 | 1242 | new file mode 100644 |
|
1243 | 1243 | --- /dev/null |
|
1244 | 1244 | +++ b/d |
|
1245 | 1245 | @@ -0,0 +1,1 @@ |
|
1246 | 1246 | + |
|
1247 | 1247 | $ hg unshelve -i <<EOF |
|
1248 | 1248 | > y |
|
1249 | 1249 | > y |
|
1250 | 1250 | > EOF |
|
1251 | 1251 | unshelving change 'default' |
|
1252 | 1252 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1253 | 1253 | rebasing shelved changes |
|
1254 | 1254 | diff --git a/d b/d |
|
1255 | 1255 | new file mode 100644 |
|
1256 | 1256 | examine changes to 'd'? |
|
1257 | 1257 | (enter ? for help) [Ynesfdaq?] y |
|
1258 | 1258 | |
|
1259 | 1259 | @@ -0,0 +1,1 @@ |
|
1260 | 1260 | + |
|
1261 | 1261 | record this change to 'd'? |
|
1262 | 1262 | (enter ? for help) [Ynesfdaq?] y |
|
1263 | 1263 | |
|
1264 | 1264 | |
|
1265 | 1265 | $ hg status -v |
|
1266 | 1266 | A c |
|
1267 | 1267 | A d |
|
1268 | 1268 | $ ls |
|
1269 | 1269 | b |
|
1270 | 1270 | c |
|
1271 | 1271 | d |
|
1272 | 1272 | e |
|
1273 | 1273 | $ hg shelve --list |
|
1274 | 1274 | |
|
1275 | 1275 | -- now, unshelve selected changes from a file |
|
1276 | 1276 | |
|
1277 | 1277 | $ echo B > foo |
|
1278 | 1278 | $ hg add foo |
|
1279 | 1279 | $ hg ci -m 'add B to foo' |
|
1280 | 1280 | $ cat > foo <<EOF |
|
1281 | 1281 | > A |
|
1282 | 1282 | > B |
|
1283 | 1283 | > C |
|
1284 | 1284 | > EOF |
|
1285 | 1285 | $ echo > garbage |
|
1286 | 1286 | $ hg st |
|
1287 | 1287 | M foo |
|
1288 | 1288 | ? garbage |
|
1289 | 1289 | $ hg shelve --unknown |
|
1290 | 1290 | shelved as default |
|
1291 | 1291 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
1292 | 1292 | $ cat foo |
|
1293 | 1293 | B |
|
1294 | 1294 | $ hg unshelve -i <<EOF |
|
1295 | 1295 | > y |
|
1296 | 1296 | > y |
|
1297 | 1297 | > n |
|
1298 | 1298 | > y |
|
1299 | 1299 | > y |
|
1300 | 1300 | > EOF |
|
1301 | 1301 | unshelving change 'default' |
|
1302 | 1302 | rebasing shelved changes |
|
1303 | 1303 | diff --git a/foo b/foo |
|
1304 | 1304 | 2 hunks, 2 lines changed |
|
1305 | 1305 | examine changes to 'foo'? |
|
1306 | 1306 | (enter ? for help) [Ynesfdaq?] y |
|
1307 | 1307 | |
|
1308 | 1308 | @@ -1,1 +1,2 @@ |
|
1309 | 1309 | +A |
|
1310 | 1310 | B |
|
1311 | 1311 | record change 1/3 to 'foo'? |
|
1312 | 1312 | (enter ? for help) [Ynesfdaq?] y |
|
1313 | 1313 | |
|
1314 | 1314 | @@ -1,1 +2,2 @@ |
|
1315 | 1315 | B |
|
1316 | 1316 | +C |
|
1317 | 1317 | record change 2/3 to 'foo'? |
|
1318 | 1318 | (enter ? for help) [Ynesfdaq?] n |
|
1319 | 1319 | |
|
1320 | 1320 | diff --git a/garbage b/garbage |
|
1321 | 1321 | new file mode 100644 |
|
1322 | 1322 | examine changes to 'garbage'? |
|
1323 | 1323 | (enter ? for help) [Ynesfdaq?] y |
|
1324 | 1324 | |
|
1325 | 1325 | @@ -0,0 +1,1 @@ |
|
1326 | 1326 | + |
|
1327 | 1327 | record change 3/3 to 'garbage'? |
|
1328 | 1328 | (enter ? for help) [Ynesfdaq?] y |
|
1329 | 1329 | |
|
1330 | 1330 | $ hg st |
|
1331 | 1331 | M foo |
|
1332 | 1332 | ? garbage |
|
1333 | 1333 | $ cat foo |
|
1334 | 1334 | A |
|
1335 | 1335 | B |
|
1336 | 1336 | $ hg shelve --patch |
|
1337 | 1337 | default (*s ago) changes to: add B to foo (glob) |
|
1338 | 1338 | |
|
1339 | 1339 | diff --git a/foo b/foo |
|
1340 | 1340 | --- a/foo |
|
1341 | 1341 | +++ b/foo |
|
1342 | 1342 | @@ -1,2 +1,3 @@ |
|
1343 | 1343 | A |
|
1344 | 1344 | B |
|
1345 | 1345 | +C |
|
1346 | 1346 | |
|
1347 | 1347 | -- unshelve interactive on conflicts |
|
1348 | 1348 | |
|
1349 | 1349 | $ echo A >> bar1 |
|
1350 | 1350 | $ echo A >> bar2 |
|
1351 | 1351 | $ hg add bar1 bar2 |
|
1352 | 1352 | $ hg ci -m 'add A to bars' |
|
1353 | 1353 | $ echo B >> bar1 |
|
1354 | 1354 | $ echo B >> bar2 |
|
1355 | 1355 | $ hg shelve |
|
1356 | 1356 | shelved as default-01 |
|
1357 | 1357 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
1358 | 1358 | $ echo C >> bar1 |
|
1359 | 1359 | $ echo C >> bar2 |
|
1360 | 1360 | $ hg ci -m 'add C to bars' |
|
1361 | 1361 | $ hg unshelve -i |
|
1362 | 1362 | unshelving change 'default-01' |
|
1363 | 1363 | rebasing shelved changes |
|
1364 | 1364 | merging bar1 |
|
1365 | 1365 | merging bar2 |
|
1366 | 1366 | warning: conflicts while merging bar1! (edit, then use 'hg resolve --mark') |
|
1367 | 1367 | warning: conflicts while merging bar2! (edit, then use 'hg resolve --mark') |
|
1368 | 1368 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
1369 | 1369 | [1] |
|
1370 | 1370 | |
|
1371 | 1371 | $ cat > bar1 <<EOF |
|
1372 | 1372 | > A |
|
1373 | 1373 | > B |
|
1374 | 1374 | > C |
|
1375 | 1375 | > EOF |
|
1376 | 1376 | $ cat > bar2 <<EOF |
|
1377 | 1377 | > A |
|
1378 | 1378 | > B |
|
1379 | 1379 | > C |
|
1380 | 1380 | > EOF |
|
1381 | 1381 | $ hg resolve -m bar1 bar2 |
|
1382 | 1382 | (no more unresolved files) |
|
1383 | 1383 | continue: hg unshelve --continue |
|
1384 | 1384 | |
|
1385 | 1385 | -- using --continue with --interactive should throw an error |
|
1386 | 1386 | $ hg unshelve --continue -i |
|
1387 | 1387 | abort: cannot use both continue and interactive |
|
1388 | 1388 | [255] |
|
1389 | 1389 | |
|
1390 | 1390 | $ cat bar1 |
|
1391 | 1391 | A |
|
1392 | 1392 | B |
|
1393 | 1393 | C |
|
1394 | 1394 | |
|
1395 | 1395 | #if stripbased |
|
1396 | 1396 | $ hg log -r 3:: -G |
|
1397 | 1397 | @ changeset: 5:f1d5f53e397b |
|
1398 | 1398 | | tag: tip |
|
1399 | 1399 | | parent: 3:e28fd7fa7938 |
|
1400 | 1400 | | user: shelve@localhost |
|
1401 | 1401 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1402 | 1402 | | summary: changes to: add A to bars |
|
1403 | 1403 | | |
|
1404 | 1404 | | @ changeset: 4:fe451a778c81 |
|
1405 | 1405 | |/ user: test |
|
1406 | 1406 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1407 | 1407 | | summary: add C to bars |
|
1408 | 1408 | | |
|
1409 | 1409 | o changeset: 3:e28fd7fa7938 |
|
1410 | 1410 | | user: test |
|
1411 | 1411 | ~ date: Thu Jan 01 00:00:00 1970 +0000 |
|
1412 | 1412 | summary: add A to bars |
|
1413 | 1413 | |
|
1414 | 1414 | #endif |
|
1415 | 1415 | |
|
1416 | 1416 | $ hg unshelve --continue <<EOF |
|
1417 | 1417 | > y |
|
1418 | 1418 | > y |
|
1419 | 1419 | > y |
|
1420 | 1420 | > n |
|
1421 | 1421 | > EOF |
|
1422 | 1422 | diff --git a/bar1 b/bar1 |
|
1423 | 1423 | 1 hunks, 1 lines changed |
|
1424 | 1424 | examine changes to 'bar1'? |
|
1425 | 1425 | (enter ? for help) [Ynesfdaq?] y |
|
1426 | 1426 | |
|
1427 | 1427 | @@ -1,2 +1,3 @@ |
|
1428 | 1428 | A |
|
1429 | 1429 | +B |
|
1430 | 1430 | C |
|
1431 | 1431 | record change 1/2 to 'bar1'? |
|
1432 | 1432 | (enter ? for help) [Ynesfdaq?] y |
|
1433 | 1433 | |
|
1434 | 1434 | diff --git a/bar2 b/bar2 |
|
1435 | 1435 | 1 hunks, 1 lines changed |
|
1436 | 1436 | examine changes to 'bar2'? |
|
1437 | 1437 | (enter ? for help) [Ynesfdaq?] y |
|
1438 | 1438 | |
|
1439 | 1439 | @@ -1,2 +1,3 @@ |
|
1440 | 1440 | A |
|
1441 | 1441 | +B |
|
1442 | 1442 | C |
|
1443 | 1443 | record change 2/2 to 'bar2'? |
|
1444 | 1444 | (enter ? for help) [Ynesfdaq?] n |
|
1445 | 1445 | |
|
1446 | 1446 | unshelve of 'default-01' complete |
|
1447 | 1447 | |
|
1448 | 1448 | #if stripbased |
|
1449 | 1449 | $ hg log -r 3:: -G |
|
1450 | 1450 | @ changeset: 4:fe451a778c81 |
|
1451 | 1451 | | tag: tip |
|
1452 | 1452 | | user: test |
|
1453 | 1453 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1454 | 1454 | | summary: add C to bars |
|
1455 | 1455 | | |
|
1456 | 1456 | o changeset: 3:e28fd7fa7938 |
|
1457 | 1457 | | user: test |
|
1458 | 1458 | ~ date: Thu Jan 01 00:00:00 1970 +0000 |
|
1459 | 1459 | summary: add A to bars |
|
1460 | 1460 | |
|
1461 | 1461 | #endif |
|
1462 | 1462 | |
|
1463 | 1463 | $ hg unshelve --continue |
|
1464 | 1464 | abort: no unshelve in progress |
|
1465 | 1465 | [255] |
|
1466 | 1466 | |
|
1467 | 1467 | $ hg shelve --list |
|
1468 | 1468 | default-01 (*)* changes to: add A to bars (glob) |
|
1469 | 1469 | default (*)* changes to: add B to foo (glob) |
|
1470 | 1470 | $ hg unshelve -n default-01 -i <<EOF |
|
1471 | 1471 | > y |
|
1472 | 1472 | > y |
|
1473 | 1473 | > EOF |
|
1474 | 1474 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
1475 | 1475 | rebasing shelved changes |
|
1476 | 1476 | diff --git a/bar2 b/bar2 |
|
1477 | 1477 | 1 hunks, 1 lines changed |
|
1478 | 1478 | examine changes to 'bar2'? |
|
1479 | 1479 | (enter ? for help) [Ynesfdaq?] y |
|
1480 | 1480 | |
|
1481 | 1481 | @@ -1,2 +1,3 @@ |
|
1482 | 1482 | A |
|
1483 | 1483 | +B |
|
1484 | 1484 | C |
|
1485 | 1485 | record this change to 'bar2'? |
|
1486 | 1486 | (enter ? for help) [Ynesfdaq?] y |
|
1487 | 1487 | |
|
1488 | 1488 | -- test for --interactive --keep |
|
1489 | 1489 | $ hg unshelve -i --keep |
|
1490 | 1490 | abort: --keep on --interactive is not yet supported |
|
1491 | 1491 | [255] |
@@ -1,945 +1,945 b'' | |||
|
1 | 1 | #testcases stripbased phasebased |
|
2 | 2 | #testcases abortflag abortcommand |
|
3 | 3 | #testcases continueflag continuecommand |
|
4 | 4 | |
|
5 | 5 | $ cat <<EOF >> $HGRCPATH |
|
6 | 6 | > [extensions] |
|
7 | 7 | > mq = |
|
8 | 8 | > [defaults] |
|
9 | 9 | > diff = --nodates --git |
|
10 | 10 | > qnew = --date '0 0' |
|
11 | 11 | > [shelve] |
|
12 | 12 | > maxbackups = 2 |
|
13 | 13 | > EOF |
|
14 | 14 | |
|
15 | 15 | #if phasebased |
|
16 | 16 | |
|
17 | 17 | $ cat <<EOF >> $HGRCPATH |
|
18 | 18 | > [format] |
|
19 | 19 | > internal-phase = yes |
|
20 | 20 | > EOF |
|
21 | 21 | |
|
22 | 22 | #endif |
|
23 | 23 | |
|
24 | 24 | #if abortflag |
|
25 | 25 | $ cat >> $HGRCPATH <<EOF |
|
26 | 26 | > [alias] |
|
27 | 27 | > abort = unshelve --abort |
|
28 | 28 | > EOF |
|
29 | 29 | #endif |
|
30 | 30 | |
|
31 | 31 | #if continueflag |
|
32 | 32 | $ cat >> $HGRCPATH <<EOF |
|
33 | 33 | > [alias] |
|
34 | 34 | > continue = unshelve --continue |
|
35 | 35 | > EOF |
|
36 | 36 | #endif |
|
37 | 37 | |
|
38 | 38 | shelve should leave dirstate clean (issue4055) |
|
39 | 39 | |
|
40 | 40 | $ hg init shelverebase |
|
41 | 41 | $ cd shelverebase |
|
42 | 42 | $ printf 'x\ny\n' > x |
|
43 | 43 | $ echo z > z |
|
44 | 44 | $ hg commit -Aqm xy |
|
45 | 45 | $ echo z >> x |
|
46 | 46 | $ hg commit -Aqm z |
|
47 | 47 | $ hg up 5c4c67fb7dce |
|
48 | 48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
49 | 49 | $ printf 'a\nx\ny\nz\n' > x |
|
50 | 50 | $ hg commit -Aqm xyz |
|
51 | 51 | $ echo c >> z |
|
52 | 52 | $ hg shelve |
|
53 | 53 | shelved as default |
|
54 | 54 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
55 | 55 | |
|
56 | 56 | $ hg rebase -d 6c103be8f4e4 --config extensions.rebase= |
|
57 | 57 | rebasing 2:323bfa07f744 "xyz"( \(tip\))? (re) |
|
58 | 58 | merging x |
|
59 | 59 | saved backup bundle to \$TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-(78114325|7ae538ef)-rebase.hg (re) |
|
60 | 60 | $ hg unshelve |
|
61 | 61 | unshelving change 'default' |
|
62 | 62 | rebasing shelved changes |
|
63 | 63 | $ hg status |
|
64 | 64 | M z |
|
65 | 65 | |
|
66 | 66 | $ cd .. |
|
67 | 67 | |
|
68 | 68 | shelve should only unshelve pending changes (issue4068) |
|
69 | 69 | |
|
70 | 70 | $ hg init onlypendingchanges |
|
71 | 71 | $ cd onlypendingchanges |
|
72 | 72 | $ touch a |
|
73 | 73 | $ hg ci -Aqm a |
|
74 | 74 | $ touch b |
|
75 | 75 | $ hg ci -Aqm b |
|
76 | 76 | $ hg up -q 3903775176ed |
|
77 | 77 | $ touch c |
|
78 | 78 | $ hg ci -Aqm c |
|
79 | 79 | |
|
80 | 80 | $ touch d |
|
81 | 81 | $ hg add d |
|
82 | 82 | $ hg shelve |
|
83 | 83 | shelved as default |
|
84 | 84 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
85 | 85 | $ hg up -q 0e067c57feba |
|
86 | 86 | $ hg unshelve |
|
87 | 87 | unshelving change 'default' |
|
88 | 88 | rebasing shelved changes |
|
89 | 89 | $ hg status |
|
90 | 90 | A d |
|
91 | 91 | |
|
92 | 92 | unshelve should work on an ancestor of the original commit |
|
93 | 93 | |
|
94 | 94 | $ hg shelve |
|
95 | 95 | shelved as default |
|
96 | 96 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
97 | 97 | $ hg up 3903775176ed |
|
98 | 98 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
99 | 99 | $ hg unshelve |
|
100 | 100 | unshelving change 'default' |
|
101 | 101 | rebasing shelved changes |
|
102 | 102 | $ hg status |
|
103 | 103 | A d |
|
104 | 104 | |
|
105 | 105 | test bug 4073 we need to enable obsolete markers for it |
|
106 | 106 | |
|
107 | 107 | $ cat >> $HGRCPATH << EOF |
|
108 | 108 | > [experimental] |
|
109 | 109 | > evolution.createmarkers=True |
|
110 | 110 | > EOF |
|
111 | 111 | $ hg shelve |
|
112 | 112 | shelved as default |
|
113 | 113 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
114 | 114 | $ hg debugobsolete `hg log -r 0e067c57feba -T '{node}'` |
|
115 | 115 | 1 new obsolescence markers |
|
116 | 116 | obsoleted 1 changesets |
|
117 | 117 | $ hg unshelve |
|
118 | 118 | unshelving change 'default' |
|
119 | 119 | |
|
120 | 120 | unshelve should leave unknown files alone (issue4113) |
|
121 | 121 | |
|
122 | 122 | $ echo e > e |
|
123 | 123 | $ hg shelve |
|
124 | 124 | shelved as default |
|
125 | 125 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
126 | 126 | $ hg status |
|
127 | 127 | ? e |
|
128 | 128 | $ hg unshelve |
|
129 | 129 | unshelving change 'default' |
|
130 | 130 | $ hg status |
|
131 | 131 | A d |
|
132 | 132 | ? e |
|
133 | 133 | $ cat e |
|
134 | 134 | e |
|
135 | 135 | |
|
136 | 136 | unshelve should keep a copy of unknown files |
|
137 | 137 | |
|
138 | 138 | $ hg add e |
|
139 | 139 | $ hg shelve |
|
140 | 140 | shelved as default |
|
141 | 141 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
142 | 142 | $ echo z > e |
|
143 | 143 | $ hg unshelve |
|
144 | 144 | unshelving change 'default' |
|
145 | 145 | $ cat e |
|
146 | 146 | e |
|
147 | 147 | $ cat e.orig |
|
148 | 148 | z |
|
149 | 149 | $ rm e.orig |
|
150 | 150 | |
|
151 | 151 | restores backup of unknown file to right directory |
|
152 | 152 | |
|
153 | 153 | $ hg shelve |
|
154 | 154 | shelved as default |
|
155 | 155 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
156 | 156 | $ echo z > e |
|
157 | 157 | $ mkdir dir |
|
158 | 158 | $ hg unshelve --cwd dir |
|
159 | 159 | unshelving change 'default' |
|
160 | 160 | $ rmdir dir |
|
161 | 161 | $ cat e |
|
162 | 162 | e |
|
163 | 163 | $ cat e.orig |
|
164 | 164 | z |
|
165 | 165 | |
|
166 | 166 | unshelve and conflicts with tracked and untracked files |
|
167 | 167 | |
|
168 | 168 | preparing: |
|
169 | 169 | |
|
170 | 170 | $ rm -f *.orig |
|
171 | 171 | $ hg ci -qm 'commit stuff' |
|
172 | 172 | $ hg phase -p null: |
|
173 | 173 | |
|
174 | 174 | no other changes - no merge: |
|
175 | 175 | |
|
176 | 176 | $ echo f > f |
|
177 | 177 | $ hg add f |
|
178 | 178 | $ hg shelve |
|
179 | 179 | shelved as default |
|
180 | 180 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
181 | 181 | $ echo g > f |
|
182 | 182 | $ hg unshelve |
|
183 | 183 | unshelving change 'default' |
|
184 | 184 | $ hg st |
|
185 | 185 | A f |
|
186 | 186 | ? f.orig |
|
187 | 187 | $ cat f |
|
188 | 188 | f |
|
189 | 189 | $ cat f.orig |
|
190 | 190 | g |
|
191 | 191 | |
|
192 | 192 | other uncommitted changes - merge: |
|
193 | 193 | |
|
194 | 194 | $ hg st |
|
195 | 195 | A f |
|
196 | 196 | ? f.orig |
|
197 | 197 | $ hg shelve |
|
198 | 198 | shelved as default |
|
199 | 199 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
200 | 200 | #if repobundlerepo |
|
201 | 201 | $ hg log -G --template '{rev} {desc|firstline} {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()' --hidden |
|
202 | 202 | o [48] changes to: commit stuff shelve@localhost (re) |
|
203 | 203 | | |
|
204 | 204 | ~ |
|
205 | 205 | #endif |
|
206 | 206 | $ hg log -G --template '{rev} {desc|firstline} {author}' |
|
207 | 207 | @ [37] commit stuff test (re) |
|
208 | 208 | | |
|
209 | 209 | | o 2 c test |
|
210 | 210 | |/ |
|
211 | 211 | o 0 a test |
|
212 | 212 | |
|
213 | 213 | $ mv f.orig f |
|
214 | 214 | $ echo 1 > a |
|
215 | 215 | $ hg unshelve --date '1073741824 0' |
|
216 | 216 | unshelving change 'default' |
|
217 | 217 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
218 | 218 | rebasing shelved changes |
|
219 | 219 | merging f |
|
220 | 220 | warning: conflicts while merging f! (edit, then use 'hg resolve --mark') |
|
221 | 221 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
222 | 222 | [1] |
|
223 | 223 | |
|
224 | 224 | #if phasebased |
|
225 | 225 | $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}' |
|
226 | 226 | @ 9 pending changes temporary commit shelve@localhost 2004-01-10 13:37 +0000 |
|
227 | 227 | | |
|
228 | 228 | | @ 8 changes to: commit stuff shelve@localhost 1970-01-01 00:00 +0000 |
|
229 | 229 | |/ |
|
230 | 230 | o 7 commit stuff test 1970-01-01 00:00 +0000 |
|
231 | 231 | | |
|
232 | 232 | | o 2 c test 1970-01-01 00:00 +0000 |
|
233 | 233 | |/ |
|
234 | 234 | o 0 a test 1970-01-01 00:00 +0000 |
|
235 | 235 | |
|
236 | 236 | #endif |
|
237 | 237 | |
|
238 | 238 | #if stripbased |
|
239 | 239 | $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}' |
|
240 | 240 | @ 5 changes to: commit stuff shelve@localhost 1970-01-01 00:00 +0000 |
|
241 | 241 | | |
|
242 | 242 | | @ 4 pending changes temporary commit shelve@localhost 2004-01-10 13:37 +0000 |
|
243 | 243 | |/ |
|
244 | 244 | o 3 commit stuff test 1970-01-01 00:00 +0000 |
|
245 | 245 | | |
|
246 | 246 | | o 2 c test 1970-01-01 00:00 +0000 |
|
247 | 247 | |/ |
|
248 | 248 | o 0 a test 1970-01-01 00:00 +0000 |
|
249 | 249 | |
|
250 | 250 | #endif |
|
251 | 251 | |
|
252 | 252 | $ hg st |
|
253 | 253 | M f |
|
254 | 254 | ? f.orig |
|
255 | 255 | $ cat f |
|
256 |
<<<<<<< |
|
|
256 | <<<<<<< working-copy: d44eae5c3d33 - shelve: pending changes temporary commit | |
|
257 | 257 | g |
|
258 | 258 | ======= |
|
259 | 259 | f |
|
260 |
>>>>>>> |
|
|
260 | >>>>>>> shelve: aef214a5229c - shelve: changes to: commit stuff | |
|
261 | 261 | $ cat f.orig |
|
262 | 262 | g |
|
263 | 263 | $ hg unshelve --abort -t false |
|
264 | 264 | tool option will be ignored |
|
265 | 265 | unshelve of 'default' aborted |
|
266 | 266 | $ hg st |
|
267 | 267 | M a |
|
268 | 268 | ? f.orig |
|
269 | 269 | $ cat f.orig |
|
270 | 270 | g |
|
271 | 271 | $ hg unshelve |
|
272 | 272 | unshelving change 'default' |
|
273 | 273 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
274 | 274 | rebasing shelved changes |
|
275 | 275 | $ hg st |
|
276 | 276 | M a |
|
277 | 277 | A f |
|
278 | 278 | ? f.orig |
|
279 | 279 | |
|
280 | 280 | other committed changes - merge: |
|
281 | 281 | |
|
282 | 282 | $ hg shelve f |
|
283 | 283 | shelved as default |
|
284 | 284 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
285 | 285 | $ hg ci a -m 'intermediate other change' |
|
286 | 286 | $ mv f.orig f |
|
287 | 287 | $ hg unshelve |
|
288 | 288 | unshelving change 'default' |
|
289 | 289 | rebasing shelved changes |
|
290 | 290 | merging f |
|
291 | 291 | warning: conflicts while merging f! (edit, then use 'hg resolve --mark') |
|
292 | 292 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
293 | 293 | [1] |
|
294 | 294 | $ hg st |
|
295 | 295 | M f |
|
296 | 296 | ? f.orig |
|
297 | 297 | $ cat f |
|
298 |
<<<<<<< |
|
|
298 | <<<<<<< working-copy: 6b563750f973 - test: intermediate other change | |
|
299 | 299 | g |
|
300 | 300 | ======= |
|
301 | 301 | f |
|
302 |
>>>>>>> |
|
|
302 | >>>>>>> shelve: aef214a5229c - shelve: changes to: commit stuff | |
|
303 | 303 | $ cat f.orig |
|
304 | 304 | g |
|
305 | 305 | |
|
306 | 306 | #if abortcommand |
|
307 | 307 | when in dry-run mode |
|
308 | 308 | $ hg abort --dry-run |
|
309 | 309 | unshelve in progress, will be aborted |
|
310 | 310 | #endif |
|
311 | 311 | |
|
312 | 312 | $ hg abort |
|
313 | 313 | unshelve of 'default' aborted |
|
314 | 314 | $ hg st |
|
315 | 315 | ? f.orig |
|
316 | 316 | $ cat f.orig |
|
317 | 317 | g |
|
318 | 318 | $ hg shelve --delete default |
|
319 | 319 | $ cd .. |
|
320 | 320 | |
|
321 | 321 | you shouldn't be able to ask for the patch/stats of the most recent shelve if |
|
322 | 322 | there are no shelves |
|
323 | 323 | |
|
324 | 324 | $ hg init noshelves |
|
325 | 325 | $ cd noshelves |
|
326 | 326 | |
|
327 | 327 | $ hg shelve --patch |
|
328 | 328 | abort: there are no shelves to show |
|
329 | 329 | [255] |
|
330 | 330 | $ hg shelve --stat |
|
331 | 331 | abort: there are no shelves to show |
|
332 | 332 | [255] |
|
333 | 333 | |
|
334 | 334 | $ cd .. |
|
335 | 335 | |
|
336 | 336 | test .orig files go where the user wants them to |
|
337 | 337 | --------------------------------------------------------------- |
|
338 | 338 | $ hg init salvage |
|
339 | 339 | $ cd salvage |
|
340 | 340 | $ echo 'content' > root |
|
341 | 341 | $ hg commit -A -m 'root' -q |
|
342 | 342 | $ echo '' > root |
|
343 | 343 | $ hg shelve -q |
|
344 | 344 | $ echo 'contADDent' > root |
|
345 | 345 | $ hg unshelve -q --config 'ui.origbackuppath=.hg/origbackups' |
|
346 | 346 | warning: conflicts while merging root! (edit, then use 'hg resolve --mark') |
|
347 | 347 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
348 | 348 | [1] |
|
349 | 349 | $ ls .hg/origbackups |
|
350 | 350 | root |
|
351 | 351 | $ rm -rf .hg/origbackups |
|
352 | 352 | |
|
353 | 353 | test Abort unshelve always gets user out of the unshelved state |
|
354 | 354 | --------------------------------------------------------------- |
|
355 | 355 | |
|
356 | 356 | with a corrupted shelve state file |
|
357 | 357 | $ sed 's/ae8c668541e8/123456789012/' .hg/shelvedstate > ../corrupt-shelvedstate |
|
358 | 358 | $ mv ../corrupt-shelvedstate .hg/shelvestate |
|
359 | 359 | $ hg unshelve --abort 2>&1 | grep 'aborted' |
|
360 | 360 | unshelve of 'default' aborted |
|
361 | 361 | $ hg summary |
|
362 | 362 | parent: 0:ae8c668541e8 tip |
|
363 | 363 | root |
|
364 | 364 | branch: default |
|
365 | 365 | commit: 1 modified |
|
366 | 366 | update: (current) |
|
367 | 367 | phases: 1 draft |
|
368 | 368 | $ hg up -C . |
|
369 | 369 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
370 | 370 | |
|
371 | 371 | $ cd .. |
|
372 | 372 | |
|
373 | 373 | Shelve and unshelve unknown files. For the purposes of unshelve, a shelved |
|
374 | 374 | unknown file is the same as a shelved added file, except that it will be in |
|
375 | 375 | unknown state after unshelve if and only if it was either absent or unknown |
|
376 | 376 | before the unshelve operation. |
|
377 | 377 | |
|
378 | 378 | $ hg init unknowns |
|
379 | 379 | $ cd unknowns |
|
380 | 380 | |
|
381 | 381 | The simplest case is if I simply have an unknown file that I shelve and unshelve |
|
382 | 382 | |
|
383 | 383 | $ echo unknown > unknown |
|
384 | 384 | $ hg status |
|
385 | 385 | ? unknown |
|
386 | 386 | $ hg shelve --unknown |
|
387 | 387 | shelved as default |
|
388 | 388 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
389 | 389 | $ hg status |
|
390 | 390 | $ hg unshelve |
|
391 | 391 | unshelving change 'default' |
|
392 | 392 | $ hg status |
|
393 | 393 | ? unknown |
|
394 | 394 | $ rm unknown |
|
395 | 395 | |
|
396 | 396 | If I shelve, add the file, and unshelve, does it stay added? |
|
397 | 397 | |
|
398 | 398 | $ echo unknown > unknown |
|
399 | 399 | $ hg shelve -u |
|
400 | 400 | shelved as default |
|
401 | 401 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
402 | 402 | $ hg status |
|
403 | 403 | $ touch unknown |
|
404 | 404 | $ hg add unknown |
|
405 | 405 | $ hg status |
|
406 | 406 | A unknown |
|
407 | 407 | $ hg unshelve |
|
408 | 408 | unshelving change 'default' |
|
409 | 409 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
410 | 410 | rebasing shelved changes |
|
411 | 411 | merging unknown |
|
412 | 412 | $ hg status |
|
413 | 413 | A unknown |
|
414 | 414 | $ hg forget unknown |
|
415 | 415 | $ rm unknown |
|
416 | 416 | |
|
417 | 417 | And if I shelve, commit, then unshelve, does it become modified? |
|
418 | 418 | |
|
419 | 419 | $ echo unknown > unknown |
|
420 | 420 | $ hg shelve -u |
|
421 | 421 | shelved as default |
|
422 | 422 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
423 | 423 | $ hg status |
|
424 | 424 | $ touch unknown |
|
425 | 425 | $ hg add unknown |
|
426 | 426 | $ hg commit -qm "Add unknown" |
|
427 | 427 | $ hg status |
|
428 | 428 | $ hg unshelve |
|
429 | 429 | unshelving change 'default' |
|
430 | 430 | rebasing shelved changes |
|
431 | 431 | merging unknown |
|
432 | 432 | $ hg status |
|
433 | 433 | M unknown |
|
434 | 434 | $ hg remove --force unknown |
|
435 | 435 | $ hg commit -qm "Remove unknown" |
|
436 | 436 | |
|
437 | 437 | $ cd .. |
|
438 | 438 | |
|
439 | 439 | We expects that non-bare shelve keeps newly created branch in |
|
440 | 440 | working directory. |
|
441 | 441 | |
|
442 | 442 | $ hg init shelve-preserve-new-branch |
|
443 | 443 | $ cd shelve-preserve-new-branch |
|
444 | 444 | $ echo "a" >> a |
|
445 | 445 | $ hg add a |
|
446 | 446 | $ echo "b" >> b |
|
447 | 447 | $ hg add b |
|
448 | 448 | $ hg commit -m "ab" |
|
449 | 449 | $ echo "aa" >> a |
|
450 | 450 | $ echo "bb" >> b |
|
451 | 451 | $ hg branch new-branch |
|
452 | 452 | marked working directory as branch new-branch |
|
453 | 453 | (branches are permanent and global, did you want a bookmark?) |
|
454 | 454 | $ hg status |
|
455 | 455 | M a |
|
456 | 456 | M b |
|
457 | 457 | $ hg branch |
|
458 | 458 | new-branch |
|
459 | 459 | $ hg shelve a |
|
460 | 460 | shelved as default |
|
461 | 461 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
462 | 462 | $ hg branch |
|
463 | 463 | new-branch |
|
464 | 464 | $ hg status |
|
465 | 465 | M b |
|
466 | 466 | $ touch "c" >> c |
|
467 | 467 | $ hg add c |
|
468 | 468 | $ hg status |
|
469 | 469 | M b |
|
470 | 470 | A c |
|
471 | 471 | $ hg shelve --exclude c |
|
472 | 472 | shelved as default-01 |
|
473 | 473 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
474 | 474 | $ hg branch |
|
475 | 475 | new-branch |
|
476 | 476 | $ hg status |
|
477 | 477 | A c |
|
478 | 478 | $ hg shelve --include c |
|
479 | 479 | shelved as default-02 |
|
480 | 480 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
481 | 481 | $ hg branch |
|
482 | 482 | new-branch |
|
483 | 483 | $ hg status |
|
484 | 484 | $ echo "d" >> d |
|
485 | 485 | $ hg add d |
|
486 | 486 | $ hg status |
|
487 | 487 | A d |
|
488 | 488 | |
|
489 | 489 | We expect that bare-shelve will not keep branch in current working directory. |
|
490 | 490 | |
|
491 | 491 | $ hg shelve |
|
492 | 492 | shelved as default-03 |
|
493 | 493 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
494 | 494 | $ hg branch |
|
495 | 495 | default |
|
496 | 496 | $ cd .. |
|
497 | 497 | |
|
498 | 498 | When i shelve commit on newly created branch i expect |
|
499 | 499 | that after unshelve newly created branch will be preserved. |
|
500 | 500 | |
|
501 | 501 | $ hg init shelve_on_new_branch_simple |
|
502 | 502 | $ cd shelve_on_new_branch_simple |
|
503 | 503 | $ echo "aaa" >> a |
|
504 | 504 | $ hg commit -A -m "a" |
|
505 | 505 | adding a |
|
506 | 506 | $ hg branch |
|
507 | 507 | default |
|
508 | 508 | $ hg branch test |
|
509 | 509 | marked working directory as branch test |
|
510 | 510 | (branches are permanent and global, did you want a bookmark?) |
|
511 | 511 | $ echo "bbb" >> a |
|
512 | 512 | $ hg status |
|
513 | 513 | M a |
|
514 | 514 | $ hg shelve |
|
515 | 515 | shelved as default |
|
516 | 516 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
517 | 517 | $ hg branch |
|
518 | 518 | default |
|
519 | 519 | $ echo "bbb" >> b |
|
520 | 520 | $ hg status |
|
521 | 521 | ? b |
|
522 | 522 | $ hg unshelve |
|
523 | 523 | unshelving change 'default' |
|
524 | 524 | marked working directory as branch test |
|
525 | 525 | $ hg status |
|
526 | 526 | M a |
|
527 | 527 | ? b |
|
528 | 528 | $ hg branch |
|
529 | 529 | test |
|
530 | 530 | $ cd .. |
|
531 | 531 | |
|
532 | 532 | When i shelve commit on newly created branch, make |
|
533 | 533 | some changes, unshelve it and running into merge |
|
534 | 534 | conflicts i expect that after fixing them and |
|
535 | 535 | running unshelve --continue newly created branch |
|
536 | 536 | will be preserved. |
|
537 | 537 | |
|
538 | 538 | $ hg init shelve_on_new_branch_conflict |
|
539 | 539 | $ cd shelve_on_new_branch_conflict |
|
540 | 540 | $ echo "aaa" >> a |
|
541 | 541 | $ hg commit -A -m "a" |
|
542 | 542 | adding a |
|
543 | 543 | $ hg branch |
|
544 | 544 | default |
|
545 | 545 | $ hg branch test |
|
546 | 546 | marked working directory as branch test |
|
547 | 547 | (branches are permanent and global, did you want a bookmark?) |
|
548 | 548 | $ echo "bbb" >> a |
|
549 | 549 | $ hg status |
|
550 | 550 | M a |
|
551 | 551 | $ hg shelve |
|
552 | 552 | shelved as default |
|
553 | 553 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
554 | 554 | $ hg branch |
|
555 | 555 | default |
|
556 | 556 | $ echo "ccc" >> a |
|
557 | 557 | $ hg status |
|
558 | 558 | M a |
|
559 | 559 | $ hg unshelve |
|
560 | 560 | unshelving change 'default' |
|
561 | 561 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
562 | 562 | rebasing shelved changes |
|
563 | 563 | merging a |
|
564 | 564 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
565 | 565 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
566 | 566 | [1] |
|
567 | 567 | $ echo "aaabbbccc" > a |
|
568 | 568 | $ rm a.orig |
|
569 | 569 | $ hg resolve --mark a |
|
570 | 570 | (no more unresolved files) |
|
571 | 571 | continue: hg unshelve --continue |
|
572 | 572 | $ hg continue |
|
573 | 573 | marked working directory as branch test |
|
574 | 574 | unshelve of 'default' complete |
|
575 | 575 | $ cat a |
|
576 | 576 | aaabbbccc |
|
577 | 577 | $ hg status |
|
578 | 578 | M a |
|
579 | 579 | $ hg branch |
|
580 | 580 | test |
|
581 | 581 | $ hg commit -m "test-commit" |
|
582 | 582 | |
|
583 | 583 | When i shelve on test branch, update to default branch |
|
584 | 584 | and unshelve i expect that it will not preserve previous |
|
585 | 585 | test branch. |
|
586 | 586 | |
|
587 | 587 | $ echo "xxx" > b |
|
588 | 588 | $ hg add b |
|
589 | 589 | $ hg shelve |
|
590 | 590 | shelved as test |
|
591 | 591 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
592 | 592 | $ hg update -r 7049e48789d7 |
|
593 | 593 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
594 | 594 | $ hg unshelve |
|
595 | 595 | unshelving change 'test' |
|
596 | 596 | rebasing shelved changes |
|
597 | 597 | $ hg status |
|
598 | 598 | A b |
|
599 | 599 | $ hg branch |
|
600 | 600 | default |
|
601 | 601 | $ cd .. |
|
602 | 602 | |
|
603 | 603 | When i unshelve resulting in merge conflicts and makes saved |
|
604 | 604 | file shelvedstate looks like in previous versions in |
|
605 | 605 | mercurial(without restore branch information in 7th line) i |
|
606 | 606 | expect that after resolving conflicts and successfully |
|
607 | 607 | running 'shelve --continue' the branch information won't be |
|
608 | 608 | restored and branch will be unchanged. |
|
609 | 609 | |
|
610 | 610 | shelve on new branch, conflict with previous shelvedstate |
|
611 | 611 | |
|
612 | 612 | $ hg init conflict |
|
613 | 613 | $ cd conflict |
|
614 | 614 | $ echo "aaa" >> a |
|
615 | 615 | $ hg commit -A -m "a" |
|
616 | 616 | adding a |
|
617 | 617 | $ hg branch |
|
618 | 618 | default |
|
619 | 619 | $ hg branch test |
|
620 | 620 | marked working directory as branch test |
|
621 | 621 | (branches are permanent and global, did you want a bookmark?) |
|
622 | 622 | $ echo "bbb" >> a |
|
623 | 623 | $ hg status |
|
624 | 624 | M a |
|
625 | 625 | $ hg shelve |
|
626 | 626 | shelved as default |
|
627 | 627 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
628 | 628 | $ hg branch |
|
629 | 629 | default |
|
630 | 630 | $ echo "ccc" >> a |
|
631 | 631 | $ hg status |
|
632 | 632 | M a |
|
633 | 633 | $ hg unshelve |
|
634 | 634 | unshelving change 'default' |
|
635 | 635 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
636 | 636 | rebasing shelved changes |
|
637 | 637 | merging a |
|
638 | 638 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
639 | 639 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
640 | 640 | [1] |
|
641 | 641 | |
|
642 | 642 | Removing restore branch information from shelvedstate file(making it looks like |
|
643 | 643 | in previous versions) and running unshelve --continue |
|
644 | 644 | |
|
645 | 645 | $ cp .hg/shelvedstate .hg/shelvedstate_old |
|
646 | 646 | $ cat .hg/shelvedstate_old | grep -v 'branchtorestore' > .hg/shelvedstate |
|
647 | 647 | |
|
648 | 648 | $ echo "aaabbbccc" > a |
|
649 | 649 | $ rm a.orig |
|
650 | 650 | $ hg resolve --mark a |
|
651 | 651 | (no more unresolved files) |
|
652 | 652 | continue: hg unshelve --continue |
|
653 | 653 | |
|
654 | 654 | #if continuecommand |
|
655 | 655 | $ hg continue --dry-run |
|
656 | 656 | unshelve in progress, will be resumed |
|
657 | 657 | #endif |
|
658 | 658 | |
|
659 | 659 | $ hg continue |
|
660 | 660 | unshelve of 'default' complete |
|
661 | 661 | $ cat a |
|
662 | 662 | aaabbbccc |
|
663 | 663 | $ hg status |
|
664 | 664 | M a |
|
665 | 665 | $ hg branch |
|
666 | 666 | default |
|
667 | 667 | $ cd .. |
|
668 | 668 | |
|
669 | 669 | On non bare shelve the branch information shouldn't be restored |
|
670 | 670 | |
|
671 | 671 | $ hg init bare_shelve_on_new_branch |
|
672 | 672 | $ cd bare_shelve_on_new_branch |
|
673 | 673 | $ echo "aaa" >> a |
|
674 | 674 | $ hg commit -A -m "a" |
|
675 | 675 | adding a |
|
676 | 676 | $ hg branch |
|
677 | 677 | default |
|
678 | 678 | $ hg branch test |
|
679 | 679 | marked working directory as branch test |
|
680 | 680 | (branches are permanent and global, did you want a bookmark?) |
|
681 | 681 | $ echo "bbb" >> a |
|
682 | 682 | $ hg status |
|
683 | 683 | M a |
|
684 | 684 | $ hg shelve a |
|
685 | 685 | shelved as default |
|
686 | 686 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
687 | 687 | $ hg branch |
|
688 | 688 | test |
|
689 | 689 | $ hg branch default |
|
690 | 690 | marked working directory as branch default |
|
691 | 691 | (branches are permanent and global, did you want a bookmark?) |
|
692 | 692 | $ echo "bbb" >> b |
|
693 | 693 | $ hg status |
|
694 | 694 | ? b |
|
695 | 695 | $ hg unshelve |
|
696 | 696 | unshelving change 'default' |
|
697 | 697 | $ hg status |
|
698 | 698 | M a |
|
699 | 699 | ? b |
|
700 | 700 | $ hg branch |
|
701 | 701 | default |
|
702 | 702 | $ cd .. |
|
703 | 703 | |
|
704 | 704 | Prepare unshelve with a corrupted shelvedstate |
|
705 | 705 | $ hg init r1 && cd r1 |
|
706 | 706 | $ echo text1 > file && hg add file |
|
707 | 707 | $ hg shelve |
|
708 | 708 | shelved as default |
|
709 | 709 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
710 | 710 | $ echo text2 > file && hg ci -Am text1 |
|
711 | 711 | adding file |
|
712 | 712 | $ hg unshelve |
|
713 | 713 | unshelving change 'default' |
|
714 | 714 | rebasing shelved changes |
|
715 | 715 | merging file |
|
716 | 716 | warning: conflicts while merging file! (edit, then use 'hg resolve --mark') |
|
717 | 717 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
718 | 718 | [1] |
|
719 | 719 | $ echo somethingsomething > .hg/shelvedstate |
|
720 | 720 | |
|
721 | 721 | Unshelve --continue fails with appropriate message if shelvedstate is corrupted |
|
722 | 722 | $ hg continue |
|
723 | 723 | abort: corrupted shelved state file |
|
724 | 724 | (please run hg unshelve --abort to abort unshelve operation) |
|
725 | 725 | [255] |
|
726 | 726 | |
|
727 | 727 | Unshelve --abort works with a corrupted shelvedstate |
|
728 | 728 | $ hg abort |
|
729 | 729 | abort: could not read shelved state file, your working copy may be in an unexpected state |
|
730 | 730 | please update to some commit |
|
731 | 731 | |
|
732 | 732 | [255] |
|
733 | 733 | |
|
734 | 734 | Unshelve --abort fails with appropriate message if there's no unshelve in |
|
735 | 735 | progress |
|
736 | 736 | |
|
737 | 737 | #if abortflag |
|
738 | 738 | $ hg unshelve --abort |
|
739 | 739 | abort: no unshelve in progress |
|
740 | 740 | [255] |
|
741 | 741 | #else |
|
742 | 742 | $ hg abort |
|
743 | 743 | aborting the merge, updating back to 9451eaa6eee3 |
|
744 | 744 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
745 | 745 | #endif |
|
746 | 746 | $ cd .. |
|
747 | 747 | |
|
748 | 748 | Unshelve respects --keep even if user intervention is needed |
|
749 | 749 | $ hg init unshelvekeep && cd unshelvekeep |
|
750 | 750 | $ echo 1 > file && hg ci -Am 1 |
|
751 | 751 | adding file |
|
752 | 752 | $ echo 2 >> file |
|
753 | 753 | $ hg shelve |
|
754 | 754 | shelved as default |
|
755 | 755 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
756 | 756 | $ echo 3 >> file && hg ci -Am 13 |
|
757 | 757 | $ hg shelve --list |
|
758 | 758 | default (*s ago) * changes to: 1 (glob) |
|
759 | 759 | $ hg unshelve --keep |
|
760 | 760 | unshelving change 'default' |
|
761 | 761 | rebasing shelved changes |
|
762 | 762 | merging file |
|
763 | 763 | warning: conflicts while merging file! (edit, then use 'hg resolve --mark') |
|
764 | 764 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
765 | 765 | [1] |
|
766 | 766 | $ hg resolve --mark file |
|
767 | 767 | (no more unresolved files) |
|
768 | 768 | continue: hg unshelve --continue |
|
769 | 769 | $ hg continue |
|
770 | 770 | unshelve of 'default' complete |
|
771 | 771 | $ hg shelve --list |
|
772 | 772 | default (*s ago) * changes to: 1 (glob) |
|
773 | 773 | $ cd .. |
|
774 | 774 | |
|
775 | 775 | Unshelving when there are deleted files does not crash (issue4176) |
|
776 | 776 | $ hg init unshelve-deleted-file && cd unshelve-deleted-file |
|
777 | 777 | $ echo a > a && echo b > b && hg ci -Am ab |
|
778 | 778 | adding a |
|
779 | 779 | adding b |
|
780 | 780 | $ echo aa > a && hg shelve |
|
781 | 781 | shelved as default |
|
782 | 782 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
783 | 783 | $ rm b |
|
784 | 784 | $ hg st |
|
785 | 785 | ! b |
|
786 | 786 | $ hg unshelve |
|
787 | 787 | unshelving change 'default' |
|
788 | 788 | $ hg shelve |
|
789 | 789 | shelved as default |
|
790 | 790 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
791 | 791 | $ rm a && echo b > b |
|
792 | 792 | $ hg st |
|
793 | 793 | ! a |
|
794 | 794 | $ hg unshelve |
|
795 | 795 | unshelving change 'default' |
|
796 | 796 | abort: shelved change touches missing files |
|
797 | 797 | (run hg status to see which files are missing) |
|
798 | 798 | [255] |
|
799 | 799 | $ hg st |
|
800 | 800 | ! a |
|
801 | 801 | $ cd .. |
|
802 | 802 | |
|
803 | 803 | New versions of Mercurial know how to read onld shelvedstate files |
|
804 | 804 | $ hg init oldshelvedstate |
|
805 | 805 | $ cd oldshelvedstate |
|
806 | 806 | $ echo root > root && hg ci -Am root |
|
807 | 807 | adding root |
|
808 | 808 | $ echo 1 > a |
|
809 | 809 | $ hg add a |
|
810 | 810 | $ hg shelve --name ashelve |
|
811 | 811 | shelved as ashelve |
|
812 | 812 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
813 | 813 | $ echo 2 > a |
|
814 | 814 | $ hg ci -Am a |
|
815 | 815 | adding a |
|
816 | 816 | $ hg unshelve |
|
817 | 817 | unshelving change 'ashelve' |
|
818 | 818 | rebasing shelved changes |
|
819 | 819 | merging a |
|
820 | 820 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
821 | 821 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
822 | 822 | [1] |
|
823 | 823 | putting v1 shelvedstate file in place of a created v2 |
|
824 | 824 | $ cat << EOF > .hg/shelvedstate |
|
825 | 825 | > 1 |
|
826 | 826 | > ashelve |
|
827 | 827 | > 8b058dae057a5a78f393f4535d9e363dd5efac9d |
|
828 | 828 | > 8b058dae057a5a78f393f4535d9e363dd5efac9d |
|
829 | 829 | > 8b058dae057a5a78f393f4535d9e363dd5efac9d f543b27db2cdb41737e2e0008dc524c471da1446 |
|
830 | 830 | > f543b27db2cdb41737e2e0008dc524c471da1446 |
|
831 | 831 | > |
|
832 | 832 | > nokeep |
|
833 | 833 | > :no-active-bookmark |
|
834 | 834 | > EOF |
|
835 | 835 | $ echo 1 > a |
|
836 | 836 | $ hg resolve --mark a |
|
837 | 837 | (no more unresolved files) |
|
838 | 838 | continue: hg unshelve --continue |
|
839 | 839 | mercurial does not crash |
|
840 | 840 | $ hg continue |
|
841 | 841 | unshelve of 'ashelve' complete |
|
842 | 842 | |
|
843 | 843 | #if phasebased |
|
844 | 844 | |
|
845 | 845 | Unshelve with some metadata file missing |
|
846 | 846 | ---------------------------------------- |
|
847 | 847 | |
|
848 | 848 | $ hg shelve |
|
849 | 849 | shelved as default |
|
850 | 850 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
851 | 851 | $ echo 3 > a |
|
852 | 852 | |
|
853 | 853 | Test with the `.shelve` missing, but the changeset still in the repo (non-natural case) |
|
854 | 854 | |
|
855 | 855 | $ rm .hg/shelved/default.shelve |
|
856 | 856 | $ hg unshelve |
|
857 | 857 | unshelving change 'default' |
|
858 | 858 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
859 | 859 | rebasing shelved changes |
|
860 | 860 | merging a |
|
861 | 861 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
862 | 862 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
863 | 863 | [1] |
|
864 | 864 | $ hg abort |
|
865 | 865 | unshelve of 'default' aborted |
|
866 | 866 | |
|
867 | 867 | Unshelve without .shelve metadata (can happen when upgrading a repository with old shelve) |
|
868 | 868 | |
|
869 | 869 | $ cat .hg/shelved/default.shelve |
|
870 | 870 | node=82e0cb9893247d12667017593ce1e5655860f1ac |
|
871 | 871 | $ hg strip --hidden --rev 82e0cb989324 --no-backup |
|
872 | 872 | $ rm .hg/shelved/default.shelve |
|
873 | 873 | $ hg unshelve |
|
874 | 874 | unshelving change 'default' |
|
875 | 875 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
876 | 876 | rebasing shelved changes |
|
877 | 877 | merging a |
|
878 | 878 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
879 | 879 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
880 | 880 | [1] |
|
881 | 881 | $ cat .hg/shelved/default.shelve |
|
882 | 882 | node=82e0cb9893247d12667017593ce1e5655860f1ac |
|
883 | 883 | $ hg abort |
|
884 | 884 | unshelve of 'default' aborted |
|
885 | 885 | |
|
886 | 886 | #endif |
|
887 | 887 | |
|
888 | 888 | $ cd .. |
|
889 | 889 | |
|
890 | 890 | Block merge abort when unshelve in progress(issue6160) |
|
891 | 891 | ------------------------------------------------------ |
|
892 | 892 | |
|
893 | 893 | $ hg init a |
|
894 | 894 | $ cd a |
|
895 | 895 | $ echo foo > a ; hg commit -qAm "initial commit" |
|
896 | 896 | $ echo bar > a |
|
897 | 897 | $ hg shelve |
|
898 | 898 | shelved as default |
|
899 | 899 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
900 | 900 | $ echo foobar > a |
|
901 | 901 | $ hg unshelve |
|
902 | 902 | unshelving change 'default' |
|
903 | 903 | temporarily committing pending changes (restore with 'hg unshelve --abort') |
|
904 | 904 | rebasing shelved changes |
|
905 | 905 | merging a |
|
906 | 906 | warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
|
907 | 907 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
908 | 908 | [1] |
|
909 | 909 | |
|
910 | 910 | $ hg log --template '{desc|firstline} {author} {date|isodate} \n' -r . |
|
911 | 911 | pending changes temporary commit shelve@localhost 1970-01-01 00:00 +0000 |
|
912 | 912 | $ hg merge --abort |
|
913 | 913 | abort: cannot abort merge with unshelve in progress |
|
914 | 914 | (use 'hg unshelve --continue' or 'hg unshelve --abort') |
|
915 | 915 | [255] |
|
916 | 916 | |
|
917 | 917 | $ hg unshelve --abort |
|
918 | 918 | unshelve of 'default' aborted |
|
919 | 919 | |
|
920 | 920 | $ hg log -G --template '{desc|firstline} {author} {date|isodate} \n' -r . |
|
921 | 921 | @ initial commit test 1970-01-01 00:00 +0000 |
|
922 | 922 | |
|
923 | 923 | $ cd .. |
|
924 | 924 | |
|
925 | 925 | Demonstrate that the labels are correct in the merge conflict |
|
926 | 926 | ------------------------------------------------------------- |
|
927 | 927 | $ hg init labels |
|
928 | 928 | $ cd labels |
|
929 | 929 | $ echo r0 > foo |
|
930 | 930 | $ hg ci -qAm r0 |
|
931 | 931 | $ echo "this will be shelved" >> foo |
|
932 | 932 | $ hg shelve -q |
|
933 | 933 | $ echo "this is in wdir, conflicts with shelve" >> foo |
|
934 | 934 | $ hg unshelve -q |
|
935 | 935 | warning: conflicts while merging foo! (edit, then use 'hg resolve --mark') |
|
936 | 936 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
937 | 937 | [1] |
|
938 | 938 | $ cat foo |
|
939 | 939 | r0 |
|
940 |
<<<<<<< |
|
|
940 | <<<<<<< working-copy: 0b2fcf2a90e9 - shelve: pending changes temporary commit | |
|
941 | 941 | this is in wdir, conflicts with shelve |
|
942 | 942 | ======= |
|
943 | 943 | this will be shelved |
|
944 |
>>>>>>> |
|
|
944 | >>>>>>> shelve: 9c072a2163db - shelve: changes to: r0 | |
|
945 | 945 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now