99
99
new_path = change[1][1]
101
101
new_excluded = (new_path is not None and
102
is_inside_any(exclude, new_path))
102
is_inside_any(exclude, new_path))
104
104
old_excluded = (old_path is not None and
105
is_inside_any(exclude, old_path))
105
is_inside_any(exclude, old_path))
107
107
if old_excluded and new_excluded:
210
211
if possible_master_transports is None:
211
212
possible_master_transports = []
212
if (not u'branch-nick' in revprops and
213
if (u'branch-nick' not in revprops and
213
214
branch.repository._format.supports_storing_branch_nick):
214
215
revprops[u'branch-nick'] = branch._get_nick(
249
250
"""Commit working copy as a new revision.
251
252
:param message: the commit message (it or message_callback is required)
252
:param message_callback: A callback: message = message_callback(cmt_obj)
253
:param message_callback: A callback: message =
254
message_callback(cmt_obj)
254
256
:param timestamp: if not None, seconds-since-epoch for a
255
257
postdated/predated commit.
286
288
# XXX: Can be set on __init__ or passed in - this is a bit ugly.
287
289
self.config_stack = config or self.config_stack
288
290
return operation.run(
293
specific_files=specific_files,
295
allow_pointless=allow_pointless,
298
working_tree=working_tree,
301
message_callback=message_callback,
304
possible_master_transports=possible_master_transports,
295
specific_files=specific_files,
297
allow_pointless=allow_pointless,
300
working_tree=working_tree,
303
message_callback=message_callback,
306
possible_master_transports=possible_master_transports,
307
309
def _commit(self, operation, message, timestamp, timezone, committer,
308
specific_files, rev_id, allow_pointless, strict, verbose,
309
working_tree, local, reporter, message_callback, recursive,
310
exclude, possible_master_transports, lossy):
310
specific_files, rev_id, allow_pointless, strict, verbose,
311
working_tree, local, reporter, message_callback, recursive,
312
exclude, possible_master_transports, lossy):
311
313
mutter('preparing to commit')
313
315
if working_tree is None:
322
324
if message is not None:
323
325
if isinstance(message, bytes):
324
326
message = message.decode(get_user_encoding())
325
message_callback = lambda x: message
328
def message_callback(x):
327
331
raise BzrError("The message or message_callback keyword"
328
332
" parameter is required for commit().")
409
413
# Collect the changes
410
414
self._set_progress_stage("Collecting changes", counter=True)
411
415
self._lossy = lossy
412
self.builder = self.branch.get_commit_builder(self.parents,
413
self.config_stack, timestamp, timezone, committer, self.revprops,
416
self.builder = self.branch.get_commit_builder(
417
self.parents, self.config_stack, timestamp, timezone, committer,
418
self.revprops, rev_id, lossy=lossy)
416
420
if self.builder.updates_branch and self.bound_branch:
417
421
self.builder.abort()
460
464
self.work_tree.unversion(self.deleted_paths)
461
465
self._set_progress_stage("Updating the working tree")
462
466
self.work_tree.update_basis_by_delta(self.rev_id,
463
self.builder.get_basis_delta())
467
self.builder.get_basis_delta())
464
468
self.reporter.completed(new_revno, self.rev_id)
465
469
self._process_post_hooks(old_revno, new_revno)
466
470
return self.rev_id
497
501
self._process_pre_hooks(old_revno, new_revno)
502
except BaseException:
499
503
# The commit builder will already have updated the branch,
501
505
self.branch.set_last_revision_info(old_revno, old_revid)
508
512
self.master_branch.tags)
509
513
if tag_conflicts:
510
514
warning_lines = [' ' + name for name, _, _ in tag_conflicts]
511
note( gettext("Conflicting tags in bound branch:\n{0}".format(
512
"\n".join(warning_lines))) )
515
note(gettext("Conflicting tags in bound branch:\n{0}".format(
516
"\n".join(warning_lines))))
514
518
def _select_reporter(self):
515
519
"""Select the CommitReporter to use."""
549
553
# If the master branch is bound, we must fail
550
554
master_bound_location = self.master_branch.get_bound_location()
551
555
if master_bound_location:
552
raise errors.CommitToDoubleBoundBranch(self.branch,
553
self.master_branch, master_bound_location)
556
raise errors.CommitToDoubleBoundBranch(
557
self.branch, self.master_branch, master_bound_location)
555
559
# TODO: jam 20051230 We could automatically push local
556
560
# commits to the remote branch if they would fit.
562
566
local_info = self.branch.last_revision_info()
563
567
if local_info != master_info:
564
568
raise errors.BoundBranchOutOfDate(self.branch,
567
571
# Now things are ready to change the master branch
568
572
# so grab the lock
612
616
# this would be nicer with twisted.python.reflect.namedAny
613
617
for hook in hooks:
614
618
result = eval(hook + '(branch, rev_id)',
615
{'branch':self.branch,
617
'rev_id':self.rev_id})
619
{'branch': self.branch,
621
'rev_id': self.rev_id})
618
622
# process new style post commit hooks
619
623
self._process_hooks("post_commit", old_revno, new_revno)
640
644
if hook_name == "pre_commit":
641
645
future_tree = self.builder.revision_tree()
642
646
tree_delta = future_tree.changes_from(self.basis_tree,
645
649
for hook in Branch.hooks[hook_name]:
646
650
# show the running hook in the progress bar. As hooks may
668
672
mutter("Selecting files for commit with filter %r", specific_files)
670
674
self._check_strict()
671
iter_changes = self.work_tree.iter_changes(self.basis_tree,
672
specific_files=specific_files)
675
iter_changes = self.work_tree.iter_changes(
676
self.basis_tree, specific_files=specific_files)
674
678
iter_changes = filter_excluded(iter_changes, self.exclude)
675
679
iter_changes = self._filter_iter_changes(iter_changes)
680
684
def _filter_iter_changes(self, iter_changes):
681
685
"""Process iter_changes.
683
This method reports on the changes in iter_changes to the user, and
687
This method reports on the changes in iter_changes to the user, and
684
688
converts 'missing' entries in the iter_changes iterator to 'deleted'
685
689
entries. 'missing' entries have their
704
708
deleted_paths.append(change[1][1])
705
709
# Reset the new path (None) and new versioned flag (False)
706
710
change = (change[0], (change[1][0], None), change[2],
707
(change[3][0], False)) + change[4:]
711
(change[3][0], False)) + change[4:]
708
712
new_path = change[1][1]
709
713
versioned = False
710
714
elif kind == 'tree-reference':
718
722
elif old_path is None:
719
723
reporter.snapshot_change(gettext('added'), new_path)
720
724
elif old_path != new_path:
721
reporter.renamed(gettext('renamed'), old_path, new_path)
725
reporter.renamed(gettext('renamed'),
724
self.work_tree.branch.repository._format.rich_root_data):
729
or self.work_tree.branch.repository._format.rich_root_data):
725
730
# Don't report on changes to '' in non rich root
727
reporter.snapshot_change(gettext('modified'), new_path)
732
reporter.snapshot_change(
733
gettext('modified'), new_path)
728
734
self._next_progress_entry()
729
735
# Unversion files that were found to be deleted
730
736
self.deleted_paths = deleted_paths
748
754
# finally implement the explicit-caches approach design
749
755
# a while back - RBC 20070306.
750
756
if sub_tree.branch.repository.has_same_location(
751
self.work_tree.branch.repository):
757
self.work_tree.branch.repository):
752
758
sub_tree.branch.repository = \
753
759
self.work_tree.branch.repository
755
761
return sub_tree.commit(message=None, revprops=self.revprops,
756
recursive=self.recursive,
757
message_callback=self.message_callback,
758
timestamp=self.timestamp, timezone=self.timezone,
759
committer=self.committer,
760
allow_pointless=self.allow_pointless,
761
strict=self.strict, verbose=self.verbose,
762
local=self.local, reporter=self.reporter)
762
recursive=self.recursive,
763
message_callback=self.message_callback,
764
timestamp=self.timestamp,
765
timezone=self.timezone,
766
committer=self.committer,
767
allow_pointless=self.allow_pointless,
768
strict=self.strict, verbose=self.verbose,
769
local=self.local, reporter=self.reporter)
763
770
except PointlessCommit:
764
771
return self.work_tree.get_reference_revision(path)
781
788
def _emit_progress(self):
782
789
if self.pb_entries_count is not None:
783
790
text = gettext("{0} [{1}] - Stage").format(self.pb_stage_name,
784
self.pb_entries_count)
791
self.pb_entries_count)
786
793
text = gettext("%s - Stage") % (self.pb_stage_name, )
787
794
self.pb.update(text, self.pb_stage_count, self.pb_stage_total)