A way to ignore files related to versioned files

Bug #383245 reported by Gioele Barabucci
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Wishlist
Unassigned

Bug Description

I would like to have a way to tell bzr to ignore files that are generated from versioned files.

For example, I have many .svg versioned files that I export to PDF or PNG. These files are generated from the source SVG file thus I want bzr to ignore them. So I need a rule in .bzrignore to tell bzr to ignore file foo.png if (and only if) foo.svg exists. Similarly I have .tex files under bzr control that I routinely edit and convert to PDF; the process creates half a dozen of auxiliary temporary files that I'd like to ignore.

The current (1.15) regexp-based implementation of .bzrignore cannot deal with this problem.

Revision history for this message
John A Meinel (jameinel) wrote :

I'm curious what sort of syntax you think would work for this. It would be introducing some sort of conditional evaluation (ignore X if Y).

Does any other system support this that we could use as a template? Certainly none of the ignore lists I've encountered from CVS/SVN/git/hg seem to support it. Then again, maybe I'm missing some rarely used bits.

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

I doubt other VCS systems have a similar feature.

Syntax-wide, I'd exploit the fact that filenames with spaces have to be enclosed in quotes. This allow additional stuff to be added at the end of the line.

For example this line in .bzrignore

  "RE:(.*)\.png" if "RE:(\1)\.svg"

could mean ignore all the filenames matching "RE:(.*)\.png" if there is a versioned file matching "RE:\1\.svg" where \1 is a back-reference to the first group in the previous regexp.

This allow even more complex patterns. The following

  "RE:(.*)/old-(.*).[0-9]+" if "RE:(\1)/(\2).txt"

could ignore ~/Documents/old-review.1 and ~/Documents/old-review.2 if ~/Documents/review.txt exists and is versioned.

The inverse (and maybe more logical) syntax could also be used, moving the back-references to the path to be ignored.

  "RE:(\1)\.png" if "RE:(.*)\.svg"

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 383245] Re: A way to ignore files related to versioned files

I have a few thoughts here.

Firstly, if this was done with care I'd have no objection to bzr having
it. Performance is potentially problematic - this could add another
check on every unversioned file in the system, raising the motivation to
get tracking of unversioned files/caching in place.

Secondly, if your build system knows it is producing a file, it could do
'bzr ignore $@' when it outputs the file. Its a bit of layering
confusion inherent in the interactions between vcs and build tool chain
that we should perhaps spend some time thinking about. The confusion is
that build tools know what they are creating, and vcs's statically
record that list, when told by users. The relationship perhaps should be
more dynamic. Its pretty annoying having to tell any vcs 'ignore x',
'ignore y' all the time.

-Rob

Revision history for this message
Gioele Barabucci (gioele) wrote :

A way to limit the growth of checks on unversioned files would be to use the the reverse syntax

  "RE:(\1)\.png" if "RE:(.*)\.svg"
  "RE:(\1)\.pdf" if "RE:(.*)\.svg"

With that, you can check which "right side" regexp matches the versioned files and build a list of additional regexp to add to the list of checks already loaded from .bzrignore. For example, the versioned files

  ~/Documents/foo/test.svg
  ~/Documents/foo/test2.pdf
  ~/Documents/bar/try.svg

would add the following regexps to list of regexp originally loaded from .bzrignore:

  ~/Documents/foo/test.png
  ~/Documents/foo/test.pdf
  ~/Documents/bar/try.png
  ~/Documents/bar/try.pdf

The end result, performance-wise, would not be different from letting the application or the build system call "bzr ignore" on the generated file, with the additional benefit that there no "dangling" regexp left in .bzrignore, a problem to take into account if you want applications and build systems to "bzr ignore" all the generated files.

Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
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.