Patchwork [1,of,3,V2] shelve: refactor directory name into constant

login
register
mail settings
Submitter Oleg Afanasyev
Date April 9, 2016, 5:34 p.m.
Message ID <020c21d9ea7ffd534b2a.1460223248@devvm815.lla1.facebook.com>
Download mbox | patch
Permalink /patch/14466/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Oleg Afanasyev - April 9, 2016, 5:34 p.m.
# HG changeset patch
# User Oleg Afanasyev <olegaf@fb.com>
# Date 1460183608 25200
#      Fri Apr 08 23:33:28 2016 -0700
# Node ID 020c21d9ea7ffd534b2abd589d3bd12bbb0ed265
# Parent  ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
shelve: refactor directory name into constant

Shelve directory name extracted into constant to avoid typos/duplication.
Yuya Nishihara - April 12, 2016, 1:47 p.m.
On Sat, 9 Apr 2016 10:34:08 -0700, Oleg Afanasyev wrote:
> # HG changeset patch
> # User Oleg Afanasyev <olegaf@fb.com>
> # Date 1460183608 25200
> #      Fri Apr 08 23:33:28 2016 -0700
> # Node ID 020c21d9ea7ffd534b2abd589d3bd12bbb0ed265
> # Parent  ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
> shelve: refactor directory name into constant

I've queued only this, thanks.

I'm not pretty sure if the other patches are right or wrong. Needs other eyes.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -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