Rev 2214: Warn when retrieving revision properties slowly. in file:///data/jelmer/bzr-svn/mappings/
Jelmer Vernooij
jelmer at samba.org
Sun Dec 7 04:20:14 GMT 2008
At file:///data/jelmer/bzr-svn/mappings/
------------------------------------------------------------
revno: 2214
revision-id: jelmer at samba.org-20081207042006-gg02bnson2u612sg
parent: jelmer at samba.org-20081207034405-hzbjkqfcrcp9d9ah
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: mappings
timestamp: Sun 2008-12-07 05:20:06 +0100
message:
Warn when retrieving revision properties slowly.
modified:
TODO todo-20060729211917-2kpobww0zyvvo0j2-1
repository.py repository.py-20060306123302-1f8c5069b3fe0265
revmeta.py revmeta.py-20080901215045-n8a6arqybs9ez5hl-1
=== modified file 'TODO'
--- a/TODO 2008-12-07 03:44:05 +0000
+++ b/TODO 2008-12-07 04:20:06 +0000
@@ -5,9 +5,9 @@
- set-revprops upgrades v3 stuff as well?
- set-revprops should refuse to work when there is no commit-revprops capability
- use special fileproperty bzr:use-revprops for when log-revprops is not available
+- make distinction between "don't know" and "empty" in _import_from_properties
- automatically disable cache in some situations, allow partial cache?
- in-memory caching of revid mapping (LRUCache ?)
-- warn when retrieving revision properties slowly
- inventory problem that shows up in bigboard, evolution
more tests:
=== modified file 'repository.py'
--- a/repository.py 2008-12-07 03:44:05 +0000
+++ b/repository.py 2008-12-07 04:20:06 +0000
@@ -278,13 +278,18 @@
return mapping_registry.get_default()
def _properties_to_set(self, mapping):
+ """Determine what sort of custom properties to set when
+ committing a new round-tripped revision.
+
+ :return: tuple with two booleans: whether to use revision properties
+ and whether to use file properties.
+ """
supports_custom_revprops = self.transport.has_capability("commit-revprops")
if supports_custom_revprops and mapping.can_use_revprops:
return (True, mapping.must_use_fileprops)
else:
return (mapping.can_use_fileprops, False)
-
def get_mapping(self):
"""Get the default mapping that is used for this repository."""
if self._default_mapping is None:
=== modified file 'revmeta.py'
--- a/revmeta.py 2008-12-07 02:58:26 +0000
+++ b/revmeta.py 2008-12-07 04:20:06 +0000
@@ -29,6 +29,9 @@
from bzrlib.revision import (
NULL_REVISION,
)
+from bzrlib.trace import (
+ warning,
+ )
from bzrlib.plugins.svn import (
changes,
errors as svn_errors,
@@ -43,6 +46,7 @@
is_bzr_revision_fileprops,
parse_svn_revprops,
SVN_REVPROP_BZR_SIGNATURE,
+ SVN_PROP_BZR_REVPROP_REDIRECT,
)
from bzrlib.plugins.svn.svk import (
estimate_svk_ancestors,
@@ -57,6 +61,15 @@
from itertools import ifilter, imap
+_warned_slow_revprops = False
+
+def warn_slow_revprops():
+ global _warned_slow_revprops
+ if not _warned_slow_revprops:
+ warning("Upgrade to Subversion 1.5 or higher for faster retrieving of revision properties.")
+ _warned_slow_revprops = True
+
+
class MetaHistoryIncomplete(Exception):
"""No revision metadata branch."""
@@ -105,6 +118,7 @@
self._is_bzr_revision = None
self._direct_lhs_parent_known = False
self._consider_bzr_fileprops = None
+ self._consider_bzr_revprops = None
self._consider_svk_fileprops = None
self._estimated_fileprop_ancestors = {}
self.metaiterators = set()
@@ -553,24 +567,48 @@
self._import_from_props(mapping,
lambda changed_fileprops: mapping.import_revision_fileprops(changed_fileprops, rev),
lambda revprops: mapping.import_revision_revprops(revprops, rev),
- False)
+ False, check_branch_root=False)
rev.svn_meta = self
return rev
- def _import_from_props(self, mapping, fileprop_fn, revprop_fn, default):
- # FIXME: Magic happens here
- # FIXME: Check whatever is available first
- if mapping is None or mapping.can_use_fileprops:
- ret = fileprop_fn(self.get_changed_fileprops())
- if ret != default:
- return ret
- if mapping is not None and mapping.must_use_fileprops:
- return default
- if mapping is None or mapping.can_use_revprops:
- if mapping is None or mapping.get_branch_root(self.get_revprops()) == self.branch_path:
- return revprop_fn(self.get_revprops())
+ def _import_from_props(self, mapping, fileprop_fn, revprop_fn, default,
+ check_branch_root=True):
+ can_use_revprops = (mapping is None or mapping.can_use_revprops)
+ can_use_fileprops = (mapping is None or mapping.can_use_fileprops)
+ # Check revprops if self.knows_revprops() and can_use_revprops
+ if can_use_revprops and self.knows_revprops():
+ if (mapping is None or not check_branch_root or
+ mapping.get_branch_root(self.get_revprops()) == self.branch_path):
+ ret = revprop_fn(self.get_revprops())
+ if ret != default:
+ return ret
+
+ # Check changed_fileprops if self.knows_changed_fileprops() and
+ # can_use_fileprops
+ if can_use_fileprops and self.knows_changed_fileprops():
+ ret = fileprop_fn(self.get_changed_fileprops())
+ if ret != default:
+ return ret
+
+ # Check revprops if the last descendant has bzr:check-revprops set;
+ # if it has and the revnum there is < self.revnum
+ if can_use_revprops and self.consider_bzr_revprops():
+ warn_slow_revprops()
+ if (mapping is None or not check_branch_root or
+ mapping.get_branch_root(self.get_revprops()) == self.branch_path):
+ ret = revprop_fn(self.get_revprops())
+ if ret != default:
+ return ret
+
+ # Check whether we should consider file properties at all
+ # for this revision, if we should -> check fileprops
+ if can_use_fileprops and self.consider_bzr_fileprops():
+ ret = fileprop_fn(self.get_changed_fileprops())
+ if ret != default:
+ return ret
+
return default
def get_fileid_map(self, mapping):
@@ -591,6 +629,20 @@
mapping.import_text_parents_fileprops,
mapping.import_text_parents_revprops, {})
+ def consider_bzr_revprops(self):
+ """See if bzr revision properties should be checked at all.
+
+ """
+ if self._consider_bzr_revprops is not None:
+ return self._consider_bzr_revprops
+ if not self.is_changes_root():
+ self._consider_bzr_revprops = False
+ else:
+ # FIXME: Check nearest descendant with bzr:see-revprops set
+ # and return True if revnum in that property < self.revnum
+ self._consider_bzr_revprops = True
+ return self._consider_bzr_revprops
+
def consider_bzr_fileprops(self):
"""See if any bzr file properties should be checked at all.
More information about the bazaar-commits
mailing list