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