explain uncommit to me please

Stephen J. Turnbull stephen at xemacs.org
Sun Aug 15 15:31:57 BST 2010


Chris Hecker writes:

 > I just used bzr uncommit for the first time tonite, and I feel a
 > little dirty.  :)

No, you're pure and clean.  Using uncommit in the privacy of your own
repo is like getting into your private jacuzzi naked.

 > What happens to that revision in the branch?

It disappears.  It's not technically part of the branch any more.

 > It's still got a revid, so it's in there somewhere?

Yes, it's still in that repository.  IIRC under some conditions it can
eventually get garbage collected, and it won't be added to a "bzr
branch" off that branch, so if you delete that repository or it gets
garbage collected, it's gone forever.

 > If I try to log -r revid:blah I hit the crash bug referenced here
 > (https://bugs.launchpad.net/ubuntu/+source/bzr/+bug/409266).

That's a bug.  It should work.

Do you crash if you do

bzr merge revid:blah

?  If not, as long as you haven't done any commits or changed your
workspace since the uncommit, that should undo the uncommit.  (The
other cases should also work, but describing what should happen is
more complex than I want to deal with.)

 > What would have happened if I'd pushed to another branch before
 > uncommitting?

That's like flashing the Prime Minister on national TV.  Dirty.  Don't
do it, you could be arrested and charged with public indecency.  :-)

Probably it wouldn't be a big deal in the scenario you describe,
actually, but it can be quite confusing if you try to push again to
that branch after that.  You won't be able to, without pulling the
commit you uncommitted back into the branch where it was uncommitted,
or uncommitting that commit from the other branch.  Neither of those
operations will necessarily be easy or obvious to accomplish once the
two branches have diverged a bit.

And the other direction is much worse.  If you allow somebody else to
pull from your branch, uncommit, then let them try to pull again,
they're likely to get quite confused because they don't know anything
about the uncommit.

 > I have a feeling this has something to do with multiple heads or

Exactly.

 > something like that, that I don't really understand since I'm
 > pretty new to dvcs.

Do you need to understand it?  The rule is very simple: don't uncommit
if the commit(s) involved have been merged (pushed, pulled) to another
branch, *especially* not if it's not your branch.  (Like any good rule
there are interesting exceptions, but again I'm too lazy to explain
them. :-)




More information about the bazaar mailing list