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