~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Dmitry Vasiliev
  • Date: 2009-06-29 11:02:31 UTC
  • mto: (4517.1.1 integration2)
  • mto: This revision was merged to the branch mainline in revision 4520.
  • Revision ID: dima@hlabs.spb.ru-20090629110231-tsy00fwr6aud4en3
Optimize configuration for build documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
# The newly committed revision is going to have a shape corresponding
60
60
    debug,
61
61
    errors,
62
62
    revision,
 
63
    trace,
63
64
    tree,
 
65
    xml_serializer,
64
66
    )
65
67
from bzrlib.branch import Branch
66
68
import bzrlib.config
68
70
                           ConflictsInTree,
69
71
                           StrictCommitFailed
70
72
                           )
71
 
from bzrlib.osutils import (kind_marker, isdir,isfile, is_inside_any,
 
73
from bzrlib.osutils import (get_user_encoding,
 
74
                            kind_marker, isdir,isfile, is_inside_any,
72
75
                            is_inside_or_parent_of_any,
73
76
                            minimum_path_selection,
74
77
                            quotefn, sha_file, split_lines,
76
79
                            )
77
80
from bzrlib.testament import Testament
78
81
from bzrlib.trace import mutter, note, warning, is_quiet
79
 
from bzrlib.xml5 import serializer_v5
80
 
from bzrlib.inventory import InventoryEntry, make_entry
 
82
from bzrlib.inventory import Inventory, InventoryEntry, make_entry
81
83
from bzrlib import symbol_versioning
82
84
from bzrlib.symbol_versioning import (deprecated_passed,
83
85
        deprecated_function,
103
105
    def completed(self, revno, rev_id):
104
106
        pass
105
107
 
106
 
    def deleted(self, file_id):
107
 
        pass
108
 
 
109
 
    def escaped(self, escape_count, message):
 
108
    def deleted(self, path):
110
109
        pass
111
110
 
112
111
    def missing(self, path):
129
128
        note(format, *args)
130
129
 
131
130
    def snapshot_change(self, change, path):
132
 
        if change == 'unchanged':
133
 
            return
134
 
        if change == 'added' and path == '':
 
131
        if path == '' and change in ('added', 'modified'):
135
132
            return
136
133
        self._note("%s %s", change, path)
137
134
 
150
147
    def completed(self, revno, rev_id):
151
148
        self._note('Committed revision %d.', revno)
152
149
 
153
 
    def deleted(self, file_id):
154
 
        self._note('deleted %s', file_id)
155
 
 
156
 
    def escaped(self, escape_count, message):
157
 
        self._note("replaced %d control characters in message", escape_count)
 
150
    def deleted(self, path):
 
151
        self._note('deleted %s', path)
158
152
 
159
153
    def missing(self, path):
160
154
        self._note('missing %s', path)
205
199
               config=None,
206
200
               message_callback=None,
207
201
               recursive='down',
208
 
               exclude=None):
 
202
               exclude=None,
 
203
               possible_master_transports=None):
209
204
        """Commit working copy as a new revision.
210
205
 
211
206
        :param message: the commit message (it or message_callback is required)
235
230
            pending changes of any sort during this commit.
236
231
        :param exclude: None or a list of relative paths to exclude from the
237
232
            commit. Pending changes to excluded files will be ignored by the
238
 
            commit. 
 
233
            commit.
239
234
        """
240
235
        mutter('preparing to commit')
241
236
 
250
245
        if message_callback is None:
251
246
            if message is not None:
252
247
                if isinstance(message, str):
253
 
                    message = message.decode(bzrlib.user_encoding)
 
248
                    message = message.decode(get_user_encoding())
254
249
                message_callback = lambda x: message
255
250
            else:
256
251
                raise BzrError("The message or message_callback keyword"
257
252
                               " parameter is required for commit().")
258
253
 
259
254
        self.bound_branch = None
260
 
        self.any_entries_changed = False
261
255
        self.any_entries_deleted = False
262
256
        if exclude is not None:
263
257
            self.exclude = sorted(
274
268
                minimum_path_selection(specific_files))
275
269
        else:
276
270
            self.specific_files = None
277
 
        self.specific_file_ids = None
 
271
            
278
272
        self.allow_pointless = allow_pointless
279
273
        self.revprops = revprops
280
274
        self.message_callback = message_callback
283
277
        self.committer = committer
284
278
        self.strict = strict
285
279
        self.verbose = verbose
286
 
        # accumulates an inventory delta to the basis entry, so we can make
287
 
        # just the necessary updates to the workingtree's cached basis.
288
 
        self._basis_delta = []
289
280
 
290
281
        self.work_tree.lock_write()
 
282
        self.parents = self.work_tree.get_parent_ids()
 
283
        # We can use record_iter_changes IFF iter_changes is compatible with
 
284
        # the command line parameters, and the repository has fast delta
 
285
        # generation. See bug 347649.
 
286
        self.use_record_iter_changes = (
 
287
            not self.specific_files and
 
288
            not self.exclude and 
 
289
            not self.branch.repository._format.supports_tree_reference and
 
290
            (self.branch.repository._format.fast_deltas or
 
291
             len(self.parents) < 2))
291
292
        self.pb = bzrlib.ui.ui_factory.nested_progress_bar()
292
293
        self.basis_revid = self.work_tree.last_revision()
293
294
        self.basis_tree = self.work_tree.basis_tree()
298
299
                raise ConflictsInTree
299
300
 
300
301
            # Setup the bound branch variables as needed.
301
 
            self._check_bound_branch()
 
302
            self._check_bound_branch(possible_master_transports)
302
303
 
303
304
            # Check that the working tree is up to date
304
305
            old_revno, new_revno = self._check_out_of_date_tree()
311
312
            if self.config is None:
312
313
                self.config = self.branch.get_config()
313
314
 
314
 
            # If provided, ensure the specified files are versioned
315
 
            if self.specific_files is not None:
316
 
                # Note: This routine is being called because it raises
317
 
                # PathNotVersionedError as a side effect of finding the IDs. We
318
 
                # later use the ids we found as input to the working tree
319
 
                # inventory iterator, so we only consider those ids rather than
320
 
                # examining the whole tree again.
321
 
                # XXX: Dont we have filter_unversioned to do this more
322
 
                # cheaply?
323
 
                self.specific_file_ids = tree.find_ids_across_trees(
324
 
                    specific_files, [self.basis_tree, self.work_tree])
 
315
            self._set_specific_file_ids()
325
316
 
326
317
            # Setup the progress bar. As the number of files that need to be
327
318
            # committed in unknown, progress is reported as stages.
338
329
            self.pb.show_count = True
339
330
            self.pb.show_bar = True
340
331
 
341
 
            self.basis_inv = self.basis_tree.inventory
342
332
            self._gather_parents()
343
333
            # After a merge, a selected file commit is not supported.
344
334
            # See 'bzr help merge' for an explanation as to why.
349
339
                raise errors.CannotCommitSelectedFileMerge(self.exclude)
350
340
 
351
341
            # Collect the changes
352
 
            self._set_progress_stage("Collecting changes",
353
 
                    entries_title="Directory")
 
342
            self._set_progress_stage("Collecting changes", counter=True)
354
343
            self.builder = self.branch.get_commit_builder(self.parents,
355
344
                self.config, timestamp, timezone, committer, revprops, rev_id)
356
 
            
 
345
 
357
346
            try:
 
347
                self.builder.will_record_deletes()
358
348
                # find the location being committed to
359
349
                if self.bound_branch:
360
350
                    master_location = self.master_branch.base
365
355
                self.reporter.started(new_revno, self.rev_id, master_location)
366
356
 
367
357
                self._update_builder_with_changes()
368
 
                self._report_and_accumulate_deletes()
369
358
                self._check_pointless()
370
359
 
371
360
                # TODO: Now the new inventory is known, check for conflicts.
378
367
                # Prompt the user for a commit message if none provided
379
368
                message = message_callback(self)
380
369
                self.message = message
381
 
                self._escape_commit_message()
382
370
 
383
371
                # Add revision data to the local branch
384
372
                self.rev_id = self.builder.commit(self.message)
385
373
 
386
 
            except:
 
374
            except Exception, e:
 
375
                mutter("aborting commit write group because of exception:")
 
376
                trace.log_exception_quietly()
 
377
                note("aborting commit write group: %r" % (e,))
387
378
                self.builder.abort()
388
379
                raise
389
380
 
392
383
            # Upload revision data to the master.
393
384
            # this will propagate merged revisions too if needed.
394
385
            if self.bound_branch:
395
 
                if not self.master_branch.repository.has_same_location(
396
 
                        self.branch.repository):
397
 
                    self._set_progress_stage("Uploading data to master branch")
398
 
                    self.master_branch.repository.fetch(self.branch.repository,
399
 
                        revision_id=self.rev_id)
400
 
                # now the master has the revision data
 
386
                self._set_progress_stage("Uploading data to master branch")
401
387
                # 'commit' to the master first so a timeout here causes the
402
388
                # local branch to be out of date
403
 
                self.master_branch.set_last_revision_info(new_revno,
404
 
                                                          self.rev_id)
 
389
                self.master_branch.import_last_revision_info(
 
390
                    self.branch.repository, new_revno, self.rev_id)
405
391
 
406
392
            # and now do the commit locally.
407
393
            self.branch.set_last_revision_info(new_revno, self.rev_id)
409
395
            # Make the working tree up to date with the branch
410
396
            self._set_progress_stage("Updating the working tree")
411
397
            self.work_tree.update_basis_by_delta(self.rev_id,
412
 
                 self._basis_delta)
 
398
                 self.builder.get_basis_delta())
413
399
            self.reporter.completed(new_revno, self.rev_id)
414
400
            self._process_post_hooks(old_revno, new_revno)
415
401
        finally:
428
414
        # A merge with no effect on files
429
415
        if len(self.parents) > 1:
430
416
            return
431
 
        # TODO: we could simplify this by using self._basis_delta.
 
417
        # TODO: we could simplify this by using self.builder.basis_delta.
432
418
 
433
419
        # The initial commit adds a root directory, but this in itself is not
434
420
        # a worthwhile commit.
435
421
        if (self.basis_revid == revision.NULL_REVISION and
436
 
            len(self.builder.new_inventory) == 1):
 
422
            ((self.builder.new_inventory is not None and
 
423
             len(self.builder.new_inventory) == 1) or
 
424
            len(self.builder._basis_delta) == 1)):
437
425
            raise PointlessCommit()
438
 
        # If length == 1, then we only have the root entry. Which means
439
 
        # that there is no real difference (only the root could be different)
440
 
        # unless deletes occured, in which case the length is irrelevant.
441
 
        if (self.any_entries_deleted or 
442
 
            (len(self.builder.new_inventory) != 1 and
443
 
             self.any_entries_changed)):
 
426
        if self.builder.any_changes():
444
427
            return
445
428
        raise PointlessCommit()
446
429
 
447
 
    def _check_bound_branch(self):
 
430
    def _check_bound_branch(self, possible_master_transports=None):
448
431
        """Check to see if the local branch is bound.
449
432
 
450
433
        If it is bound, then most of the commit will actually be
455
438
            raise errors.LocalRequiresBoundBranch()
456
439
 
457
440
        if not self.local:
458
 
            self.master_branch = self.branch.get_master_branch()
 
441
            self.master_branch = self.branch.get_master_branch(
 
442
                possible_master_transports)
459
443
 
460
444
        if not self.master_branch:
461
445
            # make this branch the reference branch for out of date checks.
472
456
        #       commits to the remote branch if they would fit.
473
457
        #       But for now, just require remote to be identical
474
458
        #       to local.
475
 
        
 
459
 
476
460
        # Make sure the local branch is identical to the master
477
461
        master_info = self.master_branch.last_revision_info()
478
462
        local_info = self.branch.last_revision_info()
535
519
    def _process_hooks(self, hook_name, old_revno, new_revno):
536
520
        if not Branch.hooks[hook_name]:
537
521
            return
538
 
        
 
522
 
539
523
        # new style commit hooks:
540
524
        if not self.bound_branch:
541
525
            hook_master = self.branch
550
534
            old_revid = self.parents[0]
551
535
        else:
552
536
            old_revid = bzrlib.revision.NULL_REVISION
553
 
        
 
537
 
554
538
        if hook_name == "pre_commit":
555
539
            future_tree = self.builder.revision_tree()
556
540
            tree_delta = future_tree.changes_from(self.basis_tree,
557
541
                                             include_root=True)
558
 
        
 
542
 
559
543
        for hook in Branch.hooks[hook_name]:
560
544
            # show the running hook in the progress bar. As hooks may
561
545
            # end up doing nothing (e.g. because they are not configured by
591
575
            # typically this will be useful enough.
592
576
            except Exception, e:
593
577
                found_exception = e
594
 
        if found_exception is not None: 
 
578
        if found_exception is not None:
595
579
            # don't do a plan raise, because the last exception may have been
596
580
            # trashed, e is our sure-to-work exception even though it loses the
597
581
            # full traceback. XXX: RBC 20060421 perhaps we could check the
598
 
            # exc_info and if its the same one do a plain raise otherwise 
 
582
            # exc_info and if its the same one do a plain raise otherwise
599
583
            # 'raise e' as we do now.
600
584
            raise e
601
585
 
611
595
        if self.master_locked:
612
596
            self.master_branch.unlock()
613
597
 
614
 
    def _escape_commit_message(self):
615
 
        """Replace xml-incompatible control characters."""
616
 
        # FIXME: RBC 20060419 this should be done by the revision
617
 
        # serialiser not by commit. Then we can also add an unescaper
618
 
        # in the deserializer and start roundtripping revision messages
619
 
        # precisely. See repository_implementations/test_repository.py
620
 
        
621
 
        # Python strings can include characters that can't be
622
 
        # represented in well-formed XML; escape characters that
623
 
        # aren't listed in the XML specification
624
 
        # (http://www.w3.org/TR/REC-xml/#NT-Char).
625
 
        self.message, escape_count = re.subn(
626
 
            u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
627
 
            lambda match: match.group(0).encode('unicode_escape'),
628
 
            self.message)
629
 
        if escape_count:
630
 
            self.reporter.escaped(escape_count, self.message)
631
 
 
632
598
    def _gather_parents(self):
633
599
        """Record the parents of a merge for merge detection."""
634
 
        # TODO: Make sure that this list doesn't contain duplicate 
 
600
        # TODO: Make sure that this list doesn't contain duplicate
635
601
        # entries and the order is preserved when doing this.
636
 
        self.parents = self.work_tree.get_parent_ids()
 
602
        if self.use_record_iter_changes:
 
603
            return
 
604
        self.basis_inv = self.basis_tree.inventory
637
605
        self.parent_invs = [self.basis_inv]
638
606
        for revision in self.parents[1:]:
639
607
            if self.branch.repository.has_revision(revision):
646
614
    def _update_builder_with_changes(self):
647
615
        """Update the commit builder with the data about what has changed.
648
616
        """
649
 
        # Build the revision inventory.
650
 
        #
651
 
        # This starts by creating a new empty inventory. Depending on
652
 
        # which files are selected for commit, and what is present in the
653
 
        # current tree, the new inventory is populated. inventory entries 
654
 
        # which are candidates for modification have their revision set to
655
 
        # None; inventory entries that are carried over untouched have their
656
 
        # revision set to their prior value.
657
 
        #
658
 
        # ESEPARATIONOFCONCERNS: this function is diffing and using the diff
659
 
        # results to create a new inventory at the same time, which results
660
 
        # in bugs like #46635.  Any reason not to use/enhance Tree.changes_from?
661
 
        # ADHB 11-07-2006
662
 
 
663
617
        exclude = self.exclude
664
618
        specific_files = self.specific_files or []
665
619
        mutter("Selecting files for commit with filter %s", specific_files)
666
620
 
667
 
        # Build the new inventory
668
 
        self._populate_from_inventory()
669
 
 
 
621
        self._check_strict()
 
622
        if self.use_record_iter_changes:
 
623
            iter_changes = self.work_tree.iter_changes(self.basis_tree)
 
624
            iter_changes = self._filter_iter_changes(iter_changes)
 
625
            for file_id, path, fs_hash in self.builder.record_iter_changes(
 
626
                self.work_tree, self.basis_revid, iter_changes):
 
627
                self.work_tree._observed_sha1(file_id, path, fs_hash)
 
628
        else:
 
629
            # Build the new inventory
 
630
            self._populate_from_inventory()
 
631
            self._record_unselected()
 
632
            self._report_and_accumulate_deletes()
 
633
 
 
634
    def _filter_iter_changes(self, iter_changes):
 
635
        """Process iter_changes.
 
636
 
 
637
        This method reports on the changes in iter_changes to the user, and 
 
638
        converts 'missing' entries in the iter_changes iterator to 'deleted'
 
639
        entries. 'missing' entries have their
 
640
 
 
641
        :param iter_changes: An iter_changes to process.
 
642
        :return: A generator of changes.
 
643
        """
 
644
        reporter = self.reporter
 
645
        report_changes = reporter.is_verbose()
 
646
        deleted_ids = []
 
647
        for change in iter_changes:
 
648
            if report_changes:
 
649
                old_path = change[1][0]
 
650
                new_path = change[1][1]
 
651
                versioned = change[3][1]
 
652
            kind = change[6][1]
 
653
            versioned = change[3][1]
 
654
            if kind is None and versioned:
 
655
                # 'missing' path
 
656
                if report_changes:
 
657
                    reporter.missing(new_path)
 
658
                deleted_ids.append(change[0])
 
659
                # Reset the new path (None) and new versioned flag (False)
 
660
                change = (change[0], (change[1][0], None), change[2],
 
661
                    (change[3][0], False)) + change[4:]
 
662
            elif kind == 'tree-reference':
 
663
                if self.recursive == 'down':
 
664
                    self._commit_nested_tree(change[0], change[1][1])
 
665
            if change[3][0] or change[3][1]:
 
666
                yield change
 
667
                if report_changes:
 
668
                    if new_path is None:
 
669
                        reporter.deleted(old_path)
 
670
                    elif old_path is None:
 
671
                        reporter.snapshot_change('added', new_path)
 
672
                    elif old_path != new_path:
 
673
                        reporter.renamed('renamed', old_path, new_path)
 
674
                    else:
 
675
                        if (new_path or 
 
676
                            self.work_tree.branch.repository._format.rich_root_data):
 
677
                            # Don't report on changes to '' in non rich root
 
678
                            # repositories.
 
679
                            reporter.snapshot_change('modified', new_path)
 
680
            self._next_progress_entry()
 
681
        # Unversion IDs that were found to be deleted
 
682
        self.work_tree.unversion(deleted_ids)
 
683
 
 
684
    def _record_unselected(self):
670
685
        # If specific files are selected, then all un-selected files must be
671
686
        # recorded in their previous state. For more details, see
672
687
        # https://lists.ubuntu.com/archives/bazaar/2007q3/028476.html.
673
 
        if specific_files or exclude:
 
688
        if self.specific_files or self.exclude:
 
689
            specific_files = self.specific_files or []
674
690
            for path, old_ie in self.basis_inv.iter_entries():
675
691
                if old_ie.file_id in self.builder.new_inventory:
676
692
                    # already added - skip.
677
693
                    continue
678
694
                if (is_inside_any(specific_files, path)
679
 
                    and not is_inside_any(exclude, path)):
 
695
                    and not is_inside_any(self.exclude, path)):
680
696
                    # was inside the selected path, and not excluded - if not
681
697
                    # present it has been deleted so skip.
682
698
                    continue
683
699
                # From here down it was either not selected, or was excluded:
684
 
                if old_ie.kind == 'directory':
685
 
                    self._next_progress_entry()
686
700
                # We preserve the entry unaltered.
687
701
                ie = old_ie.copy()
688
702
                # Note: specific file commits after a merge are currently
690
704
                # required after that changes.
691
705
                if len(self.parents) > 1:
692
706
                    ie.revision = None
693
 
                delta, version_recorded = self.builder.record_entry_contents(
694
 
                    ie, self.parent_invs, path, self.basis_tree, None)
695
 
                if version_recorded:
696
 
                    self.any_entries_changed = True
697
 
                if delta: self._basis_delta.append(delta)
 
707
                self.builder.record_entry_contents(ie, self.parent_invs, path,
 
708
                    self.basis_tree, None)
698
709
 
699
710
    def _report_and_accumulate_deletes(self):
700
 
        # XXX: Could the list of deleted paths and ids be instead taken from
701
 
        # _populate_from_inventory?
702
 
        deleted_ids = set(self.basis_inv._byid.keys()) - \
703
 
            set(self.builder.new_inventory._byid.keys())
 
711
        if (isinstance(self.basis_inv, Inventory)
 
712
            and isinstance(self.builder.new_inventory, Inventory)):
 
713
            # the older Inventory classes provide a _byid dict, and building a
 
714
            # set from the keys of this dict is substantially faster than even
 
715
            # getting a set of ids from the inventory
 
716
            #
 
717
            # <lifeless> set(dict) is roughly the same speed as
 
718
            # set(iter(dict)) and both are significantly slower than
 
719
            # set(dict.keys())
 
720
            deleted_ids = set(self.basis_inv._byid.keys()) - \
 
721
               set(self.builder.new_inventory._byid.keys())
 
722
        else:
 
723
            deleted_ids = set(self.basis_inv) - set(self.builder.new_inventory)
704
724
        if deleted_ids:
705
725
            self.any_entries_deleted = True
706
726
            deleted = [(self.basis_tree.id2path(file_id), file_id)
708
728
            deleted.sort()
709
729
            # XXX: this is not quite directory-order sorting
710
730
            for path, file_id in deleted:
711
 
                self._basis_delta.append((path, None, file_id, None))
 
731
                self.builder.record_delete(path, file_id)
712
732
                self.reporter.deleted(path)
713
733
 
714
 
    def _populate_from_inventory(self):
715
 
        """Populate the CommitBuilder by walking the working tree inventory."""
 
734
    def _check_strict(self):
 
735
        # XXX: when we use iter_changes this would likely be faster if
 
736
        # iter_changes would check for us (even in the presence of
 
737
        # selected_files).
716
738
        if self.strict:
717
739
            # raise an exception as soon as we find a single unknown.
718
740
            for unknown in self.work_tree.unknowns():
719
741
                raise StrictCommitFailed()
720
 
        
 
742
 
 
743
    def _populate_from_inventory(self):
 
744
        """Populate the CommitBuilder by walking the working tree inventory."""
 
745
        # Build the revision inventory.
 
746
        #
 
747
        # This starts by creating a new empty inventory. Depending on
 
748
        # which files are selected for commit, and what is present in the
 
749
        # current tree, the new inventory is populated. inventory entries
 
750
        # which are candidates for modification have their revision set to
 
751
        # None; inventory entries that are carried over untouched have their
 
752
        # revision set to their prior value.
 
753
        #
 
754
        # ESEPARATIONOFCONCERNS: this function is diffing and using the diff
 
755
        # results to create a new inventory at the same time, which results
 
756
        # in bugs like #46635.  Any reason not to use/enhance Tree.changes_from?
 
757
        # ADHB 11-07-2006
 
758
 
721
759
        specific_files = self.specific_files
722
760
        exclude = self.exclude
723
761
        report_changes = self.reporter.is_verbose()
737
775
            name = existing_ie.name
738
776
            parent_id = existing_ie.parent_id
739
777
            kind = existing_ie.kind
740
 
            if kind == 'directory':
741
 
                self._next_progress_entry()
742
778
            # Skip files that have been deleted from the working tree.
743
779
            # The deleted path ids are also recorded so they can be explicitly
744
780
            # unversioned later.
773
809
                    for segment in path_segments:
774
810
                        deleted_dict = deleted_dict.setdefault(segment, {})
775
811
                    self.reporter.missing(path)
 
812
                    self._next_progress_entry()
776
813
                    deleted_ids.append(file_id)
777
814
                    continue
778
815
            # TODO: have the builder do the nested commit just-in-time IF and
813
850
        # FIXME: be more comprehensive here:
814
851
        # this works when both trees are in --trees repository,
815
852
        # but when both are bound to a different repository,
816
 
        # it fails; a better way of approaching this is to 
 
853
        # it fails; a better way of approaching this is to
817
854
        # finally implement the explicit-caches approach design
818
855
        # a while back - RBC 20070306.
819
856
        if sub_tree.branch.repository.has_same_location(
843
880
        else:
844
881
            ie = existing_ie.copy()
845
882
            ie.revision = None
846
 
        delta, version_recorded = self.builder.record_entry_contents(ie,
847
 
            self.parent_invs, path, self.work_tree, content_summary)
848
 
        if delta:
849
 
            self._basis_delta.append(delta)
850
 
        if version_recorded:
851
 
            self.any_entries_changed = True
 
883
        # For carried over entries we don't care about the fs hash - the repo
 
884
        # isn't generating a sha, so we're not saving computation time.
 
885
        _, _, fs_hash = self.builder.record_entry_contents(
 
886
            ie, self.parent_invs, path, self.work_tree, content_summary)
852
887
        if report_changes:
853
888
            self._report_change(ie, path)
 
889
        if fs_hash:
 
890
            self.work_tree._observed_sha1(ie.file_id, path, fs_hash)
854
891
        return ie
855
892
 
856
893
    def _report_change(self, ie, path):
864
901
        else:
865
902
            basis_ie = None
866
903
        change = ie.describe_change(basis_ie, ie)
867
 
        if change in (InventoryEntry.RENAMED, 
 
904
        if change in (InventoryEntry.RENAMED,
868
905
            InventoryEntry.MODIFIED_AND_RENAMED):
869
906
            old_path = self.basis_inv.id2path(ie.file_id)
870
907
            self.reporter.renamed(change, old_path, path)
 
908
            self._next_progress_entry()
871
909
        else:
 
910
            if change == 'unchanged':
 
911
                return
872
912
            self.reporter.snapshot_change(change, path)
 
913
            self._next_progress_entry()
873
914
 
874
 
    def _set_progress_stage(self, name, entries_title=None):
 
915
    def _set_progress_stage(self, name, counter=False):
875
916
        """Set the progress stage and emit an update to the progress bar."""
876
917
        self.pb_stage_name = name
877
918
        self.pb_stage_count += 1
878
 
        self.pb_entries_title = entries_title
879
 
        if entries_title is not None:
 
919
        if counter:
880
920
            self.pb_entries_count = 0
881
 
            self.pb_entries_total = '?'
 
921
        else:
 
922
            self.pb_entries_count = None
882
923
        self._emit_progress()
883
924
 
884
925
    def _next_progress_entry(self):
887
928
        self._emit_progress()
888
929
 
889
930
    def _emit_progress(self):
890
 
        if self.pb_entries_title:
891
 
            if self.pb_entries_total == '?':
892
 
                text = "%s [%s %d] - Stage" % (self.pb_stage_name,
893
 
                    self.pb_entries_title, self.pb_entries_count)
894
 
            else:
895
 
                text = "%s [%s %d/%s] - Stage" % (self.pb_stage_name,
896
 
                    self.pb_entries_title, self.pb_entries_count,
897
 
                    str(self.pb_entries_total))
 
931
        if self.pb_entries_count is not None:
 
932
            text = "%s [%d] - Stage" % (self.pb_stage_name,
 
933
                self.pb_entries_count)
898
934
        else:
899
 
            text = "%s - Stage" % (self.pb_stage_name)
 
935
            text = "%s - Stage" % (self.pb_stage_name, )
900
936
        self.pb.update(text, self.pb_stage_count, self.pb_stage_total)
901
937
 
 
938
    def _set_specific_file_ids(self):
 
939
        """populate self.specific_file_ids if we will use it."""
 
940
        if not self.use_record_iter_changes:
 
941
            # If provided, ensure the specified files are versioned
 
942
            if self.specific_files is not None:
 
943
                # Note: This routine is being called because it raises
 
944
                # PathNotVersionedError as a side effect of finding the IDs. We
 
945
                # later use the ids we found as input to the working tree
 
946
                # inventory iterator, so we only consider those ids rather than
 
947
                # examining the whole tree again.
 
948
                # XXX: Dont we have filter_unversioned to do this more
 
949
                # cheaply?
 
950
                self.specific_file_ids = tree.find_ids_across_trees(
 
951
                    self.specific_files, [self.basis_tree, self.work_tree])
 
952
            else:
 
953
                self.specific_file_ids = None