/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to doc/developers/integration.txt

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Integrating with Bazaar
3
3
=======================
4
4
 
5
 
This page should hopefully become a quick guide to integrating other
6
 
(Python-based) software with Bazaar.
 
5
This document provides some general observations on integrating with
 
6
Bazaar and some recipes for typical tasks.  It is intended to be useful to
 
7
someone developing either a plugin or some other piece of software that
 
8
integrates with bzr.  If you want to know about a topic that's not covered
 
9
here, just ask us.
 
10
 
 
11
 
 
12
 
 
13
 
 
14
Starting with bzrlib
 
15
====================
 
16
 
 
17
Before doing anything else with bzrlib, you should run `bzrlib.initialize`
 
18
which sets up some global state.  
 
19
 
 
20
 
 
21
Running bzr commands
 
22
====================
 
23
 
 
24
To run command-line commands in-process::
 
25
 
 
26
  from bzrlib.commands import get_command
 
27
  
 
28
  cmd = get_command('version')
 
29
  cmd.run([])
 
30
  
 
31
This will send output through the current UIFactory; you can redirect this
 
32
elsewhere through the parameters to `bzrlib.initialize`.
 
33
 
7
34
 
8
35
Manipulating the Working Tree
9
36
=============================
21
48
to see which methods are available.
22
49
 
23
50
Compare trees
24
 
===============
 
51
-------------
 
52
 
25
53
There are two methods for comparing trees: ``changes_from`` and
26
54
``iter_changes``.  ``iter_changes`` is more regular and precise, but it is
27
55
somewhat harder to work with.  See the API documentation for more details.
54
82
 
55
83
 
56
84
Adding Files
57
 
============
 
85
------------
58
86
 
59
87
If you want to add files the same way ``bzr add`` does, you can use
60
88
MutableTree.smart_add.  By default, this is recursive. Paths can either be
70
98
 
71
99
 
72
100
Removing Files
73
 
==============
 
101
--------------
74
102
 
75
103
You can remove multiple files at once.  The file paths need to be relative
76
104
to the workingtree::
85
113
 
86
114
 
87
115
Renaming a File
88
 
===============
 
116
---------------
89
117
 
90
118
You can rename one file to a different name using WorkingTree.rename_one.
91
119
You just provide the old and new names, eg::
94
122
 
95
123
 
96
124
Moving Files
97
 
============
 
125
------------
98
126
 
99
127
You can move multiple files from one directory into another using
100
128
WorkingTree.move::
107
135
 
108
136
 
109
137
Committing Changes
110
 
==================
 
138
------------------
111
139
 
112
140
To commit _all_ the changes to our working tree we can just call the
113
141
WorkingTree's commit method, giving it a commit message, eg::
187
215
 
188
216
 
189
217
Branching from an existing branch
190
 
=================================
 
218
---------------------------------
191
219
 
192
220
To branch you create a branch object representing the branch you are
193
221
branching from, and supply a path/url to the new branch location.
205
233
 
206
234
 
207
235
Pushing and pulling branches
208
 
============================
 
236
----------------------------
209
237
 
210
238
To push a branch you need to open the source and destination branches, then
211
239
just call push with the other branch as a parameter::