<div dir="ltr">Messed up a for loop in my shell, drop this one for now please.<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 12, 2014 at 7:58 PM, Augie Fackler <span dir="ltr"><<a href="mailto:raf@durin42.com" target="_blank">raf@durin42.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Augie Fackler <<a href="mailto:raf@durin42.com">raf@durin42.com</a>><br>
# Date 1380062977 14400<br>
#      Tue Sep 24 18:49:37 2013 -0400<br>
# Node ID c51e6e04d8c581e6d7109fb3a54a69121c12d7e5<br>
# Parent  1cd5bff45db28150d7c140be493fe851e6560f27<br>
WIP: lookaside clone extension<br>
<br>
diff --git a/hgext/lookaside.py b/hgext/lookaside.py<br>
new file mode 100644<br>
--- /dev/null<br>
+++ b/hgext/lookaside.py<br>
@@ -0,0 +1,53 @@<br>
+"""Hacky proof of concept for lookaside bundle.<br>
+<br>
+Right now this doesn't do anything clever about bundle generation or<br>
+distribution. Put a bundle file (generated with 'hg bundle --all' at a<br>
+URL that urllib2 can fetch, then put that url in<br>
+.hg/durin42-lookaside-location.<br>
+<br>
+This might mulch your data somehow. It's relatively untested, but it<br>
+proves the concept.<br>
+"""<br>
+<br>
+import shutil<br>
+import urllib2<br>
+<br>
+from mercurial import changegroup<br>
+from mercurial import extensions<br>
+from mercurial import wireproto<br>
+<br>
+def addcap(orig, *args, **kwargs):<br>
+    c = orig(*args, **kwargs)<br>
+    return c + ' x-durin42-lookaside'<br>
+<br>
+extensions.wrapfunction(wireproto, 'capabilities', addcap)<br>
+wireproto.commands['capabilities'] = wireproto.capabilities, ''<br>
+<br>
+def lookaside(repo, proto):<br>
+    try:<br>
+        with repo.opener('durin42-lookaside-location') as f:<br>
+            return f.read().strip()<br>
+    except IOError:<br>
+        return ''<br>
+<br>
+<br>
+wireproto.commands['x-durin42-lookaside-clone'] = lookaside, ''<br>
+<br>
+def reposetup(ui, repo):<br>
+    origcls = repo.__class__<br>
+<br>
+    class lookasiderepo(origcls):<br>
+<br>
+        def clone(self, remote, heads=[], stream=False):<br>
+            if not heads and remote.capable('x-durin42-lookaside'):<br>
+                url = remote._call('x-durin42-lookaside-clone')<br>
+                if url:<br>
+                    ui.debug('fetching lookaside bundle %s\n' % url)<br>
+                    # TODO: support resuming the bundle stream if a connection fails<br>
+                    self.addchangegroup(<br>
+                        changegroup.readbundle(urllib2.urlopen(url), 'lookaside bundle'),<br>
+                        'unbundle', 'bundle:lookaside bundle')<br>
+                return self.pull(remote, heads)<br>
+            return origcls.clone(self, remote, heads, stream=False)<br>
+<br>
+    repo.__class__ = lookasiderepo<br>
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@selenic.com">Mercurial-devel@selenic.com</a><br>
<a href="http://selenic.com/mailman/listinfo/mercurial-devel" target="_blank">http://selenic.com/mailman/listinfo/mercurial-devel</a><br>
</blockquote></div><br></div></div></div>