Sharing files between 2 or more projects

John Arbash Meinel john at arbash-meinel.com
Sat Jan 13 17:46:06 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Massimo Manca wrote:
> I am new to bazaar so I have 2 simple questions:
> 1. is it possible to share some files between 2 or more projects without
> requiring to have them in every project?

I'm a little confused with what you are trying to do here. I'm not sure
how you are thinking to share the files, and how it would work to share
between all projects.

In general, if I had a set of files that were repeated between projects,
I would consider trying to turn them into a library of their own, so
that each project could just share the library. (So instead of having 2
projects where some files overlapped, I would do 3 projects with the
overlapping files in the 3rd section).

If you are trying to have some files common between branches, but other
files that are *not* common between branches, and maintain that
divergence, that is a different situation. We handle having a
one-direction flow of patches very well. We don't handle a 2-way flow
quite as well. Maybe a concrete example would help.

I have a project "Proj" with a structure something like:

Proj/
  Makefile
  lib1/
    source for library1
  src/
    source for project

Then I decide that 'lib1' should be standalone, so I can use it with
another project, but I don't want to give up having it all tied together
in this project. So I do:

$ bzr branch Proj lib1
$ cd lib1
$ bzr rm Makefile src; rm -r Makefile src
$ bzr mv lib1/* .
$ bzr rm lib1; rmdir lib1
# At this point, all of the library files are in the root of the new
# tree, and only library files.
$ bzr commit -m "Splitting off into a single library project."

# This is the one "voodoo" step, which makes the direction of patches
# flow easily from the library to the all-in-one project
# Basically, we have to tell the all-in-one that we recognize the
# library has been split off, and we don't want to turn ourselves into
# just the library files.

$ cd ../Proj
$ bzr merge ../lib1 # Merge the changes from the library
$ bzr revert . # Reject the content changes, but not the merge record
$ bzr commit -m "Acknowledging library"


At this point, you have 2 projects, and whenever you make changes to the
'lib1' project, you can simply:

$ cd Proj
$ bzr merge ../lib1
$ bzr commit -m "Merged latest changes from lib1"

The downside is that if you make changes in the all-in-one project, you
have to cherry-pick them into the lib1 project. (In some ways it makes
sense, because you don't want to merge the changes to all the other
files, just the lib1 changes). So if you just committed a change to the
all-in-one, then you want to do:

$ cd lib1
$ bzr merge -r-2..-1 ../Proj
$ bzr commit -m "Cherrypick the fixes for lib1 from Proj"

# -2..-1 says to merge the change from the 2nd to last revision versus
# the last revision, or in other words, merge the changes just
# introduced in the last commit.

I'm not sure if this is what you were asking for, but you are welcome to
rephrase and ask me again.


> 2. May bazaar handle binary files?

Bazaar handles binary files without any problems (to my knowledge). It
doesn't necessarily handle them optimally (it does do deltas, but they
are fairly coarse, etc), but you shouldn't run into any problems with them.


John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFqRreJdeBCYSNAAMRAgGOAJ0ZyM++FLIYwXXlJCnSgZWLJkDeVQCgln8o
8XLBfjwjDAO3hzjhGveN+Nc=
=XtyR
-----END PGP SIGNATURE-----



More information about the bazaar mailing list