/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

Merge bzr.dev and fully converted uses of new parents api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
# XXX: Can we do any better about making interrupted commits change
19
 
# nothing?  Perhaps the best approach is to integrate commit of
20
 
# AtomicFiles with releasing the lock on the Branch.
 
19
# nothing?  
21
20
 
22
21
# TODO: Separate 'prepare' phase where we find a list of potentially
23
22
# committed files.  We then can then pause the commit to prompt for a
67
66
import re
68
67
import sys
69
68
import time
70
 
import warnings
71
69
 
72
70
from cStringIO import StringIO
73
71
 
74
 
from bzrlib.atomicfile import AtomicFile
75
72
import bzrlib.config
76
73
import bzrlib.errors as errors
77
74
from bzrlib.errors import (BzrError, PointlessCommit,
85
82
from bzrlib.trace import mutter, note, warning
86
83
from bzrlib.xml5 import serializer_v5
87
84
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
 
85
from bzrlib import symbol_versioning
88
86
from bzrlib.symbol_versioning import (deprecated_passed,
89
87
        deprecated_function,
90
 
        zero_seven,
91
88
        DEPRECATED_PARAMETER)
92
89
from bzrlib.workingtree import WorkingTree
93
90
 
94
91
 
95
 
@deprecated_function(zero_seven)
96
 
def commit(*args, **kwargs):
97
 
    """Commit a new revision to a branch.
98
 
 
99
 
    Function-style interface for convenience of old callers.
100
 
 
101
 
    New code should use the Commit class instead.
102
 
    """
103
 
    ## XXX: Remove this in favor of WorkingTree.commit?
104
 
    Commit().commit(*args, **kwargs)
105
 
 
106
 
 
107
92
class NullCommitReporter(object):
108
93
    """I report on progress of a commit."""
109
94
 
223
208
        mutter('preparing to commit')
224
209
 
225
210
        if deprecated_passed(branch):
226
 
            warnings.warn("Commit.commit (branch, ...): The branch parameter is "
 
211
            symbol_versioning.warn("Commit.commit (branch, ...): The branch parameter is "
227
212
                 "deprecated as of bzr 0.8. Please use working_tree= instead.",
228
213
                 DeprecationWarning, stacklevel=2)
229
214
            self.branch = branch
262
247
            # check for out of date working trees
263
248
            # if we are bound, then self.branch is the master branch and this
264
249
            # test is thus all we need.
265
 
            if self.work_tree.last_revision() != self.master_branch.last_revision():
 
250
            master_last = self.master_branch.last_revision()
 
251
            if (master_last is not None and 
 
252
                master_last != self.work_tree.last_revision()):
266
253
                raise errors.OutOfDateTree(self.work_tree)
267
254
    
268
255
            if strict:
294
281
            if len(self.parents) > 1 and self.specific_files:
295
282
                raise NotImplementedError('selected-file commit of merges is not supported yet: files %r',
296
283
                        self.specific_files)
297
 
            self._check_parents_present()
 
284
            
298
285
            self.builder = self.branch.get_commit_builder(self.parents, 
299
286
                self.config, timestamp, timezone, committer, revprops, rev_id)
300
287
            
308
295
                raise PointlessCommit()
309
296
 
310
297
            self._emit_progress_update()
311
 
            # TODO: Now the new inventory is known, check for conflicts and prompt the 
312
 
            # user for a commit message.
 
298
            # TODO: Now the new inventory is known, check for conflicts and
 
299
            # prompt the user for a commit message.
 
300
            # ADHB 2006-08-08: If this is done, populate_new_inv should not add
 
301
            # weave lines, because nothing should be recorded until it is known
 
302
            # that commit will succeed.
313
303
            self.builder.finish_inventory()
314
304
            self._emit_progress_update()
315
305
            self.rev_id = self.builder.commit(self.message)
453
443
        self.parent_invs = []
454
444
        for revision in self.parents:
455
445
            if self.branch.repository.has_revision(revision):
 
446
                mutter('commit parent revision {%s}', revision)
456
447
                inventory = self.branch.repository.get_inventory(revision)
457
448
                self.parent_invs.append(inventory)
 
449
            else:
 
450
                mutter('commit parent ghost revision {%s}', revision)
458
451
 
459
 
    def _check_parents_present(self):
460
 
        for parent_id in self.parents:
461
 
            mutter('commit parent revision {%s}', parent_id)
462
 
            if not self.branch.repository.has_revision(parent_id):
463
 
                if parent_id == self.branch.last_revision():
464
 
                    warning("parent is missing %r", parent_id)
465
 
                    raise BzrCheckError("branch %s is missing revision {%s}"
466
 
                            % (self.branch, parent_id))
467
 
            
468
452
    def _remove_deleted(self):
469
453
        """Remove deleted files from the working inventories.
470
454
 
505
489
        # in bugs like #46635.  Any reason not to use/enhance Tree.changes_from?
506
490
        # ADHB 11-07-2006
507
491
        mutter("Selecting files for commit with filter %s", self.specific_files)
508
 
        # at this point we dont copy the root entry:
509
492
        entries = self.work_inv.iter_entries()
510
 
        entries.next()
511
 
        self._emit_progress_update()
 
493
        if not self.builder.record_root_entry:
 
494
            symbol_versioning.warn('CommitBuilders should support recording'
 
495
                ' the root entry as of bzr 0.10.', DeprecationWarning, 
 
496
                stacklevel=1)
 
497
            self.builder.new_inventory.add(self.basis_inv.root.copy())
 
498
            entries.next()
 
499
            self._emit_progress_update()
512
500
        for path, new_ie in entries:
513
501
            self._emit_progress_update()
514
502
            file_id = new_ie.file_id