Rev 2397: Branch construction cleanups in http://sourcefrog.net/bzr/no-controlfiles

Martin Pool mbp at sourcefrog.net
Thu Apr 5 07:25:08 BST 2007


At http://sourcefrog.net/bzr/no-controlfiles

------------------------------------------------------------
revno: 2397
revision-id: mbp at sourcefrog.net-20070405062507-qjd6t24fthqe07ay
parent: mbp at sourcefrog.net-20070404130829-pwu65c1xf5hcsszi
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: no-controlfiles
timestamp: Thu 2007-04-05 16:25:07 +1000
message:
  Branch construction cleanups
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-04-04 13:08:29 +0000
+++ b/bzrlib/branch.py	2007-04-05 06:25:07 +0000
@@ -826,11 +826,12 @@
         self._transport = branch_transport
         control_files = lockable_files.LockableFiles(branch_transport,
             lock_name, lock_class)
+        self._lock = control_files._lock
         control_files.create_lock()
         control_files.lock_write()
-        if set_format:
-            utf8_files[:0] = [('format', self.get_format_string())]
         try:
+            if set_format:
+                utf8_files[:0] = [('format', self.get_format_string())]
             for name, content in utf8_files:
                 self._transport.put_bytes_non_atomic(name,
                         content.encode('utf-8'),
@@ -880,20 +881,6 @@
         """True if this format supports tags stored in the branch"""
         return False  # by default
 
-    # XXX: Probably doesn't really belong here -- mbp 20070212
-    def _initialize_control_files(self, a_bzrdir, utf8_files, lock_filename,
-            lock_class):
-        branch_transport = a_bzrdir.get_branch_transport(self)
-        control_files = lockable_files.LockableFiles(branch_transport,
-            lock_filename, lock_class)
-        control_files.create_lock()
-        control_files.lock_write()
-        try:
-            for filename, content in utf8_files:
-                control_files.put_utf8(filename, content)
-        finally:
-            control_files.unlock()
-
 
 class BranchHooks(dict):
     """A dictionary mapping hook name to a list of callables for branch hooks.
@@ -1094,6 +1081,9 @@
         """
         if not _found:
             format = BranchFormat.find_format(a_bzrdir)
+            # XXX: When would this fail?  If someone explicitly asked this
+            # class to open when the branch was actually of a different type?
+            # Can that happen?  mbp 20070404
             assert format.__class__ == self.__class__
         transport = a_bzrdir.get_branch_transport(None)
         control_files = lockable_files.LockableFiles(transport, 'lock',
@@ -1217,6 +1207,7 @@
         if _control_files is None:
             raise ValueError('BzrBranch _control_files is None')
         self.control_files = _control_files
+        self._lock = _control_files._lock
         self._transport = _control_files._transport
         self.repository = _repository
 




More information about the bazaar-commits mailing list