2

I'm aware of this answer and maybe there is no solution to my problem in the end anyway. However, what I want to achieve is this:

Whenever a changeset for a repo on my server is incoming, I want to perform some custom tasks. I added a hooks section to hgweb.config:

[hooks]
changegroup = printenv > /tmp/test/env.txt

From the info that printenv gives me I see that I'm able to extract my unique identifier for the repo, but not the name of project! I do need the name of the repo's root folder for an API call. Is there any way I can get this information?

Community
  • 1
  • 1
LarsVegas
  • 6,522
  • 10
  • 43
  • 67
  • External hooks should be executed with the repository's root as the working directory. You can get that via `"$PWD"` or `"$(pwd)"` in a shell script. For the last part of the folder, use `"$(basename $PWD)"` or `"$(basename "$(pwd)")"`. – Reimer Behrends Sep 04 '15 at 16:12
  • What I said, when I look at the output of ``printenv`` I see the content of ``"$PWD"`` but the basename is the unique identifier not the name of the project as it was initially created. – LarsVegas Sep 05 '15 at 08:00
  • 3
    Mercurial projects do not have a name and it is not stored anywhere, except as the directory name (or part of it) as a matter of convention. If you store a repository in a differently named directory, you lose that information. – Reimer Behrends Sep 05 '15 at 16:56
  • You are absolutely right. I thought the server-side directory name was some unique hash created by mercurial. But in my case it is created by the ``django`` app that exposes the repos via an UI. If you put your first comment into an answer, I'll accept. – LarsVegas Sep 07 '15 at 09:54

1 Answers1

2

hg root gives you the directory the repository resides in.

However there is no "unique name" or anything like that - it's simply the name of the directory and it can be changed by a simple rename command on file system level.

planetmaker
  • 5,884
  • 3
  • 28
  • 37