~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-22 08:00:50 UTC
  • Revision ID: mbp@sourcefrog.net-20050322080050-fcf2e3a320ad29d0
- new relpath command and function

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        return os.path.join(self.base, name)
131
131
 
132
132
 
 
133
    def relpath(self, path):
 
134
        """Return path relative to this branch of something inside it.
 
135
 
 
136
        Raises an error if path is not in this branch."""
 
137
        rp = os.path.realpath(path)
 
138
        # FIXME: windows
 
139
        if not rp.startswith(self.base):
 
140
            bailout("path %r is not within branch %r" % (rp, self.base))
 
141
        rp = rp[len(self.base):]
 
142
        rp = rp.lstrip(os.sep)
 
143
        return rp
 
144
 
 
145
 
133
146
    def controlfilename(self, file_or_path):
134
147
        """Return location relative to branch."""
135
148
        if isinstance(file_or_path, types.StringTypes):