Rev 2600: nicer path display in info command in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jul 11 06:51:53 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2600
revision-id: pqm at pqm.ubuntu.com-20070711055149-s5wsfnc1jatpoi1x
parent: pqm at pqm.ubuntu.com-20070711041950-ci5yz9nyhbcdmuqv
parent: aaron.bentley at utoronto.ca-20070711045443-oi9vk0jgepts5k5s
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-07-11 06:51:49 +0100
message:
nicer path display in info command
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/info.py info.py-20050323235939-6bbfe7d9700b0b9b
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/test_info.py test_info.py-20070320150933-m0xxm1g7xi9v6noe-1
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.44
merged: aaron.bentley at utoronto.ca-20070711045443-oi9vk0jgepts5k5s
parent: abentley at panoramicfeedback.com-20070706212010-yesdnjys9484lftu
parent: pqm at pqm.ubuntu.com-20070710021221-8o98e4q8vcpaarnk
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: Aaron's mergeable stuff
timestamp: Wed 2007-07-11 00:54:43 -0400
message:
Merge bzr.dev
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.43
merged: abentley at panoramicfeedback.com-20070706212010-yesdnjys9484lftu
parent: abentley at panoramicfeedback.com-20070706184146-e3rxswzbfslos4mi
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: Aaron's mergeable stuff
timestamp: Fri 2007-07-06 17:20:10 -0400
message:
Provide ways of getting at unicode-clean output
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.42
merged: abentley at panoramicfeedback.com-20070706184146-e3rxswzbfslos4mi
parent: abentley at panoramicfeedback.com-20070706183050-2folzf1brc3syc3a
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: Aaron's mergeable stuff
timestamp: Fri 2007-07-06 14:41:46 -0400
message:
Add NEWS entry
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.41
merged: abentley at panoramicfeedback.com-20070706183050-2folzf1brc3syc3a
parent: abentley at panoramicfeedback.com-20070706163615-wxdeft13etu780bk
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: Aaron's mergeable stuff
timestamp: Fri 2007-07-06 14:30:50 -0400
message:
Make info provide more related brances, and format all branches nicely
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.40
merged: abentley at panoramicfeedback.com-20070706163615-wxdeft13etu780bk
parent: aaron.bentley at utoronto.ca-20070705101146-on81r29qia562yfe
parent: pqm at pqm.ubuntu.com-20070706141845-sije5bdx8pjw2fhk
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: Aaron's mergeable stuff
timestamp: Fri 2007-07-06 12:36:15 -0400
message:
Merge bzr.dev
=== modified file 'NEWS'
--- a/NEWS 2007-07-10 01:37:27 +0000
+++ b/NEWS 2007-07-11 04:54:43 +0000
@@ -6,6 +6,9 @@
IMPROVEMENTS:
+ * ``info`` now formats locations more nicely and lists "submit" and
+ "public" branches (Aaron Bentley)
+
* None yet ...
LIBRARY API BREAKS:
=== modified file 'bzrlib/info.py'
--- a/bzrlib/info.py 2007-07-04 13:23:33 +0000
+++ b/bzrlib/info.py 2007-07-06 21:20:10 +0000
@@ -16,12 +16,14 @@
__all__ = ['show_bzrdir_info']
+import os
import time
-
+import sys
from bzrlib import (
bzrdir,
diff,
+ errors,
osutils,
urlutils,
)
@@ -41,41 +43,39 @@
return 's'
-def _repo_rel_url(repo_url, inner_url):
- """Return path with common prefix of repository path removed.
-
- If path is not part of the repository, the original path is returned.
- If path is equal to the repository, the current directory marker '.' is
- returned.
- Otherwise, a relative path is returned, with trailing '/' stripped.
- """
- inner_url = urlutils.normalize_url(inner_url)
- repo_url = urlutils.normalize_url(repo_url)
- if inner_url == repo_url:
- return '.'
- result = urlutils.relative_url(repo_url, inner_url)
- if result != inner_url:
- result = result.rstrip('/')
- return result
-
-class _UrlList(object):
-
- def __init__(self):
- self.urls = []
-
- def add_url(self, label, url):
- self.add_path(label, urlutils.unescape_for_display(url, 'ascii'))
-
- def add_url(self, label, url):
- self.add_path(label, url)
+class LocationList(object):
+
+ def __init__(self, base_path):
+ self.locs = []
+ self.base_path = base_path
+
+ def add_url(self, label, url):
+ """Add a URL to the list, converting it to a path if possible"""
+ if url is None:
+ return
+ try:
+ path = urlutils.local_path_from_url(url)
+ except errors.InvalidURL:
+ self.locs.append((label, url))
+ else:
+ self.add_path(label, path)
def add_path(self, label, path):
- self.urls.append((label, path))
+ """Add a path, converting it to a relative path if possible"""
+ try:
+ path = osutils.relpath(self.base_path, path)
+ except errors.PathNotChild:
+ pass
+ else:
+ if path == '':
+ path = '.'
+ if path != '/':
+ path = path.rstrip('/')
+ self.locs.append((label, path))
- def print_lines(self):
- max_len = max(len(l) for l, u in self.urls)
- for label, url in self.urls:
- print " %*s: %s" % (max_len, label, url)
+ def get_lines(self):
+ max_len = max(len(l) for l, u in self.locs)
+ return [" %*s: %s\n" % (max_len, l, u) for l, u in self.locs ]
def gather_location_info(repository, branch=None, working=None):
@@ -101,8 +101,7 @@
if working_path != master_path:
locs['checkout of branch'] = master_path
elif repository.is_shared():
- locs['repository branch'] = _repo_rel_url(repository_path,
- branch_path)
+ locs['repository branch'] = branch_path
elif branch_path is not None:
# standalone
locs['branch root'] = branch_path
@@ -111,8 +110,7 @@
if repository.is_shared():
# lightweight checkout of branch in shared repository
if branch_path is not None:
- locs['repository branch'] = _repo_rel_url(repository_path,
- branch_path)
+ locs['repository branch'] = branch_path
elif branch_path is not None:
# standalone
locs['branch root'] = branch_path
@@ -133,24 +131,26 @@
def _show_location_info(locs):
"""Show known locations for working, branch and repository."""
print 'Location:'
- path_list = _UrlList()
+ path_list = LocationList(os.getcwd())
for name, loc in locs:
path_list.add_url(name, loc)
- path_list.print_lines()
-
-
-def _show_related_info(branch):
+ sys.stdout.writelines(path_list.get_lines())
+
+def _gather_related_branches(branch):
+ locs = LocationList(os.getcwd())
+ locs.add_url('public branch', branch.get_public_branch())
+ locs.add_url('push branch', branch.get_push_location())
+ locs.add_url('parent branch', branch.get_parent())
+ locs.add_url('submit branch', branch.get_submit_branch())
+ return locs
+
+def _show_related_info(branch, outfile):
"""Show parent and push location of branch."""
- if branch.get_parent() or branch.get_push_location():
- print
- print 'Related branches:'
- if branch.get_parent():
- if branch.get_push_location():
- print ' parent branch: %s' % branch.get_parent()
- else:
- print ' parent branch: %s' % branch.get_parent()
- if branch.get_push_location():
- print ' publish to branch: %s' % branch.get_push_location()
+ locs = _gather_related_branches(branch)
+ if len(locs.locs) > 0:
+ print >> outfile
+ print >> outfile, 'Related branches:'
+ outfile.writelines(locs.get_lines())
def _show_format_info(control=None, repository=None, branch=None, working=None):
@@ -344,7 +344,7 @@
print "%s (format: %s)" % (layout, format)
_show_location_info(gather_location_info(repository, branch, working))
if branch is not None:
- _show_related_info(branch)
+ _show_related_info(branch, sys.stdout)
if verbose == 0:
return
_show_format_info(control, repository, branch, working)
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py 2007-07-06 13:27:52 +0000
+++ b/bzrlib/tests/blackbox/test_info.py 2007-07-06 18:30:50 +0000
@@ -17,12 +17,15 @@
"""Tests for the info command of bzr."""
+import os
import sys
import bzrlib
from bzrlib import (
bzrdir,
+ osutils,
repository,
+ urlutils,
)
from bzrlib.osutils import format_date
from bzrlib.tests import TestSkipped
@@ -53,15 +56,15 @@
self.assertEqualDiff(
"""Standalone tree (format: weave)
Location:
- branch root: %s
-""" % branch1.bzrdir.root_transport.base, out)
+ branch root: standalone
+""", out)
self.assertEqual('', err)
out, err = self.run_bzr('info standalone -v')
self.assertEqualDiff(
"""Standalone tree (format: weave)
Location:
- branch root: %s
+ branch root: standalone
Format:
control: All-in-one format 6
@@ -86,7 +89,7 @@
Repository:
0 revisions
0 KiB
-""" % branch1.bzrdir.root_transport.base, out)
+""", out)
self.assertEqual('', err)
tree1.commit('commit one')
rev = branch1.repository.get_revision(branch1.revision_history()[0])
@@ -100,25 +103,23 @@
self.assertEqualDiff(
"""Standalone tree (format: weave)
Location:
- branch root: %s
+ branch root: branch
Related branches:
- parent branch: %s
- publish to branch: %s
-""" % (branch2.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base), out)
+ push branch: standalone
+ parent branch: standalone
+""", out)
self.assertEqual('', err)
out, err = self.run_bzr('info branch --verbose')
self.assertEqualDiff(
"""Standalone tree (format: weave)
Location:
- branch root: %s
+ branch root: branch
Related branches:
- parent branch: %s
- publish to branch: %s
+ push branch: standalone
+ parent branch: standalone
Format:
control: All-in-one format 6
@@ -146,10 +147,7 @@
Repository:
1 revision
%d KiB
-""" % (branch2.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- datestring_first, datestring_first,
+""" % (datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
branch2.repository._revision_store.total_size(
@@ -169,11 +167,11 @@
self.assertEqualDiff(
"""Checkout (format: knit)
Location:
- checkout root: %s
- checkout of branch: %s
+ checkout root: bound
+ checkout of branch: standalone
Related branches:
- parent branch: %s
+ parent branch: standalone
Format:
control: Meta directory format 1
@@ -201,10 +199,7 @@
Repository:
1 revision
%d KiB
-""" % (branch3.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- bound_tree._format.get_format_description(),
+""" % (bound_tree._format.get_format_description(),
branch3._format.get_format_description(),
branch3.repository._format.get_format_description(),
datestring_first, datestring_first,
@@ -224,8 +219,8 @@
self.assertEqualDiff(
"""Checkout (format: knit)
Location:
- checkout root: %s
- checkout of branch: %s
+ checkout root: checkout
+ checkout of branch: standalone
Format:
control: Meta directory format 1
@@ -253,9 +248,7 @@
Repository:
1 revision
%d KiB
-""" % (branch4.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch4.repository._format.get_format_description(),
+""" % (branch4.repository._format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
@@ -271,8 +264,8 @@
self.assertEqualDiff(
"""Lightweight checkout (format: dirstate or dirstate-tags)
Location:
- light checkout root: %s
- checkout of branch: %s
+ light checkout root: lightcheckout
+ checkout of branch: standalone
Format:
control: Meta directory format 1
@@ -300,10 +293,7 @@
Repository:
1 revision
0 KiB
-""" % (tree5.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- datestring_first, datestring_first,
- ), out)
+""" % (datestring_first, datestring_first,), out)
self.assertEqual('', err)
# Update initial standalone branch
@@ -318,11 +308,11 @@
self.assertEqualDiff(
"""Standalone tree (format: weave)
Location:
- branch root: %s
+ branch root: branch
Related branches:
- parent branch: %s
- publish to branch: %s
+ push branch: standalone
+ parent branch: standalone
Format:
control: All-in-one format 6
@@ -350,10 +340,7 @@
Repository:
1 revision
0 KiB
-""" % (branch2.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- datestring_first, datestring_first,
+""" % (datestring_first, datestring_first,
), out)
self.assertEqual('', err)
@@ -362,11 +349,11 @@
self.assertEqualDiff(
"""Checkout (format: knit)
Location:
- checkout root: %s
- checkout of branch: %s
+ checkout root: bound
+ checkout of branch: standalone
Related branches:
- parent branch: %s
+ parent branch: standalone
Format:
control: Meta directory format 1
@@ -396,10 +383,7 @@
Repository:
1 revision
%d KiB
-""" % (branch3.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch3.repository._format.get_format_description(),
+""" % (branch3.repository._format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
@@ -413,8 +397,8 @@
self.assertEqualDiff(
"""Checkout (format: knit)
Location:
- checkout root: %s
- checkout of branch: %s
+ checkout root: checkout
+ checkout of branch: standalone
Format:
control: Meta directory format 1
@@ -444,9 +428,7 @@
Repository:
1 revision
%d KiB
-""" % (branch4.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- branch4.repository._format.get_format_description(),
+""" % (branch4.repository._format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
@@ -460,8 +442,8 @@
self.assertEqualDiff(
"""Lightweight checkout (format: dirstate or dirstate-tags)
Location:
- light checkout root: %s
- checkout of branch: %s
+ light checkout root: lightcheckout
+ checkout of branch: standalone
Format:
control: Meta directory format 1
@@ -491,10 +473,7 @@
Repository:
2 revisions
0 KiB
-""" % (tree5.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- datestring_first, datestring_last,
- ), out)
+""" % (datestring_first, datestring_last,), out)
self.assertEqual('', err)
def test_info_standalone_no_tree(self):
@@ -506,7 +485,7 @@
self.assertEqualDiff(
"""Standalone branch (format: dirstate or knit)
Location:
- branch root: %s
+ branch root: branch
Format:
control: Meta directory format 1
@@ -520,8 +499,7 @@
Repository:
0 revisions
0 KiB
-""" % (branch.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -546,8 +524,7 @@
Repository:
0 revisions
0 KiB
-""" % (repo.bzrdir.root_transport.base,
- format.repository_format.get_format_description(),
+""" % ('repo', format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -559,8 +536,8 @@
self.assertEqualDiff(
"""Repository branch (format: dirstate or knit)
Location:
- shared repository: %s
- repository branch: branch
+ shared repository: repo
+ repository branch: repo/branch
Format:
control: Meta directory format 1
@@ -574,8 +551,7 @@
Repository:
0 revisions
0 KiB
-""" % (repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -604,9 +580,9 @@
self.assertEqualDiff(
"""Lightweight checkout (format: dirstate or dirstate-tags)
Location:
- light checkout root: %s
- checkout of branch: %s
- shared repository: %s
+ light checkout root: tree/lightcheckout
+ checkout of branch: repo/branch
+ shared repository: repo
Format:
control: Meta directory format 1
@@ -634,10 +610,7 @@
Repository:
1 revision
%d KiB
-""" % (tree2.bzrdir.root_transport.base,
- tree2.branch.bzrdir.root_transport.base,
- repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
@@ -651,8 +624,8 @@
self.assertEqualDiff(
"""Checkout (format: dirstate)
Location:
- checkout root: %s
- checkout of branch: %s
+ checkout root: tree/checkout
+ checkout of branch: repo/branch
Format:
control: Meta directory format 1
@@ -679,9 +652,7 @@
Repository:
0 revisions
0 KiB
-""" % (tree3.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -694,8 +665,8 @@
self.assertEqualDiff(
"""Checkout (format: dirstate)
Location:
- checkout root: %s
- checkout of branch: %s
+ checkout root: tree/checkout
+ checkout of branch: repo/branch
Format:
control: Meta directory format 1
@@ -723,8 +694,7 @@
Repository:
1 revision
%d KiB
-""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
@@ -741,9 +711,9 @@
self.assertEqualDiff(
"""Lightweight checkout (format: dirstate or dirstate-tags)
Location:
- light checkout root: %s
- checkout of branch: %s
- shared repository: %s
+ light checkout root: tree/lightcheckout
+ checkout of branch: repo/branch
+ shared repository: repo
Format:
control: Meta directory format 1
@@ -773,10 +743,7 @@
Repository:
2 revisions
%d KiB
-""" % (tree2.bzrdir.root_transport.base,
- tree2.branch.bzrdir.root_transport.base,
- repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_last,
# poking at _revision_store isn't all that clean, but neither is
@@ -790,8 +757,8 @@
self.assertEqualDiff(
"""Repository branch (format: dirstate or knit)
Location:
- shared repository: %s
- repository branch: branch
+ shared repository: repo
+ repository branch: repo/branch
Format:
control: Meta directory format 1
@@ -808,8 +775,7 @@
Repository:
2 revisions
%d KiB
-""" % (repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_last,
# poking at _revision_store isn't all that clean, but neither is
@@ -823,7 +789,7 @@
self.assertEqualDiff(
"""Shared repository (format: dirstate or dirstate-tags or knit)
Location:
- shared repository: %s
+ shared repository: repo
Format:
control: Meta directory format 1
@@ -832,8 +798,7 @@
Repository:
2 revisions
%d KiB
-""" % (repo.bzrdir.root_transport.base,
- format.repository_format.get_format_description(),
+""" % (format.repository_format.get_format_description(),
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
@@ -851,7 +816,7 @@
self.assertEqualDiff(
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
Location:
- shared repository: %s
+ shared repository: repo
Format:
control: Meta directory format 1
@@ -862,8 +827,7 @@
Repository:
0 revisions
0 KiB
-""" % (repo.bzrdir.root_transport.base,
- format.repository_format.get_format_description(),
+""" % (format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -878,8 +842,8 @@
self.assertEqualDiff(
"""Repository tree (format: knit)
Location:
- shared repository: %s
- repository branch: branch1
+ shared repository: repo
+ repository branch: repo/branch1
Format:
control: Meta directory format 1
@@ -904,8 +868,7 @@
Repository:
0 revisions
0 KiB
-""" % (repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -921,8 +884,8 @@
self.assertEqualDiff(
"""Repository tree (format: knit)
Location:
- shared repository: %s
- repository branch: branch1
+ shared repository: repo
+ repository branch: repo/branch1
Format:
control: Meta directory format 1
@@ -950,8 +913,7 @@
Repository:
1 revision
%d KiB
-""" % (repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
@@ -965,11 +927,11 @@
self.assertEqualDiff(
"""Repository tree (format: knit)
Location:
- shared repository: %s
- repository branch: branch2
+ shared repository: repo
+ repository branch: repo/branch2
Related branches:
- parent branch: %s
+ parent branch: repo/branch1
Format:
control: Meta directory format 1
@@ -994,9 +956,7 @@
Repository:
1 revision
%d KiB
-""" % (repo.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
@@ -1011,11 +971,11 @@
self.assertEqualDiff(
"""Repository tree (format: knit)
Location:
- shared repository: %s
- repository branch: branch2
+ shared repository: repo
+ repository branch: repo/branch2
Related branches:
- parent branch: %s
+ parent branch: repo/branch1
Format:
control: Meta directory format 1
@@ -1043,9 +1003,7 @@
Repository:
1 revision
%d KiB
-""" % (repo.bzrdir.root_transport.base,
- branch1.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
datestring_first, datestring_first,
# poking at _revision_store isn't all that clean, but neither is
@@ -1059,7 +1017,7 @@
self.assertEqualDiff(
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
Location:
- shared repository: %s
+ shared repository: repo
Format:
control: Meta directory format 1
@@ -1070,8 +1028,7 @@
Repository:
1 revision
%d KiB
-""" % (repo.bzrdir.root_transport.base,
- format.repository_format.get_format_description(),
+""" % (format.repository_format.get_format_description(),
# poking at _revision_store isn't all that clean, but neither is
# having the ui test dependent on the exact overhead of a given store.
repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
@@ -1090,7 +1047,7 @@
self.assertEqualDiff(
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
Location:
- shared repository: %s
+ shared repository: repo
Format:
control: Meta directory format 1
@@ -1101,8 +1058,7 @@
Repository:
0 revisions
0 KiB
-""" % (repo.bzrdir.root_transport.base,
- format.repository_format.get_format_description(),
+""" % (format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -1114,8 +1070,8 @@
self.assertEqualDiff(
"""Repository tree (format: knit)
Location:
- shared repository: %s
- repository branch: .
+ shared repository: repo
+ repository branch: repo
Format:
control: Meta directory format 1
@@ -1140,8 +1096,7 @@
Repository:
0 revisions
0 KiB
-""" % (repo.bzrdir.root_transport.base,
- format.get_branch_format().get_format_description(),
+""" % (format.get_branch_format().get_format_description(),
format.repository_format.get_format_description(),
), out)
self.assertEqual('', err)
@@ -1173,6 +1128,13 @@
:param repo_locked: If true, expect the repository to be locked.
:param verbose: If true, expect verbose output
"""
+ def friendly_location(url):
+ path = urlutils.unescape_for_display(url, 'ascii')
+ try:
+ return osutils.relpath(os.getcwd(), path)
+ except errors.PathNotChild:
+ return path
+
if tree_locked and sys.platform == 'win32':
# We expect this to fail because of locking errors. (A write-locked
# file cannot be read-locked in the same process).
@@ -1210,22 +1172,22 @@
extra_space = ''
if light_checkout:
tree_data = (" light checkout root: %s\n" %
- lco_tree.bzrdir.root_transport.base)
+ friendly_location(lco_tree.bzrdir.root_transport.base))
extra_space = ' '
if lco_tree.branch.get_bound_location() is not None:
tree_data += ("%s checkout root: %s\n" % (extra_space,
- lco_tree.branch.bzrdir.root_transport.base))
+ friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
if shared_repo is not None:
branch_data = (
" checkout of branch: %s\n"
" shared repository: %s\n" %
- (repo_branch.bzrdir.root_transport.base,
- shared_repo.bzrdir.root_transport.base))
+ (friendly_location(repo_branch.bzrdir.root_transport.base),
+ friendly_location(shared_repo.bzrdir.root_transport.base)))
elif repo_branch is not None:
branch_data = (
"%s checkout of branch: %s\n" %
(extra_space,
- repo_branch.bzrdir.root_transport.base))
+ friendly_location(repo_branch.bzrdir.root_transport.base)))
else:
branch_data = (" checkout of branch: %s\n" %
lco_tree.branch.bzrdir.root_transport.base)
@@ -1428,8 +1390,7 @@
Repository:
0 revisions
0 KiB
-""" % (tree.bzrdir.root_transport.base,
- tree.branch.repository._format.get_format_description(),
+""" % ('branch', tree.branch.repository._format.get_format_description(),
), out)
self.assertEqual('', err)
# L L L
@@ -1463,8 +1424,7 @@
Repository:
0 revisions
0 KiB
-""" % (tree.bzrdir.root_transport.base,
- tree.branch.repository._format.get_format_description(),
+""" % ('branch', tree.branch.repository._format.get_format_description(),
), out)
self.assertEqual('', err)
tree.unlock()
=== modified file 'bzrlib/tests/test_info.py'
--- a/bzrlib/tests/test_info.py 2007-06-14 04:43:35 +0000
+++ b/bzrlib/tests/test_info.py 2007-07-06 21:20:10 +0000
@@ -14,6 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+from urllib import quote
from bzrlib import (
branch as _mod_branch,
@@ -187,7 +188,7 @@
tree = self.make_branch_and_tree('shared/tree')
self.assertEqual([('shared repository',
srepo.bzrdir.root_transport.base),
- ('repository branch', 'tree')],
+ ('repository branch', tree.branch.base)],
info.gather_location_info(srepo, tree.branch, tree))
def test_gather_location_light_checkout(self):
@@ -239,3 +240,29 @@
('bound to branch', branch.bzrdir.root_transport.base)],
info.gather_location_info(bound_branch.repository, bound_branch)
)
+
+ 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.locs, [('a', '.'),
+ ('b', 'bar'),
+ ('c', '/home/bar/bar'),
+ ('d', 'http://example.com/example/')])
+ self.assertEqualDiff(' a: .\n b: bar\n c: /home/bar/bar\n'
+ ' d: http://example.com/example/\n',
+ ''.join(locs.get_lines()))
+
+ def test_gather_related_braches(self):
+ branch = self.make_branch('.')
+ branch.set_public_branch('baz')
+ branch.set_push_location('bar')
+ branch.set_parent('foo')
+ branch.set_submit_branch('qux')
+ self.assertEqual(
+ [('public branch', 'baz'), ('push branch', 'bar'),
+ ('parent branch', 'foo'), ('submit branch', 'qux')],
+ info._gather_related_branches(branch).locs)
More information about the bazaar-commits
mailing list