53
53
class RevisionInfo(object):
54
54
"""Gets filled out for each revision object that is read.
56
57
def __init__(self, revision_id):
57
58
self.revision_id = revision_id
350
351
def do_patch(path, lines, encoding):
351
352
if encoding == 'base64':
352
patch = base64.decodestring(''.join(lines))
353
patch = base64.b64decode(b''.join(lines))
353
354
elif encoding is None:
354
patch = ''.join(lines)
355
patch = b''.join(lines)
356
357
raise ValueError(encoding)
357
358
bundle_tree.note_patch(path, patch)
628
629
base_id = self.old_contents_id(file_id)
629
630
if (base_id is not None and
630
631
base_id != self.base_tree.get_root_id()):
632
old_path = self.old_path(path)
631
633
patch_original = self.base_tree.get_file(
632
self.base_tree.id2path(base_id), base_id)
634
636
patch_original = None
635
637
file_patch = self.patches.get(path)
641
643
raise AssertionError("None: %s" % file_id)
642
644
return patch_original
644
if file_patch.startswith('\\'):
646
if file_patch.startswith(b'\\'):
645
647
raise ValueError(
646
648
'Malformed patch for %s, %r' % (file_id, file_patch))
647
649
return patched_file(file_patch, patch_original)
651
653
return self._targets[path]
653
return self.base_tree.get_symlink_target(path, file_id)
655
old_path = self.old_path(path)
656
return self.base_tree.get_symlink_target(old_path, file_id)
655
658
def kind(self, path, file_id=None):
657
660
return self._kinds[path]
659
return self.base_tree.kind(path, file_id)
662
old_path = self.old_path(path)
663
return self.base_tree.kind(old_path, file_id)
661
665
def get_file_revision(self, path, file_id=None):
662
666
if path in self._last_changed:
663
667
return self._last_changed[path]
665
return self.base_tree.get_file_revision(path, file_id)
669
old_path = self.old_path(path)
670
return self.base_tree.get_file_revision(old_path, file_id)
667
672
def is_executable(self, path, file_id=None):
668
673
if path in self._executable:
669
674
return self._executable[path]
671
return self.base_tree.is_executable(path, file_id)
676
old_path = self.old_path(path)
677
return self.base_tree.is_executable(old_path, file_id)
673
679
def get_last_changed(self, path, file_id=None):
674
680
if path in self._last_changed:
675
681
return self._last_changed[path]
676
return self.base_tree.get_file_revision(path, file_id)
682
old_path = self.old_path(path)
683
return self.base_tree.get_file_revision(old_path, file_id)
678
685
def get_size_and_sha1(self, new_path, file_id=None):
679
686
"""Return the size and sha1 hash of the given file id.
685
692
if new_path not in self.patches:
686
693
# If the entry does not have a patch, then the
687
694
# contents must be the same as in the base_tree
688
base_path = self.base_tree.id2path(file_id)
695
base_path = self.old_path(new_path)
689
696
text_size = self.base_tree.get_file_size(base_path, file_id)
690
697
text_sha1 = self.base_tree.get_file_sha1(base_path, file_id)
691
698
return text_size, text_sha1
785
792
"""Produce a file-like object with the patched version of a text"""
786
793
from breezy.patches import iter_patched
787
794
from breezy.iterablefile import IterableFile
795
if file_patch == b"":
789
796
return IterableFile(())
790
797
# string.splitlines(True) also splits on '\r', but the iter_patched code
791
798
# only expects to iterate over '\n' style lines