Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.repo_tree.RepositoryTree Class Reference

List of all members.

Public Member Functions

def __init__
def init_forest
def start_changes
def commit

Public Attributes

 fs
 dirname
 key_bytes
 node_size
 upload_queue_size
 lru_size
 repo
 forest
 forest_allows_writes
 tree
 keep_just_one_tree

Detailed Description

A B-tree within an obnamlib.Repository.

For read-only operation, call init_forest before doing anything.

For read-write operation, call start_changes before doing anything,
and commit afterwards. In between, self.tree is the new tree to be 
modified. Note that self.tree is NOT available after init_forest.

After init_forest or start_changes, self.forest is the opened forest.
Unlike self.tree, it will not go away after commit.

Definition at line 23 of file repo_tree.py.


Constructor & Destructor Documentation

def obnamlib.repo_tree.RepositoryTree.__init__ (   self,
  fs,
  dirname,
  key_bytes,
  node_size,
  upload_queue_size,
  lru_size,
  repo 
)

Definition at line 39 of file repo_tree.py.

00039 
00040                  lru_size, repo):
00041         self.fs = fs
00042         self.dirname = dirname
00043         self.key_bytes = key_bytes
00044         self.node_size = node_size
00045         self.upload_queue_size = upload_queue_size
00046         self.lru_size = lru_size
00047         self.repo = repo
00048         self.forest = None
00049         self.forest_allows_writes = False
00050         self.tree = None
00051         self.keep_just_one_tree = False


Member Function Documentation

Definition at line 101 of file repo_tree.py.

00101 
00102     def commit(self):
00103         tracing.trace('committing')
00104         if self.forest:
00105             if self.keep_just_one_tree:
00106                 while len(self.forest.trees) > 1:
00107                     tracing.trace('not keeping tree with root id %s',
00108                                   self.forest.trees[0].root.id)
00109                     self.forest.remove_tree(self.forest.trees[0])
00110             self.forest.commit()
00111             self.tree = None
00112 
def obnamlib.repo_tree.RepositoryTree.init_forest (   self,
  allow_writes = False 
)

Definition at line 52 of file repo_tree.py.

00052 
00053     def init_forest(self, allow_writes=False):
00054         if self.forest is None:
00055             tracing.trace('initializing forest dirname=%s', self.dirname)
00056             assert self.tree is None
00057             if not self.fs.exists(self.dirname):
00058                 tracing.trace('%s does not exist', self.dirname)
00059                 return False
00060             self.forest = larch.open_forest(key_size=self.key_bytes,
00061                                             node_size=self.node_size,
00062                                             dirname=self.dirname,
00063                                             upload_max=self.upload_queue_size,
00064                                             lru_size=self.lru_size,
00065                                             vfs=self.fs,
00066                                             allow_writes=allow_writes)
00067             self.forest_allows_writes = allow_writes
00068         return True

Here is the caller graph for this function:

def obnamlib.repo_tree.RepositoryTree.start_changes (   self,
  create_tree = True 
)

Definition at line 69 of file repo_tree.py.

00069 
00070     def start_changes(self, create_tree=True):
00071         tracing.trace('start changes for %s', self.dirname)
00072         
00073         if self.forest is None or not self.forest_allows_writes:
00074             if not self.fs.exists(self.dirname):
00075                 need_init = True
00076             else:
00077                 filenames = self.fs.listdir(self.dirname)
00078                 need_init = filenames == [] or filenames == ['lock']
00079 
00080             if need_init:
00081                 if not self.fs.exists(self.dirname):
00082                     tracing.trace('create %s', self.dirname)
00083                     self.fs.mkdir(self.dirname)
00084                 self.repo.hooks.call('repository-toplevel-init', self.repo, 
00085                                      self.dirname)
00086             self.forest = None
00087             self.init_forest(allow_writes=True)
00088 
00089         assert self.forest is not None
00090         assert self.forest_allows_writes, \
00091             'it is "%s"' % repr(self.forest_allows_writes)
00092 
00093         if self.tree is None and create_tree:
00094             if self.forest.trees:
00095                 self.tree = self.forest.new_tree(self.forest.trees[-1])
00096                 tracing.trace('use newest tree %s (of %d)', self.tree.root.id,
00097                                 len(self.forest.trees))
00098             else:
00099                 self.tree = self.forest.new_tree()
00100                 tracing.trace('new tree root id %s', self.tree.root.id)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 41 of file repo_tree.py.

Definition at line 47 of file repo_tree.py.

Definition at line 48 of file repo_tree.py.

Definition at line 40 of file repo_tree.py.

Definition at line 50 of file repo_tree.py.

Definition at line 42 of file repo_tree.py.

Definition at line 45 of file repo_tree.py.

Definition at line 43 of file repo_tree.py.

Definition at line 46 of file repo_tree.py.

Definition at line 49 of file repo_tree.py.

Definition at line 44 of file repo_tree.py.


The documentation for this class was generated from the following file: