481
477
def _gather_parents(self):
482
478
"""Record the parents of a merge for merge detection."""
479
# TODO: Make sure that this list doesn't contain duplicate
480
# entries and the order is preserved when doing this.
483
481
pending_merges = self.work_tree.pending_merges()
484
482
self.parents = []
485
483
self.parent_invs = []
486
self.present_parents = []
487
484
precursor_id = self.branch.last_revision()
489
486
self.parents.append(precursor_id)
542
538
del self.work_inv[file_id]
543
539
self.work_tree._write_inventory(self.work_inv)
545
def _store_snapshot(self):
546
"""Pass over inventory and record a snapshot.
548
Entries get a new revision when they are modified in
549
any way, which includes a merge with a new set of
550
parents that have the same entry.
552
# XXX: Need to think more here about when the user has
553
# made a specific decision on a particular value -- c.f.
556
# iter_entries does not visit the ROOT_ID node so we need to call
557
# self._emit_progress_update once by hand.
558
self._emit_progress_update()
559
for path, ie in self.builder.new_inventory.iter_entries():
560
self._emit_progress_update()
561
self.builder.record_entry_contents(ie, self.parent_invs,
562
self.rev_id, path, self.work_tree)
563
# describe the nature of the change that has occured relative to
564
# the basis inventory.
565
if (self.basis_inv.has_id(ie.file_id)):
566
basis_ie = self.basis_inv[ie.file_id]
569
change = ie.describe_change(basis_ie, ie)
570
if change in (InventoryEntry.RENAMED,
571
InventoryEntry.MODIFIED_AND_RENAMED):
572
old_path = self.basis_inv.id2path(ie.file_id)
573
self.reporter.renamed(change, old_path, path)
575
self.reporter.snapshot_change(change, path)
577
541
def _populate_new_inv(self):
578
542
"""Build revision inventory.
589
553
# iter_entries does not visit the ROOT_ID node so we need to call
590
554
# self._emit_progress_update once by hand.
591
555
self._emit_progress_update()
556
self._emit_progress_update()
592
557
for path, new_ie in self.work_inv.iter_entries():
593
558
self._emit_progress_update()
559
self._emit_progress_update()
594
560
file_id = new_ie.file_id
595
561
mutter('check %s {%s}', path, new_ie.file_id)
596
562
if (not self.specific_files or
597
563
is_inside_or_parent_of_any(self.specific_files, path)):
598
564
mutter('%s selected for commit', path)
599
self._select_entry(new_ie)
601
568
mutter('%s not selected for commit', path)
602
self._carry_entry(file_id)
569
if self.basis_inv.has_id(file_id):
570
ie = self.basis_inv[file_id].copy()
572
# this entry is new and not being committed
575
self.builder.record_entry_contents(ie, self.parent_invs,
576
self.rev_id, path, self.work_tree)
577
# describe the nature of the change that has occured relative to
578
# the basis inventory.
579
if (self.basis_inv.has_id(ie.file_id)):
580
basis_ie = self.basis_inv[ie.file_id]
583
change = ie.describe_change(basis_ie, ie)
584
if change in (InventoryEntry.RENAMED,
585
InventoryEntry.MODIFIED_AND_RENAMED):
586
old_path = self.basis_inv.id2path(ie.file_id)
587
self.reporter.renamed(change, old_path, path)
589
self.reporter.snapshot_change(change, path)
604
591
def _emit_progress_update(self):
605
592
"""Emit an update to the progress bar."""
606
593
self.pb.update("Committing", self.pb_count, self.pb_total)
607
594
self.pb_count += 1
609
def _select_entry(self, new_ie):
610
"""Make new_ie be considered for committing."""
613
self.builder.new_inventory.add(ie)
616
def _carry_entry(self, file_id):
617
"""Carry the file unchanged from the basis revision."""
618
if self.basis_inv.has_id(file_id):
619
self.builder.new_inventory.add(self.basis_inv[file_id].copy())
621
# this entry is new and not being committed
624
596
def _report_deletes(self):
625
597
for path, ie in self.basis_inv.iter_entries():
626
598
if ie.file_id not in self.builder.new_inventory: