Adding a filemap-like option to handle special character \n and \r
Using hg-git to port a Git -> Hg repo and got a lot of issue with files with names containing '\r' and/or '\n'
I did a monkey patch to my local Hg-Git to by-pass this but I want to raise it as an issue moving forward.
Perhaps a more elegant solution is required here (i.e. using filemap config as seen in hg convert
)
Monkey Patch:
~/hg-git% hg diff
diff -r 5ce77f7f466c hggit/git_handler.py
--- a/hggit/git_handler.py Mon Jun 10 17:59:01 2019 +0200
+++ b/hggit/git_handler.py Sun Feb 02 15:50:37 o020 +0100
@@ -1496,6 +1496,16 @@
for change in changes:
oldfile, oldmode, oldsha = change.old
newfile, newmode, newsha = change.new
+
+ # sluongngoc: monkey patch
+ if oldfile is not None:
+ if '\r' in oldfile:
+ self.ui.debug("oldfile has special character \\r: %s\n" % oldfile)
+ oldfile = oldfile.replace('\r','_r')
+ if '\n' in oldfile:
+ self.ui.debug("oldfile has special character \\n: %s\n" % oldfile)
+ oldfile = oldfile.replace('\n','_n')
+
# actions are described by the following table ('no' means 'does
# not exist'):
# old new | action
@@ -1544,6 +1554,16 @@
gitlinks[oldfile] = None
continue
if newfile is not None:
+
+ # sluongngoc: monkey patch
+ if newfile is not None:
+ if '\r' in newfile:
+ self.ui.debug("newfile has special character \\r: %s\n" % newfile)
+ newfile = newfile.replace('\r','_r')
+ if '\n' in newfile:
+ self.ui.debug("newfile has special character \\n: %s\n" % newfile)
+ newfile = newfile.replace('\n','_n')
+
self.audit_hg_path(newfile)
# new = file
files[newfile] = False, newmode, newsha