shelve: refactor directory name into constant
authorOleg Afanasyev <olegaf@fb.com>
Fri, 08 Apr 2016 23:33:28 -0700
changeset 28862 39130afcce60
parent 28861 86db5cb55d46
child 28863 6e06fbee9244
shelve: refactor directory name into constant Shelve directory name extracted into constant to avoid typos/duplication.
hgext/shelve.py
--- a/hgext/shelve.py	Sun Apr 10 20:55:37 2016 +0000
+++ b/hgext/shelve.py	Fri Apr 08 23:33:28 2016 -0700
@@ -60,6 +60,7 @@
 testedwith = 'internal'
 
 backupdir = 'shelve-backup'
+shelvedir = 'shelved'
 
 class shelvedfile(object):
     """Helper for the file storing a single shelve
@@ -69,7 +70,7 @@
     def __init__(self, repo, name, filetype=None):
         self.repo = repo
         self.name = name
-        self.vfs = scmutil.vfs(repo.join('shelved'))
+        self.vfs = scmutil.vfs(repo.join(shelvedir))
         self.backupvfs = scmutil.vfs(repo.join(backupdir))
         self.ui = self.repo.ui
         if filetype:
@@ -408,7 +409,7 @@
     """subcommand that deletes all shelves"""
 
     with repo.wlock():
-        for (name, _type) in repo.vfs.readdir('shelved'):
+        for (name, _type) in repo.vfs.readdir(shelvedir):
             suffix = name.rsplit('.', 1)[-1]
             if suffix in ('hg', 'patch'):
                 shelvedfile(repo, name).movetobackup()
@@ -432,7 +433,7 @@
 def listshelves(repo):
     """return all shelves in repo as list of (time, filename)"""
     try:
-        names = repo.vfs.readdir('shelved')
+        names = repo.vfs.readdir(shelvedir)
     except OSError as err:
         if err.errno != errno.ENOENT:
             raise