[Pkg-bazaar-commits] ./bzr/unstable r67: use abspath() for the function that makes an absolute
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:27:23 UTC 2009
------------------------------------------------------------
revno: 67
committer: mbp at sourcefrog.net
timestamp: Tue 2005-03-22 18:28:45 +1100
message:
use abspath() for the function that makes an absolute
path to something in a branch or tree
modified:
bzrlib/branch.py
bzrlib/tests.py
bzrlib/tree.py
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-03-22 07:09:56 +0000
+++ b/bzrlib/branch.py 2005-03-22 07:28:45 +0000
@@ -125,10 +125,10 @@
__repr__ = __str__
- def _rel(self, name):
- """Return filename relative to branch top"""
+ def abspath(self, name):
+ """Return absolute filename for something in the branch"""
return os.path.join(self.base, name)
-
+
def controlfilename(self, file_or_path):
"""Return location relative to branch."""
@@ -257,7 +257,7 @@
if len(fp) == 0:
bailout("cannot add top-level %r" % f)
- fullpath = os.path.normpath(self._rel(f))
+ fullpath = os.path.normpath(self.abspath(f))
if isfile(fullpath):
kind = 'file'
@@ -417,7 +417,7 @@
entry = entry.copy()
- p = self._rel(path)
+ p = self.abspath(path)
file_id = entry.file_id
mutter('commit prep file %s, id %r ' % (p, file_id))
@@ -698,7 +698,7 @@
A foo
>>> b.commit("add foo")
>>> b.show_status()
- >>> os.unlink(b._rel('foo'))
+ >>> os.unlink(b.abspath('foo'))
>>> b.show_status()
D foo
=== modified file 'bzrlib/tests.py'
--- a/bzrlib/tests.py 2005-03-22 00:21:11 +0000
+++ b/bzrlib/tests.py 2005-03-22 07:28:45 +0000
@@ -139,17 +139,17 @@
Tests for adding subdirectories, etc.
>>> b = bzrlib.branch.ScratchBranch()
- >>> os.mkdir(b._rel('d1'))
- >>> os.mkdir(b._rel('d2'))
- >>> os.mkdir(b._rel('d2/d3'))
+ >>> os.mkdir(b.abspath('d1'))
+ >>> os.mkdir(b.abspath('d2'))
+ >>> os.mkdir(b.abspath('d2/d3'))
>>> list(b.working_tree().unknowns())
['d1', 'd2']
Create some files, but they're not seen as unknown yet:
- >>> file(b._rel('d1/f1'), 'w').close()
- >>> file(b._rel('d2/f2'), 'w').close()
- >>> file(b._rel('d2/f3'), 'w').close()
+ >>> file(b.abspath('d1/f1'), 'w').close()
+ >>> file(b.abspath('d2/f2'), 'w').close()
+ >>> file(b.abspath('d2/f3'), 'w').close()
>>> [v[0] for v in b.inventory.directories()]
['']
>>> list(b.working_tree().unknowns())
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2005-03-09 07:29:44 +0000
+++ b/bzrlib/tree.py 2005-03-22 07:28:45 +0000
@@ -138,26 +138,26 @@
return "<%s of %s>" % (self.__class__.__name__,
self.basedir)
- def _rel(self, filename):
+ def abspath(self, filename):
return os.path.join(self.basedir, filename)
def has_filename(self, filename):
- return os.path.exists(self._rel(filename))
+ return os.path.exists(self.abspath(filename))
def get_file(self, file_id):
return self.get_file_byname(self.id2path(file_id))
def get_file_byname(self, filename):
- return file(self._rel(filename), 'rb')
+ return file(self.abspath(filename), 'rb')
def _get_store_filename(self, file_id):
- return self._rel(self.id2path(file_id))
+ return self.abspath(self.id2path(file_id))
def has_id(self, file_id):
# files that have been deleted are excluded
if not self.inventory.has_id(file_id):
return False
- return os.access(self._rel(self.inventory.id2path(file_id)), os.F_OK)
+ return os.access(self.abspath(self.inventory.id2path(file_id)), os.F_OK)
def get_file_size(self, file_id):
return os.stat(self._get_store_filename(file_id))[ST_SIZE]
@@ -177,9 +177,9 @@
def file_kind(self, filename):
- if isfile(self._rel(filename)):
+ if isfile(self.abspath(filename)):
return 'file'
- elif isdir(self._rel(filename)):
+ elif isdir(self.abspath(filename)):
return 'directory'
else:
return 'unknown'
More information about the Pkg-bazaar-commits
mailing list