IDEA: other repository sync methods
Matt Mackall
mpm at selenic.com
Sat Jun 11 07:35:36 UTC 2005
On Sat, Jun 11, 2005 at 01:42:08AM -0400, Andrew Thompson wrote:
> I was thinking that it might be useful to have a non-http based pull
> mechanism. Digging in hg.py, I found that class remoterepository only
> needs a few tweaks to be able to support this.
>
> What I've done so far was easy, now I just have to figure out how to
> reimplement the client/server communications. I was thinking of using
> ssh to call a program that would accept a request and spit back a changeset.
My plan currently is to do http over other types of pipes.
The one I'm very close to implementing is the moral equivalent of:
ssh user at remotehost -L <rnd>:localhost:<rnd> 'cd <path>;hg serve -p
<rnd>' && hg pull http://localhost:<rnd>/
> First step patch attached.
>
> Please let me know if this interests anyone else.
> # HG changeset patch
> # User Andrew Thompson <andrewkt at aktzero.com>
> # Node ID ab2705c8e42bc2f572e2d316f52635d401825e84
> # Parent 273f6a01d18b3459bbb24b1f393ccfd71900cf0b
>
> Turn remoterepository into a base class. Create subclass httprepository using the do_cmds that was originally in remoterepository.
>
> --- a/mercurial/hg.py Fri Jun 10 22:10:07 2005
> +++ b/mercurial/hg.py Sat Jun 11 04:34:07 2005
> @@ -1223,12 +1223,7 @@
> self.ui = ui
>
> def do_cmd(self, cmd, **args):
> - self.ui.debug("sending %s command\n" % cmd)
> - q = {"cmd": cmd}
> - q.update(args)
> - qs = urllib.urlencode(q)
> - cu = "%s?%s" % (self.url, qs)
> - return urllib.urlopen(cu)
> + raise NotImplementedError, "must be implemented in subclass"
>
> def heads(self):
> d = self.do_cmd("heads").read()
> @@ -1272,11 +1267,20 @@
> yield zd.decompress(d)
> self.ui.note("%d bytes of data transfered\n" % bytes)
>
> +class httprepository(remoterepository):
> + def do_cmd(self, cmd, **args):
> + self.ui.debug("sending %s command\n" % cmd)
> + q = {"cmd": cmd}
> + q.update(args)
> + qs = urllib.urlencode(q)
> + cu = "%s?%s" % (self.url, qs)
> + return urllib.urlopen(cu)
> +
> def repository(ui, path=None, create=0):
> if path and path[:7] == "http://":
> - return remoterepository(ui, path)
> + return httprepository(ui, path)
> if path and path[:5] == "hg://":
> - return remoterepository(ui, path.replace("hg://", "http://"))
> + return httprepository(ui, path.replace("hg://", "http://"))
> if path and path[:11] == "old-http://":
> return localrepository(ui, path.replace("old-http://", "http://"))
> else:
Not bad, I'll think about it.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list