Rev 4409: Make _get_object_and_label() private to upgrade.py, its inmplementation is both incomplete and returning info that are not used. in file:///home/vila/src/bzr/reviews/smooth-upgrades/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sat Dec 18 18:32:01 GMT 2010
At file:///home/vila/src/bzr/reviews/smooth-upgrades/
------------------------------------------------------------
revno: 4409
revision-id: v.ladeuil+lp at free.fr-20101218183200-t7u3dysnp37v6fkv
parent: v.ladeuil+lp at free.fr-20101217120306-dqmliafiuyjnc7qf
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: smooth-upgrades
timestamp: Sat 2010-12-18 19:32:00 +0100
message:
Make _get_object_and_label() private to upgrade.py, its inmplementation is both incomplete and returning info that are not used.
-------------- next part --------------
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2010-12-04 15:25:12 +0000
+++ b/bzrlib/bzrdir.py 2010-12-18 18:32:00 +0000
@@ -927,41 +927,6 @@
return format.initialize_on_transport(t)
- def _get_object_and_label(self):
- """Return the primary object and type label for a control directory.
-
- :return: object, label where
- object is a Branch, Repository or WorkingTree and
- label is one of:
- branch - a branch
- repository - a repository
- tree - a lightweight checkout
- """
- try:
- try:
- br = self.open_branch(unsupported=True, ignore_fallbacks=True)
- except NotImplementedError:
- # RemoteRepository doesn't support the unsupported parameter
- br = self.open_branch(ignore_fallbacks=True)
- except errors.NotBranchError:
- pass
- else:
- return br, "branch"
- try:
- repo = self.open_repository()
- except errors.NoRepositoryPresent:
- pass
- else:
- return repo, "repository"
- try:
- wt = self.open_workingtree()
- except (errors.NoWorkingTree, errors.NotLocalUrl):
- pass
- else:
- return wt, "tree"
- raise AssertionError("unknown type of control directory %s", self)
-
-
class BzrDirHooks(hooks.Hooks):
"""Hooks for BzrDir operations."""
=== modified file 'bzrlib/upgrade.py'
--- a/bzrlib/upgrade.py 2010-12-17 11:35:28 +0000
+++ b/bzrlib/upgrade.py 2010-12-18 18:32:00 +0000
@@ -211,6 +211,46 @@
# Return the result
return attempted, succeeded, exceptions
+# FIXME: There are several problems below:
+# - RemoteRepository doesn't support _unsupported (really ?)
+# - raising AssertionError is rude and may not be necessary
+# - no tests
+# - the only caller uses only the label
+def _get_object_and_label(control_dir):
+ """Return the primary object and type label for a control directory.
+
+ :return: object, label where
+ object is a Branch, Repository or WorkingTree and
+ label is one of:
+ branch - a branch
+ repository - a repository
+ tree - a lightweight checkout
+ """
+ try:
+ try:
+ br = control_dir.open_branch(unsupported=True,
+ ignore_fallbacks=True)
+ except NotImplementedError:
+ # RemoteRepository doesn't support the unsupported parameter
+ br = control_dir.open_branch(ignore_fallbacks=True)
+ except errors.NotBranchError:
+ pass
+ else:
+ return br, "branch"
+ try:
+ repo = control_dir.open_repository()
+ except errors.NoRepositoryPresent:
+ pass
+ else:
+ return repo, "repository"
+ try:
+ wt = control_dir.open_workingtree()
+ except (errors.NoWorkingTree, errors.NotLocalUrl):
+ pass
+ else:
+ return wt, "tree"
+ raise AssertionError("unknown type of control directory %s", control_dir)
+
def _convert_items(items, format, clean_up, dry_run, label=None):
"""Convert a sequence of control directories to the given format.
@@ -230,7 +270,7 @@
for i, control_dir in enumerate(items):
# Do the conversion
location = control_dir.root_transport.base
- bzr_object, bzr_label = control_dir._get_object_and_label()
+ bzr_object, bzr_label = _get_object_and_label(control_dir)
type_label = label or bzr_label
child_pb.update("Upgrading %s" % (type_label), i+1, len(items))
ui.ui_factory.note('Upgrading %s %s ...' % (type_label, location,))
More information about the bazaar-commits
mailing list