chg will call reposetup multiple times, and we would end up double-wrapping (or
worse) the dirstate functions; this can cause issues like OSError 'No such file
or directory' during rebase operations, when we go to double-delete our
narrowspec backup file.
Details
- Reviewers
durin42 - Group Reviewers
hg-reviewers - Commits
- rHG1cba497491be: narrow: only wrap dirstate functions once, instead of per-reposetup
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
-def setup(repo):
+# Mapping of root:str to repo for repos that have the narrow requirement
+# specified.
+_rootrepomap = {}
+
+def _getrepo(ds):
+ """Check if narrow is enabled for repo associated with ds; return repo."""
+ return _rootrepomap.get(ds._root, None)
This might cause problem on long-running processes such as hgweb and
commandserver.
Instead, maybe we can extract a factory function of repo.dirstate() so that
the narrowrepo can easily override it.
class localrepository(object): @repofilecache('dirstate') def dirstate(self): return self._makedirstate() ... class narrowrepository(repo.__class__): def _makedirstate(self): d = super(...) return wrapdirstate(d)
Queued, thanks.
- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -778,6 +778,9 @@@repofilecache('dirstate') def dirstate(self):+ return self._makedirstate()
+
+ def _makedirstate(self):
Can you add a docstring so we wouldn't remove this function by mistake?
- # Prevent adding files that are outside the sparse checkout
- editfuncs = ['normal', 'add', 'normallookup', 'copy', 'remove', 'merge']
+ @_editfunc
+ def remove(self, *args):
+ return super(narrowdirstate, self).remove(*args)
+
+ @_editfunc
+ def remove(self, *args):
+ return super(narrowdirstate, self).remove(*args)
s/remove/merge/ the last function in flight.