~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

[merge] land Robert's branch-formats branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
from bzrlib.trace import mutter, note, warning
91
91
from bzrlib.xml5 import serializer_v5
92
92
from bzrlib.inventory import Inventory, ROOT_ID
 
93
from bzrlib.symbol_versioning import *
93
94
from bzrlib.weave import Weave
94
95
from bzrlib.weavefile import read_weave, write_weave_v5
95
96
from bzrlib.workingtree import WorkingTree
96
97
 
97
98
 
 
99
@deprecated_function(zero_seven)
98
100
def commit(*args, **kwargs):
99
101
    """Commit a new revision to a branch.
100
102
 
168
170
            self.config = None
169
171
        
170
172
    def commit(self,
171
 
               branch, message,
 
173
               branch=DEPRECATED_PARAMETER, message=None,
172
174
               timestamp=None,
173
175
               timezone=None,
174
176
               committer=None,
177
179
               allow_pointless=True,
178
180
               strict=False,
179
181
               verbose=False,
180
 
               revprops=None):
 
182
               revprops=None,
 
183
               working_tree=None):
181
184
        """Commit working copy as a new revision.
182
185
 
 
186
        branch -- the deprecated branch to commit to. New callers should pass in 
 
187
                  working_tree instead
 
188
 
 
189
        message -- the commit message, a mandatory parameter
 
190
 
183
191
        timestamp -- if not None, seconds-since-epoch for a
184
192
             postdated/predated commit.
185
193
 
201
209
        """
202
210
        mutter('preparing to commit')
203
211
 
204
 
        self.branch = branch
205
 
        self.weave_store = branch.repository.weave_store
 
212
        if deprecated_passed(branch):
 
213
            warn("Commit.commit (branch, ...): The branch parameter is "
 
214
                 "deprecated as of bzr 0.8. Please use working_tree= instead.",
 
215
                 DeprecationWarning, stacklevel=2)
 
216
            self.branch = branch
 
217
            self.work_tree = WorkingTree(branch.base, branch)
 
218
        elif working_tree is None:
 
219
            raise BzrError("One of branch and working_tree must be passed into commit().")
 
220
        else:
 
221
            self.work_tree = working_tree
 
222
            self.branch = self.work_tree.branch
 
223
        if message is None:
 
224
            raise BzrError("The message keyword parameter is required for commit().")
 
225
 
 
226
        self.weave_store = self.branch.repository.weave_store
206
227
        self.rev_id = rev_id
207
228
        self.specific_files = specific_files
208
229
        self.allow_pointless = allow_pointless
209
 
        self.revprops = {'branch-nick': branch.nick}
 
230
        self.revprops = {'branch-nick': self.branch.nick}
210
231
        if revprops:
211
232
            self.revprops.update(revprops)
212
 
        self.work_tree = WorkingTree(branch.base, branch)
213
233
 
214
234
        if strict:
215
235
            # raise an exception as soon as we find a single unknown.
274
294
            self._make_revision()
275
295
            self.work_tree.set_pending_merges([])
276
296
            self.branch.append_revision(self.rev_id)
 
297
            if len(self.parents):
 
298
                precursor = self.parents[0]
 
299
            else:
 
300
                precursor = None
 
301
            self.work_tree.set_last_revision(self.rev_id, precursor)
277
302
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
278
303
            if self.config.post_commit() is not None:
279
304
                hooks = self.config.post_commit().split(' ')