capistrano-mercurial-ext 0.0.1

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,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$" />
14
+ <orderEntry type="inheritedJdk" />
15
+ <orderEntry type="sourceFolder" forTests="false" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.5, ruby-1.8.7-p358) [gem]" level="application" />
17
+ </component>
18
+ </module>
19
+
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-1.8.7-p358" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/capistrano-mercurial-ext.iml" filepath="$PROJECT_DIR$/.idea/capistrano-mercurial-ext.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-mercurial-ext.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Capistrano::Mercurial::Ext
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-mercurial-ext'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-mercurial-ext
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "capistrano-mercurial-ext"
3
+ spec.version = "0.0.1"
4
+ spec.authors = ["Anton Rubtsov"]
5
+ spec.email = ["anton.roubtsov@gmail.com"]
6
+ spec.description = %q{Replacement for the rails mercurial scm implementation which ships with Capistrano, allows you to configure pull and clone commands}
7
+ spec.summary = %q{Pull and clone commands extended implementation}
8
+ spec.homepage = "https://github.com/rubtsov/capistrano-mercurial-ext"
9
+ spec.license = "MIT"
10
+ spec.files = `git ls-files`.split($/)
11
+ spec.require_paths = ["lib"]
12
+ end
data/lib/mercurial.rb ADDED
@@ -0,0 +1,153 @@
1
+ # based on work by Copyright 2007 Matthew Elder <sseses@gmail.com>
2
+ # based on work by Tobias Luetke
3
+
4
+ require 'capistrano/recipes/deploy/scm/base'
5
+
6
+ module Capistrano
7
+ module Deploy
8
+ module SCM
9
+
10
+ # Implements the Capistrano SCM interface for the Mercurial revision
11
+ # control system (http://www.selenic.com/mercurial/).
12
+ # Latest updates at http://tackletechnology.org/oss/cap2-mercurial
13
+ class Mercurial < Base
14
+ # Sets the default command name for this SCM. Users may override this
15
+ # by setting the :scm_command variable.
16
+ default_command "hg"
17
+
18
+ # For mercurial HEAD == tip except that it bases this assumption on what
19
+ # tip is in the current repository (so push before you deploy)
20
+ def head
21
+ variable(:branch) || "tip"
22
+ end
23
+
24
+ # Clone the repository and update to the specified changeset.
25
+ def checkout(changeset, destination)
26
+ clone(destination) + " && " + update(changeset, destination)
27
+ end
28
+
29
+ # Pull from the repository and update to the specified changeset.
30
+ def sync(changeset, destination)
31
+ pull(destination) + " && " + update(changeset, destination)
32
+ end
33
+
34
+ # One day we will have hg archive, although i think its not needed
35
+ def export(revision, destination)
36
+ raise NotImplementedError, "`diff' is not implemented by #{self.class.name}" +
37
+ "use checkout strategy"
38
+ end
39
+
40
+ # Compute the difference between the two changesets +from+ and +to+
41
+ # as a unified diff.
42
+ def diff(from, to=nil)
43
+ scm :diff,
44
+ "--rev #{from}",
45
+ (to ? "--rev #{to}" : nil)
46
+ end
47
+
48
+ # Return a log of all changes between the two specified changesets,
49
+ # +from+ and +to+, inclusive or the log for +from+ if +to+ is omitted.
50
+ def log(from, to=nil)
51
+ scm :log,
52
+ verbose,
53
+ "--rev #{from}" +
54
+ (to ? ":#{to}" : "")
55
+ end
56
+
57
+ # Translates a tag to a changeset if needed or just returns changeset.
58
+ def query_revision(changeset)
59
+ cmd = scm :log,
60
+ verbose,
61
+ "-r #{changeset}",
62
+ '--template "{node|short}"'
63
+ yield cmd
64
+ end
65
+
66
+ # Determine response for SCM prompts
67
+ # user/pass can come from ssh and http distribution methods
68
+ # yes/no is for when ssh asks you about fingerprints
69
+ def handle_data(state, stream, text)
70
+ host = state[:channel][:host]
71
+ logger.info "[#{host} :: #{stream}] #{text}"
72
+ case text
73
+ when /^user:/mi
74
+ # support :scm_user for backwards compatibility of this module
75
+ if user = variable(:scm_username) || variable(:scm_user)
76
+ "#{user}\n"
77
+ else
78
+ raise "No variable :scm_username specified and Mercurial asked!\n" +
79
+ "Prompt was: #{text}"
80
+ end
81
+ when /\bpassword:/mi
82
+ unless pass = scm_password_or_prompt
83
+ # fall back on old behavior of erroring out with msg
84
+ raise "No variable :scm_password specified and Mercurial asked!\n" +
85
+ "Prompt was: #{text}"
86
+ end
87
+ "#{pass}\n"
88
+ when /yes\/no/i
89
+ "yes\n"
90
+ end
91
+ end
92
+
93
+ private
94
+
95
+ # Fine grained mercurial commands
96
+ def clone(destination)
97
+ scm :clone,
98
+ hg_clone_params,
99
+ verbose,
100
+ "--noupdate", # do not update to tip when cloning is done
101
+ repository, # clone which repository?
102
+ destination # and put the clone where?
103
+ end
104
+
105
+ def pull(destination)
106
+ scm :pull,
107
+ hg_pull_params,
108
+ verbose,
109
+ "--repository #{destination}", # pull changes into what?
110
+ repository # and pull the changes from?
111
+ end
112
+
113
+ def update(changeset, destination)
114
+ scm :update,
115
+ verbose,
116
+ "--repository #{destination}", # update what?
117
+ "--clean", # ignore untracked changes
118
+ changeset # update to this changeset
119
+ end
120
+
121
+ # verbosity configuration grokking :)
122
+ def verbose
123
+ case variable(:scm_verbose)
124
+ when nil then nil
125
+ when false then "--quiet"
126
+ else "--verbose"
127
+ end
128
+ end
129
+
130
+ def hg_pull_params
131
+ case variable(:scm_hg_pull_params)
132
+ when nil then nil
133
+ else variable(:scm_hg_pull_params)
134
+ end
135
+ end
136
+
137
+ def hg_clone_params
138
+ case variable(:scm_hg_clone_params)
139
+ when nil then nil
140
+ else variable(:scm_hg_clone_params)
141
+ end
142
+ end
143
+
144
+ # honor Cap 2.1+'s :scm_prefer_prompt if present
145
+ def scm_password_or_prompt
146
+ @scm_password_or_prompt ||= variable(:scm_password) ||
147
+ (Capistrano::CLI.password_prompt("hg password: ") if variable(:scm_prefer_prompt))
148
+ end
149
+
150
+ end
151
+ end
152
+ end
153
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-mercurial-ext
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Anton Rubtsov
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-04-19 00:00:00 +04:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Replacement for the rails mercurial scm implementation which ships with Capistrano, allows you to configure pull and clone commands
22
+ email:
23
+ - anton.roubtsov@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - .idea/capistrano-mercurial-ext.iml
33
+ - .idea/encodings.xml
34
+ - .idea/misc.xml
35
+ - .idea/modules.xml
36
+ - .idea/scopes/scope_settings.xml
37
+ - .idea/vcs.xml
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - capistrano-mercurial-ext.gemspec
43
+ - lib/mercurial.rb
44
+ has_rdoc: true
45
+ homepage: https://github.com/rubtsov/capistrano-mercurial-ext
46
+ licenses:
47
+ - MIT
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.6
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Pull and clone commands extended implementation
74
+ test_files: []
75
+