~garyvdm/qbzr/diff-images

« back to all changes in this revision

Viewing changes to lib/diffview.py

  • Committer: Gary van der Merwe
  • Date: 2008-07-17 20:58:25 UTC
  • Revision ID: garyvdm@gmail.com-20080717205825-sswhabyc3wbjrb6y
qdiff: Correct unidiff format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from PyQt4 import QtGui, QtCore
21
21
 
 
22
from bzrlib import timestamp
22
23
from bzrlib.plugins.qbzr.lib.i18n import gettext
23
24
from bzrlib.plugins.qbzr.lib.util import htmlencode
24
25
from bzrlib.plugins.qbzr.lib.util import (
25
26
    file_extension,
 
27
    format_timestamp,
26
28
    )
27
29
 
28
30
 
238
240
            cursor.insertBlock()
239
241
            if present[i]:
240
242
                cursor.insertText(self.lastModifiedLabel, self.metadataLabelFormat)
241
 
                cursor.insertText(" %s, " % dates[i], self.metadataFormat)
 
243
                cursor.insertText(" %s, " % format_timestamp(dates[i]), self.metadataFormat)
242
244
                cursor.insertText(self.statusLabel, self.metadataLabelFormat)
243
245
                cursor.insertText(" %s, " % gettext(status), self.metadataFormat)
244
246
                cursor.insertText(self.kindLabel, self.metadataLabelFormat)
454
456
                                                   gettext(kind[0] if kind[0] is not None else kind[1]),
455
457
                                                   paths[0] if paths[0] is not None else paths[1] ),
456
458
                                  self.monospacedHeaderFormat)
457
 
        self.cursor.insertText('--- %s %s\n' % (paths[0], dates[0]),
458
 
                                  self.monospacedBoldInsertFormat)
459
 
        self.cursor.insertText('+++ %s %s\n' % (paths[1], dates[1]),
460
 
                               self.monospacedBoldDeleteFormat)
 
459
        
 
460
        # GNU Patch uses the epoch date to detect files that are being added
 
461
        # or removed in a diff.
 
462
        EPOCH_DATE = '1970-01-01 00:00:00 +0000'
 
463
        for i in range(2):
 
464
            if present[i]:
 
465
                dates[i] = timestamp.format_patch_date(dates[i])
 
466
            else:
 
467
                paths[i] = paths[i+1%2]
 
468
                dates[i] = EPOCH_DATE
 
469
        
461
470
        if not binary:
 
471
            self.cursor.insertText('--- %s %s\n' % (paths[0], dates[0]),
 
472
                                      self.monospacedBoldInsertFormat)
 
473
            self.cursor.insertText('+++ %s %s\n' % (paths[1], dates[1]),
 
474
                                   self.monospacedBoldDeleteFormat)
462
475
            a = lines[0]
463
476
            b = lines[1]
464
477
            for i, group in enumerate(groups):
476
489
                        text = "".join("+" + l for l in b[j1:j2])
477
490
                        self.cursor.insertText(text, self.monospacedInsertFormat)
478
491
        else:
479
 
            pass
 
492
            self.cursor.insertText("Binary files %s %s and %s %s differ\n" % \
 
493
                                   (paths[0], dates[0], paths[1], dates[1]))
 
494
        self.cursor.insertText("\n")
480
495