Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 863
Wei Hu Avatar asked Jan 11 '10 20:01

Wei Hu


3 Answers

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.

like image 60
Chris Conway Avatar answered Nov 18 '22 08:11

Chris Conway


Merge is for merging two different branches, not copies (local and remote). Use pull.

like image 45
myfreeweb Avatar answered Nov 18 '22 08:11

myfreeweb


$ bzr help pull

Purpose: Turn this branch into a mirror of another branch.

--overwrite Ignore differences between branches and overwrite unconditionally.

If you want to replace your local changes and just want your branch to match the remote one, use pull --overwrite. This will work even if the two branches have diverged.

so you can use:

$ bzr pull --overwrite

like image 2
galen Avatar answered Nov 18 '22 09:11

galen