Bug 4187 - Extensions fail to load on Windows if the path in the .hgrc ends with a '\'
Summary: Extensions fail to load on Windows if the path in the .hgrc ends with a '\'
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 2.9.1
Hardware: PC Windows
: normal bug
Assignee: Ed Morley
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-04 17:56 UTC by Ed Morley
Modified: 2014-05-13 11:30 UTC (History)
1 user (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Morley 2014-03-04 17:56 UTC
[extensions]
foo = C:\bar\foo

-> Succeeds.

[extensions]
foo = C:\bar\foo\

*** failed to import extension foo from C:\bar\foo\: No module named

The cause is the OS specific strip here:
http://selenic.com/hg/file/779ceb84f4f7/mercurial/extensions.py#l49
>         d, f = os.path.split(path.rstrip('/'))

This was added by:
http://selenic.com/hg/rev/5c794e7331e7

Looks like it wasn't intentionally OS-specific.

We should just switch to using os.path.sep
Comment 2 Ed Morley 2014-03-05 04:38 UTC
Replaced os.sep with normpath otherwise we lose support for paths with trailing forward slashes on Windows, which whilst presumably less common, we want to maintain.
Comment 3 Ed Morley 2014-03-06 10:13 UTC
Updated extensions wiki page to mention trailing backwards slash needs to be omitted on current release on Windows:
http://mercurial.selenic.com/wiki/UsingExtensions?action=diff&rev1=327&rev2=328

Will update again with version numbers once this is released.
Comment 4 HG Bot 2014-03-06 13:00 UTC
Fixed by http://selenic.com/repo/hg/rev/7d83c3b6e8d9
Ed Morley <emorley@mozilla.com>
extensions: use normpath to allow trailing '\' on Windows (issue4187)

Fixes same issue as 5c794e7331e7 but now works on Windows too.

With this patch a trailing backward slash won't prevent the extension from
being found on Windows, and we continue to support any combination of forward
and back slashes within the path.

(please test the fix)
Comment 5 Ed Morley 2014-05-13 11:30 UTC
http://mercurial.selenic.com/wiki/WhatsNew#Mercurial_3.0_.282014-05-01.29

Confirmed fixed with the TortoiseHg v3.0 release (that ships with hg 3.0+3).