Mercurial > hg
changeset 13426:643b8212813e
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.
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Wed, 16 Feb 2011 15:02:30 +0100 |
parents | 0fe36c347c00 |
children | 2432b3227303 c39e9cead0ae |
files | mercurial/statichttprepo.py mercurial/store.py |
diffstat | 2 files changed, 21 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/statichttprepo.py Wed Feb 16 18:36:45 2011 +0100 +++ b/mercurial/statichttprepo.py Wed Feb 16 15:02:30 2011 +0100 @@ -115,9 +115,7 @@ 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
--- a/mercurial/store.py Wed Feb 16 18:36:45 2011 +0100 +++ b/mercurial/store.py Wed Feb 16 15:02:30 2011 +0100 @@ -169,8 +169,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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)