Skip to main content

import a set of files from a file-system into a repository

Project description

Imports a set of files from a given file-system into a Mercurial repository as a changeset.

The development of this extension was paid for by Lantiq. It was written and released as Open Source by Markus Zapke-Gründemann.

Repository: https://bitbucket.org/keimlink/hg-importfs

Issue tracker: https://bitbucket.org/keimlink/hg-importfs/issues

Python Package Index: http://pypi.python.org/pypi/hg-importfs

Mercurial wiki: http://mercurial.selenic.com/wiki/ImportfsExtension

Installation

It is assumed that you already have Mercurial installed. If not, please do so first either by downloading and installing the appropriate package for your operating system or by using pip:

$ pip install Mercurial

As a Python package

The easiest way is to install the importfs extension is to use pip:

$ pip install hg-importfs

Using easy_install instead of pip is also possible:

$ easy_install hg-importfs

Now add the extension to the extensions section in your .hgrc/mercurial.ini file:

[extensions]
importfs =

As a Mercurial repository

Instead of installing the Python package you can also clone the repository:

$ hg clone https://bitbucket.org/keimlink/hg-importfs

To activate the extension you have to add the full path to importfs.py to your .hgrc/mercurial.ini file:

[extensions]
importfs = /path/to/hg-importfs/importfs.py

Usage

After installing the extension you can use the following command to show the full help including all options:

$ hg help importfs

Example

Assuming you have a project on your file system which has different versions in different directories. Maybe because you never used a version control system (VCS) for your project. Or maybe because there is no convert extension available for the VCS you are using. In our scenario the three versions of the project look like this:

.
├── myproject-v1
│   ├── LICENSE
│   ├── README
│   ├── doc
│   │   ├── index.rst
│   │   ├── start.rst
│   │   └── widgets.rst
│   └── src
│       ├── cmdutils.py
│       ├── dispatcher.py
│       └── widgets.py
├── myproject-v2
│   ├── LICENSE
│   ├── README
│   ├── doc
│   │   ├── index.rst
│   │   ├── start.rst
│   │   └── widgets.rst
│   └── src
│       ├── cmdutils.py
│       ├── dispatcher.py
│       ├── resources.py
│       └── widgets.py
└── myproject-v3
    ├── LICENSE
    ├── README
    ├── doc
    │   ├── index.rst
    │   ├── start.rst
    │   └── widgets.rst
    └── src
        ├── dispatcher.py
        ├── resources.py
        └── widgets.py

Run the following command to import the first version of the project into a Mercurial repository myrepo. The repository does not exist so it will be created for you:

$ hg importfs myrepo myproject-v1
created repository myrepo
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding LICENSE
adding README
adding doc/index.rst
adding doc/start.rst
adding doc/widgets.rst
adding src/cmdutils.py
adding src/dispatcher.py
adding src/widgets.py

Now you have a repository with one changeset. This changeset contains all your files from myproject-v1.

$ hg log -R myrepo
changeset:   0:60304fa41a49
tag:         tip
user:        Markus Zapke-Gründemann <markus@keimlink.de>
date:        Tue Jul 10 10:19:10 2012 +0200
summary:     importfs commit.

As you can see importfs created a commit message for you because you didn’t specify one for the first import.

The second import will put all the files from myproject-v2 as a new changeset on top of changeset 0. And this time we want to use our own commit message and tag the changeset:

$ hg importfs myrepo myproject-v2 -m "Second import." -t second_import
8 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding src/resources.py

Now there are two new changesets:

$ hg log -R myrepo
changeset:   2:c8ff824da6c8
tag:         tip
user:        Markus Zapke-Gründemann <markus@keimlink.de>
date:        Tue Jul 10 10:27:10 2012 +0200
summary:     Added tag second_import for changeset 825c9a9356fd

changeset:   1:825c9a9356fd
tag:         second_import
user:        Markus Zapke-Gründemann <markus@keimlink.de>
date:        Tue Jul 10 10:27:10 2012 +0200
summary:     Second import.

changeset:   0:60304fa41a49
user:        Markus Zapke-Gründemann <markus@keimlink.de>
date:        Tue Jul 10 10:19:10 2012 +0200
summary:     importfs commit.

Let’s import the last version of the project into a new branch with changeset 0 as parent:

$ hg importfs myrepo myproject-v3 -m "Third import." -t third_import -b branch_2 -r 0
8 files updated, 0 files merged, 1 files removed, 0 files unresolved
marked working directory as branch branch_2
(branches are permanent and global, did you want a bookmark?)
removing src/cmdutils.py
adding src/resources.py

The repository history looks now like this:

$ hg glog -R myrepo
@  changeset:   4:3ec5adb0448e
|  branch:      branch_2
|  tag:         tip
|  user:        Markus Zapke-Gründemann <markus@keimlink.de>
|  date:        Tue Jul 10 10:32:32 2012 +0200
|  summary:     Added tag third_import for changeset bfcf48ac159e
|
o  changeset:   3:bfcf48ac159e
|  branch:      branch_2
|  tag:         third_import
|  parent:      0:60304fa41a49
|  user:        Markus Zapke-Gründemann <markus@keimlink.de>
|  date:        Tue Jul 10 10:32:32 2012 +0200
|  summary:     Third import.
|
| o  changeset:   2:c8ff824da6c8
| |  user:        Markus Zapke-Gründemann <markus@keimlink.de>
| |  date:        Tue Jul 10 10:27:10 2012 +0200
| |  summary:     Added tag second_import for changeset 825c9a9356fd
| |
| o  changeset:   1:825c9a9356fd
|/   tag:         second_import
|    user:        Markus Zapke-Gründemann <markus@keimlink.de>
|    date:        Tue Jul 10 10:27:10 2012 +0200
|    summary:     Second import.
|
o  changeset:   0:60304fa41a49
   user:        Markus Zapke-Gründemann <markus@keimlink.de>
   date:        Tue Jul 10 10:19:10 2012 +0200
   summary:     importfs commit.

How to set up a development environment

If you havn’t created a clone of the importfs repository yet it’s time to do it now:

$ hg clone https://bitbucket.org/keimlink/hg-importfs

Setup a virtualenv

The best way to do the development is to use a virtualenv. So first create one using virtualenvwrapper:

$ mkvirtualenv --distribute hg-importfs

Then install all packages needed for development into the virtualenv using pip:

(hg-importfs)$ cd hg-importfs
(hg-importfs)$ pip install -r requirements.txt

You also need a clone of the hg repository:

(hg-importfs)$ cd ..
(hg-importfs)$ hg clone http://selenic.com/repo/hg

Update to your desired version (if you don’t want to use tip) and build for local use:

(hg-importfs)$ cd hg
(hg-importfs)$ hg up VERSION
(hg-importfs)$ make local

After creating the clone create a few symlinks in your importfs repository:

(hg-importfs)$ cd ../hg-importfs
(hg-importfs)$ ln -s ../hg/contrib/pylintrc
(hg-importfs)$ ln -s ../hg/tests/hghave
(hg-importfs)$ ln -s ../hg/tests/run-tests.py

Finally add the hg directory to your virtualenv:

(hg-importfs)$ add2virtualenv ../hg

Run the tests

To run all tests you can now execute the following command:

(hg-importfs)$ ./run-tests.py -l

Create a new source distribution package

A new Python source distribution package can be created using this command:

(hg-importfs)$ python setup.py sdist

Changelog

1.3.2

  • Tested with 2.2.3, 2.3, 2.3.1, 2.3.2, 2.4

  • Updated documentation

  • Added links to issue tracker

1.3.1

  • Improved installation instructions

1.3.0

  • Changed package name to hg-importfs (as initially intended)

1.2.3

  • Changelog appears now at the of package description

  • Added repository and PyPI urls to README

1.2.2

  • Removed reStructuredText header from CHANGELOG.rst

1.2.1

  • Updated README to render as reStructuredText on PyPI

1.2.0

  • First Open Source release!

  • Added testedwith variable

  • Test suite works now with Mercurial 2.2.x

  • Added installation instructions and example to README

  • Moved development information to README

1.1.0

  • Symlinks are no longer dereferenced on Linux (but still dereferenced on Windows).

  • If the path of a symlink on Linux contains backward slashes (i.e. the link was intended for Windows), the slashes are converted to forward slashes and the link is dereferenced.

  • Renamed –exclude option to –exclude-pattern.

  • Added new option –exclude-path to exclude a path relative to SOURCE.

  • Added new option –retain-empty-dirs to import empty directories.

  • The update operation inside the repository is using the –clean option.

  • The repository is purged before each update/commit because there can be files without write permissions and Mercurial fails to update them.

1.0.1

  • Write warnings on ignored copy errors to stdout instead of stderr.

  • Using a slash as new exclude pattern separator.

1.0

  • Added new options exclude and ignore-copy-errors.

0.9

  • Allow to create anonymous branches.

0.8.1

  • Fixed the problem with wrong permissons of single files in the root of the repo on Windows.

0.8

  • Changed filesystem operations to be OS independent. Extension can now be used on Windows.

  • SOURCE can now be a list of directories.

0.7.1

  • Fixed the version number (which was still 0.6 for the 0.7 release).

0.7

  • Removed the “dereference” option.

0.6

  • Fixed missing updates. The repository wasn’t always at the lastest revision when doing the import.

  • Added new option “dereference” to follow symlinks.

  • Updated package classifiers.

  • Added this Changelog.

  • Added long_description to package metadata.

0.5.1

  • Removed importfs.py from MANIFEST.in.

0.5

  • Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hg-importfs-1.3.2.tar.gz (17.0 kB view details)

Uploaded Source

File details

Details for the file hg-importfs-1.3.2.tar.gz.

File metadata

  • Download URL: hg-importfs-1.3.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hg-importfs-1.3.2.tar.gz
Algorithm Hash digest
SHA256 ce06426d4981c78e8b0585ca7c2aff9de3bcb7a4b142f7756b05dea658274426
MD5 054335d32095e3169e908247ce8ca719
BLAKE2b-256 a596c9e3c64e57b052fb35702aa3837894cb3116da6c2c545537d2bfdf1ec5a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page