# HG changeset patch # User Matt Mackall # Date 2009-06-04 21:21:55 # Node ID e8de59577257b2d3dbf2423397d6ab953cf57adc # Parent f3322bb29a0efbb94f35fbeb8b7a5cff94e2630d context: add a dirty method to detect modified contexts diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -618,6 +618,13 @@ class workingctx(changectx): def walk(self, match): return sorted(self._repo.dirstate.walk(match, True, False)) + def dirty(self, missing=False): + "check whether a working directory is modified" + + return (self.p2() or self.branch() != self.p1().branch() or + self.modified() or self.added() or self.removed() or + (missing and self.deleted())) + class workingfilectx(filectx): """A workingfilectx object makes access to data related to a particular file in the working directory convenient."""