Compatibility fix for Branch.{get,set}_parent()
Wouter van Heyst
larstiq at larstiq.dyndns.org
Thu Jun 15 22:33:32 BST 2006
On Thu, Jun 15, 2006 at 02:18:00PM -0500, John Arbash Meinel wrote:
> As part of the Encoding work, Wouter and I fixed Branch.set_parent() so
> that it takes a full URL, but only saves the relative portion if possible.
> So the contents of .bzr/branch/parent are always a URL, and relative if
> possible.
> It means we do weird things with old formats, where they included a
> fully absolute local path.
> So I added a workaround that would detect this, and change it into a
> full url before returning it.
> I kept running into this on my branches. I think it is a reasonable fix
> and comes with a test case. Can I get a +1?
>
> John
> =:->
> === modified file 'bzrlib/branch.py'
> --- bzrlib/branch.py 2006-06-15 17:26:25 +0000
> +++ bzrlib/branch.py 2006-06-15 19:16:55 +0000
> @@ -1188,10 +1188,14 @@
> assert self.base[-1] == '/'
> for l in _locs:
> try:
> - return urlutils.join(self.base[:-1],
> - self.control_files.get(l).read().strip('\n'))
> + parent = self.control_files.get(l).read().strip('\n')
> except NoSuchFile:
> - pass
> + continue
> + # This is an old-format absolute path to a local branch
> + # turn it into a url
> + if parent.startswith('/'):
> + parent = urlutils.local_path_to_url(parent.decode('utf8')
> + return urlutils.join(self.base[:-1], parent)
> return None
Will this dealing with old formats always be needed? I have a hard time
estimating how necessary a win32 codepath is. Considering no one has
complained yet, a +0.5 from me.
Wouter van Heyst
More information about the bazaar
mailing list