1
# Copyright (C) 2005 Canonical Ltd
1
# Copyright (C) 2005, 2006 Canonical Ltd
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
124
124
def missing(self, path):
127
def renamed(self, change, old_path, new_path):
128
131
class ReportCommitToLog(NullCommitReporter):
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
130
138
def snapshot_change(self, change, path):
131
139
if change == 'unchanged':
144
152
def missing(self, path):
145
153
note('missing %s', path)
155
def renamed(self, change, old_path, new_path):
156
note('%s %s => %s', change, old_path, new_path)
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())
518
self.reporter.snapshot_change(change, path)
524
# we are creating a new revision for ie in the history store
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]
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)
541
self.reporter.snapshot_change(change, path)
520
543
def _populate_new_inv(self):
521
544
"""Build revision inventory.
568
591
self.new_inv.add(self.basis_inv[file_id].copy())
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)
575
598
def _gen_revision_id(config, when):
576
599
"""Return new revision-id."""