~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2005-10-17 23:13:00 UTC
  • mto: This revision was merged to the branch mainline in revision 1462.
  • Revision ID: robertc@robertcollins.net-20051017231300-e1c9e931bcfacd6a
Branch.open_containing now returns a tuple (Branch, relative-path).

This allows direct access to the common case of 'get me this file
from its branch'. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
# merges from, then it should still be reported as newly added
57
57
# relative to the basis revision.
58
58
 
59
 
# TODO: Do checks that the tree can be committed *before* running the 
60
 
# editor; this should include checks for a pointless commit and for 
61
 
# unknown or missing files.
62
 
 
63
 
# TODO: If commit fails, leave the message in a file somewhere.
64
 
 
65
59
 
66
60
import os
67
61
import re
81
75
import bzrlib.config
82
76
from bzrlib.errors import (BzrError, PointlessCommit,
83
77
                           HistoryMissing,
84
 
                           ConflictsInTree,
85
 
                           StrictCommitFailed
 
78
                           ConflictsInTree
86
79
                           )
87
80
import bzrlib.gpg as gpg
88
81
from bzrlib.revision import Revision
173
166
               specific_files=None,
174
167
               rev_id=None,
175
168
               allow_pointless=True,
176
 
               strict=False,
177
169
               verbose=False,
178
170
               revprops=None):
179
171
        """Commit working copy as a new revision.
192
184
        allow_pointless -- If true (default), commit even if nothing
193
185
            has changed and no merges are recorded.
194
186
 
195
 
        strict -- If true, don't allow a commit if the working tree
196
 
            contains unknown files.
197
 
 
198
187
        revprops -- Properties for new revision
199
188
        """
200
189
        mutter('preparing to commit')
206
195
        self.allow_pointless = allow_pointless
207
196
        self.revprops = revprops
208
197
 
209
 
        if strict:
210
 
            # raise an exception as soon as we find a single unknown.
211
 
            for unknown in branch.unknowns():
212
 
                raise StrictCommitFailed()
213
 
 
214
198
        if timestamp is None:
215
199
            self.timestamp = time.time()
216
200
        else:
266
250
 
267
251
            self._record_inventory()
268
252
            self._make_revision()
 
253
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
269
254
            self.branch.append_revision(self.rev_id)
270
255
            self.branch.set_pending_merges([])
271
 
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
272
 
            if self.config.post_commit() is not None:
273
 
                hooks = self.config.post_commit().split(' ')
274
 
                # this would be nicer with twisted.python.reflect.namedAny
275
 
                for hook in hooks:
276
 
                    result = eval(hook + '(branch, rev_id)',
277
 
                                  {'branch':self.branch,
278
 
                                   'bzrlib':bzrlib,
279
 
                                   'rev_id':self.rev_id})
280
256
        finally:
281
257
            self.branch.unlock()
282
258