[MERGE] branch.has_explicit_nick

Robert Collins robertc at robertcollins.net
Fri Jun 30 19:20:54 BST 2006


On Fri, 2006-06-30 at 14:07 -0400, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Robert Collins wrote:
> 
> > I'm +1 on the patch you suggested, as it provides the feature I needed.
> > That makes two - ok to merge with a test case added?
> 
> Okay, +1, given a test case.

This is what I'm submitting ... the change to use TestCaseWithTransport
just makes the test simpler.

=== modified file 'bzrlib/config.py' 
--- bzrlib/config.py    2006-06-21 21:35:06 +0000
+++ bzrlib/config.py    2006-06-30 18:19:29 +0000
@@ -512,11 +512,18 @@
         return self._get_safe_value('_post_commit')

     def _get_nickname(self):
-        value = self._get_best_value('_get_nickname')
+        value = self._explicit_nickname()
         if value is not None:
             return value
         return self.branch.base.split('/')[-2]

+    def has_explicit_nickname(self):
+        """Return true if a nickname has been explicitly assigned."""
+        return self._get_explicit_nickname() is not None
+
+    def _get_explicit_nickname(self):
+        return self._get_best_value('_get_nickname')
+
     def _log_format(self):
         """See Config.log_format."""
         return self._get_best_value('_log_format')

=== modified file 'bzrlib/tests/test_config.py'
--- bzrlib/tests/test_config.py 2006-06-26 23:11:38 +0000
+++ bzrlib/tests/test_config.py 2006-06-30 18:19:04 +0000
@@ -27,7 +27,7 @@
 from bzrlib.branch import Branch
 from bzrlib.bzrdir import BzrDir
 import bzrlib.errors as errors
-from bzrlib.tests import TestCase, TestCaseInTempDir
+from bzrlib.tests import TestCase, TestCaseInTempDir,
TestCaseWithTransport


 sample_long_alias="log -r-15..-1 --line"
@@ -321,7 +321,7 @@
                                           'utf-8')])


-class TestBranchConfig(TestCaseInTempDir):
+class TestBranchConfig(TestCaseWithTransport):

     def test_constructs(self):
         branch = FakeBranch()
@@ -348,6 +348,12 @@
         my_config2 = b2.get_config()
         self.assertEqual(my_config2.get_user_option('wacky'),
'unlikely')

+    def test_has_explicit_nickname(self):
+        b = self.make_branch('.')
+        self.assertFalse(b.get_config().has_explicit_nickname())
+        b.nick = 'foo'
+        self.assertTrue(b.get_config().has_explicit_nickname())
+

 class TestGlobalConfigItems(TestCase):



-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060701/eb2185da/attachment.pgp 


More information about the bazaar mailing list