Cool Mercurial Bundles

Although OpenJDK is mostly in open source state but there are still some code repositories closed. When I work from home and need to update these repositories, I'll have to connect to the Oracle VPN to access them. I always hesitate to use VPN at home because I won't be able to see other machines on the LAN (especially, VirtualBox guests using this machine as the host) and I don't like accessing the Internet using the Oracle proxy servers. My solution is to create a VirtualBox guest for VPN exclusively.

But then I see a problem, there is a VirtualBox bug saying that symlinks in a shared folder shows incorrectly inside the guest. Now I share the OpenJDK forest in read-write mode to the guest, when trying to run hg pull -R jdk/src/closed inside the guest, it would complain

abort: Is a directory: /mnt/root/openjdk7/jdk/src/closed/.hg/wlock
This is bad.

So I go take a look at the Mercurial commands and notice this cool feature: bundles. A bundle looks like a code repository as a single file, which can contain the whole history or only part of it. Now in the guest I would call

hg inc -R jdk/src/closed --bundle jsc
to create a bundle file to contain all incoming changesets of the jdk/src/closed repo. Note that there is no problem creating a normal file from within the guest in a shared folder. Then I can go back to the host machine, and call this
hg fetch -R jdk/src/closed bundle://jsc
Cool, a bundle-schemed URI. In fact, I can now make the shared folder as read-only, and create another another smaller read-write shared folder only for file transmission from guest to host. Mecurial has dedicated commands like bundle and unbundle to deal with bundles, but I'm not eager to look into their details now.

Something else to say, I wrap the calls into a script, and it's a single script that can be called on both guest and host. In fact, this script does not perform any real mercurial/file actions, all it does is to iterate thru repository names and call echo to output command lines on the screen (plus #comments). I often write scripts in this way so that I can take a second look at the output commands for safety. After making sure they are OK I can simply copy and paste (drag thru and middle-click) lines I want to run to execute them. In this case, I run the "hg inc" lines on the guest and "hg fetch" lines on the host.

Comments:

Yes, bundles have a lot of potential. I move changesets among the repos on my laptop and the repos in the internal network in much the same fashion. Someday I'd like to see a code review workflow based on bundles instead of on webrev.

Posted by Stuart Marks on March 14, 2011 at 09:33 PM CST #

a code review only needs a single changeset. btw, have you seen my http://hgrev.appspot.com ?

Posted by Weijun on March 15, 2011 at 04:39 AM CST #

Just 'hg fetch -R jdk/src/closed jsc' ought to work - i.e. Mercurial seems smart enough to figure out that a "remote repository location" which is actually a bundle file should be read as a bundle file.

Really advanced usage is a special scheme that lets you combine a regular repo with an added bundle, but this is rarely needed.

Posted by Jesse Glick on March 24, 2011 at 03:01 PM CST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blog has a comments managing system that requires me to approve each comment manually. Please do not re-post and I will reply it (if I have an answer) when I get pinged.

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today