##// END OF EJS Templates
shelve: refactor directory name into constant...
Oleg Afanasyev -
r28862:39130afc default
parent child Browse files
Show More
@@ -60,6 +60,7 command = cmdutil.command(cmdtable)
60 testedwith = 'internal'
60 testedwith = 'internal'
61
61
62 backupdir = 'shelve-backup'
62 backupdir = 'shelve-backup'
63 shelvedir = 'shelved'
63
64
64 class shelvedfile(object):
65 class shelvedfile(object):
65 """Helper for the file storing a single shelve
66 """Helper for the file storing a single shelve
@@ -69,7 +70,7 class shelvedfile(object):
69 def __init__(self, repo, name, filetype=None):
70 def __init__(self, repo, name, filetype=None):
70 self.repo = repo
71 self.repo = repo
71 self.name = name
72 self.name = name
72 self.vfs = scmutil.vfs(repo.join('shelved'))
73 self.vfs = scmutil.vfs(repo.join(shelvedir))
73 self.backupvfs = scmutil.vfs(repo.join(backupdir))
74 self.backupvfs = scmutil.vfs(repo.join(backupdir))
74 self.ui = self.repo.ui
75 self.ui = self.repo.ui
75 if filetype:
76 if filetype:
@@ -408,7 +409,7 def cleanupcmd(ui, repo):
408 """subcommand that deletes all shelves"""
409 """subcommand that deletes all shelves"""
409
410
410 with repo.wlock():
411 with repo.wlock():
411 for (name, _type) in repo.vfs.readdir('shelved'):
412 for (name, _type) in repo.vfs.readdir(shelvedir):
412 suffix = name.rsplit('.', 1)[-1]
413 suffix = name.rsplit('.', 1)[-1]
413 if suffix in ('hg', 'patch'):
414 if suffix in ('hg', 'patch'):
414 shelvedfile(repo, name).movetobackup()
415 shelvedfile(repo, name).movetobackup()
@@ -432,7 +433,7 def deletecmd(ui, repo, pats):
432 def listshelves(repo):
433 def listshelves(repo):
433 """return all shelves in repo as list of (time, filename)"""
434 """return all shelves in repo as list of (time, filename)"""
434 try:
435 try:
435 names = repo.vfs.readdir('shelved')
436 names = repo.vfs.readdir(shelvedir)
436 except OSError as err:
437 except OSError as err:
437 if err.errno != errno.ENOENT:
438 if err.errno != errno.ENOENT:
438 raise
439 raise
General Comments 0
You need to be logged in to leave comments. Login now