##// END OF EJS Templates
release: Bump version 5.1.0 to 5.1.1
release: Bump version 5.1.0 to 5.1.1

File last commit:

r1:854a839a default
r5481:be158c0f v5.1.1 stable
Show More
merging.rst
110 lines | 4.0 KiB | text/x-rst | RstLexer

Merging in |hg|

Sometimes you will need to fix conflicts when merging files. In |hg| there are a number of different options which you can use for handling merging, and you can set your preferred one in the :file:`~/.hgrc` file. The options fall into two categories internal merging or tool merging.

Internal merging marks the files with the <<<<<, >>>>>, and ======= symbols denoting the position of the conflict in the file and you resolve the changes on your terminal. The following example sets Meld as the merge handler.

[ui]
merge = internal:merge

Tool merging differs slightly depending on the tool you use, but they will all do the same thing. Highlight the conflict area in some manner, and allow you to make the necessary changes to resolve the conflicts. Set a merge tool using the following example.

[merge-tools]
meld3.executable = /usr/local/bin/meld

For more detailed information, see the :ref:`basic-vcs-cmds` section, or the Mercurial merge-tools documentation. Use the following example steps to handle merging conflicts.

  1. Check the list of conflicts on the command line, in this example you can see the list as the default and stable branches are in the process of being merged.
  1. Open each of the highlighted files, and fix the conflicts in each. Each merge conflict will look something like the following example, with the <<<<<, >>>>>, and ======= symbols denoting the position of the conflict in the file. You need to fix the content so that it is correct.
# Change this example conflict
def pre_request(worker, req):
<<<<<<<<<<<<<<
    worker.log.debug("[%s] PRE WORKER: %s" %(worker.pid, req.method))
 ===============
    worker.log.debug("[%s] PRE WORKER: %s %s" % (worker.pid, req.method,
    req.path))
>>>>>>>>>>>>>>

# To this working code
def pre_request(worker, req):
    worker.log.debug("[%s] PRE WORKER: %s %s" % (worker.pid, req.method,
    req.path))
  1. Once you have finished fixing the conflicts, you need to mark them as resolved, and then commit the changes.
# Mark the merges as resolved
$ hg resolve --mark

# Commit the changes
$ hg commit -m "merge commit message"
  1. Once you have finished your merge, if the the original |repo| history on the server is different you have two options:
    • Push with force using hg push --force which will create a new head.
    • Strip your commits on the server back to a previous revision, and then push the new history. To strip commits on the server, see the strip information in the :ref:`api` documentation.