~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Pool
  • Date: 2006-03-09 07:14:10 UTC
  • mfrom: (1600 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1602.
  • Revision ID: mbp@sourcefrog.net-20060309071410-4ab7d54905541c75
[merge] from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
WorkingTree.open(dir).
30
30
"""
31
31
 
 
32
MERGE_MODIFIED_HEADER_1 = "BZR merge-modified list format 1"
 
33
 
32
34
# TODO: Give the workingtree sole responsibility for the working inventory;
33
35
# remove the variable and references to it from the branch.  This may require
34
36
# updating the commit code so as to update the inventory within the working
56
58
                           WeaveRevisionNotPresent,
57
59
                           NotBranchError,
58
60
                           NoSuchFile,
59
 
                           NotVersionedError)
 
61
                           NotVersionedError,
 
62
                           MergeModifiedFormatError)
60
63
from bzrlib.inventory import InventoryEntry, Inventory
61
64
from bzrlib.lockable_files import LockableFiles, TransportLock
62
65
from bzrlib.lockdir import LockDir
81
84
                            )
82
85
from bzrlib.progress import DummyProgress
83
86
from bzrlib.revision import NULL_REVISION
 
87
from bzrlib.rio import RioReader, RioWriter, Stanza
84
88
from bzrlib.symbol_versioning import *
85
89
from bzrlib.textui import show_status
86
90
import bzrlib.tree
448
452
            tree.set_last_revision(revision_id)
449
453
 
450
454
    @needs_write_lock
451
 
    def commit(self, *args, **kwargs):
 
455
    def commit(self, message=None, revprops=None, *args, **kwargs):
 
456
        # avoid circular imports
452
457
        from bzrlib.commit import Commit
 
458
        if revprops is None:
 
459
            revprops = {}
 
460
        if not 'branch-nick' in revprops:
 
461
            revprops['branch-nick'] = self.branch.nick
453
462
        # args for wt.commit start at message from the Commit.commit method,
454
463
        # but with branch a kwarg now, passing in args as is results in the
455
464
        #message being used for the branch
456
 
        args = (DEPRECATED_PARAMETER, ) + args
457
 
        Commit().commit(working_tree=self, *args, **kwargs)
 
465
        args = (DEPRECATED_PARAMETER, message, ) + args
 
466
        Commit().commit(working_tree=self, revprops=revprops, *args, **kwargs)
458
467
        self._set_inventory(self.read_working_inventory())
459
468
 
460
469
    def id2abspath(self, file_id):
594
603
    def set_pending_merges(self, rev_list):
595
604
        self._control_files.put_utf8('pending-merges', '\n'.join(rev_list))
596
605
 
 
606
    @needs_write_lock
 
607
    def set_merge_modified(self, modified_hashes):
 
608
        my_file = StringIO()
 
609
        my_file.write(MERGE_MODIFIED_HEADER_1 + '\n')
 
610
        writer = RioWriter(my_file)
 
611
        for file_id, hash in modified_hashes.iteritems():
 
612
            s = Stanza(file_id=file_id, hash=hash)
 
613
            writer.write_stanza(s)
 
614
        my_file.seek(0)
 
615
        self._control_files.put('merge-hashes', my_file)
 
616
 
 
617
    @needs_read_lock
 
618
    def merge_modified(self):
 
619
        try:
 
620
            hashfile = self._control_files.get('merge-hashes')
 
621
        except NoSuchFile:
 
622
            return {}
 
623
        merge_hashes = {}
 
624
        try:
 
625
            if hashfile.next() != MERGE_MODIFIED_HEADER_1 + '\n':
 
626
                raise MergeModifiedFormatError()
 
627
        except StopIteration:
 
628
            raise MergeModifiedFormatError()
 
629
        for s in RioReader(hashfile):
 
630
            file_id = s.get("file_id")
 
631
            hash = s.get("hash")
 
632
            if hash == self.get_file_sha1(file_id):
 
633
                merge_hashes[file_id] = hash
 
634
        return merge_hashes
 
635
 
597
636
    def get_symlink_target(self, file_id):
598
637
        return os.readlink(self.id2abspath(file_id))
599
638
 
844
883
                else:
845
884
                    other_revision = None
846
885
                repository = self.branch.repository
847
 
                merge_inner(self.branch,
848
 
                            self.branch.basis_tree(),
849
 
                            basis_tree, 
850
 
                            this_tree=self, 
851
 
                            pb=bzrlib.ui.ui_factory.progress_bar())
 
886
                pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
887
                try:
 
888
                    merge_inner(self.branch,
 
889
                                self.branch.basis_tree(),
 
890
                                basis_tree, 
 
891
                                this_tree=self, 
 
892
                                pb=pb)
 
893
                finally:
 
894
                    pb.finished()
852
895
                self.set_last_revision(self.branch.last_revision())
853
896
            return count
854
897
        finally: