Rev 4334: Make it easier to blackbox test rules (Marius Kruger) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed May 6 05:07:41 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4334
revision-id: pqm at pqm.ubuntu.com-20090506040737-tdiqyojy2uia33qb
parent: pqm at pqm.ubuntu.com-20090506031725-stmw1gm2fs6qpq0f
parent: ian.clatworthy at canonical.com-20090506013746-3d9zv74xyq6urodb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-05-06 05:07:37 +0100
message:
  Make it easier to blackbox test rules (Marius Kruger)
modified:
  bzrlib/rules.py                properties.py-20080506032617-9k06uqalkf09ck0z-1
  bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
    ------------------------------------------------------------
    revno: 4332.1.1
    revision-id: ian.clatworthy at canonical.com-20090506013746-3d9zv74xyq6urodb
    parent: pqm at pqm.ubuntu.com-20090505195559-0qmeyyua7e407sym
    parent: amanic at gmail.com-20090502212605-xw6027quavhmbl4v
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: integration
    timestamp: Wed 2009-05-06 11:37:46 +1000
    message:
      Make it easier to blackbox test rules (Marius Kruger)
    modified:
      bzrlib/rules.py                properties.py-20080506032617-9k06uqalkf09ck0z-1
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
    ------------------------------------------------------------
    revno: 4324.4.1
    revision-id: amanic at gmail.com-20090502212605-xw6027quavhmbl4v
    parent: pqm at pqm.ubuntu.com-20090502005030-s11zizqqgrf3s3k2
    committer: Marius Kruger <amanic at gmail.com>
    branch nick: bzr.rules
    timestamp: Sat 2009-05-02 23:26:05 +0200
    message:
      Make it possible to blackboxtest rules
      * extract rules.reset_rules()
      * tree.iter_search_rules now uses the default parameter differently
        to ensure that if we change our rules._per_user_searcher
        after tree.py loaded, that the new one will get used.
    modified:
      bzrlib/rules.py                properties.py-20080506032617-9k06uqalkf09ck0z-1
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
=== modified file 'bzrlib/rules.py'
--- a/bzrlib/rules.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/rules.py	2009-05-02 21:26:05 +0000
@@ -36,6 +36,9 @@
 FILE_PREFS_PREFIX = 'name '
 FILE_PREFS_PREFIX_LEN = len(FILE_PREFS_PREFIX)
 
+# The object providing default rules
+_per_user_searcher = None
+
 
 class _RulesSearcher(object):
     """An object that provides rule-based preferences."""
@@ -146,5 +149,8 @@
     return osutils.pathjoin(config.config_dir(), 'rules')
 
 
-# The object providing default rules
-_per_user_searcher = _IniBasedRulesSearcher(rules_filename())
+def reset_rules():
+    global _per_user_searcher
+    _per_user_searcher = _IniBasedRulesSearcher(rules_filename())
+
+reset_rules()

=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2009-04-09 20:23:07 +0000
+++ b/bzrlib/tree.py	2009-05-02 21:26:05 +0000
@@ -657,7 +657,7 @@
             return None
 
     def iter_search_rules(self, path_names, pref_names=None,
-        _default_searcher=rules._per_user_searcher):
+        _default_searcher=None):
         """Find the preferences for filenames in a tree.
 
         :param path_names: an iterable of paths to find attributes for.
@@ -667,6 +667,8 @@
         :return: an iterator of tuple sequences, one per path-name.
           See _RulesSearcher.get_items for details on the tuple sequence.
         """
+        if _default_searcher is None:
+            _default_searcher = rules._per_user_searcher
         searcher = self._get_rules_searcher(_default_searcher)
         if searcher is not None:
             if pref_names is not None:




More information about the bazaar-commits mailing list