How to cope with bazaar uncommits - bazaar

Hit the following situtation a couple of times today:
Myself and another dev both have bazaar local checkouts of a repository.
I make some changes.
The other dev makes and commits some changes.
I update.
The other dev realises their previous changes were broken and uncommits them.
I update.
Now the other dev's uncommitted changes appear as a pending merge in my local checkout, and I can't find a way to separate them from my changes and remove them from my 'local' tree.
Every time this has happened I've had to manually work out which changes are mine and which are not, save my changes, revert, and then re-apply my changes.
I've tried doing a "cherrypicking" reverse merge on my checkout between -r -1..-2, and between -r 0..-1, but neither helped. (0..-1 said "nothing to do", although I might not have done it properly. -1..-2 was the wrong set of changes and thus made things worse.)
How can I fix this situation when it happens (other than going over and smacking the other dev upside the head)?

It is recommended that you don't uncommit in branches that are published somehow, thus avoiding this issue.

Well once you have updated (step 4), the other guy's changes will be merged with yours permanently. Since your changes were uncommitted, they aren't stored anywhere. Therefore, once step 6 has happened, I don't really see a way of automatically separating out your changes from his.
So let's say you manually remove all of his changes so you're just left with yours. You still have this pending merge to deal with. You can fix that by typing
$ bzr revert --forget-merges
That will not change your working tree; it will only remove the pending merge from your "bzr st" so that when you commit it will not look like a merge. This should save you from having to save your changes, revert and re-apply.
To avoid this happening again, you could run bzr update only immediately before you commit. Once merged, to a bzr commit right away, and your changes are locked in. Now he won't be able to uncommit without first updating and seeing your changes, and now it's probably too late for him to do that. If he really wants to go ahead with his uncommit, he's the one that has to deal with the mess, not you.
One final thing you can do -- if you really don't want to deal with it and you don't care too much about having a nice version history. After step 6, just commit. Maybe explain in your log that the other dev uncommitted this change but too late.
This is where the pending merge comes in. If you commit, the uncommitted revision will go back into the repository, as a branch, just as if the other dev had send those changes to you in an email and you merged them. It will look like this:
------------------------------------------------------------
revno: 34 [merge]
committer: You
branch nick: trunk
timestamp: Fri 2010-11-26 15:57:27 +1100
message:
Made my changes to the file.
Note, other guy did some of these changes and uncommitted, but
I already merged.
------------------------------------------------------------
revno: 33.1.1
committer: Other Guy
branch nick: trunk
timestamp: Fri 2010-11-26 15:39:39 +1100
message:
Made some changes to the file.
------------------------------------------------------------
When he runs update again, he'll have his old changes thrown back at him, and probably get a conflict. He'll have to clean it up, then commit his fixes (whatever reason he had to uncommit in the first place). This is probably just as effective as a smack upside the head, and works over a network :)

It looks like bzr pull --overwrite :bound is what you're after.

Related

Git: merge two working copies without committing

I have a clone for server development and another for client development. Both material will eventually make it into the same branch, but I want to synchronize them and I want it to perform a merge as though I had commit pushed and pulled, but I want to do it without that.
I'm able to make a patch with this script I wrote:
git diff --cached
git diff
on the server, but applying that to the client is much harder.
I've tried the Unix patch command, for some reason, it keeps asking me what files to patch, like I can't find them. (Yes, they're there) I've tried
git apply -3 patch.patch
but that gives a lot of errors like "with conflicts" (without making any changes) and "does not match index". It doesn't even seem to be trying to patch the other half of the files.
Stashing, then applying the patch, and then popping from the stash doesn't work, because unstashing refuses to do merges.
It looks like doing it without the pulling isn't going to work--I haven't found a way to do it conveniently and safely. However, my problem with committing is that I didn't want to spam the git log with garbage like:
Sync'ing to client
Sync'ing back to server
Oops! Sync'ing something I forgot to the server again!
etc.
But I can avoid all this by committing, then pulling from the remote repos. In the end, I wouldn't have to push those commits, since I would use reset to remove them all from the local repo and then, with all my changes in the working directory, do a proper commit and push it.
Gotachas
They are many.
It's commonly known that you shouldn't reset your local repo if something has already pulled from it. This is probably from the obvious confusion that results when one repo delete commits that another repo believes were there. For that reason it's important that the same reset is performed on both repos before they start sharing code again.
If after you've done your commits that you later want to reset, then pull/merge, you could make things very difficult for yourself. There should be a way to manage it, but I haven't yet figured it out. One idea is to reset, stash, pull, merge, and commit again. Another involves revert with the -n option.
Instructions
The following example assumes you have 2 clones; one called "client" and the other "server".
Following https://help.github.com/articles/adding-a-remote, setup your client's and server's repo on each others' systems to they can pull from each other.
When you want to sync, just commit on the donor system, then instead of pulling from the origin, pull from a remote. Say the client wanted a commit from the server. On the client:: git pull myserver-repo mybranch.
Merge and conflict-resolve as necessary.
Loop back to 2 as many times as is necessary.
After several iterations of 2-4, you arrive at the point when you are ready to push your changes to the server. Go to whichever local repo has all the changes you want pushed, then run git log. Find the commit before the first commit you did in 2. Copy its hash to the clipboard.
Then git reset: git reset <hash you copied in 5>.
You should then see all the commits you don't want disappear from the log and all the changes therein in your working directory. Commit and push.
It's important that you do a cleanup on the repo from which you didn't perform 5-7. So if you pushed from your server repo, you need to perform the same reset operation on your client, then dispense with the changes as you see fit. My preferred method is git stash save "delete_me".

Is there a way to recover my code in Microsoft Visual Studio Community?

Technology used:
Microsoft Visual Studio Community 2015
VB.NET
GitHub
When i was altering skin in my form to design it, i was having trouble undoing my design to return back to its normal design. And as i go to my Form in Solution Explorer and clicked Undo everything had vanished including my code. I'm having trouble on how to retrieve my code ? Is there a way to retrieve my codes and my design or a garbage collector where i can easily retrieve it?
I would be so happy for your suggestions.I really need your Help.
The only way that you will be able to retrieve your old code at this point is if you did a
git push origin master
(or other branch) to github before you made these changes.
If you haven't use Git Extensions - I would suggest downloading and linking it to your github repo for this project. Git Extensions will give you a nice quick view of all your branches and what is sitting in your local repo.
Provided that you did a
git commit
You will still have your changes saved locally and this can be easily identified using Git Extensions.
If you have made the changes after you did a commit, you will see the old code in Git Extensions. From here you will be able to revert selected lines or all of the files. This is provided, that you had at least one major commit in git before this happened.
Update 1:
Based on your comment on your OP you should still have the original files in git. You should then be able to find your code easily via Git Extensions. You should see a list of changed files and from here you can revert them easily.
Update 2: Based on your comments, it appears that you have completely lost your changes. Git is a change tracker - and based on what you have said you did an Undo Changes on git. This means, that git had reset all the changes that it was tracking and went back to the last commit that you made. There is no way to get your changes back unless you had the files stored on DropBox or something similar where files are tracked on each save of the file. With git, changes made are only stored once committed. If you do an undo changes on the git repo before committing what it actually does is a
git reset
This removes all the changes and reverts it to the last commit.
I've checked and found this. I expect this should deal with your problem. Afterall, as long as you didn't intentionally delete anything, they are still in your target folder where you saved it.
If you checked in your code BEFORE the error on GitHub you can try this:(although I am not certain of community edition as I know it works on Pro and Enterprise).
Go to class in question
Right Click to get context menu
Select Source Control>History
Select a prior version
Right Click Reset>Reset and Delete Changes
This will basically say: "I don't care what happened just take me back to my safe place at this point in time with all affected files!". When performing code I cannot stress the importance to having source control and committing often.

restore uncommitted files from bazaar which have been inadvertently deleted elsewhere

I have tried diligently to find bazaar user groups. I tried pressing the community tab on their website. There seem to be only mailing lists, but where does one start? The title says it all. I have tried revert, but since it was uncommitted, it did not work. The names of the files in question show up on 'bzr status' under 'missing'. the other files show up under 'added'. I am a bazaar rank beginner, and though I knew about commit, just forgot to do it after adding. Are the files well and truly lost, or is there a way to get them back? In the list you presented before answering, the only one which comes close to my situation is: "How can I un-delete an uncommitted", but unfortunately is for svn, not bazaar. This is my last shred of hope. I have held off doing commit now because I am afraid of losing the little which remains, since Bazaar says the are missing.
If bzr status says missing rather than removed, then the files were deleted from disk after they had been added but before a commit happened, I'm afraid.
Under these circumstances, bzr revert cannot help you; it will restore the working directory (or part of it) to the state of a specific revision. Without a commit, there is no revision to revert from, because the system has no record of your files.
If you have backups for your system, you may still be able to recover files from there.

Accurev - why not Auto-Update?

Why isn't it standard behavior for Accurev to automatically run an "Update" upon opening the program? "Update" updates a user's local sandbox with the latest files from the building/promoted area.
It seems like expected functionality that the most recent files should be synchronized first.
I'm not claiming that it should always update, but curious as to why an auto-Update wouldn't be correct.
Auto-updating could produce some very unwanted results.
Take this scenario: you're in the middle of a development task, but you've made a mistake and need to revert a file that you just modified. So you open AccuRev, but before you have a chance to "revert to most recent version", you are bombarded with 100 files that have been changed upstream including the one you want to revert. You are now forced into the position of resolving all the merge conflicts before your solution will build, including the merge of your (possibly unstable) code in progress.
Requiring the user to manually update keeps a protective 'bubble' around the developer, allowing them to commit (keep) changes within their own workspace without bringing down code changes that could destabilise the work in their sandbox. When the developer gets to a point where his code is ready to share with others, that is the appropriate time to do an update and subsequently build/retest the merged codebase before promoting.
However there is one scenario that I do believe auto-updating could be useful: after a workspace is reparented. i.e. when a developer's workspace is moved from one part of the stream hierarchy to another. Every time we reparent we have to do a little dance:
Accept the confirmation dialog that reminds us (rather verbosely) that we need to update our workspace before we can promote any changes.
Double-click the workspace to view its files.
Wait for AccuRev to do a "Pending" search, to determine whether any file changes are waiting to be committed.
And finally, perform the Update.
Instead of just giving us a confirmation dialog, it would be nice if AccuRev could just ask us if we want to Update immediately.
I guess it depends on preference. I for one wouldn't like the auto-update feature.
Imagine you have a huge project and you don't want to build it every time you start Accurev. But you also can't debug because the source files and debugging info no longer correspond.

How can I copy my git revision history into svn?

I use Git, but some of my colleagues are unable to move away from SVN right now. We want the integration between the two systems to be seamless -- all of our development has been in git so far, so we need to copy that over into svn with complete revision history.
I've been able to jigger this such that it copies the repository in a single commit, but I would like it to copy all of the history. I would imagine that this should be pretty easy with git svn dcommit, etc., but it hasn't worked out that way -- merges seem to only go in as a single commit, rebasing kills git-svn, and pull just merges.
So, I've been trying things for the last couple of hours, but can't seem to get it. Tailor almost works, but dies amidst import with what appears to be a bug.
All help is appreciated, and thanks again.
Have you tried creating the svn repository, git-svn clonning it, git-pull'ing from the old git repo (the one with all the history), git-rebase those changes into the master branch, then git-svn dcommitting the changes up to svn? That's just off the top of my head, but might work.
Googling for "git svn export" also showed up this : http://kerneltrap.org/mailarchive/git/2008/10/29/3848124 which seems similar to what I've just described, but with more detail and accuracy, which should get you there.
But knowing Git - i'm sure this will be possible for you :)
Let me know how you get on! I'm also interested in this problem...