Fix libbe.vcs.VCS.get_file_contents(allow_no_vcs=True,binary=True).
authorW. Trevor King <wking@drexel.edu>
Sat, 21 Nov 2009 19:54:11 +0000 (14:54 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 21 Nov 2009 19:54:11 +0000 (14:54 -0500)
In it's previous form it had ignored the binary option if
self._use_vcs() returned False.

Also added a few more details to the docstring, explaining the
arguments.

libbe/vcs.py

index b1fd1141a0ffc568a060ce06a9ba9ed36ba91434..57a024539b750b65f07008e295732fc100a6e784 100644 (file)
@@ -334,6 +334,10 @@ class VCS(object):
         """
         Get the file as it was in a given revision.
         Revision==None specifies the current revision.
+
+        allow_no_vcs==True allows direct access to files through
+        codecs.open() or open() if the vcs decides it can't handle the
+        given path.
         """
         if not os.path.exists(path):
             raise NoSuchFile(path)
@@ -341,7 +345,10 @@ class VCS(object):
             relpath = self._u_rel_path(path)
             contents = self._vcs_get_file_contents(relpath,revision,binary=binary)
         else:
-            f = codecs.open(path, "r", self.encoding)
+            if binary == True:
+                f = codecs.open(path, "r", self.encoding)
+            else:
+                f = open(path, "rb")
             contents = f.read()
             f.close()
         return contents