changeset 7634:14a4337a9b9b

revlog: kill from-style imports They're slow.
author Matt Mackall <mpm@selenic.com>
date Sun, 11 Jan 2009 22:55:36 -0600
parents 08cabecfa8a8
children d22c43724745
files mercurial/changelog.py mercurial/filelog.py mercurial/manifest.py
diffstat 3 files changed, 20 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Sun Jan 11 22:48:28 2009 -0600
+++ b/mercurial/changelog.py	Sun Jan 11 22:55:36 2009 -0600
@@ -6,9 +6,8 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 from node import bin, hex, nullid
-from revlog import revlog, RevlogError
 from i18n import _
-import util, error
+import util, error, revlog
 
 def _string_escape(text):
     """
@@ -75,9 +74,9 @@
         self.data.append(str(s))
         self.offset += len(s)
 
-class changelog(revlog):
+class changelog(revlog.revlog):
     def __init__(self, opener):
-        revlog.__init__(self, opener, "00changelog.i")
+        revlog.revlog.__init__(self, opener, "00changelog.i")
 
     def delayupdate(self):
         "delay visibility of index updates to other readers"
@@ -119,7 +118,7 @@
     def checkinlinesize(self, tr, fp=None):
         if self.opener == self._delayopener:
             return
-        return revlog.checkinlinesize(self, tr, fp)
+        return revlog.revlog.checkinlinesize(self, tr, fp)
 
     def decode_extra(self, text):
         extra = {}
--- a/mercurial/filelog.py	Sun Jan 11 22:48:28 2009 -0600
+++ b/mercurial/filelog.py	Sun Jan 11 22:55:36 2009 -0600
@@ -5,12 +5,11 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-from node import bin, nullid
-from revlog import revlog
+import revlog
 
-class filelog(revlog):
+class filelog(revlog.revlog):
     def __init__(self, opener, path):
-        revlog.__init__(self, opener,
+        revlog.revlog.__init__(self, opener,
                         "/".join(("data", self.encodedir(path + ".i"))))
 
     # This avoids a collision between a file named foo and a dir named
@@ -55,11 +54,11 @@
         return self.addrevision(text, transaction, link, p1, p2)
 
     def renamed(self, node):
-        if self.parents(node)[0] != nullid:
+        if self.parents(node)[0] != revlog.nullid:
             return False
         m = self._readmeta(node)
         if m and "copy" in m:
-            return (m["copy"], bin(m["copyrev"]))
+            return (m["copy"], revlog.bin(m["copyrev"]))
         return False
 
     def size(self, rev):
@@ -70,7 +69,7 @@
         if self.renamed(node):
             return len(self.read(node))
 
-        return revlog.size(self, rev)
+        return revlog.revlog.size(self, rev)
 
     def cmp(self, node, text):
         """compare text with a given file revision"""
@@ -80,4 +79,4 @@
             t2 = self.read(node)
             return t2 != text
 
-        return revlog.cmp(self, node, text)
+        return revlog.revlog.cmp(self, node, text)
--- a/mercurial/manifest.py	Sun Jan 11 22:48:28 2009 -0600
+++ b/mercurial/manifest.py	Sun Jan 11 22:55:36 2009 -0600
@@ -5,10 +5,8 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-from node import bin, hex, nullid
-from revlog import revlog
 from i18n import _
-import array, struct, mdiff, parsers, util, error
+import array, struct, mdiff, parsers, util, error, revlog
 
 class manifestdict(dict):
     def __init__(self, mapping=None, flags=None):
@@ -23,11 +21,11 @@
     def copy(self):
         return manifestdict(dict.copy(self), dict.copy(self._flags))
 
-class manifest(revlog):
+class manifest(revlog.revlog):
     def __init__(self, opener):
         self.mapcache = None
         self.listcache = None
-        revlog.__init__(self, opener, "00manifest.i")
+        revlog.revlog.__init__(self, opener, "00manifest.i")
 
     def parse(self, lines):
         mfdict = manifestdict()
@@ -39,7 +37,8 @@
         return self.parse(mdiff.patchtext(self.revdiff(r - 1, r)))
 
     def read(self, node):
-        if node == nullid: return manifestdict() # don't upset local cache
+        if node == revlog.nullid:
+            return manifestdict() # don't upset local cache
         if self.mapcache and self.mapcache[0] == node:
             return self.mapcache[1]
         text = self.revision(node)
@@ -101,7 +100,7 @@
             return None, None
         l = text[start:end]
         f, n = l.split('\0')
-        return bin(n[:40]), n[40:-1]
+        return revlog.bin(n[:40]), n[40:-1]
 
     def add(self, map, transaction, link, p1=None, p2=None,
             changed=None):
@@ -136,7 +135,8 @@
 
             # if this is changed to support newlines in filenames,
             # be sure to check the templates/ dir again (especially *-raw.tmpl)
-            text = ["%s\000%s%s\n" % (f, hex(map[f]), map.flags(f))
+            hex, flags = revlog.hex, map.flags
+            text = ["%s\000%s%s\n" % (f, hex(map[f]), flags(f))
                     for f in files]
             self.listcache = array.array('c', "".join(text))
             cachedelta = None
@@ -164,7 +164,7 @@
                 # bs will either be the index of the item or the insert point
                 start, end = self._search(addbuf, f, start)
                 if w[1] == 0:
-                    l = "%s\000%s%s\n" % (f, hex(map[f]), map.flags(f))
+                    l = "%s\000%s%s\n" % (f, revlog.hex(map[f]), map.flags(f))
                 else:
                     l = ""
                 if start == end and w[1] == 1: