Wednesday, December 29, 2010

Mercurial goes down in my list comparing to git

For a long time a valued Merurial not less, if not more, than git. Well, until I started to use it for more than just local tracking of files.

So, you have working copy changes, do hg pull/update which conflicts with them. You're told:

use 'hg resolve' to retry unresolved file merges

So you edit the file to resolve conflicts, then run

hg resolve hg.txt

Right? No, because you get very strange output:


merging foo.txt
warning: conflicts during merge.
merging foo.txt failed!


And see that all your careful edits are blown away and file is back to conflicted state. Now you read man, to find out that you need to use -m option to mark file as resolved.

The question is: how can someone design such a UI that not only requires additional option for the most common operation, but also by default silently clobber users changes, which may be result of an hour or so of work? They say that git's interface is not that good (I used to think that too). Just look around.

Thursday, December 16, 2010

Saturday, December 4, 2010

WebKitGtk vs QtWebKit

Comparing functionality and features of Qt (QtWebKit) and GTK+ (WebKitGtk) ports of WebKit.

Scrolling Performance

It seems that as of 1.2.5, WebKitGtk has one fairly big usability issue comparing to QtWebKit: it has very slow (and high CPU usage) scrolling on some pages/sites. All browsers based on WebKitGit are slow on those pages, while all browsers based on QtWebKit are OK there, so that's indeed a framework issue.

Midori FAQ has an entry on this ("Scrolling on website xyz is very slow").

It turns out that this can be result of multiple bugs:
WebKitGtk 1.3.7 status: Seems to be mostly fixed, all pages from below show good scrolling performance, though ones with image backgrounds show not as smooth scrolling (but that's yet another issue).

Examples:

Related:
  • http://blogs.igalia.com/alex/2010/09/17/rendering-shadows-and-tiles/
  • https://bbs.archlinux.org/viewtopic.php?pid=860692 

Image Scaling Quality

On the other hand, when scaling images, QtWebKit 4.6.3 appears to (by default?) use nearest neighbour filter, while WebKitGtk uses smooth bilinear filter. In Qt 4.7.1 it's the same.

But it seems to be fixed in the latest QtWebKit, this post tells:
[01 Sep 2010] Re: no interpolation after scale image to a larger size?

This was fixed here:
[Qt] Enable smooth pixmap transforms by default

The change was too late for Qt 4.7 but will be part of the upcoming
QtWebKit 2.1 release.

As of now, QtWebKit 2.1 is still not released.

Btw, according to the patch, nearest-neigh filter is used exactly by default, it can be changed by client. Need to try that in Arora. - Well, not in Qt 4.6.3, there GraphicsContext::setImageInterpolationQuality() is empty.

Thursday, December 2, 2010

Bash Braindeadness: Logical Connectives

UPDATE: As was pointed out on Ubuntuforums, "true -a false" on its own is running command "true" with parameters "-a" and "false", and "true" deliberately silently ignores its arguments. So again, "-a" & "-o" have logical connective semantics only as arguments to test/[. The below is stylistic feature ;-).

So I've been debugging a shellscript which didn't do what it should have been (not mine). Everyone likes using kewl idioms, so there was:

check val1 -a check val2 && do_something


Well, just gotta choose right language. Because in bash:

$ false -a false; echo $?
1
$ false -a true; echo $?
1
$ true -a false; echo $?
0
$ true -a true; echo $?
0


Wanna more? Easily:

$ false -o false; echo $?
1
$ false -o true; echo $?
1
$ true -o false; echo $?
0
$ true -o true; echo $?
0


So, from looks of these examples, in bash, both logical AND and OR have the same truth table, and semantics of "return first argument". Now, wazzup?

Googling surprisingly doesn't give good hits - obviously, because you have troubles searching for "-a", "-o", "and" or "or". Googling for "logical and in bash" gives one good hit on 1st page - http://ubuntuforums.org/showthread.php?t=754338. There, some guy wonders why both [ 0 -a 0 ] and [ 0 -a 1 ] are true, but not really being answered.

So, by reading man bash a really careful reader may notice that -a and -o (in a sense of binary logical connectives) are defined within description of test aka [ command. The description also says "Expressions are composed of the primaries described above under CONDITIONAL EXPRESSIONS." And CONDITIONAL EXPRESSIONS list only checks like -a and comparisons, and no thing like shell commands, integer or string literals, etc. So, careful deductive reader might pose hypothesis:

Logical -a, -o are defined only within scope of test aka [ command. And there, they must apply only to legitime boolean expressions - checks and comparisons. Usage of -a, -o in any other context silently produces undefined result.

Of course, any decent language would give error if some operator is used in wrong context. But Unix shell in general, and Bash in particular, have always been special. So, be it historically preserved bug, or GNU Bash own invention, the end result is the same - you don't need the Brainfuck language or other alike novelties to have some fun - with bash, you can get unexpected results right at your fingertips, at any Linux workstaion around the world.

USB gives a lesson in physics

With a recently bought mouse:


[176149.256699] hub 3-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
[176149.256706] hub 3-0:1.0: over-current change on port 1
[176149.357643] usb 3-1: USB disconnect, address 3
[176149.569692] usb 3-1: new low speed USB device using uhci_hcd and address 4
[176149.734362] usb 3-1: New USB device found, idVendor=093a, idProduct=2510
[176149.734371] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[176149.734377] usb 3-1: Product: USB OPTICAL MOUSE


Googling shows affected are many, yet few good explanations are provided. This good post explains that it is indeed caused by an electrostatic discharge (ESD), which, kernel can be agreed with, may be seen as an extreme case of electo-magnetic interference (EMI).