~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-03-01 03:47:49 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1595.
  • Revision ID: aaron.bentley@utoronto.ca-20060301034749-8e59bf2706d3c9c0
Switched to Rio format for merge-modified list

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
83
84
                            )
84
85
from bzrlib.progress import DummyProgress
85
86
from bzrlib.revision import NULL_REVISION
86
 
import bzrlib.splatfile as splatfile
 
87
from bzrlib.rio import RioReader, RioWriter, Stanza
87
88
from bzrlib.symbol_versioning import *
88
89
from bzrlib.textui import show_status
89
90
import bzrlib.tree
603
604
    @needs_write_lock
604
605
    def set_merge_modified(self, modified_hashes):
605
606
        my_file = StringIO()
606
 
        splatfile.dump_dict(my_file, modified_hashes)
 
607
        my_file.write(MERGE_MODIFIED_HEADER_1 + '\n')
 
608
        writer = RioWriter(my_file)
 
609
        for file_id, hash in modified_hashes.iteritems():
 
610
            s = Stanza(file_id=file_id.encode("UTF-8"), hash=hash)
 
611
            writer.write_stanza(s)
607
612
        my_file.seek(0)
608
613
        self._control_files.put('merge-hashes', my_file)
609
614
 
613
618
            hashfile = self._control_files.get('merge-hashes')
614
619
        except NoSuchFile:
615
620
            return {}
616
 
        merge_hashes = splatfile.read_dict(hashfile)
617
 
        return dict([(f,h) for f,h in merge_hashes.items() if 
618
 
                      h == self.get_file_sha1(f)])
 
621
        merge_hashes = {}
 
622
        try:
 
623
            if hashfile.next() != MERGE_MODIFIED_HEADER_1 + '\n':
 
624
                raise MergeModifiedFormatError()
 
625
        except StopIteration:
 
626
            raise MergeModifiedFormatError()
 
627
        for s in RioReader(hashfile):
 
628
            file_id = s.get("file_id").decode("UTF-8")
 
629
            hash = s.get("hash")
 
630
            if hash == self.get_file_sha1(file_id):
 
631
                merge_hashes[file_id] = hash
 
632
        return merge_hashes
619
633
 
620
634
    def get_symlink_target(self, file_id):
621
635
        return os.readlink(self.id2abspath(file_id))