Reputation: 85
I need one file at a certain revision. I have the changeset id of the revision I am interested. Additionally I have the all-lower-case file name without the path ((I hope) the file name is unique in the repository): example.cpp. Now I would like to find the complete path of the file. Then I would use the path to hg cat -r #REV /path/to/Example.cpp
.
Difficulty might be, that the file was renamed or deleted in the mean time. But I need the file at the specific point in time and the specific branch (identified by the changeset id).
I can see that the easiest way to achieve this, is just to update to that revision and search for the file in the local working directory. But this is too slow to do that automatically in batch mode on a server. I hope for something like hg findfile 3b62b0e7edcb48e34ca08bed31c6cd1d00df93c2 -name --ignorecase example.cpp
which would find me files at the specified revision (identified by the changeset id 3b62b0e7edcb48e34ca08bed31c6cd1d00df93c2) with that name (example.cpp). Ideally I will only find one, and can then use hg cat the get the file's content.
What would also help me, if I could print the whole file tree at that specific point in time identified by that changeset id. I am pretty sure this is possible, as the webfrontend hgweg also allows browsing that directory online at a specific changeset id. (For example here: https://www.mercurial-scm.org/repo/hg/file/de86a6872d06). Then I could recursively do a case-insensitive search for that file and hg cat
it.
Background: I am currently extending an automatic crash dump file analyzer. We use http://crashrpt.sourceforge.net/ in our application. Our crash dump analyzer knows the changeset-id of the release that crashed. It now automatically analyzes the crash dump with the correct debug symbols (pdb) by getting them from our debug symbol directory. The result is a call stack that shows the lower-case filename (example.cpp), but not the path. I would like to fetch the corresponding code of that file only.
During googling I found Retrieve old version of a file without changing working copy parent which solves half my problem. I also found hg grep
which I did not know before, but if I understood it correctly hg grep -l example.cpp
could find me the file, but it would not tell me if this is the path it used to have at the specific revision I am interested in. Because grep might get the wrong revision or a different branch. (But as I said, today was the first time I heard of hg grep, maybe I do not see an obvious solution here...).
Upvotes: 3
Views: 674
Reputation: 85
Complete Solution based on Joeri van Ruth's answer.
List all files of the specified revision:
hg manifest -r 3b62b0e7edcb48e34ca08bed31c6cd1d00df93c2
Then search for the example.cpp file and extract the whole path (e.g. by using grep)... then get the files content:
hg cat -r 3b62b0e7edcb48e34ca08bed31c6cd1d00df93c2 "Folder/Sub/Example.cpp"
Upvotes: 0
Reputation: 181
You can use hg manifest -r REV to get a list of all files in that revision. Then you can search for your file in that list.
Upvotes: 2