Patchwork D5503: vfs: add support for repo names with `$` when using with env vars (issue5739)

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2019, 12:08 p.m.
Message ID <064820e8e1748ab68904106ad721da87@localhost.localdomain>
Download mbox | patch
Permalink /patch/37524/
State Not Applicable
Headers show

Comments

phabricator - Jan. 7, 2019, 12:08 p.m.
navaneeth.suresh updated this revision to Diff 13046.
navaneeth.suresh retitled this revision from "vfs: add support for repo names with `$` sign while using with env vars (issue5739)" to "vfs: add support for repo names with `$` when using with env vars (issue5739)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5503?vs=13025&id=13046

REVISION DETAIL
  https://phab.mercurial-scm.org/D5503

AFFECTED FILES
  mercurial/vfs.py
  tests/test-issue5739.t

CHANGE DETAILS




To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-issue5739.t b/tests/test-issue5739.t
new file mode 100644
--- /dev/null
+++ b/tests/test-issue5739.t
@@ -0,0 +1,8 @@ 
+-- going to create a repo with dollar sign which even
+works even when there exists an environment variable
+
+  $ mkdir '$foo'
+  $ cd '$foo'
+  $ hg init
+  $ foo=bar hg root
+  $TESTTMP/$foo
diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -311,6 +311,10 @@ 
     '''
     def __init__(self, base, audit=True, cacheaudited=False, expandpath=False,
                  realpath=False):
+        if '$' in base and os.path.isdir(base):
+            # when there exists a repo '$foo' and an env var foo=bar, stop
+            # expanding path. refer issue5739.
+            expandpath = False
         if expandpath:
             base = util.expandpath(base)
         if realpath: