1
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
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.
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
72
71
from cStringIO import StringIO
74
from bzrlib.atomicfile import AtomicFile
75
73
import bzrlib.config
76
74
import bzrlib.errors as errors
77
75
from bzrlib.errors import (BzrError, PointlessCommit,
308
306
raise PointlessCommit()
310
308
self._emit_progress_update()
311
# TODO: Now the new inventory is known, check for conflicts and prompt the
312
# user for a commit message.
309
# TODO: Now the new inventory is known, check for conflicts and
310
# prompt the user for a commit message.
311
# ADHB 2006-08-08: If this is done, populate_new_inv should not add
312
# weave lines, because nothing should be recorded until it is known
313
# that commit will succeed.
313
314
self.builder.finish_inventory()
314
315
self._emit_progress_update()
315
316
self.rev_id = self.builder.commit(self.message)
497
498
None; inventory entries that are carried over untouched have their
498
499
revision set to their prior value.
501
# ESEPARATIONOFCONCERNS: this function is diffing and using the diff
502
# results to create a new inventory at the same time, which results
503
# in bugs like #46635. Any reason not to use/enhance Tree.changes_from?
500
505
mutter("Selecting files for commit with filter %s", self.specific_files)
501
# iter_entries does not visit the ROOT_ID node so we need to call
502
# self._emit_progress_update once by hand.
503
self._emit_progress_update()
504
for path, new_ie in self.work_inv.iter_entries():
506
entries = self.work_inv.iter_entries()
507
if not self.builder.record_root_entry:
508
warnings.warn('CommitBuilders should support recording the root'
509
' entry as of bzr 0.10.', DeprecationWarning, stacklevel=1)
510
self.builder.new_inventory.add(self.basis_inv.root.copy())
512
self._emit_progress_update()
513
for path, new_ie in entries:
505
514
self._emit_progress_update()
506
515
file_id = new_ie.file_id
507
mutter('check %s {%s}', path, file_id)
516
# mutter('check %s {%s}', path, file_id)
508
517
if (not self.specific_files or
509
518
is_inside_or_parent_of_any(self.specific_files, path)):
510
mutter('%s selected for commit', path)
519
# mutter('%s selected for commit', path)
511
520
ie = new_ie.copy()
512
521
ie.revision = None
514
mutter('%s not selected for commit', path)
523
# mutter('%s not selected for commit', path)
515
524
if self.basis_inv.has_id(file_id):
516
525
ie = self.basis_inv[file_id].copy()
535
544
self.reporter.snapshot_change(change, path)
546
if not self.specific_files:
549
# ignore removals that don't match filespec
550
for path, new_ie in self.basis_inv.iter_entries():
551
if new_ie.file_id in self.work_inv:
553
if is_inside_any(self.specific_files, path):
557
self.builder.record_entry_contents(ie, self.parent_invs, path,
537
560
def _emit_progress_update(self):
538
561
"""Emit an update to the progress bar."""
539
562
self.pb.update("Committing", self.pb_count, self.pb_total)