# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1707968631 18000 # Node ID 1d488f7be492f17ad91b8bed577f7f758dfd396d # Parent e68908edebbad6549a6ef5ec012eb08b1fca7eb2 crecord: add `content` properties to all nodes In order to have a unified API of what can be searched, let's provide a `content` property to each node type. This way we can search filenames, context headers (e.g. containing function names, if deducible from patch context) or changed lines themselves. diff -r e68908edebba -r 1d488f7be492 mercurial/crecord.py --- a/mercurial/crecord.py Wed Feb 14 22:42:08 2024 -0500 +++ b/mercurial/crecord.py Wed Feb 14 22:43:51 2024 -0500 @@ -86,6 +86,10 @@ (i.e. patchroot, header, hunk, hunkline) """ + @property + def content(self): + return b'' + def firstchild(self): raise NotImplementedError(b"method must be implemented by subclass") @@ -223,6 +227,10 @@ self.neverunfolded = True self.hunks = [uihunk(h, self) for h in self.hunks] + @property + def content(self): + return self.filename() + def prettystr(self): x = stringio() self.pretty(x) @@ -289,6 +297,10 @@ # in the previtem method. self.folded = False + @property + def content(self): + return self.linetext + def prettystr(self): return self.linetext @@ -347,6 +359,10 @@ # children are partially applied (i.e. some applied, some not). self.partial = False + @property + def content(self): + return self.proc if self.proc else b'' + def nextsibling(self): numhunksinheader = len(self.header.hunks) indexofthishunk = self.header.hunks.index(self)