[Request] [+- ] D8631: localrepo: add writerequirements() and route requires writing through it
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Mon Jun 15 15:03:46 UTC 2020
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
In upcoming patches, to implement Share Safe plan we will be introducing
requires file in store. We need to route all callers to check for
a share-safe requirement and if present, write requirements to
.hg/store/requires instead.
After this patch, callers directly calling scmutil.writerequires() are once
where we don't have the repo object, for example when initializing the object
itself.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8631
AFFECTED FILES
mercurial/interfaces/repository.py
mercurial/localrepo.py
mercurial/sparse.py
mercurial/upgrade.py
CHANGE DETAILS
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -21,7 +21,6 @@
metadata,
pycompat,
revlog,
- scmutil,
util,
vfs as vfsmod,
)
@@ -1091,9 +1090,7 @@
b'unable to read from repository\n'
)
)
- scmutil.writerequires(
- srcrepo.vfs, srcrepo.requirements | {b'upgradeinprogress'}
- )
+ srcrepo.writerequirements(srcrepo.requirements | {b'upgradeinprogress'})
ui.status(_(b'starting in-place swap of repository data\n'))
ui.status(_(b'replaced files will be backed up at %s\n') % backuppath)
@@ -1122,7 +1119,7 @@
b'again\n'
)
)
- scmutil.writerequires(srcrepo.vfs, requirements)
+ srcrepo.writerequirements(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/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -21,7 +21,6 @@
mergestate as mergestatemod,
pathutil,
pycompat,
- scmutil,
util,
)
from .utils import hashutil
@@ -601,10 +600,10 @@
if b'exp-sparse' in oldrequires and removing:
repo.requirements.discard(b'exp-sparse')
- scmutil.writerequires(repo.vfs, repo.requirements)
+ repo.writerequirements(repo.requirements)
elif b'exp-sparse' not in oldrequires:
repo.requirements.add(b'exp-sparse')
- scmutil.writerequires(repo.vfs, repo.requirements)
+ repo.writerequirements(repo.requirements)
try:
writeconfig(repo, includes, excludes, profiles)
@@ -613,7 +612,7 @@
if repo.requirements != oldrequires:
repo.requirements.clear()
repo.requirements |= oldrequires
- scmutil.writerequires(repo.vfs, repo.requirements)
+ repo.writerequirements(repo.requirements)
writeconfig(repo, oldincludes, oldexcludes, oldprofiles)
raise
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1297,6 +1297,10 @@
caps.add(b'bundle2=' + urlreq.quote(capsblob))
return caps
+ def writerequirements(self, requirements):
+ self.requirements = requirements
+ self._writerequirements()
+
def _writerequirements(self):
scmutil.writerequires(self.vfs, self.requirements)
diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py
--- a/mercurial/interfaces/repository.py
+++ b/mercurial/interfaces/repository.py
@@ -1809,6 +1809,9 @@
def savecommitmessage(text):
pass
+ def writerequirements(requirements):
+ """ writes current repository requirements """
+
class completelocalrepository(
ilocalrepositorymain, ilocalrepositoryfilestorage
To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200615/22fab057/attachment-0001.html>
More information about the Mercurial-patches
mailing list