/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 bzrlib/diff.py

  • Committer: Martin Pool
  • Date: 2009-06-05 23:21:51 UTC
  • mfrom: (4415 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4416.
  • Revision ID: mbp@sourcefrog.net-20090605232151-luwmyyl95siraqyz
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import difflib
18
18
import os
41
41
""")
42
42
 
43
43
from bzrlib.symbol_versioning import (
44
 
        deprecated_function,
45
 
        one_three
46
 
        )
 
44
    deprecated_function,
 
45
    )
47
46
from bzrlib.trace import mutter, note, warning
48
47
 
49
48
 
368
367
            if view_files:
369
368
                specific_files = view_files
370
369
                view_str = views.view_display_str(view_files)
371
 
                note("*** ignoring files outside view: %s" % view_str)
 
370
                note("*** Ignoring files outside view. View is %s" % view_str)
372
371
 
373
372
    # Get extra trees that ought to be searched for file-ids
374
373
    extra_trees = None
441
440
    return timestamp.format_patch_date(mtime)
442
441
 
443
442
 
444
 
@deprecated_function(one_three)
445
 
def get_prop_change(meta_modified):
446
 
    if meta_modified:
447
 
        return " (properties changed)"
448
 
    else:
449
 
        return  ""
450
 
 
451
443
def get_executable_change(old_is_x, new_is_x):
452
444
    descr = { True:"+x", False:"-x", None:"??" }
453
445
    if old_is_x != new_is_x:
628
620
            return self.CANNOT_DIFF
629
621
        from_label = '%s%s\t%s' % (self.old_label, old_path, old_date)
630
622
        to_label = '%s%s\t%s' % (self.new_label, new_path, new_date)
631
 
        return self.diff_text(from_file_id, to_file_id, from_label, to_label)
 
623
        return self.diff_text(from_file_id, to_file_id, from_label, to_label,
 
624
            old_path, new_path)
632
625
 
633
 
    def diff_text(self, from_file_id, to_file_id, from_label, to_label):
 
626
    def diff_text(self, from_file_id, to_file_id, from_label, to_label,
 
627
        from_path=None, to_path=None):
634
628
        """Diff the content of given files in two trees
635
629
 
636
630
        :param from_file_id: The id of the file in the from tree.  If None,
638
632
        :param to_file_id: The id of the file in the to tree.  This may refer
639
633
            to a different file from from_file_id.  If None,
640
634
            the file is not present in the to tree.
 
635
        :param from_path: The path in the from tree or None if unknown.
 
636
        :param to_path: The path in the to tree or None if unknown.
641
637
        """
642
 
        def _get_text(tree, file_id):
 
638
        def _get_text(tree, file_id, path):
643
639
            if file_id is not None:
644
 
                return tree.get_file(file_id).readlines()
 
640
                return tree.get_file(file_id, path).readlines()
645
641
            else:
646
642
                return []
647
643
        try:
648
 
            from_text = _get_text(self.old_tree, from_file_id)
649
 
            to_text = _get_text(self.new_tree, to_file_id)
 
644
            from_text = _get_text(self.old_tree, from_file_id, from_path)
 
645
            to_text = _get_text(self.new_tree, to_file_id, to_path)
650
646
            self.text_differ(from_label, from_text, to_label, to_text,
651
647
                             self.to_file)
652
648
        except errors.BinaryFile:
739
735
        return old_disk_path, new_disk_path
740
736
 
741
737
    def finish(self):
742
 
        osutils.rmtree(self._root)
 
738
        try:
 
739
            osutils.rmtree(self._root)
 
740
        except OSError, e:
 
741
            if e.errno != errno.ENOENT:
 
742
                mutter("The temporary directory \"%s\" was not "
 
743
                        "cleanly removed: %s." % (self._root, e))
743
744
 
744
745
    def diff(self, file_id, old_path, new_path, old_kind, new_kind):
745
746
        if (old_kind, new_kind) != ('file', 'file'):
890
891
                self.to_file.write("=== modified %s '%s'%s\n" % (kind[0],
891
892
                                   newpath_encoded, prop_str))
892
893
            if changed_content:
893
 
                self.diff(file_id, oldpath, newpath)
 
894
                self._diff(file_id, oldpath, newpath, kind[0], kind[1])
894
895
                has_changes = 1
895
896
            if renamed:
896
897
                has_changes = 1
911
912
            new_kind = self.new_tree.kind(file_id)
912
913
        except (errors.NoSuchId, errors.NoSuchFile):
913
914
            new_kind = None
914
 
 
 
915
        self._diff(file_id, old_path, new_path, old_kind, new_kind)
 
916
 
 
917
 
 
918
    def _diff(self, file_id, old_path, new_path, old_kind, new_kind):
915
919
        result = DiffPath._diff_many(self.differs, file_id, old_path,
916
920
                                       new_path, old_kind, new_kind)
917
921
        if result is DiffPath.CANNOT_DIFF: