Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sshrepo.py @ 2439:e8c4f3d3df8c
extend network protocol to stop clients from locking servers
now all repositories have capabilities slot, tuple with list of names.
if 'unbundle' capability present, repo supports push where client does
not need to lock server. repository classes that have unbundle capability
also have unbundle method.
implemented for ssh now, will be base for push over http.
unbundle protocol acts this way. server tells client what heads it
has during normal negotiate step. client starts unbundle by repeat
server's heads back to it. if server has new heads, abort immediately.
otherwise, transfer changes to server. once data transferred, server
locks and checks heads again. if heads same, changes can be added.
else someone else added heads, and server aborts.
if client wants to force server to add heads, sends special heads list of
'force'.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Thu, 15 Jun 2006 16:37:23 -0700 |
parents | a1cfe679192c |
children | cc1011a7ed09 |
comparison
equal
deleted
inserted
replaced
2436:f910b91dd912 | 2439:e8c4f3d3df8c |
---|---|
139 def changegroup(self, nodes, kind): | 139 def changegroup(self, nodes, kind): |
140 n = " ".join(map(hex, nodes)) | 140 n = " ".join(map(hex, nodes)) |
141 f = self.do_cmd("changegroup", roots=n) | 141 f = self.do_cmd("changegroup", roots=n) |
142 return self.pipei | 142 return self.pipei |
143 | 143 |
144 def unbundle(self, cg, heads, source): | |
145 d = self.call("unbundle", heads=' '.join(map(hex, heads))) | |
146 if d: | |
147 raise hg.RepoError(_("push refused: %s") % d) | |
148 | |
149 while 1: | |
150 d = cg.read(4096) | |
151 if not d: break | |
152 self.pipeo.write(str(len(d)) + '\n') | |
153 self.pipeo.write(d) | |
154 self.readerr() | |
155 | |
156 self.pipeo.write('0\n') | |
157 self.pipeo.flush() | |
158 | |
159 self.readerr() | |
160 d = self.pipei.readline() | |
161 if d != '\n': | |
162 return 1 | |
163 | |
164 l = int(self.pipei.readline()) | |
165 r = self.pipei.read(l) | |
166 if not r: | |
167 return 1 | |
168 return int(r) | |
169 | |
144 def addchangegroup(self, cg, source): | 170 def addchangegroup(self, cg, source): |
145 d = self.call("addchangegroup") | 171 d = self.call("addchangegroup") |
146 if d: | 172 if d: |
147 raise hg.RepoError(_("push refused: %s"), d) | 173 raise hg.RepoError(_("push refused: %s") % d) |
148 | |
149 while 1: | 174 while 1: |
150 d = cg.read(4096) | 175 d = cg.read(4096) |
151 if not d: break | 176 if not d: break |
152 self.pipeo.write(d) | 177 self.pipeo.write(d) |
153 self.readerr() | 178 self.readerr() |