##// END OF EJS Templates
shelve: avoid writing file that is never read from...
Martin von Zweigbergk -
r22581:c5ece02f default
parent child Browse files
Show More
@@ -37,7 +37,7 b" testedwith = 'internal'"
37 class shelvedfile(object):
37 class shelvedfile(object):
38 """Helper for the file storing a single shelve
38 """Helper for the file storing a single shelve
39
39
40 Handles common functions on shelve files (.hg/.files/.patch) using
40 Handles common functions on shelve files (.hg/.patch) using
41 the vfs layer"""
41 the vfs layer"""
42 def __init__(self, repo, name, filetype=None):
42 def __init__(self, repo, name, filetype=None):
43 self.repo = repo
43 self.repo = repo
@@ -169,12 +169,7 b' def createcmd(ui, repo, pats, opts):'
169 for i in xrange(1, 100):
169 for i in xrange(1, 100):
170 yield '%s-%02d' % (label, i)
170 yield '%s-%02d' % (label, i)
171
171
172 shelvedfiles = []
173
174 def commitfunc(ui, repo, message, match, opts):
172 def commitfunc(ui, repo, message, match, opts):
175 # check modified, added, removed, deleted only
176 for flist in repo.status(match=match)[:4]:
177 shelvedfiles.extend(flist)
178 hasmq = util.safehasattr(repo, 'mq')
173 hasmq = util.safehasattr(repo, 'mq')
179 if hasmq:
174 if hasmq:
180 saved, repo.mq.checkapplied = repo.mq.checkapplied, False
175 saved, repo.mq.checkapplied = repo.mq.checkapplied, False
@@ -239,9 +234,6 b' def createcmd(ui, repo, pats, opts):'
239 ui.status(_("nothing changed\n"))
234 ui.status(_("nothing changed\n"))
240 return 1
235 return 1
241
236
242 fp = shelvedfile(repo, name, 'files').opener('wb')
243 fp.write('\0'.join(shelvedfiles))
244
245 bases = list(publicancestors(repo[node]))
237 bases = list(publicancestors(repo[node]))
246 cg = changegroup.changegroupsubset(repo, bases, [node], 'shelve')
238 cg = changegroup.changegroupsubset(repo, bases, [node], 'shelve')
247 shelvedfile(repo, name, 'hg').writebundle(cg)
239 shelvedfile(repo, name, 'hg').writebundle(cg)
@@ -271,7 +263,7 b' def cleanupcmd(ui, repo):'
271 wlock = repo.wlock()
263 wlock = repo.wlock()
272 for (name, _type) in repo.vfs.readdir('shelved'):
264 for (name, _type) in repo.vfs.readdir('shelved'):
273 suffix = name.rsplit('.', 1)[-1]
265 suffix = name.rsplit('.', 1)[-1]
274 if suffix in ('hg', 'files', 'patch'):
266 if suffix in ('hg', 'patch'):
275 shelvedfile(repo, name).unlink()
267 shelvedfile(repo, name).unlink()
276 finally:
268 finally:
277 lockmod.release(wlock)
269 lockmod.release(wlock)
@@ -285,7 +277,7 b' def deletecmd(ui, repo, pats):'
285 wlock = repo.wlock()
277 wlock = repo.wlock()
286 try:
278 try:
287 for name in pats:
279 for name in pats:
288 for suffix in 'hg files patch'.split():
280 for suffix in 'hg patch'.split():
289 shelvedfile(repo, name, suffix).unlink()
281 shelvedfile(repo, name, suffix).unlink()
290 except OSError, err:
282 except OSError, err:
291 if err.errno != errno.ENOENT:
283 if err.errno != errno.ENOENT:
@@ -424,7 +416,7 b' def mergefiles(ui, repo, wctx, shelvectx'
424 def unshelvecleanup(ui, repo, name, opts):
416 def unshelvecleanup(ui, repo, name, opts):
425 """remove related files after an unshelve"""
417 """remove related files after an unshelve"""
426 if not opts['keep']:
418 if not opts['keep']:
427 for filetype in 'hg files patch'.split():
419 for filetype in 'hg patch'.split():
428 shelvedfile(repo, name, filetype).unlink()
420 shelvedfile(repo, name, filetype).unlink()
429
421
430 def unshelvecontinue(ui, repo, state, opts):
422 def unshelvecontinue(ui, repo, state, opts):
@@ -533,7 +525,7 b' def unshelve(ui, repo, *shelved, **opts)'
533 else:
525 else:
534 basename = shelved[0]
526 basename = shelved[0]
535
527
536 if not shelvedfile(repo, basename, 'files').exists():
528 if not shelvedfile(repo, basename, 'patch').exists():
537 raise util.Abort(_("shelved change '%s' not found") % basename)
529 raise util.Abort(_("shelved change '%s' not found") % basename)
538
530
539 oldquiet = ui.quiet
531 oldquiet = ui.quiet
General Comments 0
You need to be logged in to leave comments. Login now