Rev 480: Avoid expensive calls. in file:///home/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Sun Jun 17 13:18:54 BST 2007


------------------------------------------------------------
revno: 480
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2007-06-17 14:18:41 +0200
message:
  Avoid expensive calls.
modified:
  convert.py
=== modified file 'convert.py'
--- a/convert.py	2007-06-16 23:43:38 +0000
+++ b/convert.py	2007-06-17 12:18:41 +0000
@@ -22,8 +22,8 @@
 
 from bzrlib.bzrdir import BzrDir, BzrDirFormat, Converter
 from bzrlib.branch import Branch
-from bzrlib.errors import (BzrError, NotBranchError, 
-                           NoSuchFile, NoRepositoryPresent)
+from bzrlib.errors import (BzrError, NotBranchError, NoSuchFile, 
+                           NoRepositoryPresent, NoSuchRevision)
 import bzrlib.osutils as osutils
 from bzrlib.trace import mutter
 from bzrlib.transport import get_transport
@@ -137,15 +137,16 @@
                 except NotBranchError:
                     target_branch = target_dir.create_branch()
                     target_branch.set_parent(source_branch_url)
-                # FIXME: don't use revision_history()
-                if not revid in target_branch.revision_history():
+                if revid != target_branch.last_revision():
                     source_branch = Branch.open(source_branch_url)
                     # Check if target_branch contains a subset of 
                     # source_branch. If that is not the case, 
                     # assume that source_branch has been replaced 
                     # and remove target_branch
-                    if not target_branch.last_revision() in \
-                            source_branch.revision_history():
+                    try:
+                        source_branch.revision_id_to_revno(
+                                target_branch.last_revision())
+                    except NoSuchRevision:
                         target_branch.set_revision_history([])
                     target_branch.pull(source_branch)
                 if working_trees and not target_dir.has_workingtree():




More information about the bazaar-commits mailing list