Bazaar offline + branches - bazaar

I have a Bazaar repository on Host A with multiple branches. This is my main repository.
Until now, I have been doing checkouts on my other machines and committing directly to the main repository. However, now I am consolidating all my work to my laptop and multiple VMs. I need to be working offline regularly. In particular, I need to create/delete/merge branches all while offline.
I was thinking of continuing to have the master on Host A with a clone of the repository on the laptop with each vms doing checkouts of the clone.
Then, when I go offline, I could do bzr unbind on the clone and bzr bind when I am back online.
This failed as soon as I tried to bzr clone since bzr clone only clones a branch(!!!!)
I need some serious help. If Hg would handle this better please let me know (I need Windows support.) However, at this moment I cannot switch from Bazaar as it is too close to some important deadlines.
Thanks in advance!

bzr fundamentally works with one branch / directory (the branch are visible at the file system level), so if you need to clone each branch from your repository (not unlike svn, in a way). Hg, at basic level, works this way too (although you can put several branches in one repository using say named branches).
For DVCS, it is important to distinguish between the following:
Working tree: a versioned set of files (at a given revision)
Branch: a linear set of revisions
Repository: a set of revisions
When you clone locally a directory versioned by bzr, you are copying the repository subset which contains all the revisions in the branch you are cloning, and get the working tree. This assumes you are not asking for a branch wo a working tree nor using a shared repository.
What you want, IIUC, is to clone the full repository with all the branches. There is no 'native' way to do so in bzr I believe, but plugins to help you toward this, like multi-pull and push-repo, to sync multiple branches in one shot.
But I don't understand why that's such a big problem, or the link with working offline: you just clone the branches you want to work on your laptop.

Related

Use git-svn with multiple svn repos and branches

I have a svn branch that I had been working on and decided to start using git-svn to work locally. Now I have two problems. I want to move my work into another svn repository (on the same host) but I'd first like to merge the latest work from trunk. How would I do this with git-svn? Also, how would I continue my work in a separate svn-repo while continually merging work from the original repo? Also, I don't want to checkout the entire history from the original trunk because the project is rather huge. I am new to git and to git-svn, though I've taken a crash course in git branching and I feel confident enough to use advanced commands like rebase and cherry-pick. I mainly need to know how to apply these concepts thru git-svn. Do the svn repos get setup as a git remote somehow? Are there good resources on the net explaining how it works? Any guidance is much appreciated.
Create your Git repo with git svn init -s <url>.
git config --edit, add several svn-remotes for each of your Subversion repos. Later you'll use the -R option to all git-svn commands to select which svn-remote to use.
Tweak svn-remote branch mappings as needed. Keep in mind that the default refs/remotes/* namespace specifies remote branches — not Git remotes. (You'll have just a single git remote named . which I don't recommend pushing/pulling to/from).
You can easily design your remote branches namespace to keep branches from different Subversion repos separated (e.g. refs/remotes/repoA/*, /refs/remotes/repoB/* etc).
git svn fetch. This has options to scan history only partially, e.g. starting from a specific revision. Please read the manpage on instructions how to do this.
You can also ignore specific paths and/or branches here.
Work with Git as usual, trying to keep your commits as linear as possible. Rebase often. Merge commits are fine (git-svn will even set svn:mergeinfo property), but holy cow be careful (and read the manpage for caveats). Understand that Git commits with git-svn-id tags are immutable, and push -f won't save you. For example, it's forbidden to amend or rebase already dcommit'ed changes.
Are there good resources on the net explaining how it works?
By far the best resource is the manpage. The next after it is git-svn source.

How to roll back in subversion and simultaneously clear history?

My SVN repository contains several folders for different projects. 'Desktop program', 'iOS app', 'Web app' etc. All revision entries are shared between these (as it's under one repository. Revision #100 might be on the 'iOS app' folder, revision #101 on the 'Web app' folder etc).
What I want is to roll back to an earlier version on just one of these folders. Usually this is done with a 'reverse' SVN Merge as it's SVNs job to keep track of all history, even the bad times. I don't want that however. Lets say I have twenty commits on 'iOS app' since revision #5. I want to rid these from history and I want that specific folder to return to revision #5. No one should ever again be able to check those twenty commits as they 'never happened'. Is this even possible?
I have two different machines I am interacting to SVN with. A Windows PC with VisualSVN and a Mac with Subversion on Terminal level. I would be thankful for a solution on either.
From client side, there is simply no way to do this. No matter if commandline, Tortoise, or any other client.
If you have access to the server account that owns the repository, then there is some chance - but it is quite complicated and may involve a nontrivial manual work.
Roughly, these are the steps:
get the repository UUID - svn info http://svnserver/svn/repo - see the UUID line
dump the svn repository: svnadmin dump /path/to/repo > repo.dump
edit the dumpfile to exclude the commits
a) either open it in vi and delete your undesired commits
b) or use svndumpfilter command to filter them by path
create new repository and import your modified repository into it:
svnadmin create /path/to/repo2
svnadmin load < repo.dump
svnadmin setuuid /path/to/repo2 THE_ORIGINAL_UUID
Now, check that repo2 is working fine and has the content that you expect. If so, you can remove repo and rename repo2 -> repo.
Keep in mind that manual changes to the dumpfile are extremely prone to errors, and often these errors can be quite difficult to discover. It is usually bad idea to do things like this.
What I want is to roll back to an earlier version on just one of these folders. Usually this is done with a 'reverse' SVN Merge
Terrible... In order to return back part of WC-tree into some previous revision you have to cd SUBTREE-ROOT & svn up -r REVNO (commit from WC-root for this modified WC will create new revision in repo with partially rollbacked tree)
No one should ever again be able to check those twenty commits as they 'never happened'
Cheated and rewritten history in SCM is BAD IDEA. And Subversion history is immutable, you have to change history using svnadmin tools and access-level, as #petr-kozelka wrote

Bzr: Create a shared repository from an existing stand-alone repository

I have been using Bzr for version control of my project over the last few months. I am the sole developer, and currently I just have everything in a single local project directory, to which I commit and which I sync to DriveHQ.
I now have some large-scale experiments in mind which would likely break this main line, so I've been looking into the concepts of branches and shared repositories. So my question is, basically: how should I go about creating a new, shared repository from this already-version-controlled base?
I am familiar with the SVN project structure of trunk, branches and tags, and I'm going to adopt this structure. My plan is to just go ahead and do a fresh init-repo, and copy all my code (plus .bzr) over into the trunk folder. So is this OK? Or is there some way to convert what I have already into a shared repository?
Many thanks in advance for any help.
Christopher
OK, so you have some work directory where your standalone branch is.
You want to create trunk and feature branches in new shared repo.
At first you need to create a shared repository itself:
bzr init-repo /path/to/repo
Now you can put your code to repo/trunk. You can use push, branch or you can copy work and use reconfigure.
cd work; bzr push /path/to/repo/trunk
cd path/to/repo; bzr branch /path/to/work trunk
or copy/move work to /path/to/repo/trunk then cd /path/to/repo/trunk; bzr reconfigure --use-shared
In all cases you'll have branch trunk as a copy of your old work, and this trunk will use shared repository to save the revisions.
You can also look at bzr-colo plugin.
Create a folder outside your current repository.
Call bzr init-repo to create a shared repository
From your working tree push to the newly created shared repo.
You can now work directly on the shared repo

Bazaar: moving from single-developer to an accessible repository

I've started using bazaar DVCS for a project in a single-user mode, as described in their tutorial. I would like to involve another developer in this project, but the multi-user, "brancheable" repository seems to have different structure from my little ad-hoc directory. I can't find the documentation on how to go from one to the other. Can someone help?
I don't see how you managed to get something that's not branchable. It's a fundamental thing in bazaar.
Suppose you have done something like this for your code:
c:\dev> bzr init proj
c:\dev\proj> hackhackhack.bat
c:\dev\proj> bzr commit
This should be a branchable repository. i.e.
c:\dev2> bzr init-repo .
c:\dev2> bzr branch c:\dev\proj proj
You now have a branch.
If you're talking about running the built-in server, you need to do this:
c:\dev2> bzr serve

How do I export the Bazaar history of a subfolder

I'm coding a framework along with a project which uses this framework. The project is a Bazaar repository, with the framework in a subfolder below the project.
I want to give the framework a Bazaar repository of its own. How do I do it?
You use the split command:
bzr split sub_folder
This creates an independant tree in the subfolder, which you can now export and work on separately.
Use fast-import plugin (http://bazaar-vcs.org/BzrFastImport):
1) Export all your history to the stream:
bzr fast-export BRANCH > full-history.fi
2) Filter the history to produce new stream:
bzr fast-import-filter -i subfolder full-history.fi > subfolder.fi
3) Recreate new branch with subfolder only:
bzr init-repo .
bzr fast-import subfolder.fi
As far as I know, there is not a way to do this easily with bazaar. One possibility is to take the original project, branch it, and then remove everything unrelated to the framework. You can then move the files in the subdir to the main dir. It's quite a chore, but it is possible to preserve the history.
you will end up with something like:
branch project:
.. other files..
framework/a.file
framework/b.file
framework/c.file
branch framework:
a.file
b.file
c.file
As far as I know, "nested" branches are not support by Bazaar yet. Git supports "submodules", which behave similar to Subversion externals.
I have tried doing this with bzr split, however, this does not work how I expect.
The resulting branch still contains the history of all files from all original directories, and a full checkout retrieves all the files. It appears the only thing that split does is convert the repository to a rich root repository so that this particular tree can be of a certain subdirectory only, but the repository still contains all other directories and other checkouts can still retrieve the whole tree.
I used the method in jamuraa's answer above, and this was much better for me as I didn't have to mess with converting to a new repository type. It also meant that full checkouts/branching from that repository only recreated the files I wanted to.
However, it still had the downside that the repository stored the history of all those 'deleted' files, which meant that it took up more space than necessary (and could be a privacy issue if you don't want people to be able to see older revisions of those 'other' directories).
So, more advice on chopping a Bazaar branch down to only one of its subdirectories while permanently removing history of everything else would be appreciated.
Do a
bzr init .
bzr add .
bzr commit
in the framework directory.
Then you can branch and merge to just that directory.
The bazaar higher up will ignore that directory until you do a join.
Bazaar understands when you do things like
bzr branch . mycopy
bzr branch . myothercopy
The current directories .bzr won't track those subdirectories changes.
It saves you from trying to find a place to put a branch.