~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

Merge from bzr.ab.integration

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"
32
33
 
33
34
# FIXME: I don't know if writing out the cache from the destructor is really a
34
35
# good idea, because destructors are considered poor taste in Python, and it's
60
61
                           WeaveRevisionNotPresent,
61
62
                           NotBranchError,
62
63
                           NoSuchFile,
63
 
                           NotVersionedError)
 
64
                           NotVersionedError,
 
65
                           MergeModifiedFormatError)
64
66
from bzrlib.inventory import InventoryEntry, Inventory
65
67
from bzrlib.lockable_files import LockableFiles, TransportLock
66
68
from bzrlib.merge import merge_inner, transform_tree
84
86
                            )
85
87
from bzrlib.progress import DummyProgress
86
88
from bzrlib.revision import NULL_REVISION
 
89
from bzrlib.rio import RioReader, RioWriter, Stanza
87
90
from bzrlib.symbol_versioning import *
88
91
from bzrlib.textui import show_status
89
92
import bzrlib.tree
454
457
            tree.set_last_revision(revision_id)
455
458
 
456
459
    @needs_write_lock
457
 
    def commit(self, *args, **kwargs):
 
460
    def commit(self, message=None, revprops=None, *args, **kwargs):
 
461
        # avoid circular imports
458
462
        from bzrlib.commit import Commit
 
463
        if revprops is None:
 
464
            revprops = {}
 
465
        if not 'branch-nick' in revprops:
 
466
            revprops['branch-nick'] = self.branch.nick
459
467
        # args for wt.commit start at message from the Commit.commit method,
460
468
        # but with branch a kwarg now, passing in args as is results in the
461
469
        #message being used for the branch
462
 
        args = (DEPRECATED_PARAMETER, ) + args
463
 
        Commit().commit(working_tree=self, *args, **kwargs)
 
470
        args = (DEPRECATED_PARAMETER, message, ) + args
 
471
        Commit().commit(working_tree=self, revprops=revprops, *args, **kwargs)
464
472
        self._set_inventory(self.read_working_inventory())
465
473
 
466
474
    def id2abspath(self, file_id):
600
608
    def set_pending_merges(self, rev_list):
601
609
        self._control_files.put_utf8('pending-merges', '\n'.join(rev_list))
602
610
 
 
611
    @needs_write_lock
 
612
    def set_merge_modified(self, modified_hashes):
 
613
        my_file = StringIO()
 
614
        my_file.write(MERGE_MODIFIED_HEADER_1 + '\n')
 
615
        writer = RioWriter(my_file)
 
616
        for file_id, hash in modified_hashes.iteritems():
 
617
            s = Stanza(file_id=file_id, hash=hash)
 
618
            writer.write_stanza(s)
 
619
        my_file.seek(0)
 
620
        self._control_files.put('merge-hashes', my_file)
 
621
 
 
622
    @needs_read_lock
 
623
    def merge_modified(self):
 
624
        try:
 
625
            hashfile = self._control_files.get('merge-hashes')
 
626
        except NoSuchFile:
 
627
            return {}
 
628
        merge_hashes = {}
 
629
        try:
 
630
            if hashfile.next() != MERGE_MODIFIED_HEADER_1 + '\n':
 
631
                raise MergeModifiedFormatError()
 
632
        except StopIteration:
 
633
            raise MergeModifiedFormatError()
 
634
        for s in RioReader(hashfile):
 
635
            file_id = s.get("file_id")
 
636
            hash = s.get("hash")
 
637
            if hash == self.get_file_sha1(file_id):
 
638
                merge_hashes[file_id] = hash
 
639
        return merge_hashes
 
640
 
603
641
    def get_symlink_target(self, file_id):
604
642
        return os.readlink(self.id2abspath(file_id))
605
643