[Updated] D8631: scmutil: add writereporequirements() and route requires writing through it
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Wed Jun 24 12:57:38 UTC 2020
Herald added a reviewer: martinvonz.
Herald added a reviewer: durin42.
pulkit edited the summary of this revision.
pulkit retitled this revision from "localrepo: add writerequirements() and route requires writing through it" to "scmutil: add writereporequirements() and route requires writing through it".
pulkit updated this revision to Diff 21694.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8631?vs=21675&id=21694
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8631/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8631
AFFECTED FILES
hgext/largefiles/lfcommands.py
hgext/largefiles/reposetup.py
hgext/lfs/__init__.py
hgext/lfs/wrapper.py
hgext/narrow/narrowbundle2.py
hgext/remotefilelog/__init__.py
mercurial/bundle2.py
mercurial/hg.py
mercurial/localrepo.py
mercurial/scmutil.py
mercurial/sparse.py
mercurial/streamclone.py
mercurial/upgrade.py
CHANGE DETAILS
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -1091,8 +1091,8 @@
b'unable to read from repository\n'
)
)
- scmutil.writerequires(
- srcrepo.vfs, srcrepo.requirements | {b'upgradeinprogress'}
+ scmutil.writereporequirements(
+ srcrepo, srcrepo.requirements | {b'upgradeinprogress'}
)
ui.status(_(b'starting in-place swap of repository data\n'))
@@ -1122,7 +1122,7 @@
b'again\n'
)
)
- scmutil.writerequires(srcrepo.vfs, requirements)
+ scmutil.writereporequirements(srcrepo, requirements)
# The lock file from the old store won't be removed because nothing has a
# reference to its new location. So clean it up manually. Alternatively, we
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -20,6 +20,7 @@
narrowspec,
phases,
pycompat,
+ scmutil,
store,
util,
)
@@ -187,7 +188,7 @@
repo.svfs.options = localrepo.resolvestorevfsoptions(
repo.ui, repo.requirements, repo.features
)
- repo._writerequirements()
+ scmutil.writereporequirements(repo)
if rbranchmap:
repo._branchcaches.replace(repo, rbranchmap)
@@ -730,4 +731,4 @@
repo.svfs.options = localrepo.resolvestorevfsoptions(
repo.ui, repo.requirements, repo.features
)
- repo._writerequirements()
+ scmutil.writereporequirements(repo)
diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -601,10 +601,10 @@
if b'exp-sparse' in oldrequires and removing:
repo.requirements.discard(b'exp-sparse')
- scmutil.writerequires(repo.vfs, repo.requirements)
+ scmutil.writereporequirements(repo)
elif b'exp-sparse' not in oldrequires:
repo.requirements.add(b'exp-sparse')
- scmutil.writerequires(repo.vfs, repo.requirements)
+ scmutil.writereporequirements(repo)
try:
writeconfig(repo, includes, excludes, profiles)
@@ -613,7 +613,7 @@
if repo.requirements != oldrequires:
repo.requirements.clear()
repo.requirements |= oldrequires
- scmutil.writerequires(repo.vfs, repo.requirements)
+ scmutil.writereporequirements(repo)
writeconfig(repo, oldincludes, oldexcludes, oldprofiles)
raise
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1470,6 +1470,13 @@
repo._quick_access_changeid_invalidate()
+def writereporequirements(repo, requirements=None):
+ """ writes requirements for the repo to .hg/requires """
+ if requirements:
+ repo.requirements = requirements
+ writerequires(repo.vfs, repo.requirements)
+
+
def writerequires(opener, requirements):
with opener(b'requires', b'w', atomictemp=True) as fp:
for r in sorted(requirements):
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1297,9 +1297,6 @@
caps.add(b'bundle2=' + urlreq.quote(capsblob))
return caps
- def _writerequirements(self):
- scmutil.writerequires(self.vfs, self.requirements)
-
# Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
# self -> auditor -> self._checknested -> self
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -356,7 +356,7 @@
repo.requirements.discard(b'shared')
repo.requirements.discard(b'relshared')
- repo._writerequirements()
+ scmutil.writereporequirements(repo)
# Removing share changes some fundamental properties of the repo instance.
# So we instantiate a new repo object and operate on it rather than
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -166,6 +166,7 @@
phases,
pushkey,
pycompat,
+ scmutil,
streamclone,
tags,
url,
@@ -1977,7 +1978,7 @@
op.repo.svfs.options = localrepo.resolvestorevfsoptions(
op.repo.ui, op.repo.requirements, op.repo.features
)
- op.repo._writerequirements()
+ scmutil.writereporequirements(op.repo)
bundlesidedata = bool(b'exp-sidedata' in inpart.params)
reposidedata = bool(b'exp-sidedata-flag' in op.repo.requirements)
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -361,7 +361,7 @@
self.unfiltered().__class__,
)
self.requirements.add(constants.SHALLOWREPO_REQUIREMENT)
- self._writerequirements()
+ scmutil.writereporequirements(self)
# Since setupclient hadn't been called, exchange.pull was not
# wrapped. So we need to manually invoke our version of it.
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -20,6 +20,7 @@
localrepo,
narrowspec,
repair,
+ scmutil,
util,
wireprototypes,
)
@@ -179,7 +180,7 @@
if not repository.NARROW_REQUIREMENT in op.repo.requirements:
op.repo.requirements.add(repository.NARROW_REQUIREMENT)
- op.repo._writerequirements()
+ scmutil.writereporequirements(op.repo)
op.repo.setnarrowpats(includepats, excludepats)
narrowspec.copytoworkingcopy(op.repo)
@@ -195,7 +196,7 @@
if repository.NARROW_REQUIREMENT not in op.repo.requirements:
op.repo.requirements.add(repository.NARROW_REQUIREMENT)
- op.repo._writerequirements()
+ scmutil.writereporequirements(op.repo)
op.repo.setnarrowpats(includepats, excludepats)
narrowspec.copytoworkingcopy(op.repo)
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -312,7 +312,7 @@
# membership before assuming it is in the context.
if any(f in ctx and ctx[f].islfs() for f, n in files):
self.repo.requirements.add(b'lfs')
- self.repo._writerequirements()
+ scmutil.writereporequirements(self.repo)
return node
diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -255,7 +255,7 @@
):
repo.requirements.add(b'lfs')
repo.features.add(repository.REPO_FEATURE_LFS)
- repo._writerequirements()
+ scmutil.writereporequirements(repo)
repo.prepushoutgoinghooks.add(b'lfs', wrapper.prepush)
break
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -448,7 +448,7 @@
lfutil.shortname + b'/' in f[0] for f in repo.store.datafiles()
):
repo.requirements.add(b'largefiles')
- repo._writerequirements()
+ scmutil.writereporequirements(repo)
ui.setconfig(
b'hooks', b'changegroup.lfiles', checkrequireslfiles, b'largefiles'
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -163,7 +163,7 @@
# to the destination repository's requirements.
if lfiles:
rdst.requirements.add(b'largefiles')
- rdst._writerequirements()
+ scmutil.writereporequirements(rdst)
else:
class lfsource(filemap.filemap_source):
To: pulkit, #hg-reviewers, durin42, martinvonz
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200624/0b6137b3/attachment-0002.html>
More information about the Mercurial-patches
mailing list