/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/diff.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
import contextlib
18
20
import difflib
19
21
import os
731
733
            new_date = self.EPOCH_DATE
732
734
        else:
733
735
            return self.CANNOT_DIFF
734
 
        from_label = '%s%s\t%s' % (
735
 
            self.old_label, old_path or new_path, old_date)
736
 
        to_label = '%s%s\t%s' % (
737
 
            self.new_label, new_path or old_path, new_date)
 
736
        from_label = '%s%s\t%s' % (self.old_label, old_path,
 
737
                                   old_date)
 
738
        to_label = '%s%s\t%s' % (self.new_label, new_path,
 
739
                                 new_date)
738
740
        return self.diff_text(old_path, new_path, from_label, to_label)
739
741
 
740
742
    def diff_text(self, from_path, to_path, from_label, to_label):
762
764
        except errors.BinaryFile:
763
765
            self.to_file.write(
764
766
                ("Binary files %s%s and %s%s differ\n" %
765
 
                 (self.old_label, from_path or to_path,
766
 
                  self.new_label, to_path or from_path)
767
 
                 ).encode(self.path_encoding, 'replace'))
 
767
                 (self.old_label, from_path, self.new_label, to_path)).encode(self.path_encoding, 'replace'))
768
768
        return self.CHANGED
769
769
 
770
770
 
1054
1054
                    'supported on this filesystem.' % (change.path[0],))
1055
1055
                continue
1056
1056
            oldpath, newpath = change.path
1057
 
            oldpath_encoded = get_encoded_path(oldpath)
1058
 
            newpath_encoded = get_encoded_path(newpath)
 
1057
            oldpath_encoded = get_encoded_path(change.path[0])
 
1058
            newpath_encoded = get_encoded_path(change.path[1])
1059
1059
            old_present = (change.kind[0] is not None and change.versioned[0])
1060
1060
            new_present = (change.kind[1] is not None and change.versioned[1])
1061
1061
            executable = change.executable
1075
1075
            if (old_present, new_present) == (True, False):
1076
1076
                self.to_file.write(b"=== removed %s '%s'\n" %
1077
1077
                                   (kind[0].encode('ascii'), oldpath_encoded))
 
1078
                newpath = oldpath
1078
1079
            elif (old_present, new_present) == (False, True):
1079
1080
                self.to_file.write(b"=== added %s '%s'\n" %
1080
1081
                                   (kind[1].encode('ascii'), newpath_encoded))
 
1082
                oldpath = newpath
1081
1083
            elif renamed:
1082
1084
                self.to_file.write(b"=== renamed %s '%s' => '%s'%s\n" %
1083
1085
                                   (kind[0].encode('ascii'), oldpath_encoded, newpath_encoded, prop_str))