Mercurial > hg
changeset 110:c37c7f784ee3
Move hg from storing files in data with base64 encoding to full
pathnames with .i and .d extensions. This means we naturally get good
FS layout, and cp and tar fix things up nicely rather than pessimizing
layout.
author | mpm@selenic.com |
---|---|
date | Fri, 20 May 2005 17:27:21 -0800 |
parents | 95699294f580 |
children | 2c80f6f8fc08 |
files | mercurial/hg.py |
diffstat | 1 files changed, 13 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Fri May 20 17:22:02 2005 -0800 +++ b/mercurial/hg.py Fri May 20 17:27:21 2005 -0800 @@ -5,7 +5,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import sys, struct, sha, socket, os, time, base64, re, urllib2 +import sys, struct, sha, socket, os, time, re, urllib2 import urllib from mercurial import byterange from mercurial.transaction import * @@ -14,16 +14,7 @@ class filelog(revlog): def __init__(self, opener, path): - s = self.encodepath(path) - revlog.__init__(self, opener, os.path.join("data", s + "i"), - os.path.join("data", s)) - - def encodepath(self, path): - s = sha.sha(path).digest() - s = base64.encodestring(s)[:-3] - s = re.sub("\+", "%", s) - s = re.sub("/", "_", s) - return s + revlog.__init__(self, opener, path + ".i", path + ".d") def read(self, node): return self.revision(node) @@ -210,11 +201,17 @@ f = os.path.join(p, path) - if mode != "r" and os.path.isfile(f): - s = os.stat(f) - if s.st_nlink > 1: - file(f + ".tmp", "w").write(file(f).read()) - os.rename(f+".tmp", f) + if mode != "r": + try: + s = os.stat(f) + except OSError: + d = os.path.dirname(f) + if not os.path.isdir(d): + os.makedirs(d) + else: + if s.st_nlink > 1: + file(f + ".tmp", "w").write(file(f).read()) + os.rename(f+".tmp", f) return file(f, mode)