~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-17 08:50:40 UTC
  • mfrom: (1704.2.18 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060517085040-ee6e33957c557fba
(mbp) merge 0.8 fixes; fix #32587

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
2
 
#
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
89
89
from bzrlib.testament import Testament
90
90
from bzrlib.trace import mutter, note, warning
91
91
from bzrlib.xml5 import serializer_v5
92
 
from bzrlib.inventory import Inventory, ROOT_ID
 
92
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
93
93
from bzrlib.symbol_versioning import *
94
94
from bzrlib.workingtree import WorkingTree
95
95
 
124
124
    def missing(self, path):
125
125
        pass
126
126
 
 
127
    def renamed(self, change, old_path, new_path):
 
128
        pass
 
129
 
127
130
 
128
131
class ReportCommitToLog(NullCommitReporter):
129
132
 
 
133
    # this may be more useful if 'note' was replaced by an overridable
 
134
    # method on self, which would allow more trivial subclassing.
 
135
    # alternative, a callable could be passed in, allowing really trivial
 
136
    # reuse for some uis. RBC 20060511
 
137
 
130
138
    def snapshot_change(self, change, path):
131
139
        if change == 'unchanged':
132
140
            return
144
152
    def missing(self, path):
145
153
        note('missing %s', path)
146
154
 
 
155
    def renamed(self, change, old_path, new_path):
 
156
        note('%s %s => %s', change, old_path, new_path)
 
157
 
147
158
 
148
159
class Commit(object):
149
160
    """Task of committing a new revision.
510
521
                self.weave_store,
511
522
                self.branch.repository.get_transaction())
512
523
            if ie.revision is None:
513
 
                change = ie.snapshot(self.rev_id, path, previous_entries,
514
 
                                     self.work_tree, self.weave_store,
515
 
                                     self.branch.repository.get_transaction())
516
 
            else:
517
 
                change = "unchanged"
518
 
            self.reporter.snapshot_change(change, path)
 
524
                # we are creating a new revision for ie in the history store
 
525
                # and inventory.
 
526
                ie.snapshot(self.rev_id, path, previous_entries,
 
527
                    self.work_tree, self.weave_store,
 
528
                    self.branch.repository.get_transaction())
 
529
            # describe the nature of the change that has occured relative to
 
530
            # the basis inventory.
 
531
            if (self.basis_inv.has_id(ie.file_id)):
 
532
                basis_ie = self.basis_inv[ie.file_id]
 
533
            else:
 
534
                basis_ie = None
 
535
            change = ie.describe_change(basis_ie, ie)
 
536
            if change in (InventoryEntry.RENAMED, 
 
537
                InventoryEntry.MODIFIED_AND_RENAMED):
 
538
                old_path = self.basis_inv.id2path(ie.file_id)
 
539
                self.reporter.renamed(change, old_path, path)
 
540
            else:
 
541
                self.reporter.snapshot_change(change, path)
519
542
 
520
543
    def _populate_new_inv(self):
521
544
        """Build revision inventory.
568
591
            self.new_inv.add(self.basis_inv[file_id].copy())
569
592
 
570
593
    def _report_deletes(self):
571
 
        for file_id in self.basis_inv:
572
 
            if file_id not in self.new_inv:
573
 
                self.reporter.deleted(self.basis_inv.id2path(file_id))
 
594
        for path, ie in self.basis_inv.iter_entries():
 
595
            if ie.file_id not in self.new_inv:
 
596
                self.reporter.deleted(path)
574
597
 
575
598
def _gen_revision_id(config, when):
576
599
    """Return new revision-id."""