Mercurial - all files that changed in a changeset?

MercurialDiffChangeset

Mercurial Problem Overview


How can you determine all the files that changed in a given changeset?

I'm not looking for a diff in this case, just a list of add/remove/modifications.

hg log -vprX does a list of diffs but I just want the files.

Mercurial Solutions


Solution 1 - Mercurial

If you want to list only files that have changed then you should be using "status command" The following will list the changes to files in revision REV

hg status --change REV

Solution 2 - Mercurial

Just remove p from your hg log -vpr will show the list of files. -p means show patch. You can also use a template to format the output to your taste.

Solution 3 - Mercurial

#Current Committed Revision

hg status --change .

. is shorthand for the current rev, just like @HEAD in Git

#Current Uncommitted Revision

hg status

#Arbitrary Committed Revision

hg status --change REV_ID

Solution 4 - Mercurial

I know the question is for a single changeset, but if you'd like to get all the files modified for a range of changesets, you can do

hg status --rev 1 --rev 10 -m

Solution 5 - Mercurial

Found this question through Googling for a similar concept. To show all files that changed through a range of changesets, it's as easy as:

hg log -r [start rev]:[end rev] --template "{file_mods}{file_adds}\n" | sed -e 's/ /\n/g' | sort -d | uniq
  1. hg log -r [start rev]:[end rev] --template "{file_mods}{file_adds}\n" will show you a list of each file changed or added in each changeset, from [start rev] to [end rev], with each changeset's files on a new line. Swap {file_mods}{file_adds} with {files} to show all files modified, added, or removed.
  2. sed -e 's/ /\n/g' will split all the files to show on separate lines and
  3. sort will, er, sort the list for you so we can filter the list with uniq
  4. uniq will filter the list to remove duplicates—files that changed in more than one revision.

Solution 6 - Mercurial

I know this question is an old question and I'm surprised nobody just offered modified code form OP. I got a list of modified/added/removed files (not labeled which is which though) by just running hg log -v. Or what I actually needed hg log -v -l5 to see files that have been modified/added/removed in the last 5 commits (including the ones that I didn't push yet to the repo).

Solution 7 - Mercurial

If you're like most shops, you use a ticketing system to track changes. If you know the ticket number and want to find all the commits associated with that ticket (assuming you include the ticket number in the commit message), you can use:

hg log -k TICKET_NUMBER

This does display the all the revisions associated with the ticket. However, it does not list the files. You could do use one of the answers above to then get the list of files associated with the revisions.

To make it simpler though, combining the info from the previous answers, you could do the following to search for commits, including files changed:

hg log -vk TICKET_NUMBER

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarcus LeonView Question on Stackoverflow
Solution 1 - MercurialpyfuncView Answer on Stackoverflow
Solution 2 - MercurialGeoffrey ZhengView Answer on Stackoverflow
Solution 3 - MercurialGiboltView Answer on Stackoverflow
Solution 4 - MercurialNick DeVoreView Answer on Stackoverflow
Solution 5 - MercurialEric L.View Answer on Stackoverflow
Solution 6 - MercurialĐorđe RelićView Answer on Stackoverflow
Solution 7 - MercurialiDimensionzView Answer on Stackoverflow