Rev 1564: Simplify tree building functions. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Fri Aug 8 23:10:27 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1564
revision-id: jelmer at samba.org-20080808221026-waj0dycxa2weaxcx
parent: jelmer at samba.org-20080808220921-3f3geqj747gv9t5g
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sat 2008-08-09 00:10:26 +0200
message:
Simplify tree building functions.
modified:
tree.py tree.py-20060624222557-dudlwqcmkf22lt2s-1
=== modified file 'tree.py'
--- a/tree.py 2008-07-08 19:09:33 +0000
+++ b/tree.py 2008-08-08 22:10:26 +0000
@@ -27,7 +27,7 @@
from cStringIO import StringIO
import urllib
-from bzrlib.plugins.svn import core, errors, properties, wc
+from bzrlib.plugins.svn import core, properties, wc
from bzrlib.plugins.svn.delta import apply_txdelta_handler
@@ -87,12 +87,10 @@
finally:
repository.transport.add_connection(conn)
- def get_file_lines(self, file_id):
- return osutils.split_lines(self.get_file_text(file_id))
-
def get_file_text(self, file_id):
return self.file_data[file_id]
+
class TreeBuildEditor(object):
"""Builds a tree given Subversion tree transform calls."""
def __init__(self, tree):
@@ -236,22 +234,21 @@
def add_file_to_inv(relpath, id, revid, adm):
(propchanges, props) = adm.get_prop_diffs(self.workingtree.abspath(relpath).encode("utf-8"))
- abspath = self._abspath(relpath)
if props.has_key(properties.PROP_SPECIAL):
- is_symlink = (open(abspath).read(5) == "link ")
+ is_symlink = (self.get_file_byname(relpath).read(5) == "link ")
else:
is_symlink = False
if is_symlink:
ie = self._inventory.add_path(relpath, 'symlink', id)
- ie.symlink_target = open(abspath).read()[len("link "):]
+ ie.symlink_target = self.get_file_byname(relpath).read()[len("link "):]
ie.text_sha1 = None
ie.text_size = None
ie.text_id = None
ie.executable = False
else:
ie = self._inventory.add_path(relpath, 'file', id)
- data = osutils.fingerprint_file(open(abspath))
+ data = osutils.fingerprint_file(self.get_file_byname(relpath))
ie.text_sha1 = data['sha1']
ie.text_size = data['size']
ie.executable = props.has_key(properties.PROP_EXECUTABLE)
@@ -309,12 +306,14 @@
finally:
adm.close()
- def _abspath(self, relpath):
+ def abspath(self, relpath):
return wc.get_pristine_copy_path(self.workingtree.abspath(relpath).encode("utf-8"))
- def get_file_lines(self, file_id):
- base_copy = self._abspath(self.id2path(file_id))
- return osutils.split_lines(open(base_copy).read())
+ def get_file_byname(self, name):
+ return open(self.abspath(name))
+
+ def get_file_text(self, file_id):
+ return self.get_file_byname(self.id2path(file_id)).read()
def annotate_iter(self, file_id,
default_revision=CURRENT_REVISION):
More information about the bazaar-commits
mailing list