jeremylightsmith-piston 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/History.txt +6 -0
- data/License.txt +20 -0
- data/Manifest.txt +86 -0
- data/README.txt +136 -0
- data/Rakefile +4 -0
- data/bin/piston +5 -0
- data/config/hoe.rb +76 -0
- data/config/requirements.rb +18 -0
- data/lib/piston.rb +18 -0
- data/lib/piston/cli.rb +279 -0
- data/lib/piston/commands.rb +4 -0
- data/lib/piston/commands/base.rb +44 -0
- data/lib/piston/commands/import.rb +69 -0
- data/lib/piston/commands/info.rb +14 -0
- data/lib/piston/commands/lock_unlock.rb +21 -0
- data/lib/piston/commands/update.rb +28 -0
- data/lib/piston/git.rb +12 -0
- data/lib/piston/git/client.rb +77 -0
- data/lib/piston/git/commit.rb +70 -0
- data/lib/piston/git/repository.rb +63 -0
- data/lib/piston/git/working_copy.rb +63 -0
- data/lib/piston/repository.rb +57 -0
- data/lib/piston/revision.rb +48 -0
- data/lib/piston/svn.rb +14 -0
- data/lib/piston/svn/client.rb +88 -0
- data/lib/piston/svn/repository.rb +67 -0
- data/lib/piston/svn/revision.rb +74 -0
- data/lib/piston/svn/working_copy.rb +55 -0
- data/lib/piston/version.rb +9 -0
- data/lib/piston/working_copy.rb +129 -0
- data/lib/subclass_responsibility_error.rb +2 -0
- data/log/.gitignore +0 -0
- data/samples/common.rb +19 -0
- data/samples/import_git_git.rb +39 -0
- data/samples/import_git_svn.rb +36 -0
- data/samples/import_svn_git.rb +29 -0
- data/samples/import_svn_svn.rb +24 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +40 -0
- data/tasks/environment.rake +7 -0
- data/tasks/samples.rake +6 -0
- data/tasks/test.rake +30 -0
- data/tasks/website.rake +17 -0
- data/test/integration/test_import_git_git.rb +96 -0
- data/test/integration/test_import_git_svn.rb +131 -0
- data/test/integration/test_import_svn_git.rb +52 -0
- data/test/integration/test_import_svn_svn.rb +43 -0
- data/test/integration_helpers.rb +33 -0
- data/test/test_helper.rb +56 -0
- data/test/unit/git/commit/test_checkout.rb +30 -0
- data/test/unit/git/commit/test_each.rb +36 -0
- data/test/unit/git/commit/test_rememberance.rb +20 -0
- data/test/unit/git/commit/test_validation.rb +33 -0
- data/test/unit/git/repository/test_at.rb +22 -0
- data/test/unit/git/repository/test_basename.rb +12 -0
- data/test/unit/git/repository/test_branchanme.rb +15 -0
- data/test/unit/git/repository/test_guessing.rb +32 -0
- data/test/unit/git/working_copy/test_copying.rb +28 -0
- data/test/unit/git/working_copy/test_creation.rb +26 -0
- data/test/unit/git/working_copy/test_existence.rb +21 -0
- data/test/unit/git/working_copy/test_finalization.rb +18 -0
- data/test/unit/git/working_copy/test_guessing.rb +34 -0
- data/test/unit/git/working_copy/test_rememberance.rb +25 -0
- data/test/unit/svn/repository/test_at.rb +18 -0
- data/test/unit/svn/repository/test_basename.rb +24 -0
- data/test/unit/svn/repository/test_guessing.rb +45 -0
- data/test/unit/svn/revision/test_checkout.rb +27 -0
- data/test/unit/svn/revision/test_each.rb +21 -0
- data/test/unit/svn/revision/test_rememberance.rb +42 -0
- data/test/unit/svn/revision/test_validation.rb +49 -0
- data/test/unit/svn/working_copy/test_copying.rb +29 -0
- data/test/unit/svn/working_copy/test_creation.rb +19 -0
- data/test/unit/svn/working_copy/test_existence.rb +26 -0
- data/test/unit/svn/working_copy/test_finalization.rb +21 -0
- data/test/unit/svn/working_copy/test_guessing.rb +17 -0
- data/test/unit/svn/working_copy/test_rememberance.rb +26 -0
- data/test/unit/test_import.rb +13 -0
- data/test/unit/test_info.rb +36 -0
- data/test/unit/test_lock_unlock.rb +46 -0
- data/test/unit/test_repository.rb +50 -0
- data/test/unit/test_revision.rb +30 -0
- data/test/unit/working_copy/test_guessing.rb +34 -0
- data/test/unit/working_copy/test_info.rb +13 -0
- data/test/unit/working_copy/test_rememberance.rb +48 -0
- data/test/unit/working_copy/test_validate.rb +68 -0
- data/website/index.html +11 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +228 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2006-2008 François Beausoleil <francois@teksol.info>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
.gitignore
|
2
|
+
History.txt
|
3
|
+
License.txt
|
4
|
+
Manifest.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
bin/piston
|
8
|
+
config/hoe.rb
|
9
|
+
config/requirements.rb
|
10
|
+
lib/piston.rb
|
11
|
+
lib/piston/cli.rb
|
12
|
+
lib/piston/commands.rb
|
13
|
+
lib/piston/commands/base.rb
|
14
|
+
lib/piston/commands/import.rb
|
15
|
+
lib/piston/commands/lock_unlock.rb
|
16
|
+
lib/piston/commands/update.rb
|
17
|
+
lib/piston/commands/info.rb
|
18
|
+
lib/piston/git.rb
|
19
|
+
lib/piston/git/client.rb
|
20
|
+
lib/piston/git/commit.rb
|
21
|
+
lib/piston/git/repository.rb
|
22
|
+
lib/piston/git/working_copy.rb
|
23
|
+
lib/piston/repository.rb
|
24
|
+
lib/piston/revision.rb
|
25
|
+
lib/piston/svn.rb
|
26
|
+
lib/piston/svn/client.rb
|
27
|
+
lib/piston/svn/repository.rb
|
28
|
+
lib/piston/svn/revision.rb
|
29
|
+
lib/piston/svn/working_copy.rb
|
30
|
+
lib/piston/version.rb
|
31
|
+
lib/piston/working_copy.rb
|
32
|
+
lib/subclass_responsibility_error.rb
|
33
|
+
log/.gitignore
|
34
|
+
samples/common.rb
|
35
|
+
samples/import_git_git.rb
|
36
|
+
samples/import_git_svn.rb
|
37
|
+
samples/import_svn_git.rb
|
38
|
+
samples/import_svn_svn.rb
|
39
|
+
script/destroy
|
40
|
+
script/generate
|
41
|
+
script/txt2html
|
42
|
+
setup.rb
|
43
|
+
tasks/deployment.rake
|
44
|
+
tasks/environment.rake
|
45
|
+
tasks/samples.rake
|
46
|
+
tasks/test.rake
|
47
|
+
tasks/website.rake
|
48
|
+
test/integration/test_import_git_git.rb
|
49
|
+
test/integration/test_import_git_svn.rb
|
50
|
+
test/integration/test_import_svn_git.rb
|
51
|
+
test/integration/test_import_svn_svn.rb
|
52
|
+
test/integration_helpers.rb
|
53
|
+
test/test_helper.rb
|
54
|
+
test/unit/git/commit/test_checkout.rb
|
55
|
+
test/unit/git/commit/test_each.rb
|
56
|
+
test/unit/git/commit/test_rememberance.rb
|
57
|
+
test/unit/git/repository/test_at.rb
|
58
|
+
test/unit/git/repository/test_basename.rb
|
59
|
+
test/unit/git/repository/test_guessing.rb
|
60
|
+
test/unit/git/working_copy/test_copying.rb
|
61
|
+
test/unit/git/working_copy/test_creation.rb
|
62
|
+
test/unit/git/working_copy/test_existence.rb
|
63
|
+
test/unit/git/working_copy/test_finalization.rb
|
64
|
+
test/unit/git/working_copy/test_guessing.rb
|
65
|
+
test/unit/git/working_copy/test_rememberance.rb
|
66
|
+
test/unit/svn/repository/test_at.rb
|
67
|
+
test/unit/svn/repository/test_basename.rb
|
68
|
+
test/unit/svn/repository/test_guessing.rb
|
69
|
+
test/unit/svn/revision/test_checkout.rb
|
70
|
+
test/unit/svn/revision/test_each.rb
|
71
|
+
test/unit/svn/revision/test_rememberance.rb
|
72
|
+
test/unit/svn/working_copy/test_copying.rb
|
73
|
+
test/unit/svn/working_copy/test_creation.rb
|
74
|
+
test/unit/svn/working_copy/test_existence.rb
|
75
|
+
test/unit/svn/working_copy/test_finalization.rb
|
76
|
+
test/unit/svn/working_copy/test_guessing.rb
|
77
|
+
test/unit/svn/working_copy/test_rememberance.rb
|
78
|
+
test/unit/test_import.rb
|
79
|
+
test/unit/working_copy/test_guessing.rb
|
80
|
+
test/unit/working_copy/test_rememberance.rb
|
81
|
+
tmp/.gitignore
|
82
|
+
website/index.html
|
83
|
+
website/index.txt
|
84
|
+
website/javascripts/rounded_corners_lite.inc.js
|
85
|
+
website/stylesheets/screen.css
|
86
|
+
website/template.rhtml
|
data/README.txt
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
Piston is a utility that eases vendor branch management.
|
2
|
+
This is similar to <tt>svn:externals</tt>, except you have a local copy of
|
3
|
+
the files, which you can modify at will. As long as the changes are
|
4
|
+
mergeable, you should have no problems.
|
5
|
+
|
6
|
+
This tool has a similar purpose than svnmerge.py which you can find in the
|
7
|
+
contrib/client-side folder of the main Subversion repository at
|
8
|
+
http://svn.collab.net/repos/svn/trunk/contrib/client-side/svnmerge.py.
|
9
|
+
The main difference is that Piston is designed to work with remote
|
10
|
+
repositories. Another tool you might want to look at, SVK, which you can find
|
11
|
+
at http://svk.elixus.org/.
|
12
|
+
|
13
|
+
From Wikipedia's Piston page (http://en.wikipedia.org/wiki/Piston):
|
14
|
+
In general, a piston is a sliding plug that fits closely inside the bore
|
15
|
+
of a cylinder.
|
16
|
+
|
17
|
+
Its purpose is either to change the volume enclosed by the cylinder, or
|
18
|
+
to exert a force on a fluid inside the cylinder.
|
19
|
+
|
20
|
+
For this utility, I retain the second meaning, "to exert a force on a fluid
|
21
|
+
inside the cylinder." Piston forces the content of a remote repository
|
22
|
+
location back into our own.
|
23
|
+
|
24
|
+
|
25
|
+
= Notes on 2.0
|
26
|
+
|
27
|
+
In the 1.0 era, Piston was exclusively geared towards Subversion repositories.
|
28
|
+
In early 2008, Git gained a lot of popularity among Ruby and Rails coders.
|
29
|
+
Piston was rewritten during that period to allow many repositories and working
|
30
|
+
copies to be used together.
|
31
|
+
|
32
|
+
The documentation still refers to Subversion throughout, but 2.0 allows any
|
33
|
+
repository to be used with any working copy.
|
34
|
+
|
35
|
+
|
36
|
+
= Installation
|
37
|
+
|
38
|
+
Nothing could be simpler:
|
39
|
+
|
40
|
+
$ gem install piston
|
41
|
+
|
42
|
+
|
43
|
+
= Usage
|
44
|
+
|
45
|
+
First, you need to import the remote repository location:
|
46
|
+
|
47
|
+
$ piston import http://dev.rubyonrails.org/svn/rails/trunk vendor/rails
|
48
|
+
Exported r4720 from 'http://dev.rubyonrails.org/svn/rails/trunk' to 'vendor/rails'
|
49
|
+
|
50
|
+
$ svn commit -m "Importing local copy of Rails"
|
51
|
+
|
52
|
+
When you want to get the latest changes from the remote repository location:
|
53
|
+
|
54
|
+
$ piston update vendor/rails
|
55
|
+
Updated 'vendor/rails' to r4720.
|
56
|
+
|
57
|
+
$ svn commit -m "Updates vendor/rails to the latest revision"
|
58
|
+
|
59
|
+
You can prevent a local Piston-managed folder from updating by using the
|
60
|
+
+lock+ subcommand:
|
61
|
+
|
62
|
+
$ piston lock vendor/rails
|
63
|
+
'vendor/rails' locked at r4720.
|
64
|
+
|
65
|
+
When you want to update again, you unlock:
|
66
|
+
|
67
|
+
$ piston unlock vendor/rails
|
68
|
+
'vendor/rails' unlocked.
|
69
|
+
|
70
|
+
If the branch you are following moves, you should use the switch subcommand:
|
71
|
+
|
72
|
+
$ piston import http://dev.rubyonrails.org/svn/rails/branches/1-2-pre-release vendor/rails
|
73
|
+
$ svn commit vendor/rails
|
74
|
+
|
75
|
+
# Vendor branch is renamed, let's follow it
|
76
|
+
$ piston switch http://dev.rubyonrails.org/svn/rails/branches/1-2-stable vendor/rails
|
77
|
+
|
78
|
+
|
79
|
+
= Contributions
|
80
|
+
|
81
|
+
== Bash Shell Completion Script
|
82
|
+
|
83
|
+
Michael Schuerig contributed a Bash shell completion script. You should copy
|
84
|
+
+contrib/piston+ from your gem repository to the appropriate folder. Michael
|
85
|
+
said:
|
86
|
+
|
87
|
+
I've put together a bash completion function for piston. On Debian, I
|
88
|
+
just put it in /etc/bash_completion.d, alternatively, the contents can
|
89
|
+
be copied to ~/.bash_completion. I don't know how things are organized
|
90
|
+
on other Unix/Linux systems.
|
91
|
+
|
92
|
+
|
93
|
+
= Caveats
|
94
|
+
|
95
|
+
== Speed
|
96
|
+
|
97
|
+
This tool is SLOW. The update process particularly so. I use a brute force
|
98
|
+
approach. Subversion cannot merge from remote repositories, so instead I
|
99
|
+
checkout the folder at the initial revision, and then run svn update and
|
100
|
+
parse the results of that to determine what changes have occured.
|
101
|
+
|
102
|
+
If a local copy of a file was changed, it's changes will be merged back in.
|
103
|
+
If that introduces a conflict, Piston will not detect it. The commit will be
|
104
|
+
rejected by Subversion anyway.
|
105
|
+
|
106
|
+
== Copies / Renames
|
107
|
+
|
108
|
+
Piston *does not* track copies. Since Subversion does renames in two
|
109
|
+
phases (copy + delete), that is what Piston does.
|
110
|
+
|
111
|
+
== Local Operations Only
|
112
|
+
|
113
|
+
Piston only works if you have a working copy. It also never commits your
|
114
|
+
working copy directly. You are responsible for reviewing the changes and
|
115
|
+
applying any pending fixes.
|
116
|
+
|
117
|
+
== Remote Repository UUID
|
118
|
+
|
119
|
+
Piston caches the remote repository UUID, allowing it to know if the remote
|
120
|
+
repos is still the same. Piston refuses to work against a different
|
121
|
+
repository than the one we checked out from originally.
|
122
|
+
|
123
|
+
|
124
|
+
= Subversion Properties Used
|
125
|
+
|
126
|
+
* <tt>piston:uuid</tt>: The remote repository's UUID, which we always confirm
|
127
|
+
before doing any operations.
|
128
|
+
* <tt>piston:root</tt>: The repository root URL from which this Piston folder
|
129
|
+
was exported from.
|
130
|
+
* <tt>piston:remote-revision</tt>: The <tt>Last Changed Rev</tt> of the remote
|
131
|
+
repository.
|
132
|
+
* <tt>piston:local-revision</tt>: The <tt>Last Changed Rev</tt> of the Piston
|
133
|
+
managed folder, to enable us to know if we need to do any merging.
|
134
|
+
* <tt>piston:locked</tt>: The revision at which this folder is locked. If
|
135
|
+
this property is set and non-blank, Piston will skip the folder with
|
136
|
+
an appropriate message.
|
data/Rakefile
ADDED
data/bin/piston
ADDED
data/config/hoe.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "piston/version"
|
2
|
+
|
3
|
+
AUTHOR = "Francois Beausoleil"
|
4
|
+
EMAIL = "francois@teksol.info"
|
5
|
+
DESCRIPTION = "description of gem"
|
6
|
+
GEM_NAME = "piston"
|
7
|
+
|
8
|
+
RUBYFORGE_PROJECT = "piston"
|
9
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
10
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
11
|
+
|
12
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
13
|
+
@config = nil
|
14
|
+
RUBYFORGE_USERNAME = "unknown"
|
15
|
+
def rubyforge_username
|
16
|
+
unless @config
|
17
|
+
begin
|
18
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
19
|
+
rescue
|
20
|
+
puts <<-EOS
|
21
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
22
|
+
Run "rubyforge setup" to prepare your env for access to Rubyforge
|
23
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
24
|
+
EOS
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
REV = nil
|
33
|
+
# UNCOMMENT IF REQUIRED:
|
34
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
35
|
+
VERS = Piston::VERSION::STRING + (REV ? ".#{REV}" : "")
|
36
|
+
RDOC_OPTS = ["--quiet", "--title", "Piston Documentation",
|
37
|
+
"--opname", "index.html",
|
38
|
+
"--line-numbers",
|
39
|
+
"--main", "README",
|
40
|
+
"--inline-source"]
|
41
|
+
|
42
|
+
class Hoe
|
43
|
+
def extra_deps
|
44
|
+
@extra_deps.reject! { |x| Array(x).first == "hoe" }
|
45
|
+
@extra_deps
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Generate all the Rake tasks
|
50
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
51
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
52
|
+
p.developer(AUTHOR, EMAIL)
|
53
|
+
p.description = DESCRIPTION
|
54
|
+
p.summary = DESCRIPTION
|
55
|
+
p.url = HOMEPATH
|
56
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
57
|
+
p.test_globs = ["test/**/test_*.rb"]
|
58
|
+
p.clean_globs |= ["**/.*.sw?", "*.gem", ".config", "**/.DS_Store"] #An array of file patterns to delete on clean.
|
59
|
+
|
60
|
+
# == Optional
|
61
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
62
|
+
p.extra_deps = [
|
63
|
+
["main", "~> 2.8.0"],
|
64
|
+
["open4", "~> 0.9.6"],
|
65
|
+
["log4r", "~> 1.0.5"],
|
66
|
+
["activesupport", "~> 2.0.2"]
|
67
|
+
]
|
68
|
+
|
69
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
CHANGES = hoe.paragraphs_of("History.txt", 0..1).join("\\n\\n")
|
74
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
75
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,""), "rdoc")
|
76
|
+
hoe.rsync_args = "-av --delete --ignore-errors"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
%w[rake hoe newgem rubigen mocha activesupport].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
16
|
+
|
17
|
+
require "piston"
|
18
|
+
require "piston/commands"
|
data/lib/piston.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "subclass_responsibility_error"
|
2
|
+
|
3
|
+
require "piston/repository"
|
4
|
+
require "piston/revision"
|
5
|
+
require "piston/working_copy"
|
6
|
+
|
7
|
+
require "piston/git"
|
8
|
+
require "piston/svn"
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
|
12
|
+
module Piston
|
13
|
+
class << self
|
14
|
+
def version_message
|
15
|
+
"Piston %s\nCopyright 2006-2008, François Beausoleil <francois@teksol.info>\nhttp://piston.rubyforge.org/\nDistributed under an MIT-like license." % Piston::VERSION::STRING
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/piston/cli.rb
ADDED
@@ -0,0 +1,279 @@
|
|
1
|
+
require "main"
|
2
|
+
require "log4r"
|
3
|
+
require "activesupport"
|
4
|
+
require "piston/version"
|
5
|
+
require "piston/commands"
|
6
|
+
|
7
|
+
Main {
|
8
|
+
program "piston"
|
9
|
+
author "François Beausoleil <francois@teksol.info>"
|
10
|
+
version Piston::VERSION::STRING
|
11
|
+
|
12
|
+
mixin :standard_options do
|
13
|
+
option("verbose", "v") {
|
14
|
+
argument_optional
|
15
|
+
cast :integer
|
16
|
+
default 0
|
17
|
+
validate {|value| (0..5).include?(value)}
|
18
|
+
description "Verbosity level (0 to 5, 0 being the default)"
|
19
|
+
}
|
20
|
+
option("quiet", "q") { default false }
|
21
|
+
option("force") { default false }
|
22
|
+
option("dry-run") { default false }
|
23
|
+
end
|
24
|
+
|
25
|
+
mixin :revision_or_commit do
|
26
|
+
option "revision", "r" do
|
27
|
+
argument_required
|
28
|
+
default "HEAD"
|
29
|
+
description "The revision you wish to operate on"
|
30
|
+
end
|
31
|
+
|
32
|
+
option "commit" do
|
33
|
+
argument_required
|
34
|
+
default "HEAD"
|
35
|
+
description "The commit you wish to operate on"
|
36
|
+
end
|
37
|
+
|
38
|
+
def target_revision
|
39
|
+
case
|
40
|
+
when params["revision"].given?
|
41
|
+
params["revision"].value
|
42
|
+
when params["commit"].given?
|
43
|
+
params["commit"].value
|
44
|
+
else
|
45
|
+
:head
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
mode "import" do
|
51
|
+
mixin :standard_options
|
52
|
+
mixin :revision_or_commit
|
53
|
+
|
54
|
+
argument "repository" do
|
55
|
+
required
|
56
|
+
description "The repository you wish to Pistonize"
|
57
|
+
end
|
58
|
+
|
59
|
+
argument "directory" do
|
60
|
+
optional
|
61
|
+
default nil
|
62
|
+
description "Where to put the Pistonized repository"
|
63
|
+
end
|
64
|
+
|
65
|
+
option("lock") do
|
66
|
+
default false
|
67
|
+
description "Automatically lock down the revision/commit to protect against blanket updates"
|
68
|
+
end
|
69
|
+
|
70
|
+
option("repository-type") do
|
71
|
+
argument :required
|
72
|
+
default nil
|
73
|
+
description "Force a specific repository type, for when it's not possible to guess"
|
74
|
+
end
|
75
|
+
|
76
|
+
logger_level Logger::DEBUG
|
77
|
+
def run
|
78
|
+
configure_logging!
|
79
|
+
|
80
|
+
if params["revision"].given? && params["commit"].given? then
|
81
|
+
raise ArgumentError, "Only one of --revision or --commit can be given. Received both."
|
82
|
+
end
|
83
|
+
|
84
|
+
cmd = Piston::Commands::Import.new(:verbose => params["verbose"].value,
|
85
|
+
:quiet => params["quiet"].value,
|
86
|
+
:force => params["force"].value,
|
87
|
+
:dry_run => params["dry-run"].value,
|
88
|
+
:repository_type => params["repository-type"].value)
|
89
|
+
|
90
|
+
begin
|
91
|
+
cmd.run(params[:repository].value, self.target_revision, params[:directory].value)
|
92
|
+
rescue Piston::Repository::UnhandledUrl => e
|
93
|
+
supported_types = Piston::Repository.handlers.collect do |handler|
|
94
|
+
handler.repository_type
|
95
|
+
end
|
96
|
+
puts "Unsure how to handle:"
|
97
|
+
puts "\t#{params[:repository].value.inspect}."
|
98
|
+
puts "You should try using --repository-type. Supported types are:"
|
99
|
+
supported_types.each do |type|
|
100
|
+
puts "\t#{type}"
|
101
|
+
end
|
102
|
+
exit_failure!
|
103
|
+
end
|
104
|
+
|
105
|
+
# Lock the working copy, if the user asked for it
|
106
|
+
cmd = Piston::Commands::LockUnlock.new(:verbose => params["verbose"].value,
|
107
|
+
:quiet => params["quiet"].value,
|
108
|
+
:force => params["force"].value,
|
109
|
+
:dry_run => params["dry-run"].value)
|
110
|
+
cmd.run(params["directory"].value, params["lock"].value) if params["lock"].value
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
mode "lock" do
|
115
|
+
mixin :standard_options
|
116
|
+
|
117
|
+
argument "directory" do
|
118
|
+
argument_required
|
119
|
+
optional
|
120
|
+
description "Which directory to lock"
|
121
|
+
end
|
122
|
+
|
123
|
+
logger_level Logger::DEBUG
|
124
|
+
def run
|
125
|
+
configure_logging!
|
126
|
+
|
127
|
+
cmd = Piston::Commands::LockUnlock.new(:wcdir => params["directory"].value,
|
128
|
+
:verbose => params["verbose"].value,
|
129
|
+
:quiet => params["quiet"].value,
|
130
|
+
:force => params["force"].value)
|
131
|
+
begin
|
132
|
+
cmd.run(true)
|
133
|
+
puts "#{params["directory"].value} locked"
|
134
|
+
rescue Piston::WorkingCopy::NotWorkingCopy
|
135
|
+
puts "The #{params["directory"].value} is not Pistonized"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
mode "unlock" do
|
141
|
+
mixin :standard_options
|
142
|
+
|
143
|
+
argument "directory" do
|
144
|
+
argument_required
|
145
|
+
optional
|
146
|
+
description "Which directory to lock"
|
147
|
+
end
|
148
|
+
|
149
|
+
logger_level Logger::DEBUG
|
150
|
+
def run
|
151
|
+
configure_logging!
|
152
|
+
|
153
|
+
cmd = Piston::Commands::LockUnlock.new(:wcdir => params["directory"].value,
|
154
|
+
:verbose => params["verbose"].value,
|
155
|
+
:quiet => params["quiet"].value,
|
156
|
+
:force => params["force"].value)
|
157
|
+
begin
|
158
|
+
cmd.run(false)
|
159
|
+
puts "#{params["directory"].value} unlocked"
|
160
|
+
rescue Piston::WorkingCopy::NotWorkingCopy
|
161
|
+
puts "The #{params["directory"].value} is not Pistonized"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
mode "info" do
|
168
|
+
mixin :standard_options
|
169
|
+
|
170
|
+
argument "directory" do
|
171
|
+
argument_required
|
172
|
+
optional
|
173
|
+
description "Which directory to get info"
|
174
|
+
end
|
175
|
+
|
176
|
+
logger_level Logger::DEBUG
|
177
|
+
def run
|
178
|
+
configure_logging!
|
179
|
+
|
180
|
+
cmd = Piston::Commands::Info.new(:wcdir => params["directory"].value,
|
181
|
+
:verbose => params["verbose"].value,
|
182
|
+
:quiet => params["quiet"].value,
|
183
|
+
:force => params["force"].value)
|
184
|
+
begin
|
185
|
+
puts cmd.run(params["directory"].value)
|
186
|
+
rescue Piston::WorkingCopy::NotWorkingCopy
|
187
|
+
puts "The #{params["directory"].value} is not Pistonized"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
mode "update" do
|
193
|
+
mixin :standard_options
|
194
|
+
mixin :revision_or_commit
|
195
|
+
|
196
|
+
argument("directory") { optional }
|
197
|
+
|
198
|
+
def run
|
199
|
+
configure_logging!
|
200
|
+
|
201
|
+
if params["revision"].given? && params["commit"].given? then
|
202
|
+
raise ArgumentError, "Only one of --revision or --commit can be given. Received both."
|
203
|
+
end
|
204
|
+
|
205
|
+
cmd = Piston::Commands::Update.new(:lock => params["lock"].value,
|
206
|
+
:verbose => params["verbose"].value,
|
207
|
+
:quiet => params["quiet"].value,
|
208
|
+
:force => params["force"].value,
|
209
|
+
:dry_run => params["dry-run"].value)
|
210
|
+
|
211
|
+
cmd.run(params["director"].value, target_revision)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
option("version", "v")
|
216
|
+
|
217
|
+
def run
|
218
|
+
if params["version"].given? || ARGV.first == "version" then
|
219
|
+
puts Piston.version_message
|
220
|
+
exit_success!
|
221
|
+
elsif ARGV.empty?
|
222
|
+
puts Piston.version_message
|
223
|
+
puts "\nNo mode given. Call with help to find out the available options."
|
224
|
+
exit_failure!
|
225
|
+
else
|
226
|
+
puts "Unrecognized mode: #{ARGV.first.inspect}. Use the help mode to find the available options."
|
227
|
+
exit_warn!
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def configure_logging!
|
232
|
+
Log4r::Logger.root.level = Log4r::INFO
|
233
|
+
|
234
|
+
case params["verbose"].value
|
235
|
+
when 0
|
236
|
+
main_level = Log4r::INFO
|
237
|
+
handler_level = Log4r::WARN
|
238
|
+
client_level = Log4r::WARN
|
239
|
+
client_out_level = Log4r::WARN
|
240
|
+
stdout_level = Log4r::INFO
|
241
|
+
when 1
|
242
|
+
main_level = Log4r::DEBUG
|
243
|
+
handler_level = Log4r::INFO
|
244
|
+
client_level = Log4r::WARN
|
245
|
+
client_out_level = Log4r::WARN
|
246
|
+
stdout_level = Log4r::DEBUG
|
247
|
+
when 2
|
248
|
+
main_level = Log4r::DEBUG
|
249
|
+
handler_level = Log4r::DEBUG
|
250
|
+
client_level = Log4r::INFO
|
251
|
+
client_out_level = Log4r::WARN
|
252
|
+
stdout_level = Log4r::DEBUG
|
253
|
+
when 3
|
254
|
+
main_level = Log4r::DEBUG
|
255
|
+
handler_level = Log4r::DEBUG
|
256
|
+
client_level = Log4r::DEBUG
|
257
|
+
client_out_level = Log4r::INFO
|
258
|
+
stdout_level = Log4r::DEBUG
|
259
|
+
when 4, 5
|
260
|
+
main_level = Log4r::DEBUG
|
261
|
+
handler_level = Log4r::DEBUG
|
262
|
+
client_level = Log4r::DEBUG
|
263
|
+
client_out_level = Log4r::DEBUG
|
264
|
+
stdout_level = Log4r::DEBUG
|
265
|
+
else
|
266
|
+
raise ArgumentError, "Did not expect verbosity to be outside 0..5: #{params["verbose"].value}"
|
267
|
+
end
|
268
|
+
|
269
|
+
Log4r::Logger.new("main", main_level)
|
270
|
+
Log4r::Logger.new("handler", handler_level)
|
271
|
+
Log4r::Logger.new("handler::client", client_level)
|
272
|
+
Log4r::Logger.new("handler::client::out", client_out_level)
|
273
|
+
|
274
|
+
Log4r::StdoutOutputter.new("stdout", :level => stdout_level)
|
275
|
+
|
276
|
+
Log4r::Logger["main"].add "stdout"
|
277
|
+
Log4r::Logger["handler"].add "stdout"
|
278
|
+
end
|
279
|
+
}
|