TheVyom
TheVyom

Reputation: 533

Mercurial: How do I find out the difference between my working copy and another copy

I am new to Mercurial and mostly worked on Clearcase.

Before I pull in changes from the latest branch, I would like to know the changes that are there and which files have conflicts. (Mainly to see if I should do a update now or later.)

Is there any way do do a hg diff between a working copy and another?

Upvotes: 4

Views: 4310

Answers (4)

Thanos Papathanasiou
Thanos Papathanasiou

Reputation: 952

If you are using TortoiseHG then you can use the incoming button which downloads the incoming changesets but gives you the choice to apply them or not.

See here.

Upvotes: -1

Laurens Holst
Laurens Holst

Reputation: 21036

You can check what changes are in the other repository using:

hg incoming path

This is basically like pull, however it doesn’t actually pull.

But actually, you can usually just pull, because pulling incoming changesets doesn’t touch your working copy. Only when you update or merge does your working copy get updated, with a risk for conflicts.

Ideally there would be an option on update and merge to do a tentative merge, that is, it would merge unless there is a conflict, but afaik such an option currently does not exist yet.

Once the changes are pulled into your repository though, you can use diff to compare it with your working copy as usual.

hg diff -r tip

Upvotes: 8

Rafael Piccolo
Rafael Piccolo

Reputation: 2338

In first place, you should commit your changes before doing anything. I never worked with ClearCase, but I think it must work like SVN, forgive me if I'm wrong. One of the greatest advantages of DVCS over CVCS is that it allows you to commit first and decide what to do later. That's very important because you consolidate your work first, if things start to get too messy in the merge later, your work is safe in the repository. In the worse cenario you can even abandon the messy merge and start all over again. And even after the merge, the version of your original work (before the merge) will be there, very important to check if that merge introduced some problem. In SVN (and assuming ClearCase is similar) it's the opposite: it doesn't allow a commit without an update and merge... I hate it!

Another thing, the pull command in mercurial doesn't change anything in the working directory. It just brings the changes to the local repository. So, in my oppinion, you should:

  1. Commit
  2. Pull, nothing will happen with the working copy
  3. Now you can check the log, compare the revisions and decide what and how to do with no risk of loosing your work. If you decide that you won't merge now, that's fine, you don't have to merge things just because you pulled other revisions (although the recommended practice is to merge often to avoid headaches merging very different revisions)

Upvotes: 2

Lazy Badger
Lazy Badger

Reputation: 97282

s there any way do do a hg diff between a working copy and a another ?

No. diff compares two revisions from repo. In you case you can blindly pull (get updatesto repo), but avoid automatic update|merge of your working copy. With synced repo you can use hg diff, hg update, hg merge by hand when and if it's needed. You can also do nothing and commit your changes - you'll have anonymous branch only and additional head in repo

Upvotes: 2

Related Questions