git merge failure caught in svx files

This commit is contained in:
Philip Sargent 2022-03-03 00:26:04 +00:00
parent 02d58d440e
commit 7f41017ce3

View File

@ -133,7 +133,7 @@ class LoadingSurvex():
rx_star = re.compile(r'(?i)\s*\*[\s,]*(\w+)\s*(.*?)\s*(?:;.*)?$')
rx_starref = re.compile(r'(?i)^\s*\*ref[\s.:]*((?:19[6789]\d)|(?:20[0123]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$')
rx_argsref = re.compile(r'(?i)^[\s.:]*((?:19[6789]\d)|(?:20[0123]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$')
rx_badmerge= re.compile(r'(?i).*(\>\>\>)|(\<\<\<).*$')
rx_badmerge= re.compile(r'(?i).*(\>\>\>\>\>)|(\=\=\=\=\=)|(\<\<\<\<\<).*$')
rx_ref2 = re.compile(r'(?i)\s*ref[.;]?')
rx_ref3 = re.compile(r'(?i)\s*wallet[.;]?')
@ -1066,6 +1066,7 @@ class LoadingSurvex():
and reads only the *include and *begin and *end statements. It produces a linearised
list of the include tree and detects blocks included more than once.
"""
thissvxline = 0
indent = " " * self.depthinclude
sys.stderr.flush();
self.callcount +=1
@ -1092,6 +1093,18 @@ class LoadingSurvex():
svxlines = fin.read().splitlines()
for svxline in svxlines:
self.lineno += 1
thissvxline += 1
# detect a merge failure inserted by version control
mfail = self.rx_badmerge.match(svxline)
if mfail:
message = f"\n!! - ERROR version control merge failure\n - '{svxline}'\n"
message = message + f" - in '{path}' at line {thissvxline}\n"
message = message + f" - line {self.lineno} {survexblock}\n - Parsing aborted. NERD++ needed to fix it"
print(message)
print(message,file=sys.stderr)
DataIssue.objects.create(parser='survex', message=message)
return # skip this survex file
includestmt =self.rx_include.match(svxline)
if not includestmt:
fcollate.write("{}\n".format(svxline.strip()))