[PATCH 1 of 8] py3: fix type of regex literals in patch.py
Yuya Nishihara
yuya at tcha.org
Sun Sep 3 14:36:19 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1504422735 -32400
# Sun Sep 03 16:12:15 2017 +0900
# Node ID 313ecdde1470bb3a0e1f9beced7e596b8004e456
# Parent 68afb88b51bb626cd25440e2df812f2306463b55
py3: fix type of regex literals in patch.py
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -205,10 +205,11 @@ def extract(ui, fileobj):
# attempt to detect the start of a patch
# (this heuristic is borrowed from quilt)
- diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
- r'retrieving revision [0-9]+(\.[0-9]+)*$|'
- r'---[ \t].*?^\+\+\+[ \t]|'
- r'\*\*\*[ \t].*?^---[ \t])', re.MULTILINE|re.DOTALL)
+ diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
+ br'retrieving revision [0-9]+(\.[0-9]+)*$|'
+ br'---[ \t].*?^\+\+\+[ \t]|'
+ br'\*\*\*[ \t].*?^---[ \t])',
+ re.MULTILINE | re.DOTALL)
data = {}
fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
@@ -230,7 +231,7 @@ def extract(ui, fileobj):
pend = subject.find(']')
if pend >= 0:
subject = subject[pend + 1:].lstrip()
- subject = re.sub(r'\n[ \t]+', ' ', subject)
+ subject = re.sub(br'\n[ \t]+', ' ', subject)
ui.debug('Subject: %s\n' % subject)
if data['user']:
ui.debug('From: %s\n' % data['user'])
@@ -1760,7 +1761,7 @@ def scanpatch(fp):
- ('hunk', [hunk_lines])
- ('range', (-start,len, +start,len, proc))
"""
- lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
+ lines_re = re.compile(br'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
lr = linereader(fp)
def scanwhile(first, p):
More information about the Mercurial-devel
mailing list