tags:

views:

41

answers:

3

Using Mercurial, say if I do an hg pull and hg up and now the local repo and working directory are both up to date.

What if I commit often, say 1 day later, and then 2 days later, and want to diff with the revision as of right now?

Otherwise, the diff is always comparing to the previous committed version.

I can use pencil and paper and write down the revision number right now, say, 4117, and then 1 day later, 2 days later, and any time before I am sure and push to the remote central repo, do an

hg vdiff -r 4117      

(either using vdiff or diff). But instead of remembering this "magic number" 4117, is there a way to make Mercurial somehow remember this number? That way, hg vdiff is to see the difference between minor changes against committed code, but there is a diff that shows all changes before pushing to the remote repo.

(or, if there is command that shows the revision number since your last pull, which should also show 4117, so on bash we can do something like hg vdiff -r `hg --what-is-last-pull` )

Update: does hg out --patch show the diff of what would be pushed to the remote repo? If so, maybe it serves the purpose without caring the "magic number". But how to show the patch diff using kdiff3 or any other diff tools? Also, it seems we can do hg out and if we see 4118, 4119, 4120, then we know if we do hg vdiff -r ___ we should use (4118 - 1) which is 4117.

Update 2: actually, hg out --patch shows the diff between local repo and the remote repo, so it is close, but not exactly the same as the diff between working directory and the local or remote repo.

+3  A: 

If you want to mark a revision you can use bookmarks extensions. It is shipped with mercurial. Documentationis available here

In your case,

hg pull -u
hg bookmarks lastpull
..hack..hack..
hg ci -m new-hack
hg diff -r lastpull:tip
hg bookmarks -d lastpull
in3xes
How do you prevent the bookmark from being updated on commits?
Rudi
+1  A: 

Do it with multiple clones. When you clone from the remote repo initially use clone -U to create a clone that has no working directory files at all. Then clone again locally, for example:

$ hg clone my-local-clone-with-no-working-files my-working-clone

Do your commits and work in my-working-clone and then at any time you can check the tip in my-local-clone-with-no-working-files to see what the last thing you pulled from the server was. If you want to get fancy you could create a shell alias for:

hg diff -r $(hg -R $(hg root)/../my-local-clone-with-no-working-files id -i -r tip)

which will compare the working directory of the repo in which you run it (my-working-clone) with the tip of whatever you last pulled from the server.

It's worth nothing that this takes no extra disk space because local clones use hardlinks under the covers the the my-local-clone-with-no-working-files has no working directory files.

Ry4an
A: 

You can replace pen and paper with a local tag: hg tag -l -r <revision number on paper> tagname. Notice the -l, which makes the tag local, which means it does not get transferred by push and pull. You can also remove this tag by hg tag -l --remove tagname.

Rudi