I am building the browser-based web development software at <http://gnymb.us>. Eventually we will have limited offline support, such that you can edit your files offline by leveraging localStorage, HTML5 databases, or Google Gears.

I am currently building in source control support for Subversion, Mercurial, and Git. This works great while the user is online. As you may know, Mercurial and Git allow us to work offline. One difficulty to offline support for the editor is that, because this software is browser-based, the user will not be able to utilize offline SCM features.

Would it be theoretically possible to bundle Mercurial or Git in a browser extension and then modify it to utilize hash-based localStorage or HTML5 databases rather than a file system hierarchy--without rewriting everything? I know Mercurial uses Python, so I'd want to use Python in the browser extension. I'm open to other solutions as well.