PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/toolkit/hg-git/README.md

https://code.google.com/p/softart/
Markdown | 223 lines | 163 code | 60 blank | 0 comment | 0 complexity | 933832c822d5162ff408e8bf3cdb261b MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, JSON, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, BSD-2-Clause
  1. Hg-Git Mercurial Plugin
  2. =======================
  3. * Homepage: http://hg-git.github.com/
  4. * https://bitbucket.org/durin42/hg-git (primary)
  5. * https://github.com/schacon/hg-git (mirror)
  6. This is the Hg-Git plugin for Mercurial, adding the ability to push
  7. and pull to/from a Git server repository from Hg. This means you can
  8. collaborate on Git based projects from Hg, or use a Git server as a
  9. collaboration point for a team with developers using both Git and Hg.
  10. The Hg-Git plugin can convert commits/changesets losslessly from one
  11. system to another, so you can push via an Hg repository and another Hg
  12. client can pull it and their changeset node ids will be identical -
  13. Mercurial data does not get lost in translation. It is intended that
  14. Hg users may wish to use this to collaborate even if no Git users are
  15. involved in the project, and it may even provide some advantages if
  16. you're using Bookmarks (see below).
  17. Dependencies
  18. ============
  19. This plugin is implemented entirely in Python - there are no Git
  20. binary dependencies, you do not need to have Git installed on your
  21. system. The only dependencies are Mercurial and Dulwich. The plugin
  22. is known to work on Hg versions 1.9.3 through 2.3.1 and requires at least
  23. Dulwich 0.8.6.
  24. Usage
  25. =====
  26. You can clone a Git repository from Hg by running `hg clone <url> [dest]`. For
  27. example, if you were to run
  28. $ hg clone git://github.com/schacon/hg-git.git
  29. Hg-Git would clone the repository and convert it to an Hg repository
  30. for you.
  31. If you want to clone a github repository for later pushing (or any
  32. other repository you access via ssh), you need to convert the ssh url
  33. to a format with an explicit protocol prefix. For example, the git url
  34. with push access
  35. git@github.com:schacon/hg-git.git
  36. would read
  37. git+ssh://git@github.com/schacon/hg-git.git
  38. (Mind the switch from colon to slash after the host!)
  39. Your clone command would thus look like this:
  40. $ hg clone git+ssh://git@github.com/schacon/hg-git.git
  41. If you are starting from an existing Hg repository, you have to set up
  42. a Git repository somewhere that you have push access to, add a path entry
  43. for it in your .hg/hgrc file, and then run `hg push [name]` from within
  44. your repository. For example:
  45. $ cd hg-git # (an Hg repository)
  46. $ # edit .hg/hgrc and add the target git url in the paths section
  47. $ hg push
  48. This will convert all your Hg data into Git objects and push them to the Git server.
  49. Now that you have an Hg repository that can push/pull to/from a Git
  50. repository, you can fetch updates with `hg pull`.
  51. $ hg pull
  52. That will pull down any commits that have been pushed to the server in
  53. the meantime and give you a new head that you can merge in.
  54. Hg-Git can also be used to convert a Mercurial repository to Git. You can use
  55. a local repository or a remote repository accessed via SSH, HTTP or HTTPS. Use
  56. the following commands to convert the repository (it assumes your running this
  57. in $HOME).
  58. $ mkdir git-repo; cd git-repo; git init; cd ..
  59. $ cd hg-repo
  60. $ hg bookmarks hg
  61. $ hg push ../git-repo
  62. The hg bookmark is necessary to prevent problems as otherwise hg-git
  63. pushes to the currently checked out branch confusing Git. This will
  64. create a branch named hg in the Git repository. To get the changes in
  65. master use the following command (only necessary in the first run,
  66. later just use git merge or rebase).
  67. $ cd git-repo
  68. $ git checkout -b master hg
  69. To import new changesets into the Git repository just rerun the hg
  70. push command and then use git merge or git rebase in your Git
  71. repository.
  72. Commands
  73. ========
  74. gclear
  75. ------
  76. TODO
  77. gimport
  78. -------
  79. TODO
  80. gexport
  81. -------
  82. TODO
  83. git-cleanup
  84. -----------
  85. TODO
  86. Hg Bookmarks Integration
  87. ========================
  88. Hg-Git pushes your bookmarks up to the Git server as branches and will
  89. pull Git branches down and set them up as bookmarks.
  90. Installing
  91. ==========
  92. Clone this repository somewhere and make the 'extensions' section in
  93. your `~/.hgrc` file look something like this:
  94. [extensions]
  95. hggit = [path-to]/hg-git/hggit
  96. That will enable the Hg-Git extension for you.
  97. This plugin is currently tested against the following Mercurial versions:
  98. * 1.9.3
  99. * 2.0.2
  100. * 2.1.2
  101. * 2.2.3
  102. * 2.3.1
  103. Configuration
  104. =============
  105. git.intree
  106. ----------
  107. hg-git keeps a git repository clone for reading and updating. By default, the
  108. git clone is the subdirectory `git` in your local Mercurial repository. If you
  109. would like this git clone to be at the same level of your Mercurial repository
  110. instead (named `.git`), add the following to your `hgrc`:
  111. [git]
  112. intree = True
  113. git.authors
  114. -----------
  115. Git uses a strict convention for "author names" when representing changesets,
  116. using the form `[realname] [email address]`. Mercurial encourages this
  117. convention as well but is not as strict, so it's not uncommon for a Mercurial
  118. repo to have authors listed as simple usernames. hg-git by default will
  119. translate such names using the email address `none@none`, which then shows up
  120. unpleasantly on GitHub as "illegal email address".
  121. The `git.authors` option provides for an "authors translation file" that will
  122. be used during outgoing transfers from mercurial to git only, by modifying
  123. `hgrc` as such:
  124. [git]
  125. authors = authors.txt
  126. Where `authors.txt` is the name of a text file containing author name translations,
  127. one per each line, using the following format:
  128. johnny = John Smith <jsmith@foo.com>
  129. dougie = Doug Johnson <dougiej@bar.com>
  130. Empty lines and lines starting with a "#" are ignored.
  131. It should be noted that **this translation is on the hg->git side only**. Changesets
  132. coming from Git back to Mercurial will not translate back into hg usernames, so
  133. it's best that the same username/email combination be used on both the hg and git sides;
  134. the author file is mostly useful for translating legacy changesets.
  135. git.branch_bookmark_suffix
  136. ---------------------------
  137. hg-git does not convert between Mercurial named branches and git branches as
  138. the two are conceptually different; instead, it uses Mercurial bookmarks to
  139. represent the concept of a git branch. Therefore, when translating an hg repo
  140. over to git, you typically need to create bookmarks to mirror all the named
  141. branches that you'd like to see transferred over to git. The major caveat with
  142. this is that you can't use the same name for your bookmark as that of the
  143. named branch, and furthermore there's no feasible way to rename a branch in
  144. Mercurial. For the use case where one would like to transfer an hg repo over
  145. to git, and maintain the same named branches as are present on the hg side,
  146. the `branch_bookmark_suffix` might be all that's needed. This presents a
  147. string "suffix" that will be recognized on each bookmark name, and stripped
  148. off as the bookmark is translated to a git branch:
  149. [git]
  150. branch_bookmark_suffix=_bookmark
  151. Above, if an hg repo had a named branch called `release_6_maintenance`, you could
  152. then link it to a bookmark called `release_6_maintenance_bookmark`. hg-git will then
  153. strip off the `_bookmark` suffix from this bookmark name, and create a git branch
  154. called `release_6_maintenance`. When pulling back from git to hg, the `_bookmark`
  155. suffix is then applied back, if and only if an hg named branch of that name exists.
  156. E.g., when changes to the `release_6_maintenance` branch are checked into git, these
  157. will be placed into the `release_6_maintenance_bookmark` bookmark on hg. But if a
  158. new branch called `release_7_maintenance` were pulled over to hg, and there was
  159. not a `release_7_maintenance` named branch already, the bookmark will be named
  160. `release_7_maintenance` with no usage of the suffix.
  161. The `branch_bookmark_suffix` option is, like the `authors` option, intended for
  162. migrating legacy hg named branches. Going forward, an hg repo that is to
  163. be linked with a git repo should only use bookmarks for named branching.