Good news and more good news!
First - all of the code related to WordPress itself and its repositories resides in version control system (Subversion). Among other things that makes publicly available sites with all code in plain sight:
One not so obvious result of that - if you can see it, so can our overlord Google. Basically you can google through that code quite successfully by adding modifier like
site:http://core.svn.wordpress.org/ to your query.
But that is not all. WordPress project also uses Trac. That is actually piece of software, not just mythical place for WP demigods to hang out.
Among other things trac has browser feature that interfaces with SVN and provides prettified, ajaxified and in other ways glorious human-friendly way to browse through code:
Note that it can take a long time to open root of browser for plugins and themes, because there are tons of either. It is usually faster to type in name of specific plugin/theme at end of URL (it will be same as in repository), for example http://themes.trac.wordpress.org/browser/hybrid
Also note that trac browser gives nice way to link to specific lines of code for reference, with number of line for an anchor http://themes.trac.wordpress.org/browser/hybrid/0.8/index.php#L13
In addition to wordpress.org theme repository, free themes for wordpress.com are available as public SVN repository at:
While development of WordPress is happening via SVN so far, GitHub mirror was created (first maintained by Mark Jaquith and later promoted to official status):
There is no official Mercurial mirror so far, but unofficial one is maintained by me at Bitbucket: