patch: turned strings with backslashes into raw strings
authorMartin Geisler <mg@daimi.au.dk>
Wed, 04 Feb 2009 20:53:38 +0100
changeset 7736 fb0776fe3e38
parent 7735 2e48668b51f0
child 7737 26bdb7109170
patch: turned strings with backslashes into raw strings In Python, the backslash in an unrecognized escape sequence is left behind, which makes '\.' the same as r'\.'. Relying on this feature is quite brittle, IMHO. Removed unnecessary string concatenation as well.
mercurial/patch.py
--- a/mercurial/patch.py	Tue Feb 03 21:38:36 2009 +0100
+++ b/mercurial/patch.py	Wed Feb 04 20:53:38 2009 +0100
@@ -52,9 +52,9 @@
 
     # attempt to detect the start of a patch
     # (this heuristic is borrowed from quilt)
-    diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |' +
-                        'retrieving revision [0-9]+(\.[0-9]+)*$|' +
-                        '(---|\*\*\*)[ \t])', re.MULTILINE)
+    diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
+                        r'retrieving revision [0-9]+(\.[0-9]+)*$|'
+                        r'(---|\*\*\*)[ \t])', re.MULTILINE)
 
     fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
     tmpfp = os.fdopen(fd, 'w')