Differences between revisions 6 and 10 (spanning 4 versions)
Revision 6 as of 2009-05-19 19:30:58
Size: 2976
Editor: localhost
Comment: converted to 1.6 markup
Revision 10 as of 2012-11-06 15:08:58
Size: 2950
Editor: abuehl
Comment: remove link to deleted page "commit"
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
Download site: [[http://furius.ca/pubcode/pub/conf/common/lib/python/hgblais/foreign.py]] Source code: http://furius.ca/pubcode/pub/conf/lib/python/hgblais/foreign.py
Line 9: Line 9:
Home page: [[http://furius.ca/pubcode/pub/conf/common/lib/python/hgblais/foreign.py.html]] Web page: [[http://furius.ca/pubcode/pub/conf/lib/python/hgblais/foreign.py.html]]
Line 11: Line 11:
Works with: Mercurial 0.9.5 and beyond. Compatibility: Mercurial 0.9.5 and beyond.
Line 20: Line 20:
repository and forgot to tell Mercurial to add some files before [[Commit|committing]], repository and forgot to tell Mercurial to add some files before committing,
Line 95: Line 95:


Line 99: Line 96:
CategoryExtension CategoryExtensionsByOthers

Foreign Extension

This extension is not distributed with Mercurial.

Author: Martin Blais

Source code: http://furius.ca/pubcode/pub/conf/lib/python/hgblais/foreign.py

Web page: http://furius.ca/pubcode/pub/conf/lib/python/hgblais/foreign.py.html

Compatibility: Mercurial 0.9.5 and beyond.

Overview

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.

Note:

  • 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.

Configuration

Configure your .hgrc to enable the extension by adding following lines:

[extensions]
foreign =

Place foreign.py somewhere accessible from your PYTHONPATH.

Usage Scenario

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.)


CategoryExtensionsByOthers

ForeignExtension (last edited 2012-11-06 15:08:58 by abuehl)