/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 bzrlib/branchbuilder.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Utility for create branches with particular contents."""
18
18
 
19
19
from bzrlib import (
20
 
    bzrdir, 
 
20
    bzrdir,
21
21
    commit,
22
22
    errors,
23
23
    memorytree,
26
26
 
27
27
class BranchBuilder(object):
28
28
    r"""A BranchBuilder aids creating Branches with particular shapes.
29
 
    
 
29
 
30
30
    The expected way to use BranchBuilder is to construct a
31
31
    BranchBuilder on the transport you want your branch on, and then call
32
32
    appropriate build_ methods on it to get the shape of history you want.
58
58
 
59
59
    def __init__(self, transport, format=None):
60
60
        """Construct a BranchBuilder on transport.
61
 
        
 
61
 
62
62
        :param transport: The transport the branch should be created on.
63
63
            If the path of the transport does not exist but its parent does
64
64
            it will be created.
75
75
            format=format, force_new_tree=False)
76
76
        self._tree = None
77
77
 
78
 
    def build_commit(self):
79
 
        """Build a commit on the branch."""
 
78
    def build_commit(self, **commit_kwargs):
 
79
        """Build a commit on the branch.
 
80
 
 
81
        This makes a commit with no real file content for when you only want
 
82
        to look at the revision graph structure.
 
83
 
 
84
        :param commit_kwargs: Arguments to pass through to commit, such as
 
85
             timestamp.
 
86
        """
80
87
        tree = memorytree.MemoryTree.create_on_branch(self._branch)
81
88
        tree.lock_write()
82
89
        try:
83
90
            tree.add('')
84
 
            return self._do_commit(tree)
 
91
            return self._do_commit(tree, **commit_kwargs)
85
92
        finally:
86
93
            tree.unlock()
87
94
 
137
144
        self._tree = None
138
145
 
139
146
    def build_snapshot(self, revision_id, parent_ids, actions,
140
 
                       message=None):
 
147
                       message=None, timestamp=None):
141
148
        """Build a commit, shaped in a specific way.
142
149
 
143
150
        :param revision_id: The handle for the new commit, can be None
150
157
            ('rename', ('orig-path', 'new-path'))
151
158
        :param message: An optional commit message, if not supplied, a default
152
159
            commit message will be written.
 
160
        :param timestamp: If non-None, set the timestamp of the commit to this
 
161
            value.
153
162
        :return: The revision_id of the new commit
154
163
        """
155
164
        if parent_ids is not None:
210
219
            tree.add(to_add_files, to_add_file_ids, to_add_kinds)
211
220
            for file_id, content in new_contents.iteritems():
212
221
                tree.put_file_bytes_non_atomic(file_id, content)
213
 
            return self._do_commit(tree, message=message, rev_id=revision_id) 
 
222
            return self._do_commit(tree, message=message, rev_id=revision_id,
 
223
                timestamp=timestamp)
214
224
        finally:
215
225
            tree.unlock()
216
226