# HG changeset patch # User Matt Mackall # Date 1120717437 28800 # Node ID 31cebba881a0bfcd5c2430066eb4f122bd2f187e # Parent 35f7adfefa69dad2c48d0988833179d472cb4a44 Add addchangegroup to the ssh protocol diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -923,6 +923,15 @@ def serve(ui, repo, **opts): out.flush() + elif cmd == "addchangegroup": + if not lock: + respond("not locked") + continue + respond("") + + r = repo.addchangegroup(fin) + respond("") + def openlog(opt, default): if opts[opt] and opts[opt] != '-': return open(opts[opt], 'w') else: return default diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1715,6 +1715,21 @@ class sshrepository: f = self.do_cmd("changegroup", roots=n) return self.pipei + def addchangegroup(self, cg): + d = self.call("addchangegroup") + if d: + raise RepoError("push refused: %s", d) + + while 1: + d = cg.read(4096) + if not d: break + self.pipeo.write(d) + + self.pipeo.flush() + + l = int(self.pipei.readline()) + return self.pipei.read(l) + def repository(ui, path=None, create=0): if path: if path.startswith("http://"):