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