Rev 2120: Try harder to avoid fetching properties when not necessary. in http://people.samba.org/bzr/jelmer/bzr-svn/0.5
Jelmer Vernooij
jelmer at samba.org
Mon Dec 1 03:37:30 GMT 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.5
------------------------------------------------------------
revno: 2120
revision-id: jelmer at samba.org-20081201033727-nc1ak28jt4nljt5k
parent: jelmer at samba.org-20081201015522-mtyuxs4s3muihx4x
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.5
timestamp: Mon 2008-12-01 04:37:27 +0100
message:
Try harder to avoid fetching properties when not necessary.
modified:
fetch.py fetch.py-20060625004942-x2lfaib8ra707a8p-1
revmeta.py revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
=== modified file 'fetch.py'
--- a/fetch.py 2008-12-01 01:25:56 +0000
+++ b/fetch.py 2008-12-01 03:37:27 +0000
@@ -666,11 +666,11 @@
self.checked = set()
def needs_fetching(self, revmeta, mapping):
- if self.target_is_empty:
- return True
try:
if revmeta.is_hidden(mapping):
return False
+ if self.target_is_empty:
+ return True
return not self.target.has_revision(revmeta.get_revision_id(mapping))
except SubversionException, (_, ERR_FS_NOT_DIRECTORY):
return False
=== modified file 'revmeta.py'
--- a/revmeta.py 2008-12-01 01:55:22 +0000
+++ b/revmeta.py 2008-12-01 03:37:27 +0000
@@ -312,23 +312,37 @@
return NULL_REVISION
return parentrevmeta.get_revision_id(mapping)
+ # TODO: Cache these results
+ def _estimate_fileprop_ancestors(self, estimate_fn, call_next):
+ if self.knows_fileprops() or not self.children:
+ # If we already have the file properties, just don't guess
+ return estimate_fn(self.get_fileprops())
+ # FIXME: Use BFS here rather than DFS ?
+ # TODO: Use loop rather than recursive call?
+ desc_cnt = call_next(iter(self.children).next())
+ if desc_cnt == 0:
+ return 0
+ if self.changes_branch_root():
+ desc_cnt -= 1
+ if desc_cnt == 0:
+ return estimate_fn(self.get_fileprops())
+ return desc_cnt
+
def estimate_bzr_fileprop_ancestors(self):
"""Estimate how many ancestors with bzr fileprops this revision has.
"""
- if not self.knows_fileprops() and 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())
+ return self._estimate_fileprop_ancestors(estimate_bzr_ancestors,
+ lambda x: x.estimate_bzr_fileprop_ancestors())
def estimate_svk_fileprop_ancestors(self):
"""Estimate how many svk ancestors this revision has."""
- if not self.knows_fileprops() and 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())
+ return self._estimate_fileprop_ancestors(estimate_svk_ancestors,
+ lambda x: x.estimate_svk_fileprop_ancestors())
+
+ def estimate_bzr_hidden_fileprop_ancestors(self, mapping):
+ return self._estimate_fileprop_ancestors(estimate_svk_ancestors,
+ lambda x: x.estimate_bzr_hidden_fileprop_ancestors(mapping))
def is_bzr_revision_revprops(self):
"""Check if any revision properties indicate this is a bzr revision.
@@ -338,8 +352,6 @@
def is_bzr_revision_fileprops(self):
"""Check if any file properties indicate this is a bzr revision.
"""
- if not self.is_changes_root():
- return False
return is_bzr_revision_fileprops(self.get_changed_fileprops())
def is_changes_root(self):
@@ -355,10 +367,12 @@
"""Check whether this revision should be hidden from Bazaar history."""
if not mapping.supports_hidden:
return False
- if self.consider_bzr_fileprops() or self.check_revprops:
- return mapping.is_bzr_revision_hidden(self.get_revprops(),
- self.get_changed_fileprops())
- return False
+ if self.estimate_bzr_hidden_fileprop_ancestors(mapping) == 0:
+ if self.check_revprops:
+ return mapping.is_bzr_revision_hidden(self.get_revprops(), {})
+ return False
+ return mapping.is_bzr_revision_hidden(self.get_revprops(),
+ self.get_changed_fileprops())
def is_bzr_revision(self):
"""Determine if this is a bzr revision.
@@ -430,8 +444,14 @@
count = 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
+ if not self.check_revprops:
+ return 0
+ ret = 0
+ lm = self
+ while lm:
+ ret += lm.is_hidden(mapping)
+ lm = lm.get_direct_lhs_parent_revmeta()
+ return ret
def get_rhs_parents(self, mapping):
"""Determine the right hand side parents for this revision.
@@ -493,20 +513,19 @@
def consider_bzr_fileprops(self):
if self._consider_bzr_fileprops is not None:
return self._consider_bzr_fileprops
- self._consider_bzr_fileprops = True # FIXME
+ if not self.is_changes_root():
+ self._consider_bzr_fileprops = False
+ else:
+ self._consider_bzr_fileprops = (self.estimate_bzr_fileprop_ancestors() > 0)
return self._consider_bzr_fileprops
def consider_svk_fileprops(self):
if self._consider_svk_fileprops is not None:
return self._consider_svk_fileprops
- self._consider_svk_fileprops = True # FIXME
+ self._consider_svk_fileprops = (self.estimate_svk_fileprop_ancestors() > 0)
return self._consider_svk_fileprops
def get_roundtrip_ancestor_revids(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 iter([])
return iter(get_roundtrip_ancestor_revids(self.get_fileprops()))
def __hash__(self):
More information about the bazaar-commits
mailing list