Skip to content

Fix repocutter pathrename with backreferences

Do not compile the arguments to pathrename as regexes. Half of them are replacement strings, not regexes, and trying to compile them as regexes was breaking backreferences:

$ repocutter pathrename '^(foo|bar)' 'trunk/\1'
Transform Node-path headers with a regexp replace......(0.00 sec) done.
Traceback (most recent call last):
  File "./repocutter", line 978, in <module>
    pathrename(DumpfileSource(sys.stdin, baton), selection, patterns_compile(arguments[1:]))
  File "./repocutter", line 915, in patterns_compile
    return [re.compile(pattern) for pattern in patterns]
  File "/usr/lib/python2.7/re.py", line 194, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.7/re.py", line 251, in _compile
    raise error, v # invalid expression
sre_constants.error: bogus escape: '\\1'

Merge request reports