pruning of empty directories

Bug #410140 reported by Ian Clatworthy
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Bazaar Fast Import
Fix Released
Medium
Ian Clatworthy

Bug Description

Tom Widmer posted to the bazaar mailing list on 21/Jul/2009 ....

Bazaar tracks directories, unlike most other DVCSes. However, the fastimport format (as far as I know) has no way of specifying directory creation or deletion, or, if it does, hg and git exporters don't to my knowledge make use of it (since they don't think that such operations exist!).

Is there any way to get bzr fast-import to prune empty directories (e.g. when the last file in a directory is removed, automatically remove the directory in the same revision)? That would resolve the problems I am having trying to convert an hg repository to bzr.

Related branches

Changed in bzr-fastimport:
assignee: nobody → Ian Clatworthy (ian-clatworthy)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Fix committed in rev 195.

Changed in bzr-fastimport:
status: Confirmed → Fix Released
Revision history for this message
Tom Widmer (tom-widmer) wrote :

Thanks for that. I've just tested the fix, and discovered that it doesn't remove parents-of-parents(-of-parents, etc.). If you have:
adir
|_
   bdir
   |_
      cfile

and you delete cfile, both adir and bdir should be pruned. Current fix only removes bdir, not adir.

Changed in bzr-fastimport:
status: Fix Released → In Progress
Tom Widmer (tom-widmer)
Changed in bzr-fastimport:
status: In Progress → Incomplete
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

I believe rev 214 fixes the upwards recursion issue.

Changed in bzr-fastimport:
status: Incomplete → Fix Released
Revision history for this message
Tom Widmer (tom-widmer) wrote :

I have a working fix locally that I can push to launchpad. I have a feeling (untested) that your fix still has problems. Use of osutils.minimum_path_selection is wrong I think - that will mean you will miss deleting subfolders. e.g.

a\b\cfile
a\bfile

A single commit deletes cfile and bfile, so a and a\b are candidates for deleting. osutils.minimum_path_selection will choose only a to check, but a is not empty (it contains b), so no folders will be removed.

My fix is attached. If you're happy with it, you could roll your fix back (except for the test case!).

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Thanks - it's late here so I'll take a look in the morning. If you're keen, it would be cool to add a test for the case above as well!

Revision history for this message
Tom Widmer (tom-widmer) wrote :

If you're happy to wait until next week (obviously it's not holding me up now, and no one else has complained), I'll see what I can do about adding a few tests and a final polished fix (including rolling back your changes if necessary). But note I've never done any Python coding before. I'll push my branch to lp and request a merge when it's ready.

Changed in bzr-fastimport:
status: Fix Released → Incomplete
Revision history for this message
Tom Widmer (tom-widmer) wrote :

I've proposed a branch for merging to fix this issue. I added some new tests that failed before my change. The change fixes these tests and causes no regressions.

Changed in bzr-fastimport:
status: Incomplete → Fix Committed
Jelmer Vernooij (jelmer)
Changed in bzr-fastimport:
status: Fix Committed → Fix Released
milestone: none → 0.10.0
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.