From 5a86dac54416ccc10dfe5694f9e342f75a8f6130 Mon Sep 17 00:00:00 2001 From: Paul Walmsley Date: Mon, 25 Jan 2021 22:00:12 +0000 Subject: [PATCH 1/3] Fixed encoding error when using --debug in python 3 --- patch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patch.py b/patch.py index 4775d70..d20d8d4 100755 --- a/patch.py +++ b/patch.py @@ -697,8 +697,8 @@ def _normalize_filenames(self): for i,p in enumerate(self.items): if debugmode: debug(" patch type = " + p.type) - debug(" source = " + p.source) - debug(" target = " + p.target) + debug(" source = " + tostr(p.source)) + debug(" target = " + tostr(p.target)) if p.type in (HG, GIT): # TODO: figure out how to deal with /dev/null entries debug("stripping a/ and b/ prefixes") From ec122d1a668d9da1cf8dc8594e75798282f32620 Mon Sep 17 00:00:00 2001 From: SVN Migration Date: Thu, 13 Jan 2022 11:11:42 +0000 Subject: [PATCH 2/3] Fix: now handles SVN patch for '.' directory without an error --- patch.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/patch.py b/patch.py index d20d8d4..93a1f1a 100755 --- a/patch.py +++ b/patch.py @@ -545,8 +545,12 @@ def lineno(self): match = re.match(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line) if not match: if not p.hunks: - warning("skipping invalid patch with no hunks for file %s" % p.source) - self.errors += 1 + if p.source == b'.': + warning("SVN patch file detected, skipping changes for '.'") + else: + warning("skipping invalid patch with no hunks for file %s" % p.source) + self.errors += 1 + # XXX review switch # switch to headscan state hunkhead = False From 825e4aa49657813ac5794a692c3c783e324f5787 Mon Sep 17 00:00:00 2001 From: SVN Migration Date: Thu, 13 Jan 2022 11:20:32 +0000 Subject: [PATCH 3/3] Fix: logging was broken if --debug wasn't given --- patch.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/patch.py b/patch.py index 93a1f1a..55bef2c 100755 --- a/patch.py +++ b/patch.py @@ -93,11 +93,6 @@ def setdebug(): logformat = "%(levelname)8s %(message)s" logger.setLevel(loglevel) - if streamhandler not in logger.handlers: - # when used as a library, streamhandler is not added - # by default - logger.addHandler(streamhandler) - streamhandler.setFormatter(logging.Formatter(logformat)) @@ -1166,6 +1161,12 @@ def main(): if options.debugmode: setdebug() # this sets global debugmode variable + if streamhandler not in logger.handlers: + # when used as a library, streamhandler is not added + # by default + logger.addHandler(streamhandler) + + if readstdin: patch = PatchSet(sys.stdin) else: