diff mercurial/hg.py @ 227:f57519cddd3d

move repo.current to dirstate.parents() -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 move repo.current to dirstate.parents() dirstate now tracks the parents for the working dir add a parents command to show them manifest hash: cd69237838c3f69f7937723c4a6803d47cb27cfa -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCoMGuywK+sNU5EO8RAg5UAKCVLUrsJtkoIOTM+e0BLqEVN3Ni3gCeNDyy ZF8jD728cl9K7S4sIN4gX4Y= =P4bu -----END PGP SIGNATURE-----
author mpm@selenic.com
date Fri, 03 Jun 2005 12:46:38 -0800
parents 1651a3e61925
children 2502aa663484
line wrap: on
line diff
--- a/mercurial/hg.py	Fri Jun 03 12:45:04 2005 -0800
+++ b/mercurial/hg.py	Fri Jun 03 12:46:38 2005 -0800
@@ -155,6 +155,7 @@
         self.dirty = 0
         self.ui = ui
         self.map = None
+        self.pl = None
 
     def __del__(self):
         if self.dirty:
@@ -171,6 +172,15 @@
         if not self.map: self.read()
         return key in self.map
 
+    def parents(self):
+        if not self.pl:
+            self.read()
+        return self.pl
+
+    def setparents(self, p1, p2 = nullid):
+        self.dirty = 1
+        self.pl = p1, p2
+
     def state(self, key):
         try:
             return self[key][0]
@@ -181,11 +191,14 @@
         if self.map is not None: return self.map
 
         self.map = {}
+        self.pl = [nullid, nullid]
         try:
             st = self.opener("dirstate").read()
         except: return
 
-        pos = 0
+        self.pl = [st[:20], st[20: 40]]
+
+        pos = 40
         while pos < len(st):
             e = struct.unpack(">cllll", st[pos:pos+17])
             l = e[4]
@@ -232,6 +245,7 @@
 
     def write(self):
         st = self.opener("dirstate", "w")
+        st.write("".join(self.pl))
         for f, e in self.map.items():
             e = struct.pack(">cllll", e[0], e[1], e[2], e[3], len(f))
             st.write(e + f)
@@ -297,15 +311,7 @@
 
         if not self.remote:
             self.dirstate = dirstate(self.opener, ui)
-            try:
-                self.current = bin(self.opener("current").read())
-            except IOError:
-                self.current = None
 
-    def setcurrent(self, node):
-        self.current = node
-        self.opener("current", "w").write(hex(node))
-      
     def ignore(self, f):
         if self.ignorelist is None:
             self.ignorelist = []
@@ -366,7 +372,7 @@
             node = self.changelog.tip()
             f.sort()
 
-            self.setcurrent(node)
+            self.dirstate.setparents(node)
             self.dirstate.update(f, 'i')
         
         else:
@@ -486,7 +492,7 @@
                 os.makedirs(os.path.dirname(f))
                 file(f, "w").write(t)
 
-        self.setcurrent(node)
+        self.dirstate.setparents(node)
         self.dirstate.clear()
         self.dirstate.update([f for f,n in l], "n")