Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize the path using replace(). #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CrossVR
Copy link

@CrossVR CrossVR commented Jul 30, 2016

On Windows os.path.normpath() will add backslashes and quotes to the path which git can't handle.

The original commit 978314a mentions that the intention for os.path.normpath() was to normalize paths with 'foo//bar'. Thus to make sure we don't get unintended consequences I suggest a manual replacement.

On Windows `os.path.normpath()` will add backslashes and quotes to the path which git can't handle.
CrossVR referenced this pull request Jul 30, 2016
Apparently Mercurial can have paths such as 'foo//bar', so normalize all
paths.

Signed-off-by: Felipe Contreras <[email protected]>
git-remote-hg Outdated
@@ -265,7 +265,7 @@ class Parser:
return (user, int(date), -tz)

def fix_file_path(path):
path = os.path.normpath(path)
path.replace('//', '/')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to set path = path.replace('//', '/'). Otherwise the replaced string isn't saved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd, because it worked for me. I'll correct it.

@BengtOFFIS
Copy link

This solved the issue of paths being falsly detected as new for me.

@IngeniousOne
Copy link

Hi, everybody!
There is a better solution, to use "posixpath" in this case (only here).
`
def fix_file_path(path):
#path = os.path.normpath(path)
path = posixpath.normpath(path)
if not os.path.isabs(path):
return path
#return os.path.relpath(path, '/')
return posixpath.relpath(path, '/')
'
Снимок

Something like that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants