markryall-basketcase 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *~
2
+ pkg
3
+ doc
4
+ ct.log
5
+ spec/ct.output
data/History.txt ADDED
@@ -0,0 +1,8 @@
1
+ === 1.1.0 / 2008-09-17
2
+
3
+ * Add 'bc-mirror' script, to support periodically publishing an
4
+ externally-managed directory into ClearCase.
5
+
6
+ === 1.0.0 / 2008-09-16
7
+
8
+ * Converted into a gem, using sow.
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/basketcase
6
+ bin/bc-mirror
7
+ lib/basketcase.rb
data/README.txt ADDED
@@ -0,0 +1,109 @@
1
+ = basketcase
2
+
3
+ * http://basketcase.rubyforge.org/
4
+ * http://rubyforge.org/projects/basketcase/
5
+ * http://dogbiscuit.org/mdub/
6
+
7
+ == Description
8
+
9
+ BasketCase is a (Ruby) script that encapsulates the Rational ClearCase
10
+ command-line interface, <code>cleartool</code>, making it (slightly) more
11
+ comfortable for developers more used to non-locking version-control systems
12
+ such as CVS or Subversion.
13
+
14
+ == Features
15
+
16
+ BasketCase can help you:
17
+
18
+ * <strong>List</strong> modified elements.
19
+ * <strong>Update</strong> a snapshot view, including <strong>automatic merge</strong> of modified elements.
20
+ * <strong>Check-out</strong> (unreserved) and <strong>check-in</strong> elements.
21
+ * <strong>Undo a check-out</strong>, reverting to the base version.
22
+ * Perform a <strong>bulk check-in</strong> (or revert).
23
+ * <strong>Add</strong>, <strong>remove</strong> and <strong>rename</strong> elements.
24
+ * Display <strong>change-logs</strong> and <strong>version-trees</strong>.
25
+ * Display <strong>differences</strong> for modified elements.
26
+
27
+ == Synopsis
28
+
29
+ usage: basketcase <command> [<options>]
30
+
31
+ GLOBAL OPTIONS
32
+
33
+ -t/--test test/dry-run/simulate mode
34
+ (ie. don't actually do anything)
35
+
36
+ -d/--debug debug cleartool interaction
37
+
38
+ COMMANDS (type 'basketcase help <command>' for details)
39
+
40
+ % list, ls, status, stat
41
+ % lsco
42
+ % diff
43
+ % log, history
44
+ % tree, vtree
45
+ % update, up
46
+ % checkin, ci, commit
47
+ % checkout, co, edit
48
+ % uncheckout, unco, revert
49
+ % add
50
+ % remove, rm, delete, del
51
+ % move, mv, rename
52
+ % auto-checkin, auto-ci, auto-commit
53
+ % auto-uncheckout, auto-unco, auto-revert
54
+ % auto-sync, auto-addrm
55
+ % help
56
+
57
+ == Installation
58
+
59
+ Is as easy as:
60
+
61
+ sudo gem install basketcase
62
+
63
+ == Background
64
+
65
+ In mid-2006, Mike Williams worked on a client project which, despite the
66
+ team's wishes, was burdened with ClearCase as it's source-code control
67
+ system.
68
+
69
+ The team was attempting to use Agile practices such as collective code
70
+ ownership, refactoring and continuous-integration, and ClearCase was in the
71
+ way:
72
+
73
+ * ClearCase enables and in many ways favours "reserved" check-outs of
74
+ elements, preventing collective code ownership.
75
+ * When add, removing or moving elements, ClearCase will sometimes apply the
76
+ change to the repository immediately, without waiting for a "commit".
77
+ * When updating, ClearCase will not attempt to merge other developers'
78
+ changes to elements you have checked-out ... leaving your view in an
79
+ inconsistent state.
80
+ * Performing an automatic merge from the command-line requires an unwieldy,
81
+ obscure command.
82
+ * There is no easy way to do a bulk-commit from the command-line.
83
+
84
+ Mike wrote BasketCase in frustration.
85
+
86
+ == License
87
+
88
+ (The MIT License)
89
+
90
+ Copyright (c) 2008 Mike Williams
91
+
92
+ Permission is hereby granted, free of charge, to any person obtaining
93
+ a copy of this software and associated documentation files (the
94
+ 'Software'), to deal in the Software without restriction, including
95
+ without limitation the rights to use, copy, modify, merge, publish,
96
+ distribute, sublicense, and/or sell copies of the Software, and to
97
+ permit persons to whom the Software is furnished to do so, subject to
98
+ the following conditions:
99
+
100
+ The above copyright notice and this permission notice shall be
101
+ included in all copies or substantial portions of the Software.
102
+
103
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
104
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
105
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
106
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
107
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
108
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
109
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+
3
+ =begin
4
+ require 'hoe'
5
+ require './lib/basketcase.rb'
6
+ Hoe.new('basketcase', Basketcase::VERSION) do |p|
7
+ p.developer('mdub', 'mdub@dogbiscuit.org')
8
+ p.remote_rdoc_dir = ''
9
+ end
10
+ =end
11
+
12
+ begin
13
+ require 'jeweler'
14
+ Jeweler::Tasks.new do |gemspec|
15
+ gemspec.name = "basketcase"
16
+ gemspec.summary = "clearcase for the masses"
17
+ gemspec.description = "basketcase fork"
18
+ gemspec.email = "mdub@dogbiscuit.org"
19
+ gemspec.homepage = "http://github.com/markryall/basketcase"
20
+ gemspec.description = "TODO"
21
+ gemspec.authors = ["mdub", 'mark ryall', 'duana stanley']
22
+ end
23
+ rescue LoadError
24
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
25
+ end
26
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.7
data/bin/basketcase ADDED
@@ -0,0 +1,13 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # This is an attempt to wrap up the ClearCase command-line interface
4
+ # (cleartool) to enable more CVS-like (or Subversion-like) usage of
5
+ # ClearCase.
6
+ #
7
+ # @author Mike Williams
8
+
9
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
10
+
11
+ require 'basketcase'
12
+
13
+ Basketcase.new.do(*ARGV)
data/bin/bc-mirror ADDED
@@ -0,0 +1,127 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # Synchronise a directory with a Clearcase snapshot view.
4
+ #
5
+ # @author Mike Williams
6
+
7
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
8
+
9
+ require 'basketcase'
10
+ require 'pathname'
11
+ require 'ftools'
12
+
13
+ class DirSyncer
14
+
15
+ def initialize(src_root, dest_root)
16
+ @src_root = Pathname(src_root)
17
+ @dest_root = Pathname(dest_root)
18
+ end
19
+
20
+ def sync
21
+ visit(@src_root)
22
+ cleanup(@dest_root)
23
+ end
24
+
25
+ private
26
+
27
+ def ignored?(path)
28
+ path.to_str =~ %r{(^|/).git($|/)}
29
+ end
30
+
31
+ def visit(src_file)
32
+ return if ignored?(src_file)
33
+ if src_file.directory?
34
+ sync_dir(src_file)
35
+ else
36
+ sync_file(src_file)
37
+ end
38
+ end
39
+
40
+ def ensure_we_can_write_to(file)
41
+ file.chmod(file.stat.mode | 0600) unless file.writable?
42
+ end
43
+
44
+ def sync_dir(src_dir)
45
+ src_dir.children.sort.each do |f|
46
+ visit(f)
47
+ end
48
+ end
49
+
50
+ def sync_file(src_file)
51
+ file_path = src_file.relative_path_from(@src_root)
52
+ dest_file = @dest_root + file_path
53
+ dest_file.parent.mkpath
54
+ ensure_we_can_write_to(dest_file.parent)
55
+ if dest_file.exist?
56
+ if File.read(src_file) == File.read(dest_file)
57
+ return
58
+ end
59
+ ensure_we_can_write_to(dest_file)
60
+ end
61
+ puts file_path
62
+ FileUtils.copy(src_file, dest_file)
63
+ end
64
+
65
+ def cleanup(dest_file)
66
+ if dest_file.directory?
67
+ cleanup_dir(dest_file)
68
+ else
69
+ cleanup_file(dest_file)
70
+ end
71
+ end
72
+
73
+ def cleanup_dir(dest_dir)
74
+ dest_dir.children.sort.each do |f|
75
+ cleanup(f)
76
+ end
77
+ if dest_dir.children.empty?
78
+ puts "rmdir #{dest_dir.relative_path_from(@dest_root)}"
79
+ dest_dir.rmdir
80
+ end
81
+ end
82
+
83
+ def cleanup_file(dest_file)
84
+ file_path = dest_file.relative_path_from(@dest_root)
85
+ src_file = @src_root + file_path
86
+ if !src_file.exist? || ignored?(file_path)
87
+ ensure_we_can_write_to(dest_file.parent)
88
+ puts "rm #{file_path}"
89
+ dest_file.delete
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+ #---( Mainline )---
96
+
97
+ def exit_with(status, message)
98
+ $stderr.puts message; exit(status)
99
+ end
100
+
101
+ exit_with(3, "usage: #{File.basename($0)} <source> <clearcase_snapshot>") unless ARGV.size == 2
102
+
103
+ source_dir, cc_snapshot_dir = ARGV
104
+ source_dir = Pathname(source_dir).expand_path
105
+ cc_snapshot_dir = Pathname(cc_snapshot_dir).expand_path
106
+
107
+ def check_dir(dir)
108
+ exit_with(5, "ERROR: no such directory? #{dir}") unless dir.exist?
109
+ exit_with(5, "ERROR: #{dir} is not a directory") unless dir.directory?
110
+ end
111
+
112
+ check_dir(source_dir)
113
+ check_dir(cc_snapshot_dir)
114
+
115
+ puts "--- Syncing to CC view"
116
+ DirSyncer.new(source_dir, cc_snapshot_dir).sync
117
+
118
+ Dir.chdir(cc_snapshot_dir)
119
+ basketcase = Basketcase.new
120
+
121
+ puts "--- Adding/removing stuff"
122
+ basketcase.do('auto-sync', '-n')
123
+
124
+ puts "--- Commiting"
125
+ basketcase.do('auto-commit', '-m', "upload from #{source_dir}")
126
+
127
+ puts "--- Done"