~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/doc/api/branch.txt

  • Committer: Vincent Ladeuil
  • Date: 2008-01-29 15:16:31 UTC
  • mto: (3206.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3207.
  • Revision ID: v.ladeuil+lp@free.fr-20080129151631-vqjd13tb405mobx6
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling.

* bzrlib/tests/test_transform.py:
(TestTransformMerge): Revert previous patch and cleanly call
preview.finalize now that we can.

* bzrlib/tests/test_merge.py:
(TestMerge.test_make_preview_transform): Catch TransformPreview
leak.

* bzrlib/builtins.py:
(cmd_merge._do_preview): Finalize the TransformPreview or the
limbodir will stay in /tmp.

* bzrlib/transform.py:
(TreeTransformBase.__init__): Create the _deletiondir since it's
reffered to by finalize.
(TreeTransformBase.finalize): Delete the dir only if _deletiondir
is set.
(TreeTransform.__init__): Use a temp var for deletiondir and set
the attribute after the base class __init__ has been called.
(TransformPreview.__init__): Read locks the tree since finalize
wants to unlock it (as suggested by Aaron).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
A Branch represents a series of commits and merges carried out by a user.
4
4
 
 
5
Make a temporary directory for these tests:
 
6
 
 
7
   >>> from bzrlib import osutils
 
8
   >>> test_dir = osutils.mkdtemp(prefix='bzrlib_doc_api_branch_txt_')
 
9
 
5
10
Branches are created by BzrDir's:
6
11
 
7
 
   >>> from bzrlib.bzrdir import ScratchDir
8
12
   >>> from bzrlib.branch import Branch
9
 
   >>> dir = ScratchDir()
10
 
   >>> new_branch = dir.create_branch()
 
13
   >>> from bzrlib.bzrdir import BzrDir
11
14
 
 
15
   >>> new_branch = BzrDir.create_branch_convenience(test_dir)
12
16
 
13
17
Existing Branches can be opened directly:
14
18
 
15
 
   >>> another_instance = Branch.open(dir.transport.clone('..').base)
 
19
   >>> transport = new_branch.bzrdir.transport
 
20
   >>> another_instance = Branch.open(transport.clone('..').base)
16
21
 
17
22
or via the BzrDir:
18
23
 
19
 
   >>> still_the_same_branch = dir.open_branch()
20
 
 
 
24
   >>> still_the_same_branch = new_branch.bzrdir.open_branch()
21
25
 
22
26
A branch has a history of revisions on it:
23
27
 
24
28
   >>> new_branch.revision_history()
25
29
   []
26
30
 
27
 
 
28
31
We need to write some more documentation, showing
29
32
push and pull operations. Cloning might also be nice.
 
33
 
 
34
And finally, clean up:
 
35
 
 
36
   >>> import shutil
 
37
   >>> shutil.rmtree(test_dir)