diff --git a/README.md b/README.md index c88e8a88c5f6b9d9f95595a02196bd133d5927d1_UkVBRE1FLm1k..9df1741f3977962b88d00c1a1bbf9eac1633e6ab_UkVBRE1FLm1k 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ Usage ===== -You can clone a Git repository from Hg by running `hg clone [url]`. For +You can clone a Git repository from Hg by running `hg clone <url> [dest]`. For example, if you were to run $ hg clone git://github.com/schacon/hg-git.git @@ -34,9 +34,9 @@ example, if you were to run $ hg clone git://github.com/schacon/hg-git.git -hg-git would clone the repository down into the directory 'munger.git', then -convert it to an Hg repository for you. +Hg-Git would clone the repository and convert it to an Hg repository +for you. If you want to clone a github repository for later pushing (or any other repository you access via ssh), you need to convert the ssh url @@ -55,12 +55,12 @@ $ hg clone git+ssh://git@github.com/schacon/hg-git.git -If you are starting from an existing Hg repository, you have to setup -a Git repository somewhere that you have push access to, add it as -default path or default-push path in your .hg/hgrc and then run `hg -push` from within your project. For example: +If you are starting from an existing Hg 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 # (an Hg repository) $ # edit .hg/hgrc and add the target git url in the paths section $ hg push @@ -62,9 +62,9 @@ $ cd hg-git # (an Hg repository) $ # edit .hg/hgrc and add the target git url in the paths section $ hg push -This will convert all your Hg data into Git objects and push them up to the Git server. +This will convert all your Hg data into Git objects and push them to the Git server. Now that you have an Hg repository that can push/pull to/from a Git repository, you can fetch updates with `hg pull`. @@ -140,6 +140,17 @@ That will enable the Hg-Git extension for you. The bookmarks section is not compulsory, but it makes some things a bit nicer for you. +This plugin is currently tested against the following Mercurial versions: + * 1.5.4 + * 1.6.4 + * 1.7.5 + * 1.8.4 + * 1.9.3 + * 2.0.2 + * 2.1.2 + * 2.2.3 + * 2.3 + Configuration ============= diff --git a/hggit/__init__.py b/hggit/__init__.py index c88e8a88c5f6b9d9f95595a02196bd133d5927d1_aGdnaXQvX19pbml0X18ucHk=..9df1741f3977962b88d00c1a1bbf9eac1633e6ab_aGdnaXQvX19pbml0X18ucHk= 100644 --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -13,5 +13,7 @@ project that is in Git. A bridger of worlds, this plugin be. Try hg clone git:// or hg clone git+ssh:// + +For more information and instructions, see :hg:`help git` ''' @@ -16,5 +18,6 @@ ''' +from bisect import insort import inspect import os @@ -22,6 +25,7 @@ from mercurial import commands from mercurial import demandimport from mercurial import extensions +from mercurial import help from mercurial import hg from mercurial import localrepo from mercurial import util as hgutil @@ -87,6 +91,16 @@ if getattr(hg, 'addbranchrevs', False): extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) +def extsetup(): + helpdir = os.path.join(os.path.dirname(__file__), 'help') + entry = (['git'], _("Working with Git Repositories"), + lambda: open(os.path.join(helpdir, 'git.rst')).read()) + # in 1.6 and earler the help table is a tuple + if getattr(help.helptable, 'extend', None): + insort(help.helptable, entry) + else: + help.helptable = help.helptable + (entry,) + def reposetup(ui, repo): if not isinstance(repo, gitrepo.gitrepo): klass = hgrepo.generate_repo_subclass(repo.__class__) diff --git a/hggit/help/git.rst b/hggit/help/git.rst new file mode 100644 index 0000000000000000000000000000000000000000..9df1741f3977962b88d00c1a1bbf9eac1633e6ab_aGdnaXQvaGVscC9naXQucnN0 --- /dev/null +++ b/hggit/help/git.rst @@ -0,0 +1,54 @@ +Basic Use +--------- + +You can clone a Git repository from Hg by running `hg clone <url> [dest]`. +For example, if you were to run:: + + $ hg clone git://github.com/schacon/hg-git.git + +Hg-Git would clone the repository and convert it to an Hg repository for +you. There are a number of different protocols that can be used for Git +repositories. Examples of Git repository URLs include:: + + https://github.com/schacon/hg-git.git + http://code.google.com/p/guava-libraries + ssh://git@github.com:schacon/hg-git.git + git://github.com/schacon/hg-git.git + +For protocols other than git://, it isn't clear whether these should be +interpreted as Mercurial or Git URLs. Thus, to specify that a URL should +use Git, prepend the URL with "git+". For example, an HTTPS URL would +start with "git+https://". Also, note that Git doesn't require the +specification of the protocol for SSH, but Mercurial does. + +If you are starting from an existing Hg 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 # (an Hg repository) + $ # edit .hg/hgrc and add the target Git URL in the paths section + $ hg push + +This will convert all your Hg data into Git objects and push them to the +Git server. + +Pulling new revisions into a repository is the same as from any other +Mercurial source. Within the earlier examples, the following commands are +all equivalent:: + + $ hg pull + $ hg pull default + $ hg pull git://github.com/schacon/hg-git.git + +Git branches are exposed in Hg as bookmarks, while Git remotes are exposed +as Hg local tags. See `hg help bookmarks` and `hg help tags` for further +information. + +Limitations +----------- + +- Cloning/pushing/pulling local Git repositories is not supported (due to + lack of support in Dulwich) +- The `hg incoming` and `hg outgoing` commands are not currently + supported. \ No newline at end of file diff --git a/setup.py b/setup.py index c88e8a88c5f6b9d9f95595a02196bd133d5927d1_c2V0dXAucHk=..9df1741f3977962b88d00c1a1bbf9eac1633e6ab_c2V0dXAucHk= 100644 --- a/setup.py +++ b/setup.py @@ -19,5 +19,6 @@ keywords='hg git mercurial', license='GPLv2', packages=['hggit'], + package_data={ 'hggit': ['help/git.rst'] }, install_requires=['dulwich>=0.8.0'], ) diff --git a/tests/test-help b/tests/test-help new file mode 100644 index 0000000000000000000000000000000000000000..9df1741f3977962b88d00c1a1bbf9eac1633e6ab_dGVzdHMvdGVzdC1oZWxw --- /dev/null +++ b/tests/test-help @@ -0,0 +1,10 @@ +#!/bin/sh + +# Tests that the various help files are properly registered + +echo "[extensions]" >> $HGRCPATH +echo "hggit=$(echo $(dirname $(dirname $0)))/hggit" >> $HGRCPATH + +hg help | grep 'git' | sed 's/ */ /g' +hg help hggit | grep 'help git' | sed 's/:hg:`help git`/"hg help git"/g' +hg help git | grep 'Working with Git Repositories' diff --git a/tests/test-help.out b/tests/test-help.out new file mode 100644 index 0000000000000000000000000000000000000000..9df1741f3977962b88d00c1a1bbf9eac1633e6ab_dGVzdHMvdGVzdC1oZWxwLm91dA== --- /dev/null +++ b/tests/test-help.out @@ -0,0 +1,4 @@ + hggit push and pull from a Git server + git Working with Git Repositories +For more information and instructions, see "hg help git" +Working with Git Repositories