This extension is not distributed with Mercurial.
Author: Martin Blais
Compatibility: Mercurial 0.9.5 and beyond.
A Mercurial extension that allows the user to quickly deal with foreign files.
This script allows you to add or delete files that are present but unknown to a repository. It deals with the case where you have been working for a while in a repository and forgot to tell Mercurial to add some files before committing, or want to cleanup and delete some of those files lying around.
Foreign runs 'status' on the given directories, to find out which files are unaccounted for and for each of these files, it interactively asks you what to do with it (commands are invoked with one keystroke):
- add it in the repository (for the next commit)
- delete it (copies the file to a backup location)
ignore/mask it (adds the path to .hgignore)
- view the file with a pager (e.g., more)
- skip it for now (leave it where it is)
- quit/exit (stop doing this)
The script works interactively and is meant to allow you to quickly deal with the forgotten files in a checkout.
- In the svn-foreign version, deleted files were being backed up to a temporary location (using some code from project xxdiff). I will eventually integrate this code in here.
Configure your .hgrc to enable the extension by adding following lines:
[extensions] foreign =
Place foreign.py somewhere accessible from your PYTHONPATH.
Here is a example repository with some modifications and unknown files in it.
banane:~/work/3rdparty$ hg status A doc/diagram.dia R bin/pgrphack ! bin/fghack ? doc/project-docs.pdf ? doc/project-docs.txt ? share/prices.data ? share/prices.data.tmp
Here is an example session running 'hg foreign' to prepare it for commit.
banane:~/work/3rdparty$ hg foreign ? doc/project-docs.pdf ? doc/project-docs.txt ? share/prices.data ? share/prices.data.tmp ! bin/fghack => [Add|Delete|Ignore|Skip|View|Quit] 2027120 doc/project-docs.pdf ? i Add ignore pattern for 'doc/project-docs.pdf' => [Add|Delete|Ignore|Skip|View|Quit] 34743 doc/project-docs.txt ? a Added 'doc/project-docs.txt' => [Add|Delete|Ignore|Skip|View|Quit] 218622 share/prices.data ? a Added 'share/prices.data' => [Add|Delete|Ignore|Skip|View|Quit] 0 share/prices.data.tmp ? d Deleted '/home/blais/work/3rdparty/share/prices.data.tmp' => [Revert|Delete|Skip|Quit] 0 bin/fghack ? d Removed 'bin/fghack' (Done.)