scmutil: try-delete `.hg/store/requires` if store requirements are empty
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 16 Oct 2020 19:03:09 +0530
changeset 45919 aba4f2c97e74
parent 45918 ac565222b9f8
child 45920 1441f4d57083
scmutil: try-delete `.hg/store/requires` if store requirements are empty When downgrading from a shared-safe repository to non-shared-safe repository, we end up in a case where we had requirements stored in `.hg/store/requires` but no longer want them there. Let's explicitly try delete the `.hg/store/requires` file if store requirements are empty. Differential Revision: https://phab.mercurial-scm.org/D9357
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Mon Nov 23 10:39:51 2020 -0800
+++ b/mercurial/scmutil.py	Fri Oct 16 19:03:09 2020 +0530
@@ -1580,6 +1580,9 @@
         writerequires(repo.vfs, wcreq)
     if storereq is not None:
         writerequires(repo.svfs, storereq)
+    elif repo.ui.configbool(b'format', b'usestore'):
+        # only remove store requires if we are using store
+        repo.svfs.tryunlink(b'requires')
 
 
 def writerequires(opener, requirements):