-1

I am trying to create a mercurial repository in a directory whose name includes dollar signs. This is an equivalent and simplified example of what i get on windows 10 cmd.exe with mercurial 4.1.3 :

C:\test\dir1>hg init

C:\test\dir1>hg status

C:\test\dir1>cd ../dir$$1

C:\test\dir$$1>hg init

C:\test\dir$$1>hg status 
abort: repository C:\test\dir$$1 not found!

so i hope this is clear, the only difference seems to be the dollar signs in the second directory name. thanks in advance!

Dan Wasson
  • 21
  • 4
  • Looks like it doesn't work. What's your question? – John Zwinck Nov 11 '17 at 04:27
  • This is a recipe for all kinds of headaches, if you even find a way to make it work. Why are you trying to do this? – elixenide Nov 11 '17 at 04:32
  • John, thanks for your response, sorry my question was not stated clearly. Is there way that I can use Mercurial on windows 10 in a directory whose name has dollar signs? Thanks – Dan Wasson Nov 11 '17 at 04:37
  • Ed, I put special chars, either $ or @ on my stuff so it sorts on top of the junk windows likes to create. While the example above doesn't have the dollars as the first chars, it's intended to be as simple as possible while showing the unexpected Mercurial behavior. Thanks for your response – Dan Wasson Nov 11 '17 at 04:41

2 Answers2

1

Mercurial seems to treat dollar signs as an environment variable escape:

C:\test>set X=abc

C:\test>echo $X          # Not the shell expanding it, that would be %X%.
$X

C:\test>hg init $X

C:\test>dir
 Volume in drive C has no label.
 Volume Serial Number is CE8B-D448

 Directory of C:\test

11/10/2017  09:27 PM    <DIR>          .
11/10/2017  09:27 PM    <DIR>          ..
11/10/2017  09:27 PM    <DIR>          abc
               0 File(s)              0 bytes
               3 Dir(s)  53,899,231,232 bytes free

Mercurial has expanded $X as an environment variable. Also:

C:\test>hg init dir$$x

C:\test>dir
 Volume in drive C has no label.
 Volume Serial Number is CE8B-D448

 Directory of C:\test

11/10/2017  09:30 PM    <DIR>          .
11/10/2017  09:30 PM    <DIR>          ..
11/10/2017  09:30 PM    <DIR>          dir$x
               0 File(s)              0 bytes
               3 Dir(s)  53,899,091,968 bytes free

Two dollar signs insert one dollar sign. When you are in a directory named dir$$x, Mercurial is using dir$x for the name. I found a workaround with hg -R. status, but better to avoid dollar signs.

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
  • Thanks Mark Tolonen for your very clear demonstration of how hg works in this case. I should've have looked at [these docs from selenic](https://www.selenic.com/mercurial/hg.1.html#specifying-file-sets) before asking. Will take your advise and avoid using dollar signs. Thank you – Dan Wasson Nov 11 '17 at 19:31
0

this has been entered as a Mercurial bug : https://bz.mercurial-scm.org/show_bug.cgi?id=5739

Dan Wasson
  • 21
  • 4