/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: Robert Collins
  • Date: 2006-07-03 08:12:23 UTC
  • mfrom: (1832 +trunk)
  • mto: (1832.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1833.
  • Revision ID: robertc@robertcollins.net-20060703081223-b106037c3fb29160
Merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
import re
68
68
import sys
69
69
import time
70
 
import pdb
 
70
import warnings
71
71
 
72
72
from cStringIO import StringIO
73
73
 
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
                           )
86
85
from bzrlib.trace import mutter, note, warning
87
86
from bzrlib.xml5 import serializer_v5
88
87
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
89
 
from bzrlib.symbol_versioning import *
 
88
from bzrlib.symbol_versioning import (deprecated_passed,
 
89
        deprecated_function,
 
90
        zero_seven,
 
91
        DEPRECATED_PARAMETER)
90
92
from bzrlib.workingtree import WorkingTree
91
93
 
92
94
 
98
100
 
99
101
    New code should use the Commit class instead.
100
102
    """
101
 
    ## XXX: Remove this in favor of Branch.commit?
 
103
    ## XXX: Remove this in favor of WorkingTree.commit?
102
104
    Commit().commit(*args, **kwargs)
103
105
 
104
106
 
221
223
        mutter('preparing to commit')
222
224
 
223
225
        if deprecated_passed(branch):
224
 
            warn("Commit.commit (branch, ...): The branch parameter is "
 
226
            warnings.warn("Commit.commit (branch, ...): The branch parameter is "
225
227
                 "deprecated as of bzr 0.8. Please use working_tree= instead.",
226
228
                 DeprecationWarning, stacklevel=2)
227
229
            self.branch = branch
234
236
        if message is None:
235
237
            raise BzrError("The message keyword parameter is required for commit().")
236
238
 
237
 
        self.weave_store = self.branch.repository.weave_store
238
239
        self.bound_branch = None
239
240
        self.local = local
240
241
        self.master_branch = None
270
271
                    raise StrictCommitFailed()
271
272
                   
272
273
            if self.config is None:
273
 
                self.config = bzrlib.config.BranchConfig(self.branch)
 
274
                self.config = self.branch.get_config()
274
275
      
275
276
            if isinstance(message, str):
276
277
                message = message.decode(bzrlib.user_encoding)
316
317
            # revision data is in the local branch now.
317
318
            
318
319
            # upload revision data to the master.
319
 
            # this will propogate merged revisions too if needed.
 
320
            # this will propagate merged revisions too if needed.
320
321
            if self.bound_branch:
321
322
                self.master_branch.repository.fetch(self.branch.repository,
322
323
                                                    revision_id=self.rev_id)
344
345
            self._emit_progress_update()
345
346
        finally:
346
347
            self._cleanup()
 
348
        return self.rev_id
347
349
 
348
350
    def _check_bound_branch(self):
349
351
        """Check to see if the local branch is bound.
386
388
        self.bound_branch = self.branch
387
389
        self.master_branch.lock_write()
388
390
        self.master_locked = True
389
 
####        
390
 
####        # Check to see if we have any pending merges. If we do
391
 
####        # those need to be pushed into the master branch
392
 
####        pending_merges = self.work_tree.pending_merges()
393
 
####        if pending_merges:
394
 
####            for revision_id in pending_merges:
395
 
####                self.master_branch.repository.fetch(self.bound_branch.repository,
396
 
####                                                    revision_id=revision_id)
397
391
 
398
392
    def _cleanup(self):
399
393
        """Cleanup any open locks, progress bars etc."""
411
405
            except Exception, e:
412
406
                found_exception = e
413
407
        if found_exception is not None: 
414
 
            # dont do a plan raise, because the last exception may have been
 
408
            # don't do a plan raise, because the last exception may have been
415
409
            # trashed, e is our sure-to-work exception even though it loses the
416
410
            # full traceback. XXX: RBC 20060421 perhaps we could check the
417
411
            # exc_info and if its the same one do a plain raise otherwise 
452
446
        """Record the parents of a merge for merge detection."""
453
447
        # TODO: Make sure that this list doesn't contain duplicate 
454
448
        # entries and the order is preserved when doing this.
455
 
        pending_merges = self.work_tree.pending_merges()
456
 
        self.parents = []
 
449
        self.parents = self.work_tree.get_parent_ids()
457
450
        self.parent_invs = []
458
 
        precursor_id = self.branch.last_revision()
459
 
        if precursor_id:
460
 
            self.parents.append(precursor_id)
461
 
        self.parents += pending_merges
462
451
        for revision in self.parents:
463
452
            if self.branch.repository.has_revision(revision):
464
453
                inventory = self.branch.repository.get_inventory(revision)
470
459
            if not self.branch.repository.has_revision(parent_id):
471
460
                if parent_id == self.branch.last_revision():
472
461
                    warning("parent is missing %r", parent_id)
473
 
                    raise HistoryMissing(self.branch, 'revision', parent_id)
474
 
                else:
475
 
                    mutter("commit will ghost revision %r", parent_id)
 
462
                    raise BzrCheckError("branch %s is missing revision {%s}"
 
463
                            % (self.branch, parent_id))
476
464
            
477
465
    def _remove_deleted(self):
478
466
        """Remove deleted files from the working inventories.
532
520
 
533
521
            self.builder.record_entry_contents(ie, self.parent_invs, 
534
522
                path, self.work_tree)
535
 
            # describe the nature of the change that has occured relative to
 
523
            # describe the nature of the change that has occurred relative to
536
524
            # the basis inventory.
537
525
            if (self.basis_inv.has_id(ie.file_id)):
538
526
                basis_ie = self.basis_inv[ie.file_id]