diff mercurial/hg.py @ 67:a182f2561c8e

Add tag support
author mpm@selenic.com
date Fri, 13 May 2005 13:12:32 -0800
parents d40cc5aacc31
children 85f1f87dc8ff
line wrap: on
line diff
--- a/mercurial/hg.py	Fri May 13 12:44:11 2005 -0800
+++ b/mercurial/hg.py	Fri May 13 13:12:32 2005 -0800
@@ -258,6 +258,7 @@
         self.manifest = manifest(self.opener)
         self.changelog = changelog(self.opener)
         self.ignorelist = None
+        self.tags = None
 
         if not self.remote:
             self.dircache = dircache(self.opener, ui)
@@ -274,7 +275,7 @@
         if self.ignorelist is None:
             self.ignorelist = []
             try:
-                l = open(os.path.join(self.root, ".hgignore")).readlines()
+                l = open(os.path.join(self.root, ".hgignore"))
                 for pat in l:
                     if pat != "\n":
                         self.ignorelist.append(re.compile(pat[:-1]))
@@ -283,6 +284,21 @@
             if pat.search(f): return True
         return False
 
+    def lookup(self, key):
+        if self.tags is None:
+            self.tags = {}
+            try:
+                fl = self.file(".hgtags")
+                for l in fl.revision(fl.tip()).splitlines():
+                    if l:
+                        n, k = l.split(" ")
+                        self.tags[k] = bin(n)
+            except KeyError: pass
+        try:
+            return self.tags[key]
+        except KeyError:
+            return self.changelog.lookup(key)
+
     def join(self, f):
         return os.path.join(self.path, f)