/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/commit.py

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
 
# XXX: Can we do any better about making interrupted commits change
19
 
# nothing?  
20
 
 
21
 
# TODO: Separate 'prepare' phase where we find a list of potentially
22
 
# committed files.  We then can then pause the commit to prompt for a
23
 
# commit message, knowing the summary will be the same as what's
24
 
# actually used for the commit.  (But perhaps simpler to simply get
25
 
# the tree status, then use that for a selective commit?)
26
 
 
27
18
# The newly committed revision is going to have a shape corresponding
28
19
# to that of the working inventory.  Files that are not in the
29
20
# working tree and that were in the predecessor are reported as
55
46
# merges from, then it should still be reported as newly added
56
47
# relative to the basis revision.
57
48
 
58
 
# TODO: Do checks that the tree can be committed *before* running the 
59
 
# editor; this should include checks for a pointless commit and for 
60
 
# unknown or missing files.
61
 
 
62
 
# TODO: If commit fails, leave the message in a file somewhere.
63
 
 
64
49
# TODO: Change the parameter 'rev_id' to 'revision_id' to be consistent with
65
50
# the rest of the code; add a deprecation of the old name.
66
51
 
87
72
from bzrlib.testament import Testament
88
73
from bzrlib.trace import mutter, note, warning
89
74
from bzrlib.xml5 import serializer_v5
90
 
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
 
75
from bzrlib.inventory import Inventory, InventoryEntry
91
76
from bzrlib import symbol_versioning
92
77
from bzrlib.symbol_versioning import (deprecated_passed,
93
78
        deprecated_function,
94
79
        DEPRECATED_PARAMETER)
95
80
from bzrlib.workingtree import WorkingTree
 
81
import bzrlib.ui
96
82
 
97
83
 
98
84
class NullCommitReporter(object):
127
113
    def snapshot_change(self, change, path):
128
114
        if change == 'unchanged':
129
115
            return
 
116
        if change == 'added' and path == '':
 
117
            return
130
118
        note("%s %s", change, path)
131
119
 
132
120
    def completed(self, revno, rev_id):
183
171
               working_tree=None,
184
172
               local=False,
185
173
               reporter=None,
186
 
               config=None):
 
174
               config=None,
 
175
               message_callback=None):
187
176
        """Commit working copy as a new revision.
188
177
 
189
178
        branch -- the deprecated branch to commit to. New callers should pass in 
190
179
                  working_tree instead
191
180
 
192
 
        message -- the commit message, a mandatory parameter
 
181
        message -- the commit message (it or message_callback is required)
193
182
 
194
183
        timestamp -- if not None, seconds-since-epoch for a
195
184
             postdated/predated commit.
224
213
        else:
225
214
            self.work_tree = working_tree
226
215
            self.branch = self.work_tree.branch
227
 
        if message is None:
228
 
            raise BzrError("The message keyword parameter is required for commit().")
 
216
        if message_callback is None:
 
217
            if message is not None:
 
218
                if isinstance(message, str):
 
219
                    message = message.decode(bzrlib.user_encoding)
 
220
                message_callback = lambda x: message
 
221
            else:
 
222
                raise BzrError("The message or message_callback keyword"
 
223
                               " parameter is required for commit().")
229
224
 
230
225
        self.bound_branch = None
231
226
        self.local = local
271
266
                   
272
267
            if self.config is None:
273
268
                self.config = self.branch.get_config()
274
 
      
275
 
            if isinstance(message, str):
276
 
                message = message.decode(bzrlib.user_encoding)
277
 
            assert isinstance(message, unicode), type(message)
278
 
            self.message = message
279
 
            self._escape_commit_message()
280
269
 
281
270
            self.work_inv = self.work_tree.inventory
282
271
            self.basis_tree = self.work_tree.basis_tree()
316
305
            # that commit will succeed.
317
306
            self.builder.finish_inventory()
318
307
            self._emit_progress_update()
 
308
            message = message_callback(self)
 
309
            assert isinstance(message, unicode), type(message)
 
310
            self.message = message
 
311
            self._escape_commit_message()
 
312
 
319
313
            self.rev_id = self.builder.commit(self.message)
320
314
            self._emit_progress_update()
321
315
            # revision data is in the local branch now.
391
385
        # A merge with no effect on files
392
386
        if len(self.parents) > 1:
393
387
            return
 
388
        # work around the fact that a newly-initted tree does differ from its
 
389
        # basis
 
390
        if len(self.basis_inv) == 0 and len(self.builder.new_inventory) == 1:
 
391
            raise PointlessCommit()
394
392
        # Shortcut, if the number of entries changes, then we obviously have
395
393
        # a change
396
394
        if len(self.builder.new_inventory) != len(self.basis_inv):
431
429
        #       to local.
432
430
        
433
431
        # Make sure the local branch is identical to the master
434
 
        master_rh = self.master_branch.revision_history()
435
 
        local_rh = self.branch.revision_history()
436
 
        if local_rh != master_rh:
 
432
        master_info = self.master_branch.last_revision_info()
 
433
        local_info = self.branch.last_revision_info()
 
434
        if local_info != master_info:
437
435
            raise errors.BoundBranchOutOfDate(self.branch,
438
436
                    self.master_branch)
439
437
 
551
549
        # in bugs like #46635.  Any reason not to use/enhance Tree.changes_from?
552
550
        # ADHB 11-07-2006
553
551
        mutter("Selecting files for commit with filter %s", self.specific_files)
 
552
        assert self.work_inv.root is not None
554
553
        entries = self.work_inv.iter_entries()
555
554
        if not self.builder.record_root_entry:
556
555
            symbol_versioning.warn('CommitBuilders should support recording'
582
581
                else:
583
582
                    # this entry is new and not being committed
584
583
                    continue
585
 
 
586
584
            self.builder.record_entry_contents(ie, self.parent_invs, 
587
585
                path, self.work_tree)
588
586
            # describe the nature of the change that has occurred relative to