123

I want to generate a list of which files changed between two revisions in a given directory in Mercurial.

In particular, I am not interested in what changed, but which files changed in that directory.

E.g., supposing that between then and otherthen, only 2 files changed:

>hg hypothetical-command -r then:otherthen
foo.baz
bar.baz
>

What's the hypothetical command? I've tried diff and log, but I can't see how to convince them to do it: either I get the patch(diff), or I get the whole repo(log).

0

2 Answers 2

172
hg status --rev x:y

where x and y are desired revision numbers (or tag or branch names).

If you are using the terminal in windows add hg status --rev x:y> your-file.txt to save the list to a file.

4
  • 3
    To only see changes in the current directory: hg status --rev x:y .
    – User
    Dec 3, 2013 at 5:04
  • 16
    To see the changes in the latest revision: hg status --rev .^
    – kunigami
    Apr 4, 2014 at 21:44
  • 9
    To get just the list of filenames (and no prefix character indicating the type of change), append -n, i.e. hg status --rev x:y -n
    – Cheetah
    Aug 11, 2015 at 20:57
  • 1
    hg status --change . lists the changed files in . - same list as hg status --rev .^ but more directly
    – Metaxis
    Oct 14, 2015 at 23:21
15

status is what you need.

But, depending what you mean by "between two revisions", you might also consider using the "x::y" (DAG - Directed Acyclic Graph) range.

Given parallel changesets,

1--2---4 \---3

hg status --rev 1:4 would return (1,2,3,4), i.e. anything between and including the endpoints, according to the local, numerical rev. This might (and most probably will) return different results in other - though related - repositories!

hg status --rev 1::4 would return (1,2,4), i.e. the endpoints, and all changesets which are descendants of '1' AND ancestors of '4'.

The latter case, x::y, is usually more useful in real-world applications. This is what you get via TortoiseHg\Visual Diff.


>hg help revsets:

"x::y" A DAG range, meaning all changesets that are descendants of x and ancestors of y, including x and y themselves. If the first endpoint is left out, this is equivalent to "ancestors(y)", if the second is left out it is equivalent to "descendants(x)".

1
  • 1
    Maybe you need to include explicitly the command so your answer isn't dependent of the other and more fool-proof. Something like "Yes, status is what you need. For example hg status --rev x::y".
    – PhoneixS
    Mar 29, 2016 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.