diff creation question

Eduard-Cristian Stefan alexandrul.ct at gmail.com
Wed Mar 16 08:57:02 CDT 2011


Hi,

Given the following code:

if a:
    b
else:
    c

when I place an outer if like this:

if extra:
    f
else:
    if a:
        b
    else:
        c

then I end up with a diff like this:

-        self._rev = ctx.rev()
-        self.clear()
-        self.annfile = wfile
-        if util.binary(fctx.data()):
-            self.setText(_('File is binary.\n'))
+
+        if fctx._filelog.rawsize(fctx.filerev()) > ctx._repo.maxdiff:
+            self.setText(_('File or diffs not displayed: ') + \
+                    _('File is larger than the specified max size.\n'))
         else:
-            self.setText(hglib.tounicode(fctx.data()))
-        if line:
-            self.setCursorPosition(int(line) - 1, 0)
-        self._updatelexer(fctx)
-        self._updatemarginwidth()
-        self.sourceChanged.emit(wfile, self._rev)
-        self._updateannotation()
+            self._rev = ctx.rev()
+            self.clear()
+            self.annfile = wfile
+            if util.binary(fctx.data()):
+                self.setText(_('File is binary.\n'))
+            else:
+                self.setText(hglib.tounicode(fctx.data()))

Is there a way to obtain a diff like this without adding a # at the
end of the else: line?
(for me at least this form is much easier to understand)

-        self._rev = ctx.rev()
-        self.clear()
-        self.annfile = wfile
-        if util.binary(fctx.data()):
-            self.setText(_('File is binary.\n'))
-        else:
-            self.setText(hglib.tounicode(fctx.data()))
+
+        if fctx._filelog.rawsize(fctx.filerev()) > ctx._repo.maxdiff:
+            self.setText(_('File or diffs not displayed: ') + \
+                    _('File is larger than the specified max size.\n'))
+        else: #
+            self._rev = ctx.rev()
+            self.clear()
+            self.annfile = wfile
+            if util.binary(fctx.data()):
+                self.setText(_('File is binary.\n'))
+            else:
+                self.setText(hglib.tounicode(fctx.data()))

Have a nice day,
  Eduard


More information about the Mercurial-devel mailing list