fast-import should not override the current branch (or should warn before doing it)

Bug #386544 reported by Gioele Barabucci
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar Fast Import
Triaged
Wishlist
Unassigned

Bug Description

I accidentally run bzr fast-import in a directory that is part of a branch. bzr fast-import overwrote the .bzr directory with the new content and asked to run "bzr update" to adjust the working tree.

fast-import should not overwrite existing .bzr files. It should refuse to run when launched from a bzr-managed directory, or, at least, it should inform the user that it is about to overwrite the .bzr directory of the current branch.

summary: fast-import should not override the current branch (or should warn
- before doing it))
+ before doing it)
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

When restarting an import or doing an 'incremental' import, we actually want to extend the current branch though.

I'm pretty sure fast-import wouldn't have succeeded if the branch wasn't compatible with the import stream. Was that your experience?

Also, you should be able to recover quite easily using:

  bzr uncommit -rxxxx
  bzr revert

Changed in bzr-fastimport:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Gioele Barabucci (gioele) wrote :

In fact the branch was compatible. Nevertheless I didn't want to overwrite.

May I suggest to add a warning along the lines of "You're about to overwrite the existing branch/repository '/path/FOO'. This is normal if you are doing an incremental import. Are you sure you want to continue?"

uncommit and revert would have not helped me: I interrupted bzr update with ^C (after seeing hundreds of "removing foo") so the branch (actually a standalone branch) was not in an usable state; at least it was not evident to me how to get back. The situation was aggravated by the presence of many unversioned (ignored) big files I was afraid to lose. For the records, I got out of this problem moving the dir away, making a branch from the push location and merging the unversioned files back into the new checkout with pax. With a little warning in place I would have probably avoided all these problems.

Revision history for this message
Neil Martinsen-Burrell (nmb) wrote :

This bit me recently. I was able to recover with the following process (motivated by the warning message that ``bzr uncommit`` gives when it rolls back a commit.

1. Find the revision-id of the last revision in your original branch. If you have an unaffected version of the same branch, then you can use ``bzr log --show-ids -r -1``. If not, you need to poke around in the index files to see the revisions that live in the repository. For me, that looked like:

$ bzr dump-btree .bzr/repository/indices/<some obscure pack name>.rix

Look for a sequence of revisions that all happened within seconds of one another. These are from fast-import. The revision before these is the one you want. It's revision-id is in the FIRST tuple. The later revision-ids are its parents.

2. Do ``bzr pull . -r revid:<the revision id from step 1>``. This should give you many, many conflicts, but you can check to make sure that this is the revision you want. Then re-do the pull with the ``--overwrite`` option to get back to where you started. You can also pull this revision into a new branch.

Revision history for this message
Matt Chapman (matt-ninjitsuweb) wrote :

I'm years late to the party, but I was just trying to import some files & history from a git repo into an existing bzr repo. Instead of incrementally adding the desired files and history, fast-import appears to have completely replaced the existing history. `bzr status` shows all the original files as unknown now, and `bzr log` shows only the history of the imported files, nothing prior. I received no warning that this would happen. It seems my only choice is to re-branch from the remote origin and start over. :-(

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.