dirstate: show develwarn for write() invocation without transaction
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sat, 17 Oct 2015 01:15:34 +0900
changeset 26749 4a82cb5c1dc8
parent 26748 5ba0a99ff27f
child 26750 9f9ec4abe700
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).
hgext/largefiles/lfutil.py
mercurial/dirstate.py
--- a/hgext/largefiles/lfutil.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/hgext/largefiles/lfutil.py	Sat Oct 17 01:15:34 2015 +0900
@@ -110,6 +110,11 @@
         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):
     '''
--- a/mercurial/dirstate.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/mercurial/dirstate.py	Sat Oct 17 01:15:34 2015 +0900
@@ -661,6 +661,11 @@
 
         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