Files not managed by Darcs

Want to know what files are not included in a darcs repository? Well, me too :) From what I can tell, darcs itself doesn’t offer something like that and if it does, it was at least a good excuse for some Ruby’ing ;)

#!/usr/bin/env ruby
require 'find'
require 'pathname'
require 'fileutils'

# Define what should not be included in the listing
IGN_EXTENSIONS = %w{.aux .log .toc .blg .bbl .lof .out .o .pyc .class .bak}
IGN_LEAVES = %w{.svn _darcs .DS_Store}
def ignore?(file)
  return true if IGN_LEAVES.include?(File.basename(file))
  return true if IGN_EXTENSIONS.include?(File.extname(file))

# Get a list of all managed files
versioned_files = []
`darcs query manifest`.each_line{|f| versioned_files << f.strip}
exit(2) unless $?.success?

# Go to the folder with the _darcs folder in it
orig_folder = File.expand_path('.')
while !File.exists?('_darcs')
  cur_folder = File.expand_path('.')
  raise "You aren't in a darcs managed folder" if cur_folder=='/'

# Do the comparision
Find.find('.') do |f|
  next if f == '.'
  Find.prune if ignore?(f)
	puts f unless versioned_files.include?(f)

# Go back to where you've come from