[PATCH 2 of 5 requirements-tidy] largefiles: use repo.addrequirement()
Gregory Szorc
gregory.szorc at gmail.com
Thu Oct 1 14:29:56 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443724984 25200
# Thu Oct 01 11:43:04 2015 -0700
# Node ID 8d51cc6b20a930f3c6fe0a2b7135eca696e2b8fc
# Parent a6ba4ec0ac210f86459ae7da0a8843d6132a0d12
largefiles: use repo.addrequirement()
We have a new API to add requirements to a repo. Use it.
This removes a call to a private API and adds a
probably-should-have-been there call to repo._applyopenerreqs() by way
of switching to the new API.
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -117,10 +117,9 @@ def lfconvert(ui, src, dest, *pats, **op
# If there were any files converted to largefiles, add largefiles
# to the destination repository's requirements.
if lfiles:
- rdst.requirements.add('largefiles')
- rdst._writerequirements()
+ rdst.addrequirement('largefiles')
else:
class lfsource(filemap.filemap_source):
def __init__(self, ui, source):
super(lfsource, self).__init__(ui, source, None)
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -364,12 +364,13 @@ def reposetup(ui, repo):
lfcommands.uploadlfiles(ui, local, remote, toupload)
repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
def checkrequireslfiles(ui, repo, **kwargs):
+ # addrequirement() no-ops. But walking data files is expensive, so do
+ # a local check to avoid that work.
if 'largefiles' not in repo.requirements and any(
lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
- repo.requirements.add('largefiles')
- repo._writerequirements()
+ repo.addrequirement('largefiles')
ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles,
'largefiles')
ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles, 'largefiles')
More information about the Mercurial-devel
mailing list