switch doesn't delete ignored files

Bug #803594 reported by Gordon Tyler on 2011-06-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Medium
Unassigned

Bug Description

If I have ignored files in a subdirectory which does not exist in a parallel branch, switching to that parallel branch produces a conflict due to it being unable to delete the subdirectory because it is not empty. If I remove the ignored files, it switches correctly.

Steps to reproduce:

C:\tmp\bzrtest>bzr init-repo .
Shared repository with trees (format: 2a)
Location:
  shared repository: .

C:\tmp\bzrtest>bzr init trunk
Created a repository tree (format: 2a)
Using shared repository: C:/tmp/bzrtest/

C:\tmp\bzrtest>cd trunk

C:\tmp\bzrtest\trunk>mkdir module1

C:\tmp\bzrtest\trunk>echo "stuff" > module1\file1.txt

C:\tmp\bzrtest\trunk>bzr add
adding module1
adding module1/file1.txt

C:\tmp\bzrtest\trunk>bzr commit -m "Added module1"
Committing to: C:/tmp/bzrtest/trunk/
added module1
added module1/file1.txt
Committed revision 1.

C:\tmp\bzrtest\trunk>cd ..

C:\tmp\bzrtest>bzr branch trunk ver1
Branched 1 revision(s).

C:\tmp\bzrtest>cd trunk

C:\tmp\bzrtest\trunk>mkdir module2

C:\tmp\bzrtest\trunk>echo "stuff" > module2\file2.txt

C:\tmp\bzrtest\trunk>bzr add
adding module2
adding module2/file2.txt

C:\tmp\bzrtest\trunk>bzr commit -m "Added module2"
Committing to: C:/tmp/bzrtest/trunk/
added module2
added module2/file2.txt
Committed revision 2.

C:\tmp\bzrtest\trunk>cd ..

C:\tmp\bzrtest>bzr co --lightweight trunk work

C:\tmp\bzrtest>cd work

C:\tmp\bzrtest\work>mkdir module2\temp

C:\tmp\bzrtest\work>echo "stuff" > module2\temp\somefile

C:\tmp\bzrtest\work>bzr ignore module2/temp

C:\tmp\bzrtest\work>bzr commit -m "added ignore"
Committing to: C:/tmp/bzrtest/trunk/
added .bzrignore
Committed revision 3.

C:\tmp\bzrtest\work>bzr switch ver1
Conflict: can't delete module2 because it is not empty. Not deleting.
Updated to revision 1.
Switched to branch: C:/tmp/bzrtest/ver1/

C:\tmp\bzrtest\work>bzr switch trunk
Conflict adding file module2. Moved existing file to module2.moved.
Updated to revision 3.
Switched to branch: C:/tmp/bzrtest/trunk/

C:\tmp\bzrtest\work>bzr revert

C:\tmp\bzrtest\work>rm -rf module2.moved

C:\tmp\bzrtest\work>bzr switch ver1
Updated to revision 1.
Switched to branch: C:/tmp/bzrtest/ver1/

C:\tmp\bzrtest\work>bzr switch trunk
Updated to revision 3.
Switched to branch: C:/tmp/bzrtest/trunk/

Martin Packman (gz) wrote :

On the other hand, if switch did delete ignored files, it would be a whole lot less useful for big branches where you want to preserve build artefacts and such like.

There are two different things that could be useful:
 * delete all ignored files -- might be a useful option, default off
 * don't conflict on deleting directories with ignored files - might be a dupe

Gordon Tyler (doxxx) wrote :

I'd be happy with the no conflicts choice.

Vincent Ladeuil (vila) wrote :

Can be reproduced with:

  bzr test-script ./803594.bug

with 803594.bug containing:

$ bzr init-repo .
Shared repository with trees (format: 2a)
Location:
  shared repository: .
$ bzr init trunk
Created a repository tree (format: 2a)
Using shared repository: ...
$ cd trunk
$ mkdir module1
$ echo "stuff" > module1/file1.txt
$ bzr add
adding module1
adding module1/file1.txt
$ bzr commit -m "Added module1"
2>Committing to: ...trunk/
2>added module1
2>added module1/file1.txt
2>Committed revision 1.
$ cd ..
$ bzr branch trunk ver1
2>Branched 1 revision(s).
$ cd trunk
$ mkdir module2
$ echo "stuff" > module2/file2.txt
$ bzr add
adding module2
adding module2/file2.txt
$ bzr commit -m "Added module2"
2>Committing to: ...trunk/
2>added module2
2>added module2/file2.txt
2>Committed revision 2.
$ cd ..
$ bzr co --lightweight trunk work
$ cd work
$ mkdir module2/temp
$ echo "stuff" > module2/temp/somefile
$ bzr ignore module2/temp
$ bzr commit -m "added ignore"
2>Committing to: .../trunk/
2>added .bzrignore
2>Committed revision 3.
$ bzr switch ver1
2>Conflict: can't delete module2 because it is not empty. Not deleting.
2>Updated to revision 1.
2>Switched to branch: .../ver1/
$ bzr switch trunk
2>Conflict adding file module2. Moved existing file to module2.moved.
2>Updated to revision 3.
2>Switched to branch: .../trunk/
$ bzr revert
$ rm -rf module2.moved
$ bzr switch ver1
2>Updated to revision 1.
2>Switched to branch: .../ver1/
$ bzr switch trunk
2>Updated to revision 3.
2>Switched to branch: .../trunk/

which makes it easier to reproduce on any platform

Changed in bzr:
status: New → Confirmed
importance: Undecided → Medium
Vincent Ladeuil (vila) wrote :

This can be worked around with bzr.transform.orphan_policy=move:

--- /home/vila/src/bzr/bugs/803594-ignored/803594.bug 2011-07-04 10:06:16.618729522 +0200
+++ /home/vila/src/bzr/bugs/803594-ignored/803594.workaround 2011-07-04 10:17:37.408074397 +0200
@@ -1,3 +1,4 @@
+$ bzr config --scope=bazaar bzr.transform.orphan_policy=move
 $ bzr init-repo .
 Shared repository with trees (format: 2a)
 Location:
@@ -41,11 +42,10 @@
 2>added .bzrignore
 2>Committed revision 3.
 $ bzr switch ver1
-2>Conflict: can't delete module2 because it is not empty. Not deleting.
+2>module2/temp has been orphaned in bzr-orphans
 2>Updated to revision 1.
 2>Switched to branch: .../ver1/
 $ bzr switch trunk
-2>Conflict adding file module2. Moved existing file to module2.moved.
 2>Updated to revision 3.
 2>Switched to branch: .../trunk/
 $ bzr revert

Vincent Ladeuil (vila) wrote :

Ignored files should not be deleted (some ignored files are very precious like build artefacts that take a long time to produce).

Once we implement a way to distinguish between junk and precious files (which are two different kind of ignored files) we can delete the junk files automatically.

Changed in bzr:
status: Confirmed → Won't Fix
Martin Pool (mbp) wrote :

There's still a real user problem here, even if we don't want to delete ignored files by default.

Changed in bzr:
status: Won't Fix → Confirmed
Jelmer Vernooij (jelmer) on 2017-11-09
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers