root relative IO and valid commit states
authormpm@selenic.com
Sat, 04 Jun 2005 11:13:25 -0800
changeset 244 43105253cf5e
parent 243 9a9ea2d1d3c4
child 245 fef0f8e041aa
root relative IO and valid commit states -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 root relative IO and valid commit states do all working dir manipulation relative to localrepository.root change the valid commit states manifest hash: def7de4dfb4cad1fd4ef6f713fa3b5c903e05c58 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCof1VywK+sNU5EO8RArEVAJ9F/zFYqRvS2dWxOhONCm1OjEjILQCfcmDq ARbGkSFSyVmyUSBSEq4n//E= =qIEI -----END PGP SIGNATURE-----
mercurial/hg.py
--- a/mercurial/hg.py	Sat Jun 04 11:10:42 2005 -0800
+++ b/mercurial/hg.py	Sat Jun 04 11:13:25 2005 -0800
@@ -150,8 +150,9 @@
         return self.addrevision(text, transaction, self.count(), p1, p2)
 
 class dirstate:
-    def __init__(self, opener, ui):
+    def __init__(self, opener, ui, root):
         self.opener = opener
+        self.root = root
         self.dirty = 0
         self.ui = ui
         self.map = None
@@ -223,7 +224,7 @@
                 self.map[f] = ('r', 0, 0, 0)
             else:
                 try:
-                    s = os.stat(f)
+                    s = os.stat(os.path.join(self.root, f))
                     self.map[f] = (state, s.st_mode, s.st_size, s.st_mtime)
                 except OSError:
                     if state != "i": raise
@@ -311,7 +312,7 @@
         self.tags = None
 
         if not self.remote:
-            self.dirstate = dirstate(self.opener, ui)
+            self.dirstate = dirstate(self.opener, ui, self.root)
 
     def ignore(self, f):
         if self.ignorelist is None:
@@ -344,6 +345,9 @@
     def join(self, f):
         return os.path.join(self.path, f)
 
+    def wjoin(self, f):
+        return os.path.join(self.root, f)
+
     def file(self, f):
         if f[0] == '/': f = f[1:]
         return filelog(self.opener, f)
@@ -420,12 +424,12 @@
         if files:
             for f in files:
                 s = self.dirstate.state(f)
-                if s in 'cai':
+                if s in 'nmai':
                     commit.append(f)
                 elif s == 'r':
                     remove.append(f)
                 else:
-                    self.warn("%s not tracked!\n")
+                    self.ui.warn("%s not tracked!\n" % f)
         else:
             (c, a, d, u) = self.diffdir(self.root)
             commit = c + a
@@ -450,7 +454,7 @@
         for f in commit:
             self.ui.note(f + "\n")
             try:
-                t = file(f).read()
+                t = file(self.wjoin(f)).read()
             except IOError:
                 self.warn("trouble committing %s!\n" % f)
                 raise
@@ -493,10 +497,10 @@
             self.ui.note(f, "\n")
             t = self.file(f).revision(n)
             try:
-                file(f, "w").write(t)
+                file(self.wjoin(f), "w").write(t)
             except IOError:
                 os.makedirs(os.path.dirname(f))
-                file(f, "w").write(t)
+                file(self.wjoin(f), "w").write(t)
 
         self.dirstate.setparents(node)
         self.dirstate.clear()
@@ -519,7 +523,7 @@
             dc = self.dirstate.copy()
 
         def fcmp(fn):
-            t1 = file(os.path.join(self.root, fn)).read()
+            t1 = file(self.wjoin(fn)).read()
             t2 = self.file(fn).revision(mf[fn])
             return cmp(t1, t2)
 
@@ -585,7 +589,7 @@
 
     def add(self, list):
         for f in list:
-            p = os.path.join(self.root, f)
+            p = self.wjoin(f)
             if not os.path.isfile(p):
                 self.ui.warn("%s does not exist!\n" % f)
             elif self.dirstate.state(f) == 'n':
@@ -602,7 +606,7 @@
 
     def remove(self, list):
         for f in list:
-            p = os.path.join(self.root, f)
+            p = self.wjoin(f)
             if os.path.isfile(p):
                 self.ui.warn("%s still exists!\n" % f)
             elif f not in self.dirstate:
@@ -935,10 +939,10 @@
             self.ui.note(f, "\n")
             t = self.file(f).revision(get[f])
             try:
-                file(f, "w").write(t)
+                file(self.wjoin(f), "w").write(t)
             except IOError:
                 os.makedirs(os.path.dirname(f))
-                file(f, "w").write(t)
+                file(self.wjoin(f), "w").write(t)
 
         # we have to remember what files we needed to get/change
         # because any file that's different from either one of its
@@ -973,7 +977,7 @@
 
         fl = self.file(fn)
         base = fl.ancestor(my, other)
-        a = fn
+        a = self.wjoin(fn)
         b = temp("other", other)
         c = temp("base", base)