views:

58

answers:

1

I have the habit of diff'ing all the changes I made before pushing to any repo. But I found that if I never commit for that period of development, such as for 5 days, then I can merge with other people's code, do testing, etc, and I can diff or kdiff3 and see all the changes I made, remove any debug code, fix any small things, and then push to the repo.

However, if I ever committed within this 5-day period, then it seems there is no easy way to "show all my changes".

The closest solution I have is:

hg log -u MyUserName -r tip:4322 --style ~/hg-style.txt | sort | uniq | xargs hg vdiff -r 4322

where ~/hg-style.txt is

changeset = "{files}"
file = "{file}\n"

and 4322 is before I start the 5-day development work. Then the above can diff all the files that was changed by me, but it also includes the changes of my teammates if they made changes to those files, and there can be lots of changes too.

Is there any easy solution?

+3  A: 

Let mercurial do the work for you. Use hg outgoing to see what you've commited but not pushed. Use hg outgoing --patch to see the actual diffs for those. Use hg status --rev tip --rev 4322 to get the list of changed files like you're doing above.

And for the love of all things holy commit frequently!

Ry4an
The most common use of a repository is to back out a change that broke something. More frequent commits means smaller chunks top back out, and less code to check when you do find which commit broke the system. Waiting five days to commit is insane for this reason, not to mention it means that any code of yours that a coworker uses will be at up to a week out of date.
Mike DeSimone
@Ry4an so `hg out --patch` is the command that will do it? It is a text version of diff. Is there a way to invoke it with `kdiff3`?
動靜能量
@Ry4an We cannot `hg status -r tip:4322` coz it is the remove flag... Hm... this hg and git are both like a 1 unit college class, while SVN is like "you can learn most in 1 hour"
動靜能量
It works for me. I'm on mercurial 1.6.3. If it doesn't then hg status with a single --rev should compare current parent to tip. Your brain just got poisoned by svn. You'll get over it and then DVCS will seem much easier. Besides, did you ever try to branch with good old CVS? *shudder*
Ry4an
I didn't say `hg status -r tip:4322` -- I said two full `--rev` arguments.
Ry4an
yes... I tried it and it worked... just need to be careful not to use `-rev` by mistake but need `--rev`. Is there a way to show the diff using kdiff3 when `hg out --patch`?
動靜能量
kdiff3 couldn't show the output of `hg outgoing --patch` because outgoing shows each changeset separately (ex: 100 csets each changing the same file will show up as 100 patches), whereas kdiff3, etc compares 2 (or 3) specific snapshots.
Ry4an
so we have to look at the text diff results? those are just too hard to read and what takes kdiff3 to tell in a seconds can take minutes in text diff.
動靜能量
@Ry4an maybe there's a way with revset to find the base cset and call hg diff -r <base> -r <tip of outgoing> ? (with kdiff3)
tonfa
Tonfa, yeah, I was thinking that his "commit periodically" workflow had him with lots of csets that needed to be considered separately. If seeing "everything I've done that they haven't" is the only goal, I'd suggest he just keep a virgin clone around and then kdiff3 between the two repositories (after updating each to tip).
Ry4an
is the idea to compare the current repo with another repo with all other people's commits? what is the command to compare to the virgin clone? Isn't it true that for that virgin clone, you still need to `hg pull` and `hg up`, so can't you just create that clone later on and compare the "current local repo" with "current remote repo"? (it can show visual diff?)
動靜能量
actually, can't I just push to the remote repo, and then clone another repo from that remote repo. Now since my push has all the commits in a row, I can just do an `hg vdiff -r 4022:4008` and be able to see all the changes I did for that push visually?
動靜能量
Yeah, you can create a clone without your unpushed changes anytime you want. Just clone and then without mercurial involved at all you can do 'kdiff3 mynewvirginclone myworkingclone' (that might require a --recursive option or something I don't install KDE).
Ry4an
There's not quite a guarantee that no one else will push between your pushing and your cloning, but yeah, if you're adding a linear group of changesets that will work just fine.
Ry4an