Search code examples
version-controlbazaar

bzr pull vs bzr merge


I'm using bzr for a very simple task: getting the development version of GNU Emacs. After the initial bzr branch, I'd like to keep my local version up to date. I read about the documentation on bzr pull and bzr merge, but couldn't make sense out of it. I tried bzr merge for a few days, and found that bzr merge often resulted in unresolvable conflicts. Note that I didn't make any local changes. Is bzr pull the recommended way?

EDIT 1 (added a diagram stolen from Chris Conway):

remote: A --> B --> C --> D
         \                 \
       (branch)           (merge)
           \                  \
local:      \--> A (no change) \--> why conflicts?

I understand git and darcs, but have no knowledge about bzr. Analogies to git or darcs will help a lot.

EDIT 2: Is update supposed to work with checkout only? Doing an update in a branch doesn't seem to do anything.


Solution

  • Note that I didn't make any local changes. Is bzr pull the recommended way?

    Yes, it sounds like bzr pull is the appropriate command for your use. pull takes a remote source branch and copies any changes from it to a local destination branch at an older revision. (I use "remote" and "local" here to mean "source" and "destination." Any two branches will do, even two local branches.)

    remote: A --> B --> C --> D
             \                 \
           (branch)           (pull)
               \                  \
    local:      \--> A (no change) \--> D
    

    A pull only works if the two branches haven't diverged, i.e., if the revision of the destination is an old revision of the source. push is just the opposite operation: it copies changes in a local branch to remote branch at an older revision.

    remote: A      (no change)       --> C
             \                      /
           (branch)             (push)
               \                  /
    local:      \--> A --> B --> C
    

    A merge is used when you want to copy changes to a local branch that has diverged from the remote branch.

    remote: A --> B --> C --> D
             \                 \  
           (branch)           (merge) 
               \                  \ 
    local:      \--> A --> X --> Y --> Z
    

    Here, Z includes all of the changes from D and the changes from Y. A pull is not possible in this case. Note that you must commit after a merge in order to save the new merged revision, whereas a pull automatically brings the branch to a saved revision point.

    A checkout allows you to use bzr in a mode that is similar to CVS/SVN: the local branch will be "attached" to a remote branch; commits will be automatically pushed; if the remote branch has diverged, the commit will fail; an update is just a merge from the "attached" remote branch.