From 2a74b103ab6ff3a3acb45cf215d5510cf2ea0a7d Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Tue, 10 Dec 2019 16:11:26 +0100 Subject: [PATCH] Remove trailing whitespace --- patch.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/patch.py b/patch.py index 4b82af0..f6c297c 100755 --- a/patch.py +++ b/patch.py @@ -2,7 +2,7 @@ """ Patch utility to apply unified diffs - Brute-force line-by-line non-recursive parsing + Brute-force line-by-line non-recursive parsing Copyright (c) 2008-2016 anatoly techtonik Available under the terms of MIT license @@ -53,7 +53,7 @@ def tostr(b): # [ ] figure out how to print non-utf-8 filenames without # information loss - return b.decode('utf-8') + return b.decode('utf-8') #------------------------------------------------ @@ -232,7 +232,7 @@ class Patch(object): If used as an iterable, returns hunks. """ def __init__(self): - self.source = None + self.source = None self.target = None self.hunks = [] self.hunkends = [] @@ -338,7 +338,7 @@ def lineno(self): # regexp to match start of hunk, used groups - 1,3,4,6 re_hunk_start = re.compile(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@") - + self.errors = 0 # temp buffers for header and filenames info header = [] @@ -374,7 +374,7 @@ def lineno(self): else: info("%d unparsed bytes left at the end of stream" % len(b''.join(header))) self.warnings += 1 - # TODO check for \No new line at the end.. + # TODO check for \No new line at the end.. # TODO test for unparsed bytes # otherwise error += 1 # this is actually a loop exit @@ -407,7 +407,7 @@ def lineno(self): p.hunkends["lf"] += 1 elif line.endswith(b"\r"): p.hunkends["cr"] += 1 - + if line.startswith(b"-"): hunkactual["linessrc"] += 1 elif line.startswith(b"+"): @@ -503,7 +503,7 @@ def lineno(self): headscan = True else: if tgtname != None: - # XXX seems to be a dead branch + # XXX seems to be a dead branch warning("skipping invalid patch - double target at line %d" % (lineno+1)) self.errors += 1 srcname = None @@ -590,7 +590,7 @@ def lineno(self): warning("error: no patch data found!") return False else: # extra data at the end of file - pass + pass else: warning("error: patch stream is incomplete!") self.errors += 1 @@ -616,7 +616,7 @@ def lineno(self): # -------- self._normalize_filenames() - + return (self.errors == 0) def _detect_type(self, p): @@ -659,14 +659,14 @@ def _detect_type(self, p): return GIT # HG check - # + # # - for plain HG format header is like "diff -r b2d9961ff1f5 filename" # - for Git-style HG patches it is "diff --git a/oldname b/newname" # - filename starts with a/, b/ or is equal to /dev/null # - exported changesets also contain the header # # HG changeset patch # # User name@example.com - # ... + # ... # TODO add MQ # TODO add revision info if len(p.header) > 0: @@ -689,7 +689,7 @@ def _normalize_filenames(self): [x] always use forward slashes to be crossplatform (diff/patch were born as a unix utility after all) - + return None """ if debugmode: @@ -739,7 +739,7 @@ def _normalize_filenames(self): if xisabs(p.target): warning("stripping absolute path from target name '%s'" % p.target) p.target = xstrip(p.target) - + self.items[i].source = p.source self.items[i].target = p.target @@ -795,7 +795,7 @@ def diffstat(self): hist = "+"*int(iwidth) + "-"*int(dwidth) # -- /calculating +- histogram -- output += (format % (tostr(names[i]), str(insert[i] + delete[i]), hist)) - + output += (" %d files changed, %d insertions(+), %d deletions(-), %+d bytes" % (len(names), sum(insert), sum(delete), delta)) return output @@ -1038,7 +1038,7 @@ class NoMatch(Exception): def patch_stream(self, instream, hunks): """ Generator that yields stream patched with hunks iterable - + Converts lineends in hunk lines to the best suitable format autodetected from input """ @@ -1091,7 +1091,7 @@ def get_line(): yield line2write.rstrip(b"\r\n")+newline else: # newlines are mixed yield line2write - + for line in instream: yield line