Rev 3591: Make it easier to introduce new WorkingTree formats (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 30 00:53:18 BST 2008


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

------------------------------------------------------------
revno: 3591
revision-id:pqm at pqm.ubuntu.com-20080729235304-ivi3yeqr6xxwtmem
parent: pqm at pqm.ubuntu.com-20080729170343-hy20k9g6euzsz04s
parent: ian.clatworthy at canonical.com-20080729232200-bodtl6ilqbgsae2x
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-07-30 00:53:04 +0100
message:
  Make it easier to introduce new WorkingTree formats (Ian Clatworthy)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 3590.1.1
    revision-id:ian.clatworthy at canonical.com-20080729232200-bodtl6ilqbgsae2x
    parent: pqm at pqm.ubuntu.com-20080729170343-hy20k9g6euzsz04s
    parent: ian.clatworthy at canonical.com-20080729130344-6ym3gsppkn3d281u
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: ianc-integration
    timestamp: Wed 2008-07-30 09:22:00 +1000
    message:
      Make it easier to introduce new WorkingTree formats (Ian Clatworthy)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 3588.2.1
    revision-id:ian.clatworthy at canonical.com-20080729130344-6ym3gsppkn3d281u
    parent: pqm at pqm.ubuntu.com-20080729093250-b1g7zu2k1pj0mswe
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: bzr.wt4-subclassing
    timestamp: Tue 2008-07-29 23:03:44 +1000
    message:
      make it easier to subclass WorkingTreeFormat4
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'NEWS'
--- a/NEWS	2008-07-29 17:03:43 +0000
+++ b/NEWS	2008-07-29 23:22:00 +0000
@@ -81,6 +81,9 @@
 
   INTERNALS:
 
+    * Make it easier to introduce new WorkingTree formats.
+      (Ian Clatworthy)
+
     * The code for exporting trees was refactored not to use the
       deprecated ``InventoryEntry`` methods. (Ian Clatworthy)
 

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2008-07-08 14:55:19 +0000
+++ b/bzrlib/workingtree_4.py	2008-07-29 13:03:44 +0000
@@ -1296,6 +1296,8 @@
 
     upgrade_recommended = False
 
+    _tree_class = WorkingTree4
+
     def get_format_string(self):
         """See WorkingTreeFormat.get_format_string()."""
         return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
@@ -1339,7 +1341,7 @@
         state = dirstate.DirState.initialize(local_path)
         state.unlock()
         del state
-        wt = WorkingTree4(a_bzrdir.root_transport.local_abspath('.'),
+        wt = self._tree_class(a_bzrdir.root_transport.local_abspath('.'),
                          branch,
                          _format=self,
                          _bzrdir=a_bzrdir,
@@ -1347,6 +1349,7 @@
         wt._new_tree()
         wt.lock_tree_write()
         try:
+            self._init_custom_control_files(wt)
             if revision_id in (None, NULL_REVISION):
                 if branch.repository.supports_rich_root():
                     wt._set_root_id(generate_ids.gen_root_id())
@@ -1390,13 +1393,22 @@
             wt.unlock()
         return wt
 
+    def _init_custom_control_files(self, wt):
+        """Subclasses with custom control files should override this method.
+        
+        The working tree and control files are locked for writing when this
+        method is called.
+        
+        :param wt: the WorkingTree object
+        """
+
     def _open(self, a_bzrdir, control_files):
         """Open the tree itself.
 
         :param a_bzrdir: the dir for the tree.
         :param control_files: the control files for the tree.
         """
-        return WorkingTree4(a_bzrdir.root_transport.local_abspath('.'),
+        return self._tree_class(a_bzrdir.root_transport.local_abspath('.'),
                            branch=a_bzrdir.open_branch(),
                            _format=self,
                            _bzrdir=a_bzrdir,




More information about the bazaar-commits mailing list