comparison hgext/largefiles/reposetup.py @ 21044:52a5eabf1f2f

largefiles: reuse "findcommonoutgoing()" result at "hg push" Before this patch, "hg push" invokes "findcommonoutgoing()" not only in "exchange.push()" but also in "lfilesrepo.push()", when largefiles is enabled. The latter is redundant. This patch registers own "prepushoutgoinghook" function into "prepushoutgoinghooks" of "localrepository" to reuse "findcommonoutgoing()" result. "prepushoutgoinghook" omits "changelog.nodesbetween()" invocation, because "findcommonoutgoing()" invocation in "exchange.push()" takes "onlyheads" argument and it considers "nodesbetween()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 16 Apr 2014 00:37:24 +0900
parents 32b3331f18eb
children 2fb3c1c0b4ef
comparison
equal deleted inserted replaced
21043:6c383c871fdb 21044:52a5eabf1f2f
8 8
9 '''setup for largefiles repositories: reposetup''' 9 '''setup for largefiles repositories: reposetup'''
10 import copy 10 import copy
11 import os 11 import os
12 12
13 from mercurial import error, manifest, match as match_, util, discovery 13 from mercurial import error, manifest, match as match_, util
14 from mercurial.i18n import _ 14 from mercurial.i18n import _
15 from mercurial import localrepo 15 from mercurial import localrepo
16 16
17 import lfcommands 17 import lfcommands
18 import lfutil 18 import lfutil
410 if missing: 410 if missing:
411 msg = _("required features are not" 411 msg = _("required features are not"
412 " supported in the destination:" 412 " supported in the destination:"
413 " %s") % (', '.join(sorted(missing))) 413 " %s") % (', '.join(sorted(missing)))
414 raise util.Abort(msg) 414 raise util.Abort(msg)
415
416 outgoing = discovery.findcommonoutgoing(repo, remote.peer(),
417 force=force)
418 if outgoing.missing:
419 toupload = set()
420 o = self.changelog.nodesbetween(outgoing.missing, revs)[0]
421 addfunc = lambda fn, lfhash: toupload.add(lfhash)
422 lfutil.getlfilestoupload(self, o, addfunc)
423 lfcommands.uploadlfiles(ui, self, remote, toupload)
424 return super(lfilesrepo, self).push(remote, force=force, revs=revs, 415 return super(lfilesrepo, self).push(remote, force=force, revs=revs,
425 newbranch=newbranch) 416 newbranch=newbranch)
426 417
427 def _subdirlfs(self, files, lfiles): 418 def _subdirlfs(self, files, lfiles):
428 ''' 419 '''
478 actualfiles += regulars 469 actualfiles += regulars
479 return actualfiles 470 return actualfiles
480 471
481 repo.__class__ = lfilesrepo 472 repo.__class__ = lfilesrepo
482 473
474 def prepushoutgoinghook(local, remote, outgoing):
475 if outgoing.missing:
476 toupload = set()
477 addfunc = lambda fn, lfhash: toupload.add(lfhash)
478 lfutil.getlfilestoupload(local, outgoing.missing, addfunc)
479 lfcommands.uploadlfiles(ui, local, remote, toupload)
480 repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
481
483 def checkrequireslfiles(ui, repo, **kwargs): 482 def checkrequireslfiles(ui, repo, **kwargs):
484 if 'largefiles' not in repo.requirements and util.any( 483 if 'largefiles' not in repo.requirements and util.any(
485 lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()): 484 lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
486 repo.requirements.add('largefiles') 485 repo.requirements.add('largefiles')
487 repo._writerequirements() 486 repo._writerequirements()