1299 tmp = discovery.findcommonincoming(self, remote, heads=heads, |
1299 tmp = discovery.findcommonincoming(self, remote, heads=heads, |
1300 force=force) |
1300 force=force) |
1301 common, fetch, rheads = tmp |
1301 common, fetch, rheads = tmp |
1302 if not fetch: |
1302 if not fetch: |
1303 self.ui.status(_("no changes found\n")) |
1303 self.ui.status(_("no changes found\n")) |
1304 return 0 |
1304 result = 0 |
1305 |
|
1306 if heads is None and fetch == [nullid]: |
|
1307 self.ui.status(_("requesting all changes\n")) |
|
1308 elif heads is None and remote.capable('changegroupsubset'): |
|
1309 # issue1320, avoid a race if remote changed after discovery |
|
1310 heads = rheads |
|
1311 |
|
1312 if heads is None: |
|
1313 cg = remote.changegroup(fetch, 'pull') |
|
1314 else: |
1305 else: |
1315 if not remote.capable('changegroupsubset'): |
1306 if heads is None and fetch == [nullid]: |
|
1307 self.ui.status(_("requesting all changes\n")) |
|
1308 elif heads is None and remote.capable('changegroupsubset'): |
|
1309 # issue1320, avoid a race if remote changed after discovery |
|
1310 heads = rheads |
|
1311 |
|
1312 if heads is None: |
|
1313 cg = remote.changegroup(fetch, 'pull') |
|
1314 elif not remote.capable('changegroupsubset'): |
1316 raise util.Abort(_("partial pull cannot be done because " |
1315 raise util.Abort(_("partial pull cannot be done because " |
1317 "other repository doesn't support " |
1316 "other repository doesn't support " |
1318 "changegroupsubset.")) |
1317 "changegroupsubset.")) |
1319 cg = remote.changegroupsubset(fetch, heads, 'pull') |
1318 else: |
1320 return self.addchangegroup(cg, 'pull', remote.url(), lock=lock) |
1319 cg = remote.changegroupsubset(fetch, heads, 'pull') |
|
1320 result = self.addchangegroup(cg, 'pull', remote.url(), |
|
1321 lock=lock) |
1321 finally: |
1322 finally: |
1322 lock.release() |
1323 lock.release() |
|
1324 |
|
1325 self.ui.debug("checking for updated bookmarks\n") |
|
1326 rb = remote.listkeys('bookmarks') |
|
1327 changed = False |
|
1328 for k in rb.keys(): |
|
1329 if k in self._bookmarks: |
|
1330 nr, nl = rb[k], self._bookmarks[k] |
|
1331 if nr in self: |
|
1332 cr = self[nr] |
|
1333 cl = self[nl] |
|
1334 if cl.rev() >= cr.rev(): |
|
1335 continue |
|
1336 if cr in cl.descendants(): |
|
1337 self._bookmarks[k] = cr.node() |
|
1338 changed = True |
|
1339 self.ui.status(_("updating bookmark %s\n") % k) |
|
1340 else: |
|
1341 self.ui.warn(_("not updating divergent" |
|
1342 " bookmark %s\n") % k) |
|
1343 if changed: |
|
1344 bookmarks.write(self) |
|
1345 |
|
1346 return result |
1323 |
1347 |
1324 def checkpush(self, force, revs): |
1348 def checkpush(self, force, revs): |
1325 """Extensions can override this function if additional checks have |
1349 """Extensions can override this function if additional checks have |
1326 to be performed before pushing, or call it if they override push |
1350 to be performed before pushing, or call it if they override push |
1327 command. |
1351 command. |
1348 lock = None |
1372 lock = None |
1349 unbundle = remote.capable('unbundle') |
1373 unbundle = remote.capable('unbundle') |
1350 if not unbundle: |
1374 if not unbundle: |
1351 lock = remote.lock() |
1375 lock = remote.lock() |
1352 try: |
1376 try: |
1353 ret = discovery.prepush(self, remote, force, revs, newbranch) |
1377 cg, remote_heads = discovery.prepush(self, remote, force, revs, |
1354 if ret[0] is None: |
1378 newbranch) |
1355 # and here we return 0 for "nothing to push" or 1 for |
1379 ret = remote_heads |
1356 # "something to push but I refuse" |
1380 if cg is not None: |
1357 return ret[1] |
1381 if unbundle: |
1358 |
1382 # local repo finds heads on server, finds out what |
1359 cg, remote_heads = ret |
1383 # revs it must push. once revs transferred, if server |
1360 if unbundle: |
1384 # finds it has different heads (someone else won |
1361 # local repo finds heads on server, finds out what revs it must |
1385 # commit/push race), server aborts. |
1362 # push. once revs transferred, if server finds it has |
1386 if force: |
1363 # different heads (someone else won commit/push race), server |
1387 remote_heads = ['force'] |
1364 # aborts. |
1388 # ssh: return remote's addchangegroup() |
1365 if force: |
1389 # http: return remote's addchangegroup() or 0 for error |
1366 remote_heads = ['force'] |
1390 ret = remote.unbundle(cg, remote_heads, 'push') |
1367 # ssh: return remote's addchangegroup() |
1391 else: |
1368 # http: return remote's addchangegroup() or 0 for error |
1392 # we return an integer indicating remote head count change |
1369 return remote.unbundle(cg, remote_heads, 'push') |
1393 ret = remote.addchangegroup(cg, 'push', self.url(), |
1370 else: |
1394 lock=lock) |
1371 # we return an integer indicating remote head count change |
|
1372 return remote.addchangegroup(cg, 'push', self.url(), lock=lock) |
|
1373 finally: |
1395 finally: |
1374 if lock is not None: |
1396 if lock is not None: |
1375 lock.release() |
1397 lock.release() |
|
1398 |
|
1399 self.ui.debug("checking for updated bookmarks\n") |
|
1400 rb = remote.listkeys('bookmarks') |
|
1401 for k in rb.keys(): |
|
1402 if k in self._bookmarks: |
|
1403 nr, nl = rb[k], hex(self._bookmarks[k]) |
|
1404 if nr in self: |
|
1405 cr = self[nr] |
|
1406 cl = self[nl] |
|
1407 if cl in cr.descendants(): |
|
1408 r = remote.pushkey('bookmarks', k, nr, nl) |
|
1409 if r: |
|
1410 self.ui.status(_("updating bookmark %s\n") % k) |
|
1411 else: |
|
1412 self.ui.warn(_('updating bookmark %s' |
|
1413 ' failed!\n') % k) |
|
1414 |
|
1415 return ret |
1376 |
1416 |
1377 def changegroupinfo(self, nodes, source): |
1417 def changegroupinfo(self, nodes, source): |
1378 if self.ui.verbose or source == 'bundle': |
1418 if self.ui.verbose or source == 'bundle': |
1379 self.ui.status(_("%d changesets found\n") % len(nodes)) |
1419 self.ui.status(_("%d changesets found\n") % len(nodes)) |
1380 if self.ui.debugflag: |
1420 if self.ui.debugflag: |