Push a local brance back to the central server

Asked by Bruce Graham

I am a sole developer. I have a main branch on our server. I have the main branch and a derived branch on my local machine. I think I want to do something like a merge but not quite. The main branch is for Board A. The derived branch is for Board B (a revised version of Board A)

Both branches are derived from identical source files but slightly different project files. What I want to end up with is "something" on the central server that will allow me to produce any version from either branch. Can I do this? Is it a "merge" or something else?

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Vincent Ladeuil
Solved:
Last query:
Last reply:
Revision history for this message
Best Vincent Ladeuil (vila) said :
#1

> I want to end up with is "something" on the central server that will allow me to produce any version from either branch.

Yes, a merge followed by a commit will create a revision with two parents (the tip revisions of your two branches for boards A and B).

If you want to experiment before pushing to the server try this locally:

  bzr branch boardA work
  cd work
  bzr merge ../boardB
  .... resolve conflicts if any
  bzr commit -m 'merge board B for <significant feature introduced by board B>'

This will give you a revision with a revno N (see below for why N matters).

Now, 'work' will describe the history of board A and the history of board B.

From there, you can explore the history with 'bzr qlog' if you have the qbzr plugin installed or with 'bzr log' otherwise.

  cd work
  bzr log
  ...the boardA history with a single revision resuming board B additions.
  bzr log --include-merges
 ...the board A history with a detailed history of board B additions.

To get back board A (reusing revno N mentioned above):

  bzr branch work -rN restore-boardA

To restore branch B, find the relevant revno (M) in the 'bzr log --include-merges' above and do:

  bzr branch work -rM restore-boardB

A branch history is a graph (with no cycles) starting at the branch tip revision. When no merges appear in a branch history, the graph is just a list of revisions.

Most projects are organized around a trunk which contains the history of the project with merges adding the history of the branches created from the trunk and being merged into it (this is required for a team but still very useful for a single dev). When and how your merge in this trunk define how the project history is recorded.

http://doc.bazaar.canonical.com/bzr.dev/en/ will tell you the whole story ;)

Revision history for this message
Bruce Graham (bgraham) said :
#2

Thanks for that additional information. Unfortunately I was unable to do a successful merge because there are compiler generated files in the two branches that cannot be effectively resolved. In the tips of the two branches all of the *.c and *.h files are identical and there is a a common base revision in both branches which can be identified, but the project files in the two tips cannot be made identical.

I just want to get the branch which is not on the server up there so I can pull it onto another machine. I'm thinking that the best way to do it might be to create another tree in the repository on the server and recommit the entire history of the revision for "Board B"

Revision history for this message
Bruce Graham (bgraham) said :
#3

I looked a little deeper and finally figured it out. Here is the thing:
1. You find the common ancestor, revision 17 for example call it BASE
2. You find the end of the branch you are merging in, revision 32 for example and call it OTHER
3. The tip of the current branch, revision 23 is call THIS

Start with a copy of the current branch on the central server on the local machine via
C:\Work\Project>bzr branch "file://Server/.../Code/Project" work

Now do the merge from the branch that resides only on the local machine via
C:\Work\Project\work>bzr merge -r17..32 ..\dev2

Now there are some conflicts to resolve. I elected to resolve them by copying the files "*.*" OTHER to "*.*"
This means the tip of the tree will be equivalent to the tip of the local branch

Now that the conflicts have been resolved the merge can be committed via
C:\Work\Project\work>bzr commit -m "Project Merge dev and dev2 branches"

Revision 24 now includes underneath it revisions
17.1.15
17.1.14
...
17.1.1
which represent revisions 18 through 32 from the local branch

I guess you have to work things through because it is really hard to explain what is going on. Thanks Vincent I greatly appreciate your efforts.

Revision history for this message
Bruce Graham (bgraham) said :
#4

Thanks Vincent Ladeuil, that solved my question.