Skip to content

Commit

Permalink
Make b'-'/b'+' constants within HunkLine
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewshadura committed Mar 24, 2022
1 parent 0b384ba commit e4089ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions git_crecord/crpatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ def allchildren(self) -> Sequence['Hunk']:
class HunkLine(PatchNode):
"""Represents a changed line in a hunk"""

DELETE = b'-'
INSERT = b'+'

linetext: bytes
hunk: 'Hunk'

Expand Down Expand Up @@ -586,10 +589,10 @@ def allchildren(self) -> Sequence[PatchNode]:
def countchanges(self) -> tuple[int, int]:
"""changedlines -> (n+,n-)"""
add = len(
[line for line in self.changedlines if line.applied and line.diffop == b"+"]
[line for line in self.changedlines if line.applied and line.diffop == HunkLine.INSERT]
)
rem = len(
[line for line in self.changedlines if line.applied and line.diffop == b"-"]
[line for line in self.changedlines if line.applied and line.diffop == HunkLine.DELETE]
)
return add, rem

Expand Down

0 comments on commit e4089ac

Please # to comment.