equal
deleted
inserted
replaced
828 def __init__(self, header): |
828 def __init__(self, header): |
829 self.header = header |
829 self.header = header |
830 self.hunks = [] |
830 self.hunks = [] |
831 |
831 |
832 def binary(self): |
832 def binary(self): |
833 return util.any(h.startswith('index ') for h in self.header) |
833 return any(h.startswith('index ') for h in self.header) |
834 |
834 |
835 def pretty(self, fp): |
835 def pretty(self, fp): |
836 for h in self.header: |
836 for h in self.header: |
837 if h.startswith('index '): |
837 if h.startswith('index '): |
838 fp.write(_('this modifies a binary file (all or nothing)\n')) |
838 fp.write(_('this modifies a binary file (all or nothing)\n')) |
851 |
851 |
852 def write(self, fp): |
852 def write(self, fp): |
853 fp.write(''.join(self.header)) |
853 fp.write(''.join(self.header)) |
854 |
854 |
855 def allhunks(self): |
855 def allhunks(self): |
856 return util.any(self.allhunks_re.match(h) for h in self.header) |
856 return any(self.allhunks_re.match(h) for h in self.header) |
857 |
857 |
858 def files(self): |
858 def files(self): |
859 match = self.diffgit_re.match(self.header[0]) |
859 match = self.diffgit_re.match(self.header[0]) |
860 if match: |
860 if match: |
861 fromfile, tofile = match.groups() |
861 fromfile, tofile = match.groups() |
870 |
870 |
871 def __repr__(self): |
871 def __repr__(self): |
872 return '<header %s>' % (' '.join(map(repr, self.files()))) |
872 return '<header %s>' % (' '.join(map(repr, self.files()))) |
873 |
873 |
874 def isnewfile(self): |
874 def isnewfile(self): |
875 return util.any(self.newfile_re.match(h) for h in self.header) |
875 return any(self.newfile_re.match(h) for h in self.header) |
876 |
876 |
877 def special(self): |
877 def special(self): |
878 # Special files are shown only at the header level and not at the hunk |
878 # Special files are shown only at the header level and not at the hunk |
879 # level for example a file that has been deleted is a special file. |
879 # level for example a file that has been deleted is a special file. |
880 # The user cannot change the content of the operation, in the case of |
880 # The user cannot change the content of the operation, in the case of |
883 # Newly added files are special if they are empty, they are not special |
883 # Newly added files are special if they are empty, they are not special |
884 # if they have some content as we want to be able to change it |
884 # if they have some content as we want to be able to change it |
885 nocontent = len(self.header) == 2 |
885 nocontent = len(self.header) == 2 |
886 emptynewfile = self.isnewfile() and nocontent |
886 emptynewfile = self.isnewfile() and nocontent |
887 return emptynewfile or \ |
887 return emptynewfile or \ |
888 util.any(self.special_re.match(h) for h in self.header) |
888 any(self.special_re.match(h) for h in self.header) |
889 |
889 |
890 class recordhunk(object): |
890 class recordhunk(object): |
891 """patch hunk |
891 """patch hunk |
892 |
892 |
893 XXX shouldn't we merge this with the other hunk class? |
893 XXX shouldn't we merge this with the other hunk class? |