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