Implement Arch._vcs_path()
authorW. Trevor King <wking@drexel.edu>
Wed, 27 Jan 2010 21:50:34 +0000 (16:50 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 27 Jan 2010 21:50:34 +0000 (16:50 -0500)
Fixes VersionedStorage_commit_TestCase.test_get_previous_children.
Should have fixed
  VersionedStorage_commit_TestCase.test_get_previous_version
too, but 'tla file-find' is buggy:
  https://bugs.launchpad.net/ubuntu/+source/tla/+bug/513472

Also:
  * sort children in test_get_previous_children, since we shouldn't
    require a particular child order
  * unescape filenames in Arch._diff()
  * remove debugging prints from Arch._parse_diff()
  * remove silly blank line in git.py I'd stumbled across ;).

libbe/storage/base.py
libbe/storage/vcs/arch.py
libbe/storage/vcs/git.py

index ade658748120f846234b2e1bcf82f22d5058634e..ad6b291402d3340cd2dc5f971831370ab32a82c5 100644 (file)
@@ -994,7 +994,7 @@ if TESTING == True:
                 cur_children.append(new_child)
                 children.append(list(cur_children))
             for i in range(10):
-                ret = self.s.children('parent', revision=revs[i])
+                ret = sorted(self.s.children('parent', revision=revs[i]))
                 self.failUnless(ret == children[i],
                                 "%s.get() returned %s not %s for revision %s"
                                 % (vars(self.Class)['name'], ret,
index 2b305ea2bafee6527cb522736fb1f3c6da399f13..38b1d02041a5c9733c9408c6ad3541dc53eb466c 100644 (file)
@@ -24,6 +24,7 @@ GNU Arch (tla) backend.
 
 import codecs
 import os
+import os.path
 import re
 import shutil
 import sys
@@ -33,6 +34,7 @@ import libbe
 import libbe.ui.util.user
 import libbe.storage.util.config
 from libbe.util.id import uuid_gen
+from libbe.util.subproc import CommandError
 import base
 
 if libbe.TESTING == True:
@@ -301,15 +303,37 @@ class Arch(base.VCS):
         if revision == None:
             return base.VCS._vcs_get_file_contents(self, path, revision)
         else:
+            relpath = self._file_find(path, revision, relpath=True)
+            return base.VCS._vcs_get_file_contents(self, relpath)
+
+    def _file_find(self, path, revision, relpath=False):
+        try:
             status,output,error = \
                 self._invoke_client(
                 'file-find', '--unescaped', path, revision)
-            relpath = output.rstrip('\n').splitlines()[-1]
-            return base.VCS._vcs_get_file_contents(self, relpath)
+            path = output.rstrip('\n').splitlines()[-1]
+        except CommandError, e:
+            if e.status == 2 \
+                    and 'illegally formed changeset index' in e.stderr:
+                raise NotImplementedError(
+"""Outstanding tla bug, see
+  https://bugs.launchpad.net/ubuntu/+source/tla/+bug/513472
+""")
+            raise
+        if relpath == True:
+            return path
+        return os.path.abspath(os.path.join(self.repo, path))
 
     def _vcs_path(self, id, revision):
-        raise NotImplementedError(
-            'Too little Arch understanding at the moment...')
+        return self._u_find_id(id, revision)
+
+    def _vcs_isdir(self, path, revision):
+        abspath = self._file_find(path, revision)
+        return os.path.isdir(abspath)
+
+    def _vcs_listdir(self, path, revision):
+        abspath = self._file_find(path, revision)
+        return [p for p in os.listdir(abspath) if self._vcs_is_versioned(p)]
 
     def _vcs_commit(self, commitfile, allow_empty=False):
         if allow_empty == False:
@@ -359,7 +383,7 @@ class Arch(base.VCS):
 
     def _diff(self, revision):
         status,output,error = self._u_invoke_client(
-            'diff', '--summary', revision, expect=(0,1))
+            'diff', '--summary', '--unescaped', revision, expect=(0,1))
         return output
     
     def _parse_diff(self, diff_text):
@@ -390,7 +414,6 @@ class Arch(base.VCS):
             if line.startswith('* ') or '/.arch-ids/' in line:
                 continue
             change,file = line.split('  ',1)
-            print '"%s" "%s"' % (change, file)
             if  file.startswith('{arch}/'):
                 continue
             if change == 'A':
@@ -399,7 +422,6 @@ class Arch(base.VCS):
                 modified.append(file)
             elif change == 'D':
                 removed.append(file)
-        print new, modified, removed
         return (new,modified,removed)
 
     def _vcs_changed(self, revision):
index e2c1b839873dca31f26a45a8eac625b96b66769e..c6638bc5f3622bf762e9fdaa1debddfcd4e6ad62 100644 (file)
@@ -118,7 +118,6 @@ class Git(base.VCS):
             status,output,error = self._u_invoke_client('show', arg)
             return output
 
-
     def _vcs_path(self, id, revision):
         return self._u_find_id(id, revision)