I have a mercurial repository that has over 300 change sets.
How can I list all change sets that contain a specific file?
I found the answer: Right click on the file and select revision history.
On the command line:
hg log <filename>
Related
I want to search for a filename across all my commits/branches and find out which commits/branches contain that filename. I don't know which subdirectory/subdirectories of the repo the file would be in.
I've tried hg grep <filename>, but that only seems to show files containing "filename".
I've also looked at Mercurial - determine where file was removed?, but that really help me if a file was created on a different branch. The person asking that question suggested hg log myfile -v, which seems like it could work, but doesn't. I know that somewhere in my repo the file exists because I get something back when I do find .hg | grep <filename>, but that doesn't tell me (at least not clearly) which commits/branches.
You have to read hg help patterns and maybe hg help filesets in order to write correct pattern for the file (most probably you'll be happy with just pattern)
If file exist now in working directory (i.e. was added and not removed later), you'll find it with hg file <PATTERN> and will determine full path by output, see above (pattern used)
>hg file **/test-extra.t
tests\test-extra.t
and call hg log with full filename
In any case (hg file returned 0 for removed file or file still in WD) you can call hg log <FILESET> and get history too. Log for existing will be too long, will show deleted unique filename sample
>hg log set:**/dulwich/tests/__init__.py -Tcompact
223 0b6c08800d16 2009-07-23 08:48 +0100 a
delete the dulwich fork we have
2 c43c02cc803a 2009-04-22 16:59 -0700 schacon
added dulwich library and got the script to call it for clone
If your set will be too wide and (may) include files with the same name in different folders, you have to verify filenames by calling log with more details about files, f.e. with -Tstatus
hg log 'glob:**/<filename>` -Tstatus
seems to do the job. It doesn't give me the commits containing <filename>, but it does give commits (and their branches) involving filename.
Credit to Lazy Badger's answer for pointing me to this.
I have a repository with one file (subdir/a.txt), and the one revision, adding it.
If I run hg convert with a filemap consisting of include subdir/a.txt, it works just fine.
But if the filemap is include subdir/*.txt, include */a.txt, or include **/*.txt, the resultant repository has no revisions in it.
Is it possible do use wildcards in the filemap of hg convert?
--
The reason I want to do this is so that I can create a new repository with history, but without any binary files. I want to be able to do something like exclude **/*.dll. Is there any way to do that?
Wildcards do not seem to be supported, but you can use hg manifest --all to get a list of all files present in all changesets, and do some filtering and editing of the output to generate what to exclude. Something like the following to list all the DLL file paths on Windows:
hg manifest --all | findstr \.dll
From one source file I made a copy using hg copy.
Now I'm going to Change some stuff in the second file (the copy) and I want to be able to merge the future changes of the original file into the second file.
Can this be done using hg merge? Right now when I try to do something like
hg merge NewFile.html -r 130:f24199b5b945
using the most current changeset of the original file, I get an error: abort: please specify just one revision.
No, the two files are separate after that, and except for one file originating from the other, they do not share any history after that.
You will either have to duplicate your modifications in the other file, or you need to find another way to do this.
ok, when I was young, I put severial big files(like resource file, dll, etc..) in my mercurial repos. and I found the size of it is so big that I cannot easily push it into bitbucket,
any way to delete this files history EASILY?
I put all those files in /res and /dll path.
edit:
this is a solution, but it will delete part of the history, so maybe there is a better solution.
Mercurial Remove History
Your best bet is to use the convert extension, but warning you'll end up with a totally different repo. Every hash will be different and every person who cloned will need to delete their clone and re-clone.
That said, here's what you do:
Create a filemap file named filemap.txt containing:
exclude res
exclude dll
and then run this command:
hg convert --filemap filemap.txt your-source-repository your-destination-repository
For example:
hg convert --filemap filemap.txt /home/you/repos/bloatedrepo /home/you/repos/slenderrepo
That gets you a whole new repo that has all of your history except the history of any files in /res and /dll, but again it will be a new, unrelated repo as far as mercurial (and bitbucket) are concerned.
Is it normal? So you just need to add \.hgignore to the list to ignore itself?
Yes, but you don't want to ignore the .hgignore file. When a new person checks out your repository, don't you want them to get your ignored-files list? Instead, do hg add .hgignore; hg commit.
Bottom line: .hgignore is tracked like any other file in the repository.
Just to supplement Borealid's answer: ? in hg status means that the file is in the working directory, but not tracked. You usually see it in one of two situations:
A file got generated that you don't need to check in, like a compiled binary or something.
You added a new file to your project, but haven't hg added it yet.
In #1, you'll want to add the file or file type to .hgignore. In #2, you want to hg add the file. In the case of .hgignore, it's #2.