[PATCH 3 of 3 ctx-cleanup] context: move dirty() to committablectx

Sean Farley sean at farley.io
Wed May 31 20:22:08 EDT 2017


# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1494536388 25200
#      Thu May 11 13:59:48 2017 -0700
# Branch wctxds
# Node ID b260e8ec9b2b0b1ba4d0ccf6b823c3a2b5d449b9
# Parent  6cdb17d89848a1bdb0fbcac24fe8c8322bb0bb02
context: move dirty() to committablectx

This is a pedantic move. It should be an error if dirty() is called on a
read-only context. Based on Mads Kiilerix's and my work at the sprint.

diff --git a/mercurial/context.py b/mercurial/context.py
index af1a4ec..30e3603 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -321,13 +321,10 @@ class basectx(object):
         return self._manifest.dirs()
 
     def hasdir(self, dir):
         return self._manifest.hasdir(dir)
 
-    def dirty(self, missing=False, merge=True, branch=True):
-        return False
-
     def status(self, other=None, match=None, listignored=False,
                listclean=False, listunknown=False, listsubrepos=False):
         """return status of files between two nodes or node and working
         directory.
 
@@ -1549,10 +1546,13 @@ class committablectx(basectx):
         # write changes out explicitly, because nesting wlock at
         # runtime may prevent 'wlock.release()' in 'repo.commit()'
         # from immediately doing so for subsequent changing files
         self._repo.dirstate.write(self._repo.currenttransaction())
 
+    def dirty(self, missing=False, merge=True, branch=True):
+        return False
+
 class workingctx(committablectx):
     """A workingctx object makes access to data related to
     the current working directory convenient.
     date - any valid date string or (unixtime, offset), or None.
     user - username string, or None.


More information about the Mercurial-devel mailing list