comparison mercurial/changegroup.py @ 32930:af31d531dda0

changegroup: let callers pass in transaction to apply() (API) I think passing in the transaction makes it a little clearer and more consistent with bundle2.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 15 Jun 2017 22:46:38 -0700
parents 038bfc384271
children b08431e1b062
comparison
equal deleted inserted replaced
32929:d11e2343762b 32930:af31d531dda0
254 self.manifestheader() 254 self.manifestheader()
255 repo.manifestlog._revlog.addgroup(self, revmap, trp) 255 repo.manifestlog._revlog.addgroup(self, revmap, trp)
256 repo.ui.progress(_('manifests'), None) 256 repo.ui.progress(_('manifests'), None)
257 self.callback = None 257 self.callback = None
258 258
259 def apply(self, repo, srctype, url, emptyok=False, 259 def apply(self, repo, tr, srctype, url, emptyok=False,
260 targetphase=phases.draft, expectedtotal=None): 260 targetphase=phases.draft, expectedtotal=None):
261 """Add the changegroup returned by source.read() to this repo. 261 """Add the changegroup returned by source.read() to this repo.
262 srctype is a string like 'push', 'pull', or 'unbundle'. url is 262 srctype is a string like 'push', 'pull', or 'unbundle'. url is
263 the URL of the repo where this changegroup is coming from. 263 the URL of the repo where this changegroup is coming from.
264 264
277 return cl.rev(x) 277 return cl.rev(x)
278 278
279 changesets = files = revisions = 0 279 changesets = files = revisions = 0
280 280
281 try: 281 try:
282 with repo.transaction("\n".join([srctype, 282 if True:
283 util.hidepassword(url)])) as tr: 283 # The transaction may already carry source information. In this
284 # The transaction could have been created before and already 284 # case we use the top level data. We overwrite the argument
285 # carries source information. In this case we use the top 285 # because we need to use the top level value (if they exist)
286 # level data. We overwrite the argument because we need to use 286 # in this function.
287 # the top level value (if they exist) in this function.
288 srctype = tr.hookargs.setdefault('source', srctype) 287 srctype = tr.hookargs.setdefault('source', srctype)
289 url = tr.hookargs.setdefault('url', url) 288 url = tr.hookargs.setdefault('url', url)
290 repo.hook('prechangegroup', throw=True, **tr.hookargs) 289 repo.hook('prechangegroup', throw=True, **tr.hookargs)
291 290
292 # write changelog data to temp files so concurrent readers 291 # write changelog data to temp files so concurrent readers