Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2008-04-05 16:09:29
Size: 2943
Editor: MartinBlais
Comment:
Revision 4 as of 2008-04-19 22:48:53
Size: 2986
Editor: MartinBlais
Comment:
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/hgforeign.py] Download site: [http://furius.ca/pubcode/pub/conf/common/lib/python/hgblais/foreign.py]
Line 9: Line 9:
Home page: [http://furius.ca/pubcode/pub/conf/common/lib/python/hgforeign.py.html] Home page: [http://furius.ca/pubcode/pub/conf/common/lib/python/hgblais/foreign.py.html]
Line 19: Line 19:
repository. It deals with the case where you have been working for a while in a
repository and forgot to tell Mercurial to add add some files before committing,
[:Repository: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 [:Commit:committing],
Line 29: Line 29:
 * ignore/mask it (adds the path to .hgignore)  * ignore/mask it (adds the path to [:.hgignore:.hgignore])
Line 35: Line 35:
the forgotten files in a checkout checkout. the forgotten files in a checkout.
Line 44: Line 44:
Configure your .hgrc to enable the extension by adding following lines: Configure your [:.hgrc:.hgrc] to enable the extension by adding following lines:
Line 48: Line 48:
hgforeign = foreign =

Foreign Extension

This extension is not distributed with Mercurial.

Author: Martin Blais

Download site: [http://furius.ca/pubcode/pub/conf/common/lib/python/hgblais/foreign.py]

Home page: [http://furius.ca/pubcode/pub/conf/common/lib/python/hgblais/foreign.py.html]

Works with: 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: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 [:Commit: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:.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:.hgrc] to enable the extension by adding following lines:

[extensions]
foreign =

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


CategoryExtension

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