~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2006-06-20 05:32:16 UTC
  • mfrom: (1797 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: mbp@sourcefrog.net-20060620053216-817857d7ca3e9d1f
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
import bzrlib.config
76
76
import bzrlib.errors as errors
77
77
from bzrlib.errors import (BzrError, PointlessCommit,
78
 
                           HistoryMissing,
79
78
                           ConflictsInTree,
80
79
                           StrictCommitFailed
81
80
                           )
87
86
from bzrlib.xml5 import serializer_v5
88
87
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
89
88
from bzrlib.symbol_versioning import (deprecated_passed,
 
89
        deprecated_function,
 
90
        zero_seven,
90
91
        DEPRECATED_PARAMETER)
91
92
from bzrlib.workingtree import WorkingTree
92
93
 
93
94
 
 
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
 
94
107
class NullCommitReporter(object):
95
108
    """I report on progress of a commit."""
96
109
 
332
345
            self._emit_progress_update()
333
346
        finally:
334
347
            self._cleanup()
 
348
        return self.rev_id
335
349
 
336
350
    def _check_bound_branch(self):
337
351
        """Check to see if the local branch is bound.
374
388
        self.bound_branch = self.branch
375
389
        self.master_branch.lock_write()
376
390
        self.master_locked = True
377
 
####        
378
 
####        # Check to see if we have any pending merges. If we do
379
 
####        # those need to be pushed into the master branch
380
 
####        pending_merges = self.work_tree.pending_merges()
381
 
####        if pending_merges:
382
 
####            for revision_id in pending_merges:
383
 
####                self.master_branch.repository.fetch(self.bound_branch.repository,
384
 
####                                                    revision_id=revision_id)
385
391
 
386
392
    def _cleanup(self):
387
393
        """Cleanup any open locks, progress bars etc."""
440
446
        """Record the parents of a merge for merge detection."""
441
447
        # TODO: Make sure that this list doesn't contain duplicate 
442
448
        # entries and the order is preserved when doing this.
443
 
        pending_merges = self.work_tree.pending_merges()
444
 
        self.parents = []
 
449
        self.parents = self.work_tree.get_parent_ids()
445
450
        self.parent_invs = []
446
 
        precursor_id = self.branch.last_revision()
447
 
        if precursor_id:
448
 
            self.parents.append(precursor_id)
449
 
        self.parents += pending_merges
450
451
        for revision in self.parents:
451
452
            if self.branch.repository.has_revision(revision):
452
453
                inventory = self.branch.repository.get_inventory(revision)
458
459
            if not self.branch.repository.has_revision(parent_id):
459
460
                if parent_id == self.branch.last_revision():
460
461
                    warning("parent is missing %r", parent_id)
461
 
                    raise HistoryMissing(self.branch, 'revision', parent_id)
462
 
                else:
463
 
                    mutter("commit will ghost revision %r", parent_id)
 
462
                    raise BzrCheckError("branch %s is missing revision {%s}"
 
463
                            % (self.branch, parent_id))
464
464
            
465
465
    def _remove_deleted(self):
466
466
        """Remove deleted files from the working inventories.