pivotal-piston 1.9.4

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.
Files changed (96) hide show
  1. data/.gitignore +8 -0
  2. data/History.txt +11 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +85 -0
  5. data/README.txt +136 -0
  6. data/Rakefile +4 -0
  7. data/bin/piston +5 -0
  8. data/config/hoe.rb +79 -0
  9. data/config/requirements.rb +18 -0
  10. data/lib/piston.rb +18 -0
  11. data/lib/piston/cli.rb +315 -0
  12. data/lib/piston/commands.rb +4 -0
  13. data/lib/piston/commands/base.rb +44 -0
  14. data/lib/piston/commands/import.rb +42 -0
  15. data/lib/piston/commands/info.rb +14 -0
  16. data/lib/piston/commands/lock_unlock.rb +21 -0
  17. data/lib/piston/commands/update.rb +29 -0
  18. data/lib/piston/git.rb +12 -0
  19. data/lib/piston/git/client.rb +77 -0
  20. data/lib/piston/git/commit.rb +74 -0
  21. data/lib/piston/git/repository.rb +63 -0
  22. data/lib/piston/git/working_copy.rb +86 -0
  23. data/lib/piston/repository.rb +57 -0
  24. data/lib/piston/revision.rb +53 -0
  25. data/lib/piston/svn.rb +14 -0
  26. data/lib/piston/svn/client.rb +88 -0
  27. data/lib/piston/svn/repository.rb +67 -0
  28. data/lib/piston/svn/revision.rb +74 -0
  29. data/lib/piston/svn/working_copy.rb +108 -0
  30. data/lib/piston/version.rb +9 -0
  31. data/lib/piston/working_copy.rb +183 -0
  32. data/lib/subclass_responsibility_error.rb +2 -0
  33. data/log/.gitignore +0 -0
  34. data/samples/common.rb +19 -0
  35. data/samples/import_git_git.rb +39 -0
  36. data/samples/import_git_svn.rb +36 -0
  37. data/samples/import_svn_git.rb +29 -0
  38. data/samples/import_svn_svn.rb +24 -0
  39. data/script/destroy +14 -0
  40. data/script/generate +14 -0
  41. data/script/txt2html +74 -0
  42. data/setup.rb +1585 -0
  43. data/tasks/deployment.rake +34 -0
  44. data/tasks/environment.rake +7 -0
  45. data/tasks/samples.rake +6 -0
  46. data/tasks/test.rake +69 -0
  47. data/tasks/website.rake +17 -0
  48. data/test/integration/test_git_git.rb +99 -0
  49. data/test/integration/test_git_svn.rb +121 -0
  50. data/test/integration/test_import_svn_git.rb +47 -0
  51. data/test/integration/test_import_svn_svn.rb +38 -0
  52. data/test/integration_helpers.rb +33 -0
  53. data/test/test_helper.rb +83 -0
  54. data/test/unit/git/commit/test_checkout.rb +31 -0
  55. data/test/unit/git/commit/test_each.rb +30 -0
  56. data/test/unit/git/commit/test_rememberance.rb +21 -0
  57. data/test/unit/git/commit/test_validation.rb +34 -0
  58. data/test/unit/git/repository/test_at.rb +23 -0
  59. data/test/unit/git/repository/test_basename.rb +12 -0
  60. data/test/unit/git/repository/test_branchanme.rb +15 -0
  61. data/test/unit/git/repository/test_guessing.rb +32 -0
  62. data/test/unit/git/working_copy/test_copying.rb +25 -0
  63. data/test/unit/git/working_copy/test_creation.rb +22 -0
  64. data/test/unit/git/working_copy/test_existence.rb +18 -0
  65. data/test/unit/git/working_copy/test_finalization.rb +15 -0
  66. data/test/unit/git/working_copy/test_guessing.rb +35 -0
  67. data/test/unit/git/working_copy/test_rememberance.rb +21 -0
  68. data/test/unit/svn/repository/test_at.rb +19 -0
  69. data/test/unit/svn/repository/test_basename.rb +24 -0
  70. data/test/unit/svn/repository/test_guessing.rb +45 -0
  71. data/test/unit/svn/revision/test_checkout.rb +28 -0
  72. data/test/unit/svn/revision/test_each.rb +22 -0
  73. data/test/unit/svn/revision/test_rememberance.rb +38 -0
  74. data/test/unit/svn/revision/test_validation.rb +50 -0
  75. data/test/unit/svn/working_copy/test_copying.rb +26 -0
  76. data/test/unit/svn/working_copy/test_creation.rb +16 -0
  77. data/test/unit/svn/working_copy/test_existence.rb +23 -0
  78. data/test/unit/svn/working_copy/test_externals.rb +56 -0
  79. data/test/unit/svn/working_copy/test_finalization.rb +17 -0
  80. data/test/unit/svn/working_copy/test_guessing.rb +18 -0
  81. data/test/unit/svn/working_copy/test_merging.rb +47 -0
  82. data/test/unit/svn/working_copy/test_rememberance.rb +26 -0
  83. data/test/unit/test_info.rb +37 -0
  84. data/test/unit/test_lock_unlock.rb +47 -0
  85. data/test/unit/test_repository.rb +51 -0
  86. data/test/unit/test_revision.rb +31 -0
  87. data/test/unit/working_copy/test_guessing.rb +35 -0
  88. data/test/unit/working_copy/test_info.rb +14 -0
  89. data/test/unit/working_copy/test_rememberance.rb +42 -0
  90. data/test/unit/working_copy/test_validate.rb +63 -0
  91. data/website/index.html +11 -0
  92. data/website/index.txt +39 -0
  93. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  94. data/website/stylesheets/screen.css +138 -0
  95. data/website/template.rhtml +48 -0
  96. metadata +244 -0
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.swp
2
+ *.log
3
+ pkg
4
+ *.iml
5
+ *.ipr
6
+ *.iws
7
+ .config
8
+ InstalledFiles
data/History.txt ADDED
@@ -0,0 +1,11 @@
1
+
2
+ * Thanks to Brian Takita (btakita), piston update with a Git repository works!
3
+ * Thanks to mattknox and scambra for manifest updates.
4
+ * Thanks to Marcos Tapajós (tapajos) for many small improvements.
5
+
6
+ == 1.9.3 2008-06-03
7
+
8
+ * Import git branches using --revision origin/BRANCH_NAME, or a tag
9
+ using --revision TAG_NAME, or even a specific commit using
10
+ --revision COMMIT_ID. In fact, use a committish and you'll be fine,
11
+ even HEAD^3.
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,85 @@
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_git_git.rb
49
+ test/integration/test_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/working_copy/test_guessing.rb
79
+ test/unit/working_copy/test_rememberance.rb
80
+ tmp/.gitignore
81
+ website/index.html
82
+ website/index.txt
83
+ website/javascripts/rounded_corners_lite.inc.js
84
+ website/stylesheets/screen.css
85
+ 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
@@ -0,0 +1,4 @@
1
+ require "config/requirements"
2
+ require "config/hoe" # setup Hoe + all gem configuration
3
+
4
+ Dir["tasks/**/*.rake"].each { |rake| load rake }
data/bin/piston ADDED
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/ruby1.8
2
+ require "piston"
3
+
4
+ # Chain to the real command-line client
5
+ require "piston/cli"
data/config/hoe.rb ADDED
@@ -0,0 +1,79 @@
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(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
+
63
+ # Don't specify dependencies using the full version or else it won't be the effect that was intended.
64
+ # ~> 2.8.0 really means "depend on 2.8.0 to 2.8.0.9999", and not 2.8.0 to 2.8.9
65
+ p.extra_deps = [
66
+ ["main", "~> 2.8"],
67
+ ["open4", "~> 0.9"],
68
+ ["log4r", "~> 1.0"],
69
+ ["activesupport", "~> 2.1"]
70
+ ]
71
+
72
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
73
+
74
+ end
75
+
76
+ CHANGES = hoe.paragraphs_of("History.txt", 0..1).join("\\n\\n")
77
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
78
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,""), "rdoc")
79
+ 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.expand_path(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,315 @@
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
+ mixin :lock_options do
51
+ option("lock") do
52
+ default false
53
+ description "Automatically lock down the revision/commit to protect against blanket updates"
54
+ end
55
+ end
56
+
57
+ mode "import" do
58
+ mixin :standard_options
59
+ mixin :revision_or_commit
60
+ mixin :lock_options
61
+
62
+ argument "repository" do
63
+ required
64
+ description "The repository you wish to Pistonize"
65
+ end
66
+
67
+ argument "directory" do
68
+ optional
69
+ default nil
70
+ description "Where to put the Pistonized repository"
71
+ end
72
+
73
+ option("repository-type") do
74
+ argument :required
75
+ default nil
76
+ description "Force a specific repository type, for when it's not possible to guess"
77
+ end
78
+
79
+ logger_level Logger::DEBUG
80
+ def run
81
+ configure_logging!
82
+
83
+ if params["revision"].given? && params["commit"].given? then
84
+ raise ArgumentError, "Only one of --revision or --commit can be given. Received both."
85
+ end
86
+
87
+ cmd = Piston::Commands::Import.new(:verbose => params["verbose"].value,
88
+ :quiet => params["quiet"].value,
89
+ :force => params["force"].value,
90
+ :dry_run => params["dry-run"].value,
91
+ :repository_type => params["repository-type"].value)
92
+
93
+ begin
94
+ cmd.run(params[:repository].value, self.target_revision, params[:directory].value)
95
+ rescue Piston::Repository::UnhandledUrl => e
96
+ supported_types = Piston::Repository.handlers.collect do |handler|
97
+ handler.repository_type
98
+ end
99
+ puts "Unsure how to handle:"
100
+ puts "\t#{params[:repository].value.inspect}."
101
+ puts "You should try using --repository-type. Supported types are:"
102
+ supported_types.each do |type|
103
+ puts "\t#{type}"
104
+ end
105
+ exit_failure!
106
+ end
107
+
108
+ # Lock the working copy, if the user asked for it
109
+ cmd = Piston::Commands::LockUnlock.new(:verbose => params["verbose"].value,
110
+ :quiet => params["quiet"].value,
111
+ :force => params["force"].value,
112
+ :dry_run => params["dry-run"].value)
113
+ cmd.run(params["directory"].value, params["lock"].value) if params["lock"].value
114
+ end
115
+ end
116
+
117
+ mode "convert" do
118
+ mixin :standard_options
119
+
120
+ argument "directories" do
121
+ argument_required
122
+ optional
123
+ arity -1
124
+ description "Which directory/directories to convert from svn:externals to Piston. Not specifying this argument recursively converts the whole directory tree starting from the current dir."
125
+ end
126
+
127
+ logger_level Logger::DEBUG
128
+ def run
129
+ configure_logging!
130
+
131
+ cmd = Piston::Commands::Convert.new(:verbose => params["verbose"].value,
132
+ :quiet => params["quiet"].value,
133
+ :force => params["force"].value)
134
+ dirs = cmd.run(params["directories"].values.map {|dir| Pathname.new(dir)})
135
+ puts "#{dirs.length} directories converted"
136
+ end
137
+ end
138
+
139
+ mode "lock" do
140
+ mixin :standard_options
141
+
142
+ argument "directory" do
143
+ argument_required
144
+ optional
145
+ description "Which directory to lock"
146
+ end
147
+
148
+ logger_level Logger::DEBUG
149
+ def run
150
+ configure_logging!
151
+
152
+ cmd = Piston::Commands::LockUnlock.new(:wcdir => params["directory"].value,
153
+ :verbose => params["verbose"].value,
154
+ :quiet => params["quiet"].value,
155
+ :force => params["force"].value)
156
+ begin
157
+ cmd.run(true)
158
+ puts "#{params["directory"].value} locked"
159
+ rescue Piston::WorkingCopy::NotWorkingCopy
160
+ puts "The #{params["directory"].value} is not Pistonized"
161
+ end
162
+ end
163
+ end
164
+
165
+ mode "unlock" do
166
+ mixin :standard_options
167
+
168
+ argument "directory" do
169
+ argument_required
170
+ optional
171
+ description "Which directory to lock"
172
+ end
173
+
174
+ logger_level Logger::DEBUG
175
+ def run
176
+ configure_logging!
177
+
178
+ cmd = Piston::Commands::LockUnlock.new(:wcdir => params["directory"].value,
179
+ :verbose => params["verbose"].value,
180
+ :quiet => params["quiet"].value,
181
+ :force => params["force"].value)
182
+ begin
183
+ cmd.run(false)
184
+ puts "#{params["directory"].value} unlocked"
185
+ rescue Piston::WorkingCopy::NotWorkingCopy
186
+ puts "The #{params["directory"].value} is not Pistonized"
187
+ end
188
+ end
189
+ end
190
+
191
+
192
+ mode "info" do
193
+ mixin :standard_options
194
+
195
+ argument "directory" do
196
+ argument_required
197
+ optional
198
+ description "Which directory to get info"
199
+ end
200
+
201
+ logger_level Logger::DEBUG
202
+ def run
203
+ configure_logging!
204
+
205
+ cmd = Piston::Commands::Info.new(:wcdir => params["directory"].value,
206
+ :verbose => params["verbose"].value,
207
+ :quiet => params["quiet"].value,
208
+ :force => params["force"].value)
209
+ begin
210
+ puts cmd.run(params["directory"].value)
211
+ rescue Piston::WorkingCopy::NotWorkingCopy
212
+ puts "#{params["directory"].value} is not Pistonized"
213
+ end
214
+ end
215
+ end
216
+
217
+ mode "update" do
218
+ mixin :standard_options
219
+ mixin :revision_or_commit
220
+ mixin :lock_options
221
+
222
+ argument("directory") do
223
+ optional
224
+ default '.'
225
+ end
226
+
227
+ logger_level Logger::DEBUG
228
+ def run
229
+ configure_logging!
230
+
231
+ if params["revision"].given? && params["commit"].given? then
232
+ raise ArgumentError, "Only one of --revision or --commit can be given. Received both."
233
+ end
234
+
235
+ cmd = Piston::Commands::Update.new(:lock => params["lock"].value,
236
+ :verbose => params["verbose"].value,
237
+ :quiet => params["quiet"].value,
238
+ :force => params["force"].value,
239
+ :dry_run => params["dry-run"].value)
240
+
241
+ begin
242
+ cmd.run(File.expand_path(params["directory"].value), target_revision)
243
+ rescue
244
+ $stderr.puts $!.message
245
+ $stderr.puts $!.backtrace.join("\n")
246
+ exit_failure!
247
+ end
248
+ end
249
+ end
250
+
251
+ option("version", "v")
252
+
253
+ def run
254
+ if params["version"].given? || ARGV.first == "version" then
255
+ puts Piston.version_message
256
+ exit_success!
257
+ elsif ARGV.empty?
258
+ puts Piston.version_message
259
+ puts "\nNo mode given. Call with help to find out the available options."
260
+ exit_failure!
261
+ else
262
+ puts "Unrecognized mode: #{ARGV.first.inspect}. Use the help mode to find the available options."
263
+ exit_warn!
264
+ end
265
+ end
266
+
267
+ def configure_logging!
268
+ Log4r::Logger.root.level = Log4r::DEBUG
269
+
270
+ case params["verbose"].value
271
+ when 0
272
+ main_level = Log4r::INFO
273
+ handler_level = Log4r::WARN
274
+ client_level = Log4r::WARN
275
+ client_out_level = Log4r::WARN
276
+ stdout_level = Log4r::INFO
277
+ when 1
278
+ main_level = Log4r::DEBUG
279
+ handler_level = Log4r::INFO
280
+ client_level = Log4r::WARN
281
+ client_out_level = Log4r::WARN
282
+ stdout_level = Log4r::DEBUG
283
+ when 2
284
+ main_level = Log4r::DEBUG
285
+ handler_level = Log4r::DEBUG
286
+ client_level = Log4r::INFO
287
+ client_out_level = Log4r::WARN
288
+ stdout_level = Log4r::DEBUG
289
+ when 3
290
+ main_level = Log4r::DEBUG
291
+ handler_level = Log4r::DEBUG
292
+ client_level = Log4r::DEBUG
293
+ client_out_level = Log4r::INFO
294
+ stdout_level = Log4r::DEBUG
295
+ when 4, 5
296
+ main_level = Log4r::DEBUG
297
+ handler_level = Log4r::DEBUG
298
+ client_level = Log4r::DEBUG
299
+ client_out_level = Log4r::DEBUG
300
+ stdout_level = Log4r::DEBUG
301
+ else
302
+ raise ArgumentError, "Did not expect verbosity to be outside 0..5: #{params["verbose"].value}"
303
+ end
304
+
305
+ Log4r::Logger.new("main", main_level)
306
+ Log4r::Logger.new("handler", handler_level)
307
+ Log4r::Logger.new("handler::client", client_level)
308
+ Log4r::Logger.new("handler::client::out", client_out_level)
309
+
310
+ Log4r::StdoutOutputter.new("stdout", :level => stdout_level)
311
+
312
+ Log4r::Logger["main"].add "stdout"
313
+ Log4r::Logger["handler"].add "stdout"
314
+ end
315
+ }