# HG changeset patch # User FUJIWARA Katsunori # Date 2015-10-16 16:15:34 # Node ID 4a82cb5c1dc87eb2dbf077f4ae9b5f93abf865d3 # Parent 5ba0a99ff27f9ee58f319acf966cd3efee3e0c7f dirstate: show develwarn for write() invocation without transaction This is used to detect 'dirstate.write()' invocation without the value gotten by 'repo.currenttransaction()' (mainly focused on 3rd party extensions). diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -110,6 +110,11 @@ class largefilesdirstate(dirstate.dirsta return super(largefilesdirstate, self).normallookup(unixpath(f)) def _ignore(self, f): return False + def write(self, tr=False): + # (1) disable PENDING mode always + # (lfdirstate isn't yet managed as a part of the transaction) + # (2) avoid develwarn 'use dirstate.write with ....' + super(largefilesdirstate, self).write(None) def openlfdirstate(ui, repo, create=True): ''' diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -661,6 +661,11 @@ class dirstate(object): filename = self._filename if tr is False: # not explicitly specified + if (self._ui.configbool('devel', 'all-warnings') + or self.ui.configbool('devel', 'check-dirstate-write')): + self._ui.develwarn('use dirstate.write with ' + 'repo.currenttransaction()') + if self._opener.lexists(self._pendingfilename): # if pending file already exists, in-memory changes # should be written into it, because it has priority