'bzr update' wiped all my local commits. Help! - bazaar

I think something bad might have happened to my changesets.
For the record, I have used git, hg and svn with general success before. My understanding of bzr is less complete.
Here's what I had (Windows XP):
1) A folder created using bzr's svn checkout. Call it stable
2) A folder branched from that which I was using for development. Call it development
My plan was to use commit --local on the development branch to keep track of changes, and it was working swell.
Then, I did a 'bzr update' on (because it complained when I tried to push). At the time, stable had a much older copy of the code. Well, now development has that same old copy. 'bzr log' shows no evidence whatsoever of my local commits!
Can someone explain to me what happened, and what I can do to recover my old code?

Ok, I found it. After some frantic searching, I uncovered the secret code word, "dead head," after viewing this other stackoverflow question:
Some code was lost after doing bzr commit --local, bzr pull, bzr commit
However, the solution they proposed didn't work for me. What did work, was found at
http://chrismarinos.com/don-t-loose-your-head-with-bazaar/
The final answer was to find the revision id using heads --all, and then use pull get get all the revisions:
bzr heads --all
bzr pull --overwrite -r revid:<revision-id>
All my code is back, and now backed up 3 or 4 times.

I honestly cannot say how that would have happened—it honestly looks like that would be the behavior of a (sounds pretty catastrophic bug), unless you did something like bzr pull --overwrite or did a bzr revert after a bzr pull that had conflicts.
First things first, see if you can reliably replicate this problem. Whether or not that is possible, though, file a bug report against bzr so that this issue can be tracked. Also, before doing ANYTHING ELSE AT ALL, back up the data that you have in these branches. If you have been working in a shared repository, back up the whole thing. That way it is available for forensic recovery if such drastic efforts are necessary. For more help on that, though, you'll have to work with the Bazaar developers. It might be helpful to hang out in the #bzr room on FreeNode's IRC network to ask for help. As is the usual for seeking out support on IRC, patience is key even if the situation you're in is pretty urgent. They may be able to give you some Python code or instructions on how to dig up those commits, and they also may be able to tell you how to find out what happened.
That said, what I typically do when doing development like this, is I have an unbound "upstream" branch, and then whatever branch I am working in. When I am finished with my changes, I'll pull from the upstream, merge my branch into the resulting tree, then push back up. For example:
$ bzr init-repo project; cd project
$ bzr branch bzr+ssh://example.org/srv/bzr/project/trunk trunk
$ bzr branch trunk my-feature-branch
$ cd my-feature-branch
... work, commit; work, commit; ...
$ cd ../trunk
$ bzr pull
$ bzr merge ../my-feature-branch
... resolve any merge conflicts here, if any ...
$ bzr ci -m 'Merge in my-feature-branch'
$ bzr push :parent
Doing it that way also keeps your work separate from the upsteam branch until you're ready to merge and push it. And it ensures that your local branch never has the chance to be overwritten.

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.

Using bzr for installing OpenERP

I am trying to use bzr for installing OpenERP. The problem is that I have a very slow internet connection.
When I try "sudo bzr branch lp:openobject-addons/7.0 addons" it takes too much time and sometimes the connection is broken. My questions are:
How can I resume the process on connection broken since every time I repeat the command I get an error "folder already exists..."
Is there any way I can restore a local backup of the files and folder structure and then just compare those files/folders with the files on the server and just upgrade the changed files/folders via bzr? This could be a solution for my slow internet connection.
If I sucessfully download all the files from a branch, which command should I use later to verify if there is any change on the files on the server and if so, how can I update this changes?
Thank you very much
Best regards
Paulo
What takes a lot of time and bandwidth is not transferring the OpenERP addons files themselves, but the repository containing the whole versioning history. It has grown quite big over the years, due to the number of commits as well as the daily translation updates exported by Launchpad.
Answering your points one by one:
If you don't actually need the revision history, you can grab a "lightweight checkout" of the addons instead of a full checkout, by using this command:
bzr checkout --lightweight lp:openobject-addons/7.0 addons
It will be much faster but will only get the files, not the history. You'll still be able to use bzr pull to grab the latest changes from upstream. See also the doc about bzr checkout.
Now if you still want a full checkout you can use the trick of grabbing only a few hundred revisions at a time (there are about 9000 in addons 7.0 right now), so you can resume at any time even after a timeout:
$ bzr branch lp:openobject-addons/7.0 addons -r 100 # grab first 100 revs
$ cd addons
$ bzr pull -r 1000
$ bzr pull -r 2000
$ bzr pull -r 3000
$ ...
There's no easy way to completely bootstrap a full addons checkout unless you manage to perform a full checkout on another machine or internet connection, in which case you should be able to simply transfer the directory (most importantly the .bzr it contains) on any other machine.
In order to see the difference between a local branch/checkout and another repository you can use bzr missing, for example bzr missing lp:openobject-addons/7.0. You can then grab the latest changes from that repository (provided it is compatible with yours) using bzr pull.
Now you should really have a look at the bzr documentation in order to get more information about the typical use cases. The documentation also contains a "bzr cheat sheet" that may help you.
Unfortunately I don't think you could resume a bzr branching.
OpenERP's official website does provide source code nightly builds,
but they use a different structure. I'd recommend you ask a friend
who has a faster Internet connection to bzr branch the source code
repositories and transfer them to you.
You could do bzr pull to get the latest changes and merge them

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

Working with GIt without branches

I am trying to work with GIT, without creating private branches.
What that means is I directly work on my cloned repository (master)
Now, Is that the right way to use GIT? I run into many issues related to updating my repository (GIT PULL / GIT FETCH). And most of the time, I am not able to use GIT Merge.
Is there a particular way in which i can use GIT MERGE, GIT PULL, and GIT FETCH. That will help me?
Looks like the best way to work with GIT is have branches.
Branch 1
GIT Commit
GIT PUSH
GIT MERGE master ( to fetch the newer changes)
Branch 2
GIT Commit
GIT PUSH
master
GIT Merge branch1
GIT Merge branch2
I dont think there any other way. Please correct me if i am wrong?
Jan Krueger's extended cheat sheet will help you cover the basics, and will expose you some common commands for using git.
IMO, git is a brilliant DVCS. If you have time; take a look at the structure of git and try to catch the ideas behind its design. For example this Tech Talk by Linus Torvalds.
Note: It looks like you are missing some core ideas behind using git, so please try to learn general approach of git before tackling with commands.
Note 2: As being a stalker, you seem to have general problems with git. So I repeat my advice once more. Learn basics, complete a tutorial, read/listen/watch a few useful source from notable people about git.
Also read about git stash. It saves your local uncommitted changes so you can pull cleanly. Then run git stash pop to replay those changes on top.

git-svn branch - How to keep branch in sync with trunk?

There are plenty of questions about git-svn workflow, but I haven't been able to figure this one out:
This section of the svn book talks about a common practice with SVN: you make a branch, and you keep merging changes from the trunk as the trunk gets updated, so that the branch always includes the latest changes.
I did git svn branch to create a branch on svn and then set up a tracking branch to work on it. These questions cover the process pretty well.
Now suppose there were changes made to the trunk, which I now want to merge into the branch. What is my best option? Note that I need to keep git-svn happy, and not mess up the work of people using the branch with subversion, so just doing a rebase would probably not work.
This question seems to talk about a similar situation, although it's pretty old, and I'm not sure what the bottom line there was - it seems to suggest I should git checkout master and then git rebase mybranch, but that can't be right.
I suspect the the answer should be something that has the effect of svn merge, preferably with setting the mergeinfo property, but alas, there is no git svn merge...
I don't really understand how this simple question was left unanswered for more than a week, with only 13 views so far. I guess it was my fault, bad question writing.
Anyway, I figured it out myself. Short version: just use git merge instead of git rebase.
My confusion came from using git rebase when syncing a branch with the changes in master. When working on local branches, this usually works great, and keeps the history clean. However, you should not rebase commits that you have pushed to a public repository, and the subversion repository is (apparenly) public enough. git merge, on the other hand, works beautifully, and doesn't have any problem.
So, the long answer is: when you want to merge the latest changes in the trunk into the svn branch you're tracking, just do:
git merge master
# Handle conflicts, git add when you're done
git commit
git svn dcommit
This will keep your branch in sync with trunk, but will not set mergeinfo, so you probably should not mix svn merge with this kind of practice.