In CVS you can add a $Log$ in a file that you commit and it will save CVS commit comments into the file upon each commit. Is there anything similar for Mercurial?
Yes, the keyword extension let's you do some of this. However, it doesn't support multi-line keywords like $Log$. It's also not very recommended to include the history like that. Running hg log is considered much better.
Related
So we work in "named" branches with what we do, but it's now come to light that this "name" we use should also be used in the commit message to help with tracking etc.
If we're using TortoiseHG or Mercurial, is there a way to automatically append/preappend the brnachname to the commit message?
I've looked around and can't find anything that matches exactly what we need :(
So for example:
hg commit "did a change" in the "RR-3498" branch will become something like
"RR-3498 did a change"
or
"did a change RR-3498"
Thanks
this "name" we use should also be used in the commit message
Branch name must NOT be used (I can not emphasize more strongly here) in commit message - it's redundant, duplicate information, which require additional actions for extracting from log message for processing
Branch-name in Mercurial is permanent meta-data, always stored in each changeset.
If you use Mercurial for "tracking", then the most of usable commands (I can imagine only hg log for now) are templateable, and you can output branch name easy. If you use some external tool, you can on preparing data for it from Mercurial combine "clean" commit-message and branch-name of changesets
Don't forget about MYOB principle
You can write a hook for this.
That said, this requirement sounds like from a pointed-hair manager.
I use Tortoise Mercurial tool to manage my mercurial repository.
And I have a separate .diff file containin0g changes to a file in my repository.
Is there any way how to use that diff to update my file ?
thank you
Most Linux repositories comes with the patch program. You can then execute:
patch original.data difference.diff
Patch will modify the original.data file in such a way that if one would calculate the diff between the final and original state, one gets the same difference.diff again.
.diff files are in general not visible in a subversioning respository. They are stored internally to hide the several commits from the user. Diffs however can be usefull to analyze the difference between two commits. Say for instance somebody worked on your project and made a lot of commits, you might want to inspect what that person actually did without having to read the reports of all commits (since some changes can be undone in the next commit)
I'm working in this file and I come across a piece of code which I think has changed at some point in history, and I would like to know where it changed.
It's a pretty big file with a lot of history, so when I use hg diff, I get a enormous list and I don't think it's efficient to search through that.
It would be really neat if I can look into an old revision of the file, to see what the file looked like at a certain point in time. Then I can see how the code worked back then so I can conclude how the bug evolved. Of course, I want to do this without updating the file, because I'm currently working in it and have made changes in it.
So, is there any way you can look into the history of a file without updating it?
There are a few tools to help you:
To get the history of a file you can just use hg log FILE which is probably the best starting point.
You can also use hg annotate FILE which lists every line in the file and says which revision changed it to be like it currently is. It can also take a revision using the --rev REV command tail to look at older versions of the file.
To just list the contents of a file at a given revision you can use hg cat FILE --rev REV.
If it proves too hard to track down the bug using those tools, you can just clone your repository somewhere else and use hg bisect to track it down.
hg bisect lets you find the changeset that intoduced a problem. To start the search run the hg bisect --reset command. It is well document in Mercurial: The Definitive Guide.
I just ran:
hg add .*
which matched all ../something files and which was something I certainly did't want! What is the easiest way to undo this command?
Not exactly what I was after, but made my life easier:
hg forget "set:added()"
this unmarks all the files that were added in the working repository. Obviously I also unmarked all the files that were added in preceding commands, so as I said this is not exactly what I was after...
If you've got a lot of uncommitted adds that you don't want to have to do over, you can use a mercurial fileset that only picks out pending adds in subdirectories of the parent directory (use this in the same directory where the erroneous command was issued):
hg forget "set:../** and added()"
Mercurial doesn't remember what path you used to refer to a file, so this will forget all files (under the parent directory) that were just added; but if you were deep in a large repository, it'll limit the scope of what you discard.
Your question is similar to this recent question, but here we have an extra condition on the mistakenly added filenames.
There is not built-in way to undo a hg add command.
The underlying problem is that hg add is manipulating the so-called "dirstate" (short for "working directory state". This is where pending changes such as files scheduled for commit is stored — and this storage is unversioned.
There is an extension, though, that can help you: hg-multiundo will make backups of all files touched by Mercurial, including the dirstate. This means that you can use it to undo things like hg add or even hg revert --no-backup.
If I do 'hg status' and see the following:
R flash/AC_OETags.js
it seems to mean that there is no file there, but there has been one at some point that has been removed.
How do I 'commit' this change so it stops showing up when I do 'hg status'?
==UPDATE==
The answer seems to be to commit the file. Actually, there are ~100 files with status R because I removed an entire directory tree. Anyone know how to commit all files in a directory tree in one go?
I don't want to do just hg commit, because there are other changes too.
The “R” means “Removed” so the next time we commit in Mercurial this file will be removed. (The history of the file will remain in the repository, so of course we can always get it back).
therefore run your hg commit command and all will be well
Thanks to hginit.com for that titbit - its my Mercurial bible
You can commit just that file:
hg commit flash/AC_OETags.js
however having "masses of other uncommitted files" is terrible process. You need to come up with a workflow that lets you commit frequently.
You can use the repository explorer from TortoiseHg to easily manage the files you want to include in a commit.
Also, removing a directory probably warrants a changeset in itself. You should get into the habit of committing more often (one concept, one commit... and it's local anyway). Furthermore, as long as you haven't pushed your changes to anyone (or anyone pulled from you) you could still use hg rebase --collapse to regroup some changesets if you think you have separated too much (this is a more advanced feature that I suggest you try on a test repository first as you could break things if you're not careful)