[PATCH] store: remove pointless pathjoiner parameter
Adrian Buehlmann
adrian at cadifra.com
Wed Feb 16 12:23:16 CST 2011
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1297864950 -3600
# Node ID 8be9fd5a98b5c47a9964d46e672650983d9eab07
# Parent a0e49e12915178da3e167ca21bf2295ca4c791a0
store: remove pointless pathjoiner parameter
We can stop pretending that we have to support anything else
than '/' for concatenating path elements anywhere.
Windows deals just fine with '/' in file paths and we already
have plenty of places which produce paths containing '/'
anyway when running on Windows.
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -115,9 +115,7 @@ class statichttprepository(localrepo.loc
raise error.RepoError(_("requirement '%s' not supported") % r)
# setup store
- def pjoin(a, b):
- return a + '/' + b
- self.store = store.store(requirements, self.path, opener, pjoin)
+ self.store = store.store(requirements, self.path, opener)
self.spath = self.store.path
self.sopener = self.store.opener
self.sjoin = self.store.join
diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -169,8 +169,7 @@ _data = 'data 00manifest.d 00manifest.i
class basicstore(object):
'''base class for local repository stores'''
- def __init__(self, path, opener, pathjoiner):
- self.pathjoiner = pathjoiner
+ def __init__(self, path, opener):
self.path = path
self.createmode = _calcmode(path)
op = opener(self.path)
@@ -178,19 +177,21 @@ class basicstore(object):
self.opener = lambda f, *args, **kw: op(encodedir(f), *args, **kw)
def join(self, f):
- return self.pathjoiner(self.path, encodedir(f))
+ return self.path + '/' + encodedir(f)
def _walk(self, relpath, recurse):
'''yields (unencoded, encoded, size)'''
- path = self.pathjoiner(self.path, relpath)
- striplen = len(self.path) + len(os.sep)
+ path = self.path
+ if relpath:
+ path += '/' + relpath
+ striplen = len(self.path) + 1
l = []
if os.path.isdir(path):
visit = [path]
while visit:
p = visit.pop()
for f, kind, st in osutil.listdir(p, stat=True):
- fp = self.pathjoiner(p, f)
+ fp = p + '/' + f
if kind == stat.S_IFREG and f[-2:] in ('.d', '.i'):
n = util.pconvert(fp[striplen:])
l.append((decodedir(n), n, st.st_size))
@@ -217,9 +218,8 @@ class basicstore(object):
pass
class encodedstore(basicstore):
- def __init__(self, path, opener, pathjoiner):
- self.pathjoiner = pathjoiner
- self.path = self.pathjoiner(path, 'store')
+ def __init__(self, path, opener):
+ self.path = path + '/store'
self.createmode = _calcmode(self.path)
op = opener(self.path)
op.createmode = self.createmode
@@ -234,11 +234,11 @@ class encodedstore(basicstore):
yield a, b, size
def join(self, f):
- return self.pathjoiner(self.path, encodefilename(f))
+ return self.path + '/' + encodefilename(f)
def copylist(self):
return (['requires', '00changelog.i'] +
- [self.pathjoiner('store', f) for f in _data.split()])
+ ['store/' + f for f in _data.split()])
class fncache(object):
# the filename used to be partially encoded
@@ -299,10 +299,9 @@ class fncache(object):
return iter(self.entries)
class fncachestore(basicstore):
- def __init__(self, path, opener, pathjoiner, encode):
+ def __init__(self, path, opener, encode):
self.encode = encode
- self.pathjoiner = pathjoiner
- self.path = self.pathjoiner(path, 'store')
+ self.path = path + '/store'
self.createmode = _calcmode(self.path)
op = opener(self.path)
op.createmode = self.createmode
@@ -316,17 +315,16 @@ class fncachestore(basicstore):
self.opener = fncacheopener
def join(self, f):
- return self.pathjoiner(self.path, self.encode(f))
+ return self.path + '/' + self.encode(f)
def datafiles(self):
rewrite = False
existing = []
- pjoin = self.pathjoiner
spath = self.path
for f in self.fncache:
ef = self.encode(f)
try:
- st = os.stat(pjoin(spath, ef))
+ st = os.stat(spath + '/' + ef)
yield f, ef, st.st_size
existing.append(f)
except OSError:
@@ -341,17 +339,16 @@ class fncachestore(basicstore):
d = ('data dh fncache'
' 00manifest.d 00manifest.i 00changelog.d 00changelog.i')
return (['requires', '00changelog.i'] +
- [self.pathjoiner('store', f) for f in d.split()])
+ ['store/' + f for f in d.split()])
def write(self):
self.fncache.write()
-def store(requirements, path, opener, pathjoiner=None):
- pathjoiner = pathjoiner or os.path.join
+def store(requirements, path, opener):
if 'store' in requirements:
if 'fncache' in requirements:
auxencode = lambda f: _auxencode(f, 'dotencode' in requirements)
encode = lambda f: _hybridencode(f, auxencode)
- return fncachestore(path, opener, pathjoiner, encode)
- return encodedstore(path, opener, pathjoiner)
- return basicstore(path, opener, pathjoiner)
+ return fncachestore(path, opener, encode)
+ return encodedstore(path, opener)
+ return basicstore(path, opener)
More information about the Mercurial-devel
mailing list