[MERGE] Nicer location display in info

Aaron Bentley aaron.bentley at utoronto.ca
Fri Jul 6 20:40:47 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel wrote:
> Aaron Bentley wrote:
> It would be nice if we could give 'LocationList' an self.outf.encoding, so that
> people who have non-ascii branches can see nicely formatted Unicode named
> locations.

Makes sense.

> One possible problem with 'relpath' is that it is a bit overeager. I believe it
> is willing to take:
> 
> /foo/bar/baz
> and
> 
> /biz/bang
> 
> and make one:
> 
> ../../../biz/bang

No, definitely not.  See this test:

+    def test_location_list(self):
+        locs = info.LocationList('/home/foo')
+        locs.add_url('a', 'file:///home/foo/')
+        locs.add_url('b', 'file:///home/foo/bar/')
+        locs.add_url('c', 'file:///home/bar/bar')
+        locs.add_url('d', 'http://example.com/example/')
+        locs.add_url('e', None)
+        self.assertEqual(locs.urls, [('a', '.'),
+                                     ('b', 'bar'),
+                                     ('c', '/home/bar/bar'),
+                                     ('d', 'http://example.com/example/')])

Note that 'c' is stored as '/home/bar/bar', not '../../bar/bar'

If the "base" is not a *prefix* of the target path, relpath will raise
PathNotChild, and LocationList will emit an absolute path.

> Thoughts?

I'd like to keep the current behavior of emitting a relative path only
if the cwd is a prefix of the target path.  I'll add encoding support to
LocationList.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGjpq/0F+nu1YWqI0RAmP/AJ9DSRk0qGm4xcs+hzfBpG5pijaNDQCfbYJe
p9dDMeRxqIgzOxWwrou1FXI=
=RJiI
-----END PGP SIGNATURE-----



More information about the bazaar mailing list