Rev 531: Let config return a BranchingScheme instance rather than just a string. in file:///data/jelmer/bzr-svn/0.4/

Jelmer Vernooij jelmer at samba.org
Fri Jul 13 11:38:28 BST 2007


At file:///data/jelmer/bzr-svn/0.4/

------------------------------------------------------------
revno: 531
revision-id: jelmer at samba.org-20070713103740-lg11uomlspi8kbu1
parent: jelmer at samba.org-20070713103218-ujothzh4z6t0ju6k
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Fri 2007-07-13 13:37:40 +0300
message:
  Let config return a BranchingScheme instance rather than just a string.
modified:
  config.py                      config.py-20070624185721-0j8f1ly75uo4s1lk-1
  repository.py                  repository.py-20060306123302-1f8c5069b3fe0265
  tests/test_config.py           test_config.py-20070624193244-itvnst60evjidr4z-1
=== modified file 'config.py'
--- a/config.py	2007-06-24 20:13:54 +0000
+++ b/config.py	2007-07-13 10:37:40 +0000
@@ -20,6 +20,8 @@
 
 import os
 
+from scheme import BranchingScheme
+
 # Settings are stored by UUID. 
 # Data stored includes default branching scheme and locations the repository 
 # was seen at.
@@ -39,11 +41,11 @@
             self._get_parser()[self.uuid] = {}
 
     def set_branching_scheme(self, scheme):
-        self.set_user_option('branching-scheme', scheme)
+        self.set_user_option('branching-scheme', str(scheme))
 
     def get_branching_scheme(self):
         try:
-            return self._get_parser()[self.uuid]['branching-scheme']
+            return BranchingScheme.find_scheme(self._get_parser()[self.uuid]['branching-scheme'])
         except KeyError:
             return None
 

=== modified file 'repository.py'
--- a/repository.py	2007-07-13 10:32:18 +0000
+++ b/repository.py	2007-07-13 10:37:40 +0000
@@ -188,7 +188,7 @@
         self.config = SvnRepositoryConfig(self.uuid)
         self.config.add_location(self.base)
         if self.config.get_branching_scheme() is not None:
-            self.scheme = self.get_scheme(self.config.get_branching_scheme())
+            self.scheme = self.config.get_branching_scheme()
         else:
             self.scheme = guessed_scheme
 
@@ -486,13 +486,16 @@
         :raises: NoSuchRevision
         :return: Tuple with branch path, revision number and scheme.
         """
+        def get_scheme(name):
+            assert isinstance(name, basestring)
+            return BranchingScheme.find_scheme(name)
 
         # Try a simple parse
         try:
             (uuid, branch_path, revnum, schemen) = parse_svn_revision_id(revid)
             assert isinstance(branch_path, str)
             if uuid == self.uuid:
-                return (branch_path, revnum, self.get_scheme(schemen))
+                return (branch_path, revnum, get_scheme(schemen))
             # If the UUID doesn't match, this may still be a valid revision
             # id; a revision from another SVN repository may be pushed into 
             # this one.
@@ -506,7 +509,7 @@
             assert isinstance(branch_path, str)
             # Entry already complete?
             if min_revnum == max_revnum:
-                return (branch_path, min_revnum, self.get_scheme(scheme))
+                return (branch_path, min_revnum, get_scheme(scheme))
         except NoSuchRevision:
             # If there is no entry in the map, walk over all branches:
             if scheme is None:
@@ -537,7 +540,7 @@
         # added revid
         i = min_revnum
         for (bp, rev) in self.follow_branch(branch_path, max_revnum, 
-                                            self.get_scheme(scheme)):
+                                            get_scheme(scheme)):
             try:
                 (entry_revno, entry_revid) = parse_revid_property(
                  self.branchprop_list.get_property_diff(bp, rev, 
@@ -549,7 +552,7 @@
             if entry_revid == revid:
                 self.revmap.insert_revid(revid, bp, rev, rev, scheme, 
                                          entry_revno)
-                return (bp, rev, self.get_scheme(scheme))
+                return (bp, rev, get_scheme(scheme))
 
         raise AssertionError("Revision id %s was added incorrectly" % revid)
 
@@ -818,8 +821,4 @@
                 timezone, committer, revprops, revision_id)
 
 
-    def get_scheme(self, name):
-        assert isinstance(name, basestring)
-        # FIXME: Support other branching scheme
-        return BranchingScheme.find_scheme(name)
 

=== modified file 'tests/test_config.py'
--- a/tests/test_config.py	2007-06-24 20:47:20 +0000
+++ b/tests/test_config.py	2007-07-13 10:37:40 +0000
@@ -17,6 +17,7 @@
 """Config tests."""
 
 from config import SvnRepositoryConfig
+from scheme import TrunkBranchingScheme
 
 from bzrlib.tests import TestCaseInTempDir
 
@@ -45,5 +46,5 @@
 
     def test_get_scheme_set(self):
         c = SvnRepositoryConfig("blabla2")
-        c.set_branching_scheme("random")
-        self.assertEquals("random", c.get_branching_scheme())
+        c.set_branching_scheme(TrunkBranchingScheme())
+        self.assertEquals("trunk0", str(c.get_branching_scheme()))




More information about the bazaar-commits mailing list