I have executed hg update -C and I got the minimal message x files update, y files removed etc..
How can I get more verbose information about which files were affected after executing the update?
If you know what changeset you had checked out before you updated you can do hg diff -r THAT_REVISION and see a diff or a stat depending on other options.
After you've done the update you're sunk if you don't know what you'd checked out previously . If that's happening a lot of you you could add a pre-update hook that echoes the current revision id before updating.
Adding -v will give you more information - it lists all the files that were changed.
Oddly, hg help update doesn't mention anything about the -v flag but it does work.
Related
I am new to Mercurial. I had made some some changes in the code in some of the files and i hadn't committed them yet. but when I did hg update -c <branch-name>, all my code changes were gone. Is there any way I can get my code changes back or am I screwed?
Are you perhaps using a very, very, old version of Mercurial?
The help for hg update shows that -c won't discard uncommitted changes:
-C --clean discard uncommitted changes (no backup)
-c --check update across branches if no uncommitted changes
That's been the case for at least four years. If you try to update to a revision that would discard your local changes Mercurial warns you:
ry4an#four:~/test$ hg checkout 0
abort: uncommitted changes
(commit or update --clean to discard changes)
If you used -c it should have done nothing. If you used -C you should find whomever suggested you do so and yell at them.
Sorry for your loss. :(
Unfortunately no, as explained in the update help (hg help update), --clean don't create backup.
Check if you can get the old version of your files with your text editor with CTRL + Z, it already saved my life.
Is it possible to know when a certain commit was pulled from a distant repository and the files updated with Mercurial ?
More precisely, I made a hg pull -u a few days ago, and now I'd like to know if this pull downloaded only the last commit, or if there were some commits that had not been pulled yet, making my last pull getting them as well.
hg log seems to give the dates of the commits, but nothing about the updates. Is this information anywhere ?
This information is not recorded by Mercurial. A Mercurial repository is just a container for changesets and Mercurial does not store how (or when) the changesets entered the repository.
You can setup hooks for this, though you would have to build the scripts yourself. A very rudimentary system would be
[hooks]
pre-pull = (date; hg root; hg tip) >> ~/.pull-log
post-pull = hg tip >> ~/.pull-log
This would record the current date, the current repository, and the current tip in ~/.pull-log just before every hg pull. After the pull the new tip is recorded. You could build scripts that parse the log file to extract information about what each pull did.
hg log seems to give the dates of the commits, but nothing about the updates
Yes, hg log is only concerned with the stored history (changesets) and working copy operations like updating is not part of recorded history.
Finally, let me mention that this is the first time I've seen someone ask for a "pull log". However, the opposite is quite common: there are scripts for maintaining a "push log" on a server to see who pushed what and when. This is done by Mozilla among others. See this README for some starting instructions.
If you want to log when and with which revision hg update was used to update the code, then use these hooks:
[hooks]
pre-update = (echo "---------------------------------"; date --rfc-3339=s; hg root; echo "pre-update:"; hg identify --id --branch) >> .hgupdates
post-update = (echo "post-update:"; hg identify --id --branch) >> .hgupdates
the above hooks produce a log entry like this for each time hg update is run:
2015-12-23 00:44:31+02:00
/var/www/my/project
pre-update:
802120d1d3a0 somebranch
post-update:
302720d1d3d2 otherbranch
This also works when hg update is run without a specific revision flag (-r) set
You can use qdiff to see the differences between the repository and the changes you've made in your patch queue thus far (even with qrefreshed changes). Is there a similar command for status, so that you can see all the files that are modified, even once you have qrefreshed the changes to those files?
This will show you changes in the currently applied patch:
$ hg status --change .
And this one will include changes also in your working dir:
$ hg status --rev .^
according to Mercurial's commit help message:
If a list of files is omitted, all changes reported by "hg status" will be
committed.
Is there an easy way to change this behavior?
I'd like Mercurial not to commit any changes, unless the files are explicitly specified.
edit
I am on Linux and I am using the command line.
This seems to do the trick:
$ hg commit -X *
nothing changed
It doesn't do anything because all files are excluded, but if you give any files, those will be included.
You could alias it:
[alias]
xcommit = commit -X *
then:
$ hg status
M a
M b
$ hg xcommit -m 'no files specified'
nothing changed
$ hg xcommit -m 'picking a' a
$ hg status
M b
Personally I wouldn't want to get used to this type of workflow. It's usually just as easy to:
work in smaller chunks so your changes reflect a single changeset
for the times when you forget and you're on a coding spree, use something like hg record
for the really few times when the above two don't fit, use -I/-X for that single commit
if you are using GUI like tortoiseHg you can select the files you need to commit. http://tortoisehg.bitbucket.io/
How does Mercurial tell a file was modified?
The reason I am asking is because when I run hg status its telling me several files are modified.
However, when I run hg diff there are no changes to report.
I have a theory as why this is happening: (but I am not positive)
I am using NetBeans which has Mercurial support built in. When I edit a file, it shows it as modified, although if I undo (rather than revert) those changes and save it, NetBeans tells me there are no local changes. So I am guessing NetBeans uses diffs to check for modifications while Mercurial is using something else like modification-date.
Is this correct or is something else the cause?
Mercurial does not use modification date to determine the status. This can be verified with a simple experiment:
hg init
echo "This is a test" > test.txt
hg commit -Am "commit"
touch test.txt
hg status
The code which performs the status check is in dirstate.py. If the dirstate is unsure about a file's status (e.g. because only the modification time differs, then it passes it up to localrepo.status for further analysis as seen here.
The hg help status text has some clues that may help:
status may appear to disagree with
diff if permissions have changed or a
merge has occurred. The standard diff
format does not report permission
changes and diff only reports changes
relative to one merge parent.
When you run hg diff, are you specifying any command-line options?
Is it possible the permissions of the file changed? Try hg diff --git which shows the git-style extended diffs that support permissions and binaries. By default hg diff shows only patch-friendly diffs, which don't show permissions changes.