Rev 5426: Ensures we fallback to the default policy if a bogus one is specified. in file:///home/vila/src/bzr/bugs/323111-orphans/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Sep 16 17:43:05 BST 2010
At file:///home/vila/src/bzr/bugs/323111-orphans/
------------------------------------------------------------
revno: 5426
revision-id: v.ladeuil+lp at free.fr-20100916164305-vartuzc0yalkw4fn
parent: v.ladeuil+lp at free.fr-20100916161318-c9k41sne1m12rxl9
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: orphan-config-option
timestamp: Thu 2010-09-16 18:43:05 +0200
message:
Ensures we fallback to the default policy if a bogus one is specified.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py 2010-09-16 16:13:18 +0000
+++ b/bzrlib/tests/test_transform.py 2010-09-16 16:43:05 +0000
@@ -29,6 +29,7 @@
rules,
symbol_versioning,
tests,
+ trace,
transform,
urlutils,
)
@@ -3314,3 +3315,20 @@
self.assertLength(1, remaining_conflicts)
self.assertEqual(('deleting parent', 'Not deleting', 'new-1'),
remaining_conflicts.pop())
+
+ def test_unknown_orphan_policy(self):
+ wt = self.make_branch_and_tree('.')
+ # Set a fictional policy nobody ever implemented
+ self._set_orphan_policy(wt, 'donttouchmypreciouuus')
+ tt, orphan_tid = self._prepare_orphan(wt)
+ warnings = []
+ def warning(*args):
+ warnings.append(args[0] % args[1:])
+ self.overrideAttr(trace, 'warning', warning)
+ remaining_conflicts = resolve_conflicts(tt)
+ # We fallback to the default policy which resolve the conflict by
+ # creating an orphan
+ self.assertLength(0, remaining_conflicts)
+ self.assertLength(2, warnings)
+ self.assertStartsWith( warnings[0], 'donttouchmypreciouuus')
+ self.assertStartsWith(warnings[1], 'dir/foo has been orphaned')
=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py 2010-09-16 16:13:18 +0000
+++ b/bzrlib/transform.py 2010-09-16 16:43:05 +0000
@@ -1343,9 +1343,15 @@
# but that's all we have (for now). It will find the option in
# locations,conf or bazaar.conf though) -- vila 20100916
conf = self._tree.branch.get_config()
- orphan_policy = conf.get_user_option('bzrlib.transform.orphan_policy')
+ conf_var_name = 'bzrlib.transform.orphan_policy'
+ orphan_policy = conf.get_user_option(conf_var_name)
+ default_policy = orphaning_registry.default_key
if orphan_policy is None:
- orphan_policy = orphaning_registry.default_key
+ orphan_policy = default_policy
+ if orphan_policy not in orphaning_registry:
+ trace.warning('%s (from %s) is not a known policy, defaulting to %s'
+ % (orphan_policy, conf_var_name, default_policy))
+ orphan_policy = default_policy
handle_orphan = orphaning_registry.get(orphan_policy)
handle_orphan(self, trans_id, parent_id)
More information about the bazaar-commits
mailing list