##// END OF EJS Templates
shelve: move possible shelve file extensions to a single place...
Kostia Balytskyi -
r30378:c5126aab default
parent child Browse files
Show More
@@ -62,6 +62,7 b" testedwith = 'ships-with-hg-core'"
62 62
63 63 backupdir = 'shelve-backup'
64 64 shelvedir = 'shelved'
65 shelvefileextensions = ['hg', 'patch']
65 66
66 67 class shelvedfile(object):
67 68 """Helper for the file storing a single shelve
@@ -221,7 +222,7 b' def cleanupoldbackups(repo):'
221 222 # keep it, because timestamp can't decide exact order of backups
222 223 continue
223 224 base = f[:-3]
224 for ext in 'hg patch'.split():
225 for ext in shelvefileextensions:
225 226 try:
226 227 vfs.unlink(base + '.' + ext)
227 228 except OSError as err:
@@ -399,7 +400,7 b' def cleanupcmd(ui, repo):'
399 400 with repo.wlock():
400 401 for (name, _type) in repo.vfs.readdir(shelvedir):
401 402 suffix = name.rsplit('.', 1)[-1]
402 if suffix in ('hg', 'patch'):
403 if suffix in shelvefileextensions:
403 404 shelvedfile(repo, name).movetobackup()
404 405 cleanupoldbackups(repo)
405 406
@@ -410,8 +411,15 b' def deletecmd(ui, repo, pats):'
410 411 with repo.wlock():
411 412 try:
412 413 for name in pats:
413 for suffix in 'hg patch'.split():
414 shelvedfile(repo, name, suffix).movetobackup()
414 for suffix in shelvefileextensions:
415 shfile = shelvedfile(repo, name, suffix)
416 # patch file is necessary, as it should
417 # be present for any kind of shelve,
418 # but the .hg file is optional as in future we
419 # will add obsolete shelve with does not create a
420 # bundle
421 if shfile.exists() or suffix == 'patch':
422 shfile.movetobackup()
415 423 cleanupoldbackups(repo)
416 424 except OSError as err:
417 425 if err.errno != errno.ENOENT:
@@ -557,8 +565,10 b' def restorebranch(ui, repo, branchtorest'
557 565 def unshelvecleanup(ui, repo, name, opts):
558 566 """remove related files after an unshelve"""
559 567 if not opts.get('keep'):
560 for filetype in 'hg patch'.split():
561 shelvedfile(repo, name, filetype).movetobackup()
568 for filetype in shelvefileextensions:
569 shfile = shelvedfile(repo, name, filetype)
570 if shfile.exists():
571 shfile.movetobackup()
562 572 cleanupoldbackups(repo)
563 573
564 574 def unshelvecontinue(ui, repo, state, opts):
General Comments 0
You need to be logged in to leave comments. Login now