Handling BitKeeper merge conflicts

I'm more familiar with Git and its merge process, but I also use BitKeeper and sometimes run into merge conflicts. Here's some info on how to handle them.

Unlike Git, BitKeeper doesn't have the notion of "local" branches, so all merges are from push/pull operations. BitKeeper has a merge command, but it's for merging single files, rather than merging one local branch into another.

Anyway, if you run into merge conflicts in your pull, you'll enter an interactive CLI mode to resolve them. I found a bit of documentation from BitKeeper on this, but not much about the CLI.

Here's a sample of how to do the interactive merge. I found the following interactive CLI commands useful :

  • ? - Provides list of available commands
  • D - launches graphical difftool so you can see differences between local and remote (where you pulled from)
  • ul - use the local file (don't merge - just take the local file)

This is a simple merge where I didn't do any hand editing of conflicts -- I just used the local version. Some names are changed to protect the innocent.

If you expect tricky conflicts, you may want to first clone a 'backup' repo and do your merge (pull) into that. If that looks OK, you can push into your regular repository.


$ bk pull   /usr/test/code
...
Conflicts during automerge of file.php
resolve: resolved 5 conflicts in pass 3
resolve: 3 unresolved conflicts, starting manual resolve process for:
        file.php

(content conflict) file.php>> ?
---------------------------------------------------------------------------
File:   file.php

New work has been added locally and remotely and must be merged.

GCA:    1.2
Local:  1.2.1.4
Remote: 1.4
---------------------------------------------------------------------------
Commands are:

  ?    - print this help
  !    - escape to an interactive shell
  a    - abort the patch, DISCARDING all merges
  cl   - clear the screen
  C    - commit the merged file
  CC   - commit the merged file with comments
  d    - diff the local file against the remote file
  D    - run side-by-side graphical difftool on local and remote
  dl   - diff the GCA vs. local file
  dr   - diff the GCA vs. remote file
  dlm  - diff the local file vs. merge file
  drm  - diff the remote file vs merge file
  e    - automerge (if not yet merged) and then edit the merged file
  f    - merge with graphical three-way filemerge
  f2   - merge with graphical two-way filemerge
  h    - revision history of all changes
  hl   - revision history of the local changes
  hr   - revision history of the remote changes
  H    - show merge help in helptool
  m    - automerge the two files
  p    - graphical picture of the file history
  q    - immediately exit resolve
  s    - merge the two files using SCCS' algorithm
  sd   - side-by-side diff of the local file vs. the remote file
  ul   - use the local version of the file
  ur   - use the remote version of the file
  v    - view the merged file
  vl   - view the local file
  vr   - view the remote file
  S    - skip this file and resolve it later
  x    - explain the choices

Typical command sequence: 'e' 'C';
Difficult merges may be helped by 'p'.

(content conflict) file.php>> D
(content conflict) file.php>> ul
End comments with "." by itself or a blank line.
file.php >>  Use local version of file in merge.
file.php >>  .
file.php revision 1.14: +11 -53 = 54
resolve: resolved 2 conflicts in pass 3
ChangeSet revision 1.6701: +9 -0 = 12342
resolve: applied 12 files in pass 4
resolve: running consistency check, please wait...
100% |=================================================================| OK
Consistency check passed, resolve complete.

Categories: