Mercurial: Last version dynamic link - mercurial

Is there any way to provide stakeholders a URL that will retrieve always the last version of an specific artifact versioned with Mercurial?
Thanks in advance.

If your'e running 'hgweb' there is -- use tip instead of the changeset node id (hash) in the URL. So a URL like this:
https://www.mercurial-scm.org/repo/hg/file/1c92524c37cd/CONTRIBUTORS
becomes
https://www.mercurial-scm.org/repo/hg/file/tip/CONTRIBUTORS

Related

Generating a file with Tag or Branch Name in mercurial

I need in my source code to have a text file which contains the current Tag and Branch name.
Generally I want it for browsers "cache killer", I can read this file and append it to every script/css call.
for example: <script src='file.js?v=1.0'></script> the 1.0 will be coming from this generated config file.
I am working in PHP and C# So I need this kind of functionality built in the source control.
Is it possible? I dont want to do it manually, to risky.
Thanks
hg log -r. --template='{branch}-{latesttag}' would give you the branchname of the currently checked-out revision and the last tag preceeding it in its list of ancestors. Either use that call to hg directly or write it to a config file.
See hg help templates and maybe also hg help revsets

Is there a way to email regular, aggregated mercurial changesets reports?

In an effort to boost code reviews, I am looking to send a daily/weekly/monthly/some_regular_interval report of changes from mercurial? I figure that if a person does not have to go and find the changes, but they are instead brought to the person, then that should be a step in the right direction. However, I did not see anything already out there. (We use mercurial with TortoiseHG and Jenkins for the automated build in case any of those tools might help?)
What I am looking for:
MUST HAVE
commit message
list of files that changed
NICE TO HAVE
changeset guid
name of person who did the commit
some means to see what changed on each file (probably best via a URL or else the email could become overloaded)
You don't state what OS you are using. I am assuming Windows since you are using TortoiseHG.
On Linux (or other UNIX-based OS) you can create a cron that runs once a week/month/whatever. The following simple script satisfies most of your requirements on my Linux machine:
LOG_DATE=`date -d "1 week ago" +"%Y-%m-%d 00:00:00"`
hg log -d ">$LOG_DATE"
If you use Mercurial templates you can get exactly what you want. You can construct a URL using the changeset ID to point to a Mercurial web-server.
Would the notify extension work? You can configure this on a designated master repository so that emails with a summary of the changes (you can customise the template to include the short form of the hash, the user name, the commit message) along with URLs to the individual changesets are sent out to people whenever changese are pushed to the master repository.

Mercurial API: How can I get the coming content of the file which was pulled but has not been updated yet?

I'm a complete noob at Mercurial API and Python, but I'm trying to write a useful extension for myself and my colleagues now.
Let's assume I have a repository which contains some code and an auxiliary file .hgdata. The code and .hgdata are both under Mercurial's control. When I execute a command pull-extended which is provided by my extension, I want it to make a pull and then to analyze the state of a .hgdata and probably make some additional actions. The problem is that when my command is invoked, it just pulls the incoming changesets, but it can't look into the actual .hgdata without making a preceding repository update. Is there any way to watch the after update .hgdata besides repository update?
I've received an answer on the Mercurial's official IRC channel:
In order to get an actual file state after making a pull, we may use repo[revision][file].data().
P.S. I haven't checked that yet. If it works, I will close the question.

Checking commit message in TortoiseHG

I wonder if it is possible in TortoisHG, like in TortoiseSVN, to check if a commit message includes an issue id?
In TortoiseSVN you could set the bugtraq properties on the repo to make a dialog box pop up and warn if an id was not included, and I am looking for a way to do the same thing (still need it to be possible to check in, just show a warning that id is not included and be able to abort the commit if you want to).
Thanks in advance
Jonas H.
As far as I know, nothing like that is possible directly in TortoiseHG.
But TortoiseHG is only a GUI for Mercurial, and in Mercurial, you can do stuff like that with hooks.
See chapter 10 in the HG book for a general desription of what hooks are and how they work:
Handling repository events with hooks
There is even a specific example in this chapter that rolls back a commit if it doesn't contain a bug id.
This dialog in TortoiseHg 2.4's settings looks like what you want:
I only know about the setting issue.linkmandatory = True which forces entry of an issue reference specified in issue.regex and issue.link on every commit.

Mercurial replacing values in a file that been cloned?

Say I'm cloning a repository that I always clone to C:\working_copies\<customer-name>\<customer-project>\ and that the project has variables in it's build.properties that get filled in with <customer-name> <customer-project> (by me) everytime I clone the repo.
Is there a way that I can fill in these values in the file automatically by placing some special value in the file (in ant it's something like ${base-dir} or something like that) that would fill in these build.property values for me?
option 1: make sure build process only relies on relative paths, and dont change name/project variable
option2: write a hook, specifically a post-clone hook, try the book for a hook tutorial
No, Mercurial is completely unaware of what is outside of it's repository folder.
You should be able to rig this up using the Keyword Extension. Just set up a HGRC that populates the working directory with the values you want upon update.