Here, the print line number is the line of the source file, not the line of the patch.
Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:[email protected]] On Behalf Of > Liming Gao > Sent: Thursday, July 21, 2016 4:22 PM > To: [email protected] > Subject: [edk2] [Patch] BaseTools PatchCheck.py: Add line number in the > print error message > > PatchCheck script prints File and Line information in error message. > This patch adds line number in the error message to help detect the issue. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Liming Gao <[email protected]> > --- > BaseTools/Scripts/PatchCheck.py | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/BaseTools/Scripts/PatchCheck.py > b/BaseTools/Scripts/PatchCheck.py > index 455c130..526ffe6 100755 > --- a/BaseTools/Scripts/PatchCheck.py > +++ b/BaseTools/Scripts/PatchCheck.py > @@ -242,6 +242,8 @@ class GitDiffCheck: > self.lines = diff.splitlines(True) > self.count = len(self.lines) > self.line_num = 0 > + self.line_src = 0 > + self.line_delta = 0 > self.state = START > while self.line_num < self.count and self.format_ok: > line_num = self.line_num > @@ -283,9 +285,11 @@ class GitDiffCheck: > elif self.state == PRE_PATCH: > if line.startswith('+++ b/'): > self.set_filename(line[6:].rstrip()) > + self.line_delta = 0 > if line.startswith('@@ '): > self.state = PATCH > self.binary = False > + self.line_src = int (line.split(',')[0][4:]) + > self.line_delta > elif line.startswith('GIT binary patch'): > self.state = PATCH > self.binary = True > @@ -301,13 +305,17 @@ class GitDiffCheck: > if self.binary: > pass > if line.startswith('-'): > + self.line_src -= 1 > + self.line_delta -= 1 > pass > elif line.startswith('+'): > + self.line_delta += 1 > self.check_added_line(line[1:]) > elif line.startswith(r'\ No newline '): > pass > elif not line.startswith(' '): > self.format_error("unexpected patch line") > + self.line_src += 1 > self.line_num += 1 > > pre_patch_prefixes = ( > @@ -335,8 +343,8 @@ class GitDiffCheck: > def added_line_error(self, msg, line): > lines = [ msg ] > if self.hunk_filename is not None: > - lines.append('File: ' + self.hunk_filename) > - lines.append('Line: ' + line) > + lines.append('File : ' + self.hunk_filename) > + lines.append('Line %4d: %s' %(self.line_src, line)) > > self.error(*lines) > > -- > 2.8.0.windows.1 > > _______________________________________________ > edk2-devel mailing list > [email protected] > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

