Rev 1858: Fix tests, improve efficiency. in file:///data/jelmer/bzr-svn/trunk/
Jelmer Vernooij
jelmer at samba.org
Mon Sep 8 02:19:06 BST 2008
At file:///data/jelmer/bzr-svn/trunk/
------------------------------------------------------------
revno: 1858
revision-id: jelmer at samba.org-20080908011902-kntzuyz76wjgz20u
parent: jelmer at samba.org-20080907234334-7a56zk4y6syiv2c2
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2008-09-08 03:19:02 +0200
message:
Fix tests, improve efficiency.
modified:
branch.py svnbranch.py-20051017135706-11c749eb0dab04a7
revmeta.py revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
=== modified file 'branch.py'
--- a/branch.py 2008-09-07 23:16:58 +0000
+++ b/branch.py 2008-09-08 01:19:02 +0000
@@ -35,7 +35,6 @@
from bzrlib.plugins.svn.tags import SubversionTags
from bzrlib.plugins.svn.transport import bzr_to_svn_url
-import itertools
import os
class SvnBranch(Branch):
@@ -126,7 +125,10 @@
return self.last_revmeta().revnum
def last_revmeta(self):
- return self._revision_meta_history().next()
+ for revmeta in self._revision_meta_history():
+ if not revmeta.is_hidden(self.mapping):
+ return revmeta
+ return None
def check(self):
"""See Branch.Check.
@@ -280,12 +282,8 @@
def last_revision_info(self):
"""See Branch.last_revision_info()."""
- last_revmeta = self.last_revmeta()
- last_revid = last_revmeta.get_revision_id(self.mapping)
- last_revno = last_revmeta.get_distance_to_null(self.mapping)
- if last_revno is None:
- last_revno = self.revision_id_to_revno(last_revid)
- return last_revno, last_revid
+ last_revid = self.last_revision()
+ return self.revision_id_to_revno(last_revid), last_revid
def revision_id_to_revno(self, revision_id):
"""Given a revision id, return its revno"""
@@ -294,7 +292,7 @@
revmeta_history = self._revision_meta_history()
for revmeta in revmeta_history:
if revmeta.get_revision_id(self.mapping) == revision_id:
- return revmeta.get_distance_to_null(self.mapping)
+ return len(revmeta_history) - revmeta_history.index(revmeta) - revmeta.get_hidden_lhs_ancestors_count(self.mapping)
raise NoSuchRevision(self, revision_id)
def get_root_id(self, revnum=None):
@@ -320,12 +318,12 @@
self._revmeta_cache = self.repository._revmeta_provider.get_mainline(self.get_branch_path(), self.repository.get_latest_revnum(), self.mapping, pb=pb)
finally:
pb.finished()
- return itertools.ifilter(lambda revmeta: not revmeta.is_hidden(self.mapping), self._revmeta_cache)
+ return self._revmeta_cache
def _gen_revision_history(self):
"""Generate the revision history from last revision
"""
- history = [revmeta.get_revision_id(self.mapping) for revmeta in self._revision_meta_history()]
+ history = [revmeta.get_revision_id(self.mapping) for revmeta in self._revision_meta_history() if not revmeta.is_hidden(self.mapping)]
history.reverse()
return history
=== modified file 'revmeta.py'
--- a/revmeta.py 2008-09-07 23:43:34 +0000
+++ b/revmeta.py 2008-09-08 01:19:02 +0000
@@ -131,7 +131,14 @@
def get_previous_fileprops(self):
"""Return the file properties set on the branch root before this revision."""
- prev = changes.find_prev_location(self.get_paths(), self.branch_path, self.revnum)
+ # Perhaps the metabranch already has the parent?
+ prev = None
+ if self.metabranch is not None:
+ parentrevmeta = self.metabranch.get_lhs_parent(self)
+ if parentrevmeta is not None:
+ prev = (parentrevmeta.branch_path, parentrevmeta.revnum)
+ if prev is None:
+ prev = changes.find_prev_location(self.get_paths(), self.branch_path, self.revnum)
if prev is None:
return {}
(prev_path, prev_revnum) = prev
@@ -178,14 +185,14 @@
"""Estimate how many ancestors with bzr file properties this revision has.
"""
- if self.metabranch is not None and not self.metabranch.consider_bzr_fileprops(self):
+ if not self.consider_bzr_fileprops():
# This revisions descendant doesn't have bzr fileprops set, so this one can't have them either.
return 0
return estimate_bzr_ancestors(self.get_fileprops())
def estimate_svk_fileprop_ancestors(self):
"""Estimate how many svk ancestors this revision has."""
- if self.metabranch is not None and not self.metabranch.consider_svk_fileprops(self):
+ if not self.consider_svk_fileprops():
# This revisions descendant doesn't have svk fileprops set, so this one can't have them either.
return 0
return estimate_svk_ancestors(self.get_fileprops())
@@ -199,7 +206,7 @@
def is_hidden(self, mapping):
if not mapping.supports_hidden:
return False
- if self.is_bzr_revision():
+ if self.consider_bzr_fileprops() or self.consider_bzr_revprops():
return mapping.is_bzr_revision_hidden(self.get_revprops(), self.get_changed_fileprops())
return False
@@ -211,10 +218,10 @@
# If the server already sent us all revprops, look at those first
if self._log.quick_revprops:
order.append(self.is_bzr_revision_revprops)
- if self.metabranch is None or self.metabranch.consider_bzr_fileprops(self) == True:
+ if self.consider_bzr_fileprops():
order.append(self.is_bzr_revision_fileprops)
# Only look for revprops if they could've been committed
- if (not self._log.quick_revprops and self.check_revprops):
+ if (not self._log.quick_revprops and self.consider_bzr_revprops()):
order.append(self.is_bzr_revision_revprops)
for fn in order:
ret = fn()
@@ -226,6 +233,9 @@
return mapping.get_rhs_parents(self.branch_path, self.get_revprops(), self.get_changed_fileprops())
def get_svk_merges(self, mapping):
+ if not self.consider_svk_fileprops():
+ return ()
+
if not self.changes_branch_root():
return ()
@@ -254,12 +264,16 @@
self.get_changed_fileprops())
if bzr_revno is not None:
return bzr_revno
- revno = 0
- revmeta = self
- while revmeta is not None:
- revno+=1
- revmeta = revmeta.get_lhs_parent_revmeta(mapping)
- return revno
+ return None
+
+ def get_hidden_lhs_ancestors_count(self, mapping):
+ if not mapping.supports_hidden:
+ return 0
+ count = self.mapping.get_hidden_lhs_ancestors_count(self.get_fileprops())
+ if count is not None:
+ return count
+ # FIXME: Count number of lhs ancestor revisions with bzr:hidden set
+ return 0
def get_rhs_parents(self, mapping):
"""Determine the right hand side parents for this revision.
@@ -301,10 +315,19 @@
def get_fileid_map(self, mapping):
return mapping.import_fileid_map(self.get_revprops(), self.get_changed_fileprops())
+ def consider_bzr_fileprops(self):
+ return self.metabranch is None or self.metabranch.consider_bzr_fileprops(self)
+
+ def consider_bzr_revprops(self):
+ return self.check_revprops
+
+ def consider_svk_fileprops(self):
+ return self.metabranch is None or self.metabranch.consider_svk_fileprops(self)
+
def get_roundtrip_ancestor_revids(self):
- if self.metabranch is not None and not self.metabranch.consider_bzr_fileprops(self):
+ if not self.consider_bzr_fileprops():
# This revisions descendant doesn't have bzr fileprops set, so this one can't have them either.
- return 0
+ return iter([])
return iter(get_roundtrip_ancestor_revids(self.get_fileprops()))
def __hash__(self):
@@ -375,7 +398,7 @@
this revmeta.
"""
i = self._revs.index(revmeta)
- for desc in self._revs[:i]:
+ for desc in reversed(self._revs[:i]):
if desc.knows_fileprops():
return (desc.estimate_bzr_fileprop_ancestors() > 0)
# assume the worst
@@ -386,7 +409,7 @@
this revmeta.
"""
i = self._revs.index(revmeta)
- for desc in self._revs[i+1:]:
+ for desc in reversed(self._revs[:i]):
if desc.knows_fileprops():
return (desc.estimate_svk_fileprop_ancestors() > 0)
# assume the worst
@@ -400,6 +423,7 @@
return None
def append(self, revmeta):
+ assert len(self._revs) == 0 or self._revs[-1].revnum > revmeta.revnum
self._revs.append(revmeta)
More information about the bazaar-commits
mailing list