Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 11598:5be142109ed4
localrepo: remove push_{unbundle,addchangegroup}(), factor it inside push()
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 16 Jul 2010 13:38:33 +0200 |
parents | d3c3e2fdeb0c |
children | 2eab5025f804 |
comparison
equal
deleted
inserted
replaced
11597:9141d2c9e5a5 | 11598:5be142109ed4 |
---|---|
1221 # repo (local filesystem, old ssh servers). | 1221 # repo (local filesystem, old ssh servers). |
1222 # | 1222 # |
1223 # unbundle assumes local user cannot lock remote repo (new ssh | 1223 # unbundle assumes local user cannot lock remote repo (new ssh |
1224 # servers, http servers). | 1224 # servers, http servers). |
1225 | 1225 |
1226 if remote.capable('unbundle'): | 1226 lock = None |
1227 return self.push_unbundle(remote, force, revs, newbranch) | 1227 unbundle = remote.capable('unbundle') |
1228 return self.push_addchangegroup(remote, force, revs, newbranch) | 1228 if not unbundle: |
1229 | 1229 lock = remote.lock() |
1230 def push_addchangegroup(self, remote, force, revs, newbranch): | |
1231 '''Push a changegroup by locking the remote and sending the | |
1232 addchangegroup command to it. Used for local and old SSH repos. | |
1233 Return an integer: see push(). | |
1234 ''' | |
1235 lock = remote.lock() | |
1236 try: | 1230 try: |
1237 ret = discovery.prepush(self, remote, force, revs, newbranch) | 1231 ret = discovery.prepush(self, remote, force, revs, newbranch) |
1238 if ret[0] is not None: | 1232 if ret[0] is None: |
1239 cg, remote_heads = ret | 1233 # and here we return 0 for "nothing to push" or 1 for |
1234 # "something to push but I refuse" | |
1235 return ret[1] | |
1236 | |
1237 cg, remote_heads = ret | |
1238 if unbundle: | |
1239 # local repo finds heads on server, finds out what revs it must | |
1240 # push. once revs transferred, if server finds it has | |
1241 # different heads (someone else won commit/push race), server | |
1242 # aborts. | |
1243 if force: | |
1244 remote_heads = ['force'] | |
1245 # ssh: return remote's addchangegroup() | |
1246 # http: return remote's addchangegroup() or 0 for error | |
1247 return remote.unbundle(cg, remote_heads, 'push') | |
1248 else: | |
1240 # we return an integer indicating remote head count change | 1249 # we return an integer indicating remote head count change |
1241 return remote.addchangegroup(cg, 'push', self.url(), lock=lock) | 1250 return remote.addchangegroup(cg, 'push', self.url(), lock=lock) |
1242 # and here we return 0 for "nothing to push" or 1 for | |
1243 # "something to push but I refuse" | |
1244 return ret[1] | |
1245 finally: | 1251 finally: |
1246 lock.release() | 1252 if lock is not None: |
1247 | 1253 lock.release() |
1248 def push_unbundle(self, remote, force, revs, newbranch): | |
1249 '''Push a changegroup by unbundling it on the remote. Used for new | |
1250 SSH and HTTP repos. Return an integer: see push().''' | |
1251 # local repo finds heads on server, finds out what revs it | |
1252 # must push. once revs transferred, if server finds it has | |
1253 # different heads (someone else won commit/push race), server | |
1254 # aborts. | |
1255 | |
1256 ret = discovery.prepush(self, remote, force, revs, newbranch) | |
1257 if ret[0] is not None: | |
1258 cg, remote_heads = ret | |
1259 if force: | |
1260 remote_heads = ['force'] | |
1261 # ssh: return remote's addchangegroup() | |
1262 # http: return remote's addchangegroup() or 0 for error | |
1263 return remote.unbundle(cg, remote_heads, 'push') | |
1264 # as in push_addchangegroup() | |
1265 return ret[1] | |
1266 | 1254 |
1267 def changegroupinfo(self, nodes, source): | 1255 def changegroupinfo(self, nodes, source): |
1268 if self.ui.verbose or source == 'bundle': | 1256 if self.ui.verbose or source == 'bundle': |
1269 self.ui.status(_("%d changesets found\n") % len(nodes)) | 1257 self.ui.status(_("%d changesets found\n") % len(nodes)) |
1270 if self.ui.debugflag: | 1258 if self.ui.debugflag: |