I need the current version (version of the latest file) and it's tag to be included in files when I do hg archive.
When using keywords extension in includes the latest version of each file, not the current version.
Example:
repository contents:
file1 Jan 1st 2013 latest change tag v2.0
file2 Mar 1st 2013 latest change tag v1.0
What I need is to generate archive for v2.0 and automatically insert "v2.0" in each file, even if it hasn't been changed under 2.0 changeset.
This is better done in your build/packaging/release system not in your source control system. Since you're using hg archive (great choice) then theres a .hg_archive.txt file that's available to your packaging scripts or you can pass it to your release script as a parameter.
You're better off putting something like VERSION_GOES_HERE in your files and when you're archiving do:
LATEST_TAG="$(hg log --template '{latesttag}' -r)"
perl -pie "s/VERSION_GOES_HERE/${LATEST_TAG"
Related
JDK 8 Update Releases says:
In addition, the source code for the last release, 8u162, is available by cloning the 8u master forest : http://hg.openjdk.java.net/jdk8u/jdk8u and using the 'jdk8u162-b12' mercurial tag.
Can anyone give me a detailed command sequence for the above text? I am not familiar with Mercurial.
You need to do:
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u
cd jdk8u
hg update jdk8u162-b12
You should now have the source code for that tag checked out.
I have a file (some kind of database) which is updated as developers test their code and pushed to a central mercurial repository.
I would like everyone to reuse this file and therefore whenever there is a pull / update from our central repository the local version should be replaced by the one stored centrally. In other words I would like to do a hg update -C for that file only, and having it done automatically upon a pull.
Is this possible to do with mercurial?
Developers can add a hook that does this, but you can't make them (unless you have control over their machines).
Something like this in a clone's .hg/hgrc file will delete the local file so the update replaces it fresh:
[hooks]
preupdate = rm path/to/databasefile
Keep in mind, of course, that update will put in place the version of the file as it appeared in the changeset to which the user is updating. So if you do hg update --rev 0 you'll get the very first version of that file, not the one in the most recent revision.
As an aside, usually if there's a file that changes a lot and is unumergeable you're better off having it be an untracked/ignored file that's fetched out of band -- for example, have your launch script download the latest version.
I have tried to convert an SVN project to Mercurial using svnsync and then:
mercurial-2.2.2/hg convert --authors ../authors.txt project
as described here (the version of Mercurial supplied by Ubuntu crashed when trying to convert the repository, so I deleted the output and downloaded the latest version of Mercurial instead).
However, the resulting repository has
project/trunk/blah
and
project/tags/1.1/blah
as files in the revisions, instead of recognising the trunk as the default branch, and the tags as tags.
What is the right way to convert it?
Please note: The project was originally stored something like this in SVN (due to developer error):
project/project/trunk
but in recent SVN revisions it is like this:
project/trunk
I assumed that hg convert would look at the file structure in HEAD and deduce the correct structure, but obviously I was wrong.
Add to the command line:
--config convert.svn.trunk=project/trunk --config convert.svn.branches=project/branches --config convert.svn.tags=project/tags
I'm using "Mercurial Distributed SCM (version 1.1.2)" on my Ubuntu.
I'm new to mercurial, and just created a new project on sourceforge.net.
I added some code files, commited some changes, pulled & pushed.
I created some tags "0.1.1", "0.1.2" and "0.1.3" using "hg tag" and now I want to pack it all in a revision zip file.
A friend sent me a script that automatically picks a name and create the zip file using
hg parent --template "{node|short}\n{latesttag}\n{latesttagdistance}"
I executed this command but the {latesttag} & {latesttagdistance} doesn't seem to work. When I try:
hg log --template "{latesttag}{latesttagdistance}\n"
it just prints a bunch of empty lines.
Does anyone have any suggestions for why the templates don't work? Should I configure something in some hg configuration file? Does it have anything to do with the fact I don't use branches as I'm supposed to?
Any suggestions could help. I am new to mercurial so it's probably something basic that I don't understand.
Mercurial 1.1 is quite old. {latesttag} and {latesttagdistance} are only available since Mercurial 1.4. If you don't want to update Ubuntu (Ubuntu 10.10 comes with Mercurial 1.6), you can use a PPA repository.
If you have a Ubuntu-derivative, you can install the newest version from launchpad:
https://launchpad.net/~mercurial-ppa/+archive/releases
For a given file in a Mercurial repository, how can you see the revision history?
And how can you diff two revisions of the file?
Ideally doing all this with visual tools (we use ExamDiff to do some other diffs).
I'd say this is basic source control functionality but I can't seem to figure out how to do this with Mercurial.
hg log file
hg diff -r 10 -r 20 file
The hgk extension gives you hg view file command that shows a visual history, from which you can diff/vdiff arbitrary pair of revisions.
TortoiseHg gives you thg log file command that does the same thing but looks better.
For readability
hg diff -r revision1:revision2 file
Where revision1 and revision2 can be a tag, changeset etc.
If you use TortoiseHg:
Windows users can use Windows Explorer and view the revision history by right-clicking on the file.
For Linux users, you can do it within TortoiseHg but it took me a while to figure out how. You need to right-click on the desired file and select "File History". However, for some mysterious reason, the file needs to be unaltered. Furthermore, to find the desired file there are two options:
In ### revision set query### one can type:
file("**<myfile>")
The double ** are necessary to search directories recursively. This gives you immediately an list of all repositories in which the desired file was changed.
Alternatively, next to the ### filter text ### click first on the question mark sign and select "clean" to see all files in the repository. Then inside the ### filter text ### box you can narrow down the number of files shown.
Alternatively, Linux users can do it from a terminal as suggested by Geoffrey Zheng above:
thg log file