voithos
voithos

Reputation: 70602

Mercurial, check if a particular version of a file has existed in the history before?

To somewhat elaborate on the title question, is there a way to have Mercurial search through the repository history for a particular version of a given file, and show all of the revisions (or just the most recent one) that contain that version?

For example, let's say that the current working revision is, say, 300 and a file was reverted to an earlier version (say, revision 200). I don't know this - all I can easily see is "how different" the new file is from the 300 version. How can I find out all of the possible revisions that it could have been reverted to?

And if Mercurial cannot do this natively, is there another tool that can? (TortoiseHG?)

Upvotes: 2

Views: 236

Answers (1)

regularfry
regularfry

Reputation: 3268

I don't think this is possible with any of hg's built-in functionality, but you can get something like it with judicious xargs and md5sum application:

hg log --template "{rev}\\n" | xargs -I "{}" /bin/bash -c 'echo $(hg cat -r {} <filename> | md5sum) {}'

This will give you a list of md5 checksums with the revision number, which when you sort it will give you the revisions sharing versions of the file.

Upvotes: 2

Related Questions