Catch error if unfixed merges in survex files

This commit is contained in:
Philip Sargent 2022-03-01 01:30:09 +00:00
parent 8bd20f9600
commit af50d4912d

View File

@ -33,6 +33,9 @@ todo = '''Also walk the entire tree in the :loser: repo looking for unconnected
GetPersonExpeditionNameLookup() needs to be fixed.
- fix THREEDCACHEDIR and put .3d files in same folder as .svx and fix CaveView
- LoadSurvexFile() Creates a new current survexfile and valid .survexdirectory
The survexblock passed-in is not necessarily the parent. FIX THIS.
'''
survexblockroot = None
ROOTBLOCK = "rootblock"
@ -130,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_ref2 = re.compile(r'(?i)\s*ref[.;]?')
rx_ref3 = re.compile(r'(?i)\s*wallet[.;]?')
@ -1037,12 +1040,22 @@ class LoadingSurvex():
if not sline:
continue # skip blank lines
# detect a merge failure inserted by version control
mfail = self.rx_badmerge.match(sline)
if mfail:
message = f"\n ! - ERROR version control merge failure\n - '{sline}'\n"
message = message + f" - line {self.lineno} in {blkid} in {survexblock}\n - NERD++ needed to fix it"
print(message)
print(message,file=sys.stderr)
DataIssue.objects.create(parser='survex', message=message)
continue # skip this line
# detect a star command
star = self.rx_star.match(sline)
if star:
# yes we are reading a *command
starstatement(star)
else: # not a *cmd so we are reading data OR a ";" rx_comment failed
else: # not a *cmd so we are reading data OR a ";" rx_comment failed. We hope.
self.LoadSurvexLeg(survexblock, sline, comment)
self.legsnumber = slengthtotal