Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing binaries from an hg repository

Is it possible with Mercurial to remove all files with a certaain extension? I did an addremove and then all my binary .pyc were versioned and now I get this stopper when I do versioning:

tool kdiff3 can't handle binary
tool docdiff can't handle binary
 no tool found to merge bnano-www/wtforms/widgets.pyc
keep (l)ocal or take (o)ther? o
19 files updated, 67 files merged, 0 files removed, 0 files unresolved

C:\Users\developer\bnano\bnano-www>

I don't really know what it means except I can press o for other and go on with my work. Now I'd like to clean my repository and optimal would be to be able to do an addremove without binaries getting added but I think it is not possible.

Can you give some recommendation what to do in this case?

Thanks

like image 442
Niklas Rosencrantz Avatar asked Feb 23 '12 07:02

Niklas Rosencrantz


2 Answers

HgIgnore

First of all, you can add some rules to the .hgignore file to tell Mercurial that you want to ignore some files. Then, hg addremove won't add them automatically and they won't appear in the output of the commands (ie hg status) as untracked.

Removing the files

To remove your files, you can use hg remove myfile, for example, if all your pyc files are in the same directory, you can do hg remove *.pyc and then commit the change.

If your files are scattered in various repository, something like hg remove -I *.pyc **/* should remove all .pyc files in all directories.

Exclusion patterns

FYI, will it's better to add unwanted files in the .hgignore file, you can also tell addremove to ignore some files by doing hg addremove -X *.pyc. This will add/remove every files except those having the pyc extension.

You can find help about a specific mercurial command using help. For example, hg help addremove. In general everything is neatly explained !

Tutorial

To explore various Mercurial concepts in more depth, I recommand this excellent tutorial : http://hginit.com

like image 142
krtek Avatar answered Oct 04 '22 00:10

krtek


To remove all binary files from a repository, you can use Mercurial filesets:

hg remove "set:binary()"

And as the other posters mentioned, it's a great idea to add unwanted extensions in the .hgignore file.

like image 26
Cody Piersall Avatar answered Oct 04 '22 00:10

Cody Piersall