[PATCH] extensions: don't fail to load on Windows if path ends with a '\' (issue4187)

Simon Heimberg simohe at besonet.ch
Thu Mar 6 13:57:48 CST 2014


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1394057163 -3600
#      Wed Mar 05 23:06:03 2014 +0100
# Node ID fdc109d7f256c16ef7b9fdbb76ab9bd3b49f5bcc
# Parent  779ceb84f4f782d32dfe47f6684107c08d2f6142
extensions: don't fail to load on Windows if path ends with a '\' (issue4187)

Same fix as 5c794e7331e7 but now works on Windows too.

Original idea by Ed Morley.

diff -r 779ceb84f4f7 -r fdc109d7f256 mercurial/extensions.py
--- a/mercurial/extensions.py	Tue Mar 04 09:56:59 2014 -0600
+++ b/mercurial/extensions.py	Wed Mar 05 23:06:03 2014 +0100
@@ -46,7 +46,7 @@
     path = util.expandpath(path)
     if os.path.isdir(path):
         # module/__init__.py style
-        d, f = os.path.split(path.rstrip('/'))
+        d, f = os.path.split(path.rstrip('/' + os.sep))
         fd, fpath, desc = imp.find_module(f, [d])
         return imp.load_module(module_name, fd, fpath, desc)
     else:
diff -r 779ceb84f4f7 -r fdc109d7f256 tests/test-extension.t
--- a/tests/test-extension.t	Tue Mar 04 09:56:59 2014 -0600
+++ b/tests/test-extension.t	Wed Mar 05 23:06:03 2014 +0100
@@ -68,6 +68,20 @@
   reposetup called for a
   ui == repo.ui
   Foo
+  $ echo "barfoo = $barfoopath/" >> $HGRCPATH
+  $ hg foo
+  uisetup called
+  reposetup called for a
+  ui == repo.ui
+  Foo
+#if windows
+  $ echo "barfoo = $barfoopath\\" >> $HGRCPATH
+  $ hg foo
+  uisetup called
+  reposetup called for a
+  ui == repo.ui
+  Foo
+#endif
   $ echo 'barfoo = !' >> $HGRCPATH
 
 Check that extensions are loaded in phases:


More information about the Mercurial-devel mailing list