How do I get a list of files modified between two arbitrary changesets?
Asked Answered
G

4

15

My only guess is something horrible like this:

# files where something has been added
hg diff -r AA -r BB|grep -- +++|cut -f1|cut -d/ -f2- >/tmp/ka

# files where something has been removed
hg diff -r AA -r BB|grep -- ---|cut -f1|cut -d/ -f2- >>/tmp/ka

# filtering out "dev/null": it appears when a file is added or removed from the repository
sort -u /tmp/ka |grep -v dev/null

What I need is the files modified between changeset AA and changeset BB. Something like hg diff -r AA -r BB but file names only, instead of a whole diff.

Maybe there's a mercurial command I didn't notice? The changesets I want to examine are not consecutive, otherwise I could have just used hg status.


NOT the modified files of a single changeset.
edit: I need to do this because I'm working with some programmers from the Bronze Age who don't understand what a .diff is, please bear with me...
Ginzburg answered 26/3, 2012 at 15:5 Comment(1)
Related: #3789942, although this question is a more general one IMO.Coachwhip
D
33

hg diff -r 182 -r 193 --stat

or

hg status --rev 182:193

Dunlavy answered 26/3, 2012 at 15:55 Comment(2)
--rev and -r behave the same on my system...was that a bug in 2012?Disinterest
Seems like it's fixed now, yes.Dunlavy
W
8

The basic command to look for when you want to know something about file status is hg status. The status command is the file name oriented command and you want to know some file names.

When you run it as

$ hg status

then it compares the working copy state with the working copy parent revision (.). But if you run it as

$ hg status --rev AA:BB

then it will show files modified between AA and BB! No need for grepping, cutting, sorting or templates.

(I've explained this before here, here, and here, please see those questions and answers for more tips.)

Wichern answered 26/3, 2012 at 19:9 Comment(2)
Doesn't work with -r because " -r --removed show only removed files" - that's a hard UI fail.Dunlavy
@asaddude: ups! Sorry about that, I've fixed it to use --rev instead.Wichern
D
0

Solution one. Diff-based

>hg diff -r 3 -r 4 --stat
 comments.php  |  14 +++-----------
 functions.php |  15 +++++++++++++--
 header.php    |   2 +-
 readme.txt    |  17 ++++++++++++++---
 sidebar.php   |  43 ++++---------------------------------------
 style.css     |  18 ++++++++++++------
 6 files changed, 47 insertions(+), 62 deletions(-)

you can get changed files by grepping on "|" char, or (better and nicer approach from my POV) pipe output to gawk, which, for record with exactly 4 fields, print $1

Solution two. Log + templating + revsets

>hg log -r "3::4" --template "{file_mods}\n"
footer.php functions.php header.php search.php style.css
comments.php functions.php header.php readme.txt sidebar.php style.css

convert to list, remove (possible) duplicates I'll leave for you

Daglock answered 26/3, 2012 at 16:0 Comment(0)
C
0

You can do something similar to hg stat in Tortoise Workbench.


The simplest / most built-in way is:

  • In the main listing of revisions, click/select the two that you want to compare
  • Right click one of them
  • From the context menu, select "Visual Diff..."

This will produce a window similar to the following example:

enter image description here

(Then just click the [X]).

This screen may have limited use however... for instance you can't readily export it, other than taking a screenshot. You can copy/paste the text of individual lines one-by-one, however.


An alternate way which produces a useful text output is to automate the use of hg stat right from THG Workbench, by adding a custom tool.

  • File menu > Settings
  • Global settings tab
  • Leftnav > Tools section
  • [New Tool...]
  • Enter details as shown in the screenshot:

enter image description here

  • Click OK
  • Then make sure to add the "filecomp" tool to at least one of the GUI locations in the dropdown
  • Restart THG

Now when you run that tool, you'll automatically get the results in the log pane. You can select a single or multiple changesets and it will compare them accordingly.

Note - alternately you can configure this in the settings file by adding:

[tortoisehg-tools]
filecomp.command = hg stat --rev {REVID}
filecomp.enable = istrue
filecomp.label = FILECOMP
filecomp.showoutput = True

The macro {REVID} will expand to text like 33a6bd983eab if you selected one changeset in the list, or like 33a6bd983eab+a41898ae15c4if you selected two, etc.

In this method you can actually select > 2 changesets and it will report on the combined differences among them.


Also just to note there is an alternate syntax for stat to get a listing of what file differences exist between any two changesets which I don't think was mentioned in the other answers:

hg stat --rev A --rev B

where A and B are the changeset IDs (which look like 1c845eefe22e).

(You could also use the revision number like 12345 in place of the changeset ID, but be aware that these are not permanent values unlike the IDs).

A and B could be on any two branches, or the same branch, it doesn't matter, as long as both exist in the local clone you are working with.

Coachwhip answered 17/7, 2019 at 16:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.