hg-git


Namehg-git JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttp://foss.heptapod.net/mercurial/hg-git
Summarypush to and pull from a Git repository using Mercurial
upload_time2024-03-06 11:45:50
maintainerThe hg-git maintainers
docs_urlNone
authorScott Chacon, Augie Fackler, Kevin Bullock and others
requires_python>=3.8
licenseGPLv2
keywords hg git mercurial
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Hg-Git Mercurial Plugin
=======================

Homepage:
  https://hg-git.github.io/
Repository:
  https://foss.heptapod.net/mercurial/hg-git
Mailing list:
  `hg-git@googlegroups.com <mailto:hg-git@googlegroups.com>`_ (`Google
  Group <https://groups.google.com/g/hg-git>`_)

This is the Hg-Git plugin for Mercurial, adding the ability to push and
pull to/from a Git server repository from Hg. This means you can
collaborate on Git based projects from Hg, or use a Git server as a
collaboration point for a team with developers using both Git and Hg.

The Hg-Git plugin can convert commits/changesets losslessly from one
system to another, so you can push via a Mercurial repository and another Hg
client can pull it and their changeset node ids will be identical -
Mercurial data does not get lost in translation. It is intended that Hg
users may wish to use this to collaborate even if no Git users are
involved in the project, and it may even provide some advantages if
you're using Bookmarks (see below).

Dependencies
============

This plugin is implemented entirely in Python — there are no Git
binary dependencies, and you do not need to have Git installed on your
system. The only dependencies are:

* Mercurial 6.1
* Dulwich 0.20.11
* Python 3.8

Please note that these are the earliest versions known to work; later
versions generally work better.

Installing
==========

We recommend installing the plugin using your a package manager, such
as pip::

  python -m pip install hg-git

Alternatively, you can clone this repository somewhere and install it
from the directory::

  hg clone https://foss.heptapod.net/mercurial/hg-git/
  cd hg-git
  python -m pip install .

And enable it from somewhere in your ``$PYTHONPATH``::

   [extensions]
   hggit =

Contributing
============

The primary development location for Hg-Git is `Heptapod
<http://foss.heptapod.net/mercurial/hg-git/>`_, and you can follow
their guide on `how to contribute patches
<https://heptapod.net/pages/quick-start-guide.html>`_.

Alternatively, you can follow the `guide on how to contribute to
Mercurial itself
<https://www.mercurial-scm.org/wiki/ContributingChanges>`_, and send
patches to `the list <https://groups.google.com/g/hg-git>`_.

Usage
=====

You can clone a Git repository from Mercurial by running
``hg clone <url> [dest]``. For example, if you were to run::

   $ hg clone git://github.com/hg-git/hg-git.git

Hg-Git would clone the repository and convert it to a Mercurial
repository for you. Other protocols are also supported, see ``hg help
git`` for details.

If you are starting from an existing Mercurial repository, you have to set up a
Git repository somewhere that you have push access to, add a path entry
for it in your .hg/hgrc file, and then run ``hg push [name]`` from
within your repository. For example::

   $ cd hg-git # (a Mercurial repository)
   $ # edit .hg/hgrc and add the target git url in the paths section
   $ hg push

This will convert all your Mercurial data into Git objects and push them to the
Git server.

Now that you have a Mercurial repository that can push/pull to/from a Git
repository, you can fetch updates with ``hg pull``::

   $ hg pull

That will pull down any commits that have been pushed to the server in
the meantime and give you a new head that you can merge in.

Hg-Git pushes your bookmarks up to the Git server as branches and will
pull Git branches down and set them up as bookmarks.

Hg-Git can also be used to convert a Mercurial repository to Git. You
can use a local repository or a remote repository accessed via SSH, HTTP
or HTTPS. Use the following commands to convert the repository, it
assumes you're running this in ``$HOME``::

   $ mkdir git-repo; cd git-repo; git init; cd ..
   $ cd hg-repo
   $ hg bookmarks hg
   $ hg push ../git-repo

The ``hg`` bookmark is necessary to prevent problems as otherwise
hg-git pushes to the currently checked out branch, confusing Git. The
snippet above will create a branch named ``hg`` in the Git repository.
To get the changes in ``master`` use the following command (only
necessary in the first run, later just use ``git merge`` or ``git
rebase``).

::

   $ cd git-repo
   $ git checkout -b master hg

To import new changesets into the Git repository just rerun the ``hg
push`` command and then use ``git merge`` or ``git rebase`` in your Git
repository.

``.gitignore`` and ``.hgignore``
--------------------------------

If present, ``.gitignore`` will be taken into account provided that there is
no ``.hgignore``. In the latter case, the rules from ``.hgignore`` apply,
regardless of what ``.gitignore`` prescribes.

Please note that Mercurial doesn't support exclusion patterns, so any
``.gitignore`` pattern starting with ``!`` will trigger a warning.

This has been so since version 0.5.0, released in 2013.

Further reading
===============

See ``hg help -e hggit`` and ``hg help hggit-config``.

Alternatives
============

Since version 5.4, Mercurial includes an extension called ``git``. It
interacts with a Git repository directly, avoiding the intermediate
conversion. This has certain advantages:

 * Each commit only has one node ID, which is the Git hash.
 * Data is stored only once, so the on-disk footprint is much lower.

The extension has certain drawbacks, however:

 * It cannot handle all Git repositories. In particular, it cannot
   handle `octopus merges`_, i.e. merge commits with more than two
   parents. If any such commit is included in the history, conversion
   will fail.
 * You cannot interact with Mercurial repositories.

.. _octopus merges: https://git-scm.com/docs/git-merge

Another extension packaged with Mercurial, the ``convert`` extension,
also has Git support.

Other alternatives exist for Git users wanting to access Mercurial
repositories, such as `git-remote-hg`_.

.. _git-remote-hg: https://pypi.org/project/git-remote-hg/

            

Raw data

            {
    "_id": null,
    "home_page": "http://foss.heptapod.net/mercurial/hg-git",
    "name": "hg-git",
    "maintainer": "The hg-git maintainers",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "hg-git@googlegroups.com",
    "keywords": "hg git mercurial",
    "author": "Scott Chacon, Augie Fackler, Kevin Bullock and others",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/7a/8a/cdaa0e41e0298db7c88c1bd9d16c00b89bb9f3e194005a78a6f81a2ac104/hg-git-1.1.1.tar.gz",
    "platform": null,
    "description": "Hg-Git Mercurial Plugin\n=======================\n\nHomepage:\n  https://hg-git.github.io/\nRepository:\n  https://foss.heptapod.net/mercurial/hg-git\nMailing list:\n  `hg-git@googlegroups.com <mailto:hg-git@googlegroups.com>`_ (`Google\n  Group <https://groups.google.com/g/hg-git>`_)\n\nThis is the Hg-Git plugin for Mercurial, adding the ability to push and\npull to/from a Git server repository from Hg. This means you can\ncollaborate on Git based projects from Hg, or use a Git server as a\ncollaboration point for a team with developers using both Git and Hg.\n\nThe Hg-Git plugin can convert commits/changesets losslessly from one\nsystem to another, so you can push via a Mercurial repository and another Hg\nclient can pull it and their changeset node ids will be identical -\nMercurial data does not get lost in translation. It is intended that Hg\nusers may wish to use this to collaborate even if no Git users are\ninvolved in the project, and it may even provide some advantages if\nyou're using Bookmarks (see below).\n\nDependencies\n============\n\nThis plugin is implemented entirely in Python \u2014 there are no Git\nbinary dependencies, and you do not need to have Git installed on your\nsystem. The only dependencies are:\n\n* Mercurial 6.1\n* Dulwich 0.20.11\n* Python 3.8\n\nPlease note that these are the earliest versions known to work; later\nversions generally work better.\n\nInstalling\n==========\n\nWe recommend installing the plugin using your a package manager, such\nas pip::\n\n  python -m pip install hg-git\n\nAlternatively, you can clone this repository somewhere and install it\nfrom the directory::\n\n  hg clone https://foss.heptapod.net/mercurial/hg-git/\n  cd hg-git\n  python -m pip install .\n\nAnd enable it from somewhere in your ``$PYTHONPATH``::\n\n   [extensions]\n   hggit =\n\nContributing\n============\n\nThe primary development location for Hg-Git is `Heptapod\n<http://foss.heptapod.net/mercurial/hg-git/>`_, and you can follow\ntheir guide on `how to contribute patches\n<https://heptapod.net/pages/quick-start-guide.html>`_.\n\nAlternatively, you can follow the `guide on how to contribute to\nMercurial itself\n<https://www.mercurial-scm.org/wiki/ContributingChanges>`_, and send\npatches to `the list <https://groups.google.com/g/hg-git>`_.\n\nUsage\n=====\n\nYou can clone a Git repository from Mercurial by running\n``hg clone <url> [dest]``. For example, if you were to run::\n\n   $ hg clone git://github.com/hg-git/hg-git.git\n\nHg-Git would clone the repository and convert it to a Mercurial\nrepository for you. Other protocols are also supported, see ``hg help\ngit`` for details.\n\nIf you are starting from an existing Mercurial repository, you have to set up a\nGit repository somewhere that you have push access to, add a path entry\nfor it in your .hg/hgrc file, and then run ``hg push [name]`` from\nwithin your repository. For example::\n\n   $ cd hg-git # (a Mercurial repository)\n   $ # edit .hg/hgrc and add the target git url in the paths section\n   $ hg push\n\nThis will convert all your Mercurial data into Git objects and push them to the\nGit server.\n\nNow that you have a Mercurial repository that can push/pull to/from a Git\nrepository, you can fetch updates with ``hg pull``::\n\n   $ hg pull\n\nThat will pull down any commits that have been pushed to the server in\nthe meantime and give you a new head that you can merge in.\n\nHg-Git pushes your bookmarks up to the Git server as branches and will\npull Git branches down and set them up as bookmarks.\n\nHg-Git can also be used to convert a Mercurial repository to Git. You\ncan use a local repository or a remote repository accessed via SSH, HTTP\nor HTTPS. Use the following commands to convert the repository, it\nassumes you're running this in ``$HOME``::\n\n   $ mkdir git-repo; cd git-repo; git init; cd ..\n   $ cd hg-repo\n   $ hg bookmarks hg\n   $ hg push ../git-repo\n\nThe ``hg`` bookmark is necessary to prevent problems as otherwise\nhg-git pushes to the currently checked out branch, confusing Git. The\nsnippet above will create a branch named ``hg`` in the Git repository.\nTo get the changes in ``master`` use the following command (only\nnecessary in the first run, later just use ``git merge`` or ``git\nrebase``).\n\n::\n\n   $ cd git-repo\n   $ git checkout -b master hg\n\nTo import new changesets into the Git repository just rerun the ``hg\npush`` command and then use ``git merge`` or ``git rebase`` in your Git\nrepository.\n\n``.gitignore`` and ``.hgignore``\n--------------------------------\n\nIf present, ``.gitignore`` will be taken into account provided that there is\nno ``.hgignore``. In the latter case, the rules from ``.hgignore`` apply,\nregardless of what ``.gitignore`` prescribes.\n\nPlease note that Mercurial doesn't support exclusion patterns, so any\n``.gitignore`` pattern starting with ``!`` will trigger a warning.\n\nThis has been so since version 0.5.0, released in 2013.\n\nFurther reading\n===============\n\nSee ``hg help -e hggit`` and ``hg help hggit-config``.\n\nAlternatives\n============\n\nSince version 5.4, Mercurial includes an extension called ``git``. It\ninteracts with a Git repository directly, avoiding the intermediate\nconversion. This has certain advantages:\n\n * Each commit only has one node ID, which is the Git hash.\n * Data is stored only once, so the on-disk footprint is much lower.\n\nThe extension has certain drawbacks, however:\n\n * It cannot handle all Git repositories. In particular, it cannot\n   handle `octopus merges`_, i.e. merge commits with more than two\n   parents. If any such commit is included in the history, conversion\n   will fail.\n * You cannot interact with Mercurial repositories.\n\n.. _octopus merges: https://git-scm.com/docs/git-merge\n\nAnother extension packaged with Mercurial, the ``convert`` extension,\nalso has Git support.\n\nOther alternatives exist for Git users wanting to access Mercurial\nrepositories, such as `git-remote-hg`_.\n\n.. _git-remote-hg: https://pypi.org/project/git-remote-hg/\n",
    "bugtrack_url": null,
    "license": "GPLv2",
    "summary": "push to and pull from a Git repository using Mercurial",
    "version": "1.1.1",
    "project_urls": {
        "Homepage": "http://foss.heptapod.net/mercurial/hg-git"
    },
    "split_keywords": [
        "hg",
        "git",
        "mercurial"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0e1517adcfde26d347edfd8d4d58cb0d8fca39de73935bccf7082c005a5ba278",
                "md5": "e4233fb1657b00271f2bd8456d2d954c",
                "sha256": "b6cd2742f89a44e4ca2db2c430a2ee621dfd35f00b7af2322f041e3c264b9ed3"
            },
            "downloads": -1,
            "filename": "hg_git-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e4233fb1657b00271f2bd8456d2d954c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 75463,
            "upload_time": "2024-03-06T11:45:47",
            "upload_time_iso_8601": "2024-03-06T11:45:47.944936Z",
            "url": "https://files.pythonhosted.org/packages/0e/15/17adcfde26d347edfd8d4d58cb0d8fca39de73935bccf7082c005a5ba278/hg_git-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a8acdaa0e41e0298db7c88c1bd9d16c00b89bb9f3e194005a78a6f81a2ac104",
                "md5": "9c574dfd6efbbc77dd2e2d70bab87643",
                "sha256": "af4e10eb36edf153358d892818e74966a28f3f15f2e230b55f577d9c9f9f1166"
            },
            "downloads": -1,
            "filename": "hg-git-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9c574dfd6efbbc77dd2e2d70bab87643",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 218555,
            "upload_time": "2024-03-06T11:45:50",
            "upload_time_iso_8601": "2024-03-06T11:45:50.024846Z",
            "url": "https://files.pythonhosted.org/packages/7a/8a/cdaa0e41e0298db7c88c1bd9d16c00b89bb9f3e194005a78a6f81a2ac104/hg-git-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 11:45:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "hg-git"
}
        
Elapsed time: 0.21056s