/doc/source/patches.txt

https://bitbucket.org/tortoisehg/hgtk/ · Plain Text · 168 lines · 123 code · 45 blank · 0 comment · 0 complexity · 20b05cddf7e39cb6a138f2969d2d63d9 MD5 · raw file

  1. *******
  2. Patches
  3. *******
  4. .. module:: patches
  5. :synopsis: Describe patch operations
  6. Defining a patch
  7. ================
  8. These links are recommended reading for understanding the history and nature
  9. of patches and how they can be used with Mercurial.
  10. * `The patch management problem <http://tortoisehg.bitbucket.org/hgbook/1.7/managing-change-with-mercurial-queues.html#sec:mq:patch-mgmt>`_
  11. * `Understanding patches <http://tortoisehg.bitbucket.org/hgbook/1.7/managing-change-with-mercurial-queues.html#sec:mq:patch>`_
  12. * `More about patches <http://tortoisehg.bitbucket.org/hgbook/1.7/managing-change-with-mercurial-queues.html#sec:mq:adv-patch>`_
  13. Pitfalls
  14. ========
  15. The standard patch format cannot describe binary files, renames, copies,
  16. or permission changes. If your patch needs to record any of those
  17. things, you will need to enable **git** patches via::
  18. [diff]
  19. git=True
  20. Mercurial 1.5 improves it's behavior in this regard. It will warn you
  21. when git diffs are required, or sometimes upgrade to the git format
  22. automatically. See also the
  23. `diff section <http://www.selenic.com/mercurial/hgrc.5.html#diff>`_ of
  24. the hgrc documentation.
  25. Mercurial's patch routines do not deal well with mixed EOLN between
  26. source files and patches. The **patch.eol** setting was introduced in
  27. 1.3 to improve this situation::
  28. [patch]
  29. eol = auto #strict, lf, or crlf
  30. The work on the hgeol extension is also improving this area. Perhaps it
  31. will be resolved by hg-1.5. See also the
  32. `patch section <http://www.selenic.com/mercurial/hgrc.5.html#patch>`_
  33. of the hgrc documentation.
  34. Applying a patch is not a foolproof operation. If the source file has
  35. diverged from the file that was used to create the patch, there may be
  36. conflicts during the patch application. These are written to a file
  37. with an .rej extension. TortoiseHg 1.0 includes an experimental
  38. :command:`hgtk mpatch` command that can try *harder* to apply the
  39. rejected patch hunks. This command is based on Chris Mason's `mpatch
  40. <http://oss.oracle.com/~mason/mpatch/>`_ utility. If mpatch cannot
  41. apply the rejected hunks, your only remaining choice is to apply them by
  42. hand.
  43. Export Patches
  44. ==============
  45. Changeset
  46. ---------
  47. To export a changeset as a patch file, use the changeset context menu of
  48. the Repository Explorer to select :menuselection:`Export --> Export Patch`.
  49. You will be asked to provide a filename.
  50. Changeset Ranges
  51. ----------------
  52. Select a range of changesets in the Repository Explorer. Left click on
  53. the first (base) changeset, then right click on the last (target)
  54. changeset. This opens a special revision range context menu. From this
  55. menu you can generate patches, generate a bundle, send emails, or view
  56. the accumulated changes.
  57. This is a very powerful feature and there is no restriction on the base
  58. and target changesets you can select.
  59. Email
  60. -----
  61. .. figure:: figures/email.png
  62. :alt: Email dialog
  63. Email dialog of Repository Explorer
  64. To send a changeset as an email, use the changeset context menu of the
  65. Repository Explorer. :menuselection:`Export --> Email Patch`. This
  66. opens the e-mail dialog for this single changeset.
  67. To send a changeset range, use the changeset range selection feature of
  68. the Repository Explorer and select
  69. :menuselection:`Email from here to selected...`
  70. Lastly, you can use the :guilabel:`Email` button on the syncbar of the
  71. Repository Explorer to email all outgoing changes to the selected remote
  72. repository.
  73. .. note::
  74. You must configure
  75. `SMTP <http://www.selenic.com/mercurial/hgrc.5.html#smtp>`_
  76. to send patches via email
  77. Cherry Picking
  78. --------------
  79. Use the changeset range selection feature of the Repository Explorer and
  80. select :menuselection:`Diff with selected`. This opens up a status
  81. viewer showing you the accumulated changes between your base and target
  82. changesets.
  83. From the status viewer, you can select files and diff hunks just as you
  84. can in the commit tool, and preview the final result in the
  85. :guilabel:`Save Preview` tab. Pressing :guilabel:`Save As` will save
  86. the selected changes to a patch file.
  87. For even finer cherry-picking, you can highlight a number of diff-hunks
  88. in the hunk selection pane and hit CTRL-C. This will copy the
  89. highlighted (mouse selected, not toggled) hunks to the clipboard.
  90. .. note::
  91. Reversing the order of your changeset selection reverses the effect
  92. of the patch.
  93. Import Patches
  94. ==============
  95. .. figure:: figures/import.png
  96. :alt: Import tool
  97. Import dialog of Repository Explorer
  98. The import dialog can be opened from the sync bar or menu of the
  99. Repository Explorer, or via :command:`hgtk import`. The dialog supports
  100. file and directory drag and drop. The drop down menu in the upper right
  101. corner next to the :guilabel:`Browse` button has the options:
  102. :guilabel:`Browse Directory..` and :guilabel:`Import from Clipboard`.
  103. You have the choice of importing directly into the repository, or
  104. importing into your patch queue.
  105. .. note::
  106. Importing a patch requires a clean working directory state. You
  107. must commit, revert, or shelve changes before importing a patch.
  108. .. warning::
  109. If the patch you are importing does not have a commit
  110. message, Mercurial will try to launch your editor, just as if you
  111. had tried to import the patch from the command line. Your ui.editor
  112. needs to be a GUI app to make this work correctly.
  113. Patch Queues
  114. ============
  115. .. figure:: figures/patchqueue.png
  116. :alt: Patch Queue
  117. Patch Queue panel in the Repository Explorer
  118. Both the Repository Explorer and Commit Tool have an optional Patch
  119. Queue panel that is only available when the user has enabled the MQ
  120. extension. It allows the user to perform most patch queue operations
  121. including push, pop, rename, and finish. It's recommended to learn the
  122. MQ extension before using the Patch Queue panel.
  123. .. vim: noet ts=4