Permissions and links tool (was Re: Hi - List Status?)

Ken Bloom kbloom at gmail.com
Sun Aug 13 06:38:56 CEST 2006


On Saturday 12 August 2006 23:35, Ken Bloom wrote:
> [permissions tool]

Looks like attachments (of certain kinds, at least) are stripped. Let's try again:

#!/usr/bin/env ruby

require 'pathname'
home=ENV['HOME']
Dir.chdir(home)
home=Pathname.new(home)

#File format for .svnlinks: each line has a link target, followed by all 
#of the locations to manage symlinks to this target

if Pathname.new(".svnlinks").exist?
   svnfixrc=open(".svnlinks").readlines
   svnfixrc.each do |line|
      begin
	 rest=line.split(/\s+/).collect {|x| Pathname.new(x)}
	 head=rest.delete_at(0)
	 if head.exist?
	    rest.each do |dest|
	       raise "#{dest} exists and isn't a link" if dest.exist? and not dest.symlink?
	       dest.delete if dest.exist?
	       dest.make_symlink(head)
	    end
	 else
	    rest.each do |dest|
	       raise "#{dest} exists and isn't a link" if dest.exist? and not dest.symlink?
	       raise "#{dest} points elsewhere" if dest.exist? and not (home+dest.readlink)==(home+head)
	       dest.delete if dest.exist?
	    end
	 end
      rescue StandardError => e
	 STDERR.puts e
      end
   end
end

#file format for .svnperm: a file location, followed by the permissions 
#for that file in octal. Changing users and groups is not supported

if Pathname.new(".svnperm").exist?
   svnfixrc=open(".svnperm").readlines
   svnfixrc.each do |line|
      file,perms=line.split(/\s+/)
      file=Pathname.new(file)
      begin
	 file.chmod(perms.to_i(8)) if file.exist?
      rescue StandardError => e
	 STDERR.puts "#{file}: #{e}"
      end
   end
end


-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.madduck.net/pipermail/vcs-home/attachments/20060812/0155e57a/attachment.pgp>


More information about the vcs-home mailing list