comparison mercurial/localrepo.py @ 15585:a348739da8f0

addchangegroup: remove the lock argument on the addchangegroup methods This argument is no longer require. post lock release code is now handled with dedicated post release callback code in lock itself.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 28 Nov 2011 01:32:13 +0100
parents 9df9444e96ec
children 98ec09582f72
comparison
equal deleted inserted replaced
15584:9df9444e96ec 15585:a348739da8f0
1525 raise util.Abort(_("partial pull cannot be done because " 1525 raise util.Abort(_("partial pull cannot be done because "
1526 "other repository doesn't support " 1526 "other repository doesn't support "
1527 "changegroupsubset.")) 1527 "changegroupsubset."))
1528 else: 1528 else:
1529 cg = remote.changegroupsubset(fetch, heads, 'pull') 1529 cg = remote.changegroupsubset(fetch, heads, 'pull')
1530 result = self.addchangegroup(cg, 'pull', remote.url(), 1530 result = self.addchangegroup(cg, 'pull', remote.url())
1531 lock=lock)
1532 phases.advanceboundary(self, 0, common) 1531 phases.advanceboundary(self, 0, common)
1533 finally: 1532 finally:
1534 lock.release() 1533 lock.release()
1535 1534
1536 return result 1535 return result
1581 # ssh: return remote's addchangegroup() 1580 # ssh: return remote's addchangegroup()
1582 # http: return remote's addchangegroup() or 0 for error 1581 # http: return remote's addchangegroup() or 0 for error
1583 ret = remote.unbundle(cg, remote_heads, 'push') 1582 ret = remote.unbundle(cg, remote_heads, 'push')
1584 else: 1583 else:
1585 # we return an integer indicating remote head count change 1584 # we return an integer indicating remote head count change
1586 ret = remote.addchangegroup(cg, 'push', self.url(), 1585 ret = remote.addchangegroup(cg, 'push', self.url())
1587 lock=lock)
1588 # if we don't push, the common data is already useful 1586 # if we don't push, the common data is already useful
1589 # everything exchange is public for now 1587 # everything exchange is public for now
1590 phases.advanceboundary(self, 0, fut) 1588 phases.advanceboundary(self, 0, fut)
1591 finally: 1589 finally:
1592 locallock.release() 1590 locallock.release()
1847 if nodes: 1845 if nodes:
1848 self.hook('outgoing', node=hex(nodes[0]), source=source) 1846 self.hook('outgoing', node=hex(nodes[0]), source=source)
1849 1847
1850 return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN') 1848 return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
1851 1849
1852 def addchangegroup(self, source, srctype, url, emptyok=False, lock=None): 1850 def addchangegroup(self, source, srctype, url, emptyok=False):
1853 """Add the changegroup returned by source.read() to this repo. 1851 """Add the changegroup returned by source.read() to this repo.
1854 srctype is a string like 'push', 'pull', or 'unbundle'. url is 1852 srctype is a string like 'push', 'pull', or 'unbundle'. url is
1855 the URL of the repo where this changegroup is coming from. 1853 the URL of the repo where this changegroup is coming from.
1856 If lock is not None, the function takes ownership of the lock
1857 and releases it after the changegroup is added.
1858 1854
1859 Return an integer summarizing the change to this repo: 1855 Return an integer summarizing the change to this repo:
1860 - nothing changed or no source: 0 1856 - nothing changed or no source: 0
1861 - more heads than before: 1+added heads (2..n) 1857 - more heads than before: 1+added heads (2..n)
1862 - fewer heads than before: -1-removed heads (-2..-n) 1858 - fewer heads than before: -1-removed heads (-2..-n)
2017 url=url) 2013 url=url)
2018 self._postrelease(postaddchangegroup) 2014 self._postrelease(postaddchangegroup)
2019 2015
2020 finally: 2016 finally:
2021 tr.release() 2017 tr.release()
2022 if lock:
2023 lock.release()
2024 # never return 0 here: 2018 # never return 0 here:
2025 if dh < 0: 2019 if dh < 0:
2026 return dh - 1 2020 return dh - 1
2027 else: 2021 else:
2028 return dh + 1 2022 return dh + 1