vlad-hg 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,14 @@
1
+ === 2.1.3 / 2010-11-22
2
+
3
+ * 2 bugfixes
4
+
5
+ * Honor the setting of +deploy_via+. Thanks to McClain Looney.
6
+
7
+ * Use 'default' as the actual default value of +revision+. This will break
8
+ your configuration if you were manually doing something silly like <tt>set
9
+ :revision, 'head'</tt> in your deploy.rb. But you wouldn't do that, would
10
+ you?
11
+
1
12
  === 2.1.2 / 2010-09-15
2
13
 
3
14
  * 1 bug fix
@@ -6,4 +6,3 @@ lib/vlad/mercurial.rb
6
6
  lib/vlad/mercurial_queue.rb
7
7
  test/test_vlad_mercurial.rb
8
8
  test/test_vlad_mercurial_queue.rb
9
- test/vlad_test_case.rb
@@ -3,10 +3,11 @@ require 'vlad'
3
3
  module Vlad
4
4
  class Mercurial
5
5
 
6
- VERSION = '2.1.2'.freeze
6
+ VERSION = '2.1.3'.freeze
7
7
 
8
- set :source, Vlad::Mercurial.new
9
- set :hg_cmd, "hg"
8
+ set :source, Vlad::Mercurial.new
9
+ set :hg_cmd, 'hg'
10
+ set :revision, 'default'
10
11
 
11
12
  ##
12
13
  # Returns the command that will check out +revision+ from the
@@ -14,8 +15,6 @@ module Vlad
14
15
  # changeset ID or equivalent (e.g. branch, tag, etc...)
15
16
 
16
17
  def checkout(revision, destination)
17
- revision = 'default' if revision =~ /^head$/i
18
-
19
18
  # These all get executed after a "cd #{scm_path}"
20
19
  [ "if [ ! -d .hg ]; then #{hg_cmd} init; fi",
21
20
  "#{hg_cmd} pull #{repository}",
@@ -29,9 +28,12 @@ module Vlad
29
28
  # Expects to be run from +scm_path+ after Vlad::Mercurial#checkout
30
29
 
31
30
  def export(revision, destination)
32
- revision = 'default' if revision =~ /^head$/i
33
-
34
- "#{hg_cmd} archive -r #{revision} #{destination}"
31
+ case deploy_via.to_sym
32
+ when :checkout, :clone
33
+ "#{hg_cmd} clone #{scm_path} -r #{revision} #{destination}"
34
+ else # :archive, :export (or whatever)
35
+ "#{hg_cmd} archive -r #{revision} #{destination}"
36
+ end
35
37
  end
36
38
 
37
39
  ##
@@ -4,11 +4,12 @@ module Vlad
4
4
  class MercurialQueue
5
5
 
6
6
  set :source, Vlad::MercurialQueue.new
7
- set :hg_cmd, "hg"
7
+ set :hg_cmd, 'hg'
8
+ set :revision, 'default'
8
9
  set :queue_repo do
9
10
  "#{repository}/.hg/patches"
10
11
  end
11
- set :queue_revision, "tip"
12
+ set :queue_revision, 'default'
12
13
 
13
14
  ##
14
15
  # Returns the command that will check out +revision+ from the
@@ -16,8 +17,6 @@ module Vlad
16
17
  # changeset ID or equivalent (e.g. branch, tag, etc...)
17
18
 
18
19
  def checkout(revision, destination)
19
- revision = 'default' if revision =~ /^head$/i
20
-
21
20
  commands = []
22
21
  commands << "if [ ! -d .hg ]; then #{hg_cmd} init; fi"
23
22
  commands << "if [ ! -d .hg/patches/.hg ]; then #{hg_cmd} qinit -c; fi"
@@ -36,8 +35,6 @@ module Vlad
36
35
  # Expects to be run from +scm_path+ after Vlad::Mercurial#checkout
37
36
 
38
37
  def export(revision, destination)
39
- revision = 'default' if revision =~ /^head$/i
40
-
41
38
  "#{hg_cmd} archive -r qtip #{destination}"
42
39
  end
43
40
 
@@ -1,16 +1,17 @@
1
- require 'test/vlad_test_case'
1
+ require 'rake/test_case' # from rake_remote_task
2
2
  require 'vlad'
3
3
  require 'vlad/mercurial'
4
4
 
5
- class TestVladMercurial < MiniTest::Unit::TestCase
5
+ class TestVladMercurial < Rake::TestCase
6
6
  def setup
7
+ Rake::RemoteTask.set_defaults
7
8
  @scm = Vlad::Mercurial.new
8
9
  set :repository, "http://repo/project"
9
10
  set :deploy_to, "/path/to"
10
11
  end
11
12
 
12
13
  def test_checkout
13
- cmd = @scm.checkout 'head', '/path/to/scm'
14
+ cmd = @scm.checkout 'default', '/path/to/scm'
14
15
 
15
16
  expected = "if [ ! -d .hg ]; then hg init; fi " \
16
17
  "&& hg pull http://repo/project " \
@@ -20,7 +21,8 @@ class TestVladMercurial < MiniTest::Unit::TestCase
20
21
  end
21
22
 
22
23
  def test_export
23
- cmd = @scm.export 'head', '/path/to/release'
24
+ cmd = @scm.export 'default', '/path/to/release'
25
+ assert_equal :export, deploy_via.to_sym
24
26
  assert_equal 'hg archive -r default /path/to/release', cmd
25
27
  end
26
28
 
@@ -30,5 +32,15 @@ class TestVladMercurial < MiniTest::Unit::TestCase
30
32
  expected = "`hg identify -r 000000000000 | cut -f1 -d\\ `"
31
33
  assert_equal expected, cmd
32
34
  end
35
+
36
+ def test_deploy_via
37
+ set :deploy_via, :clone
38
+ cmd = @scm.export 'default', '/path/to/release'
39
+ assert_equal 'hg clone /path/to/scm -r default /path/to/release', cmd
40
+
41
+ set :deploy_via, :checkout
42
+ cmd = @scm.export 'default', '/path/to/release'
43
+ assert_equal 'hg clone /path/to/scm -r default /path/to/release', cmd
33
44
  end
34
45
 
46
+ end
@@ -1,4 +1,4 @@
1
- require 'test/vlad_test_case'
1
+ require 'rake/test_case' # from rake_remote_task
2
2
  require 'vlad'
3
3
  require 'vlad/mercurial_queue'
4
4
 
@@ -13,7 +13,7 @@ class TestVladMercurialQueue < MiniTest::Unit::TestCase
13
13
  end
14
14
 
15
15
  def test_checkout
16
- cmd = @scm.checkout 'head', '/path/to/scm'
16
+ cmd = @scm.checkout 'default', '/path/to/scm'
17
17
 
18
18
  expected = "if [ ! -d .hg ]; then hg init; fi " \
19
19
  "&& if [ ! -d .hg/patches/.hg ]; then hg qinit -c; fi " \
@@ -28,7 +28,7 @@ class TestVladMercurialQueue < MiniTest::Unit::TestCase
28
28
  end
29
29
 
30
30
  def test_export
31
- cmd = @scm.export 'head', '/path/to/release'
31
+ cmd = @scm.export 'default', '/path/to/release'
32
32
  assert_equal 'hg archive -r qtip /path/to/release', cmd
33
33
  end
34
34
 
@@ -42,7 +42,7 @@ class TestVladMercurialQueue < MiniTest::Unit::TestCase
42
42
  set :queue_repo, 'http://repo/project-patched'
43
43
 
44
44
  # only need to test #checkout
45
- cmd = @scm.checkout 'head', '/path/to/scm'
45
+ cmd = @scm.checkout 'default', '/path/to/scm'
46
46
 
47
47
  expected = "if [ ! -d .hg ]; then hg init; fi " \
48
48
  "&& if [ ! -d .hg/patches/.hg ]; then hg qinit -c; fi " \
@@ -60,7 +60,7 @@ class TestVladMercurialQueue < MiniTest::Unit::TestCase
60
60
  set :queue_revision, "deadbeefd00d"
61
61
 
62
62
  # only need to test #checkout
63
- cmd = @scm.checkout 'head', '/path/to/scm'
63
+ cmd = @scm.checkout 'default', '/path/to/scm'
64
64
 
65
65
  expected = "if [ ! -d .hg ]; then hg init; fi " \
66
66
  "&& if [ ! -d .hg/patches/.hg ]; then hg qinit -c; fi " \
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vlad-hg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 2
10
- version: 2.1.2
9
+ - 3
10
+ version: 2.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kevin R. Bullock
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-15 00:00:00 -05:00
18
+ date: 2010-11-22 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -87,7 +87,6 @@ files:
87
87
  - lib/vlad/mercurial_queue.rb
88
88
  - test/test_vlad_mercurial.rb
89
89
  - test/test_vlad_mercurial_queue.rb
90
- - test/vlad_test_case.rb
91
90
  has_rdoc: true
92
91
  homepage: http://hitsquad.rubyforge.org/vlad-hg/
93
92
  licenses: []
@@ -1,72 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'stringio'
3
- require 'vlad'
4
-
5
- class StringIO
6
- def readpartial(size) read end # suck!
7
- end
8
-
9
- module Process
10
- def self.expected status
11
- @@expected ||= []
12
- @@expected << status
13
- end
14
-
15
- class << self
16
- alias :waitpid2_old :waitpid2
17
-
18
- def waitpid2(pid)
19
- [ @@expected.shift ]
20
- end
21
- end
22
- end
23
-
24
- class Rake::RemoteTask
25
- attr_accessor :commands, :action, :input, :output, :error
26
-
27
- Status = Struct.new :exitstatus
28
-
29
- class Status
30
- def success?() exitstatus == 0 end
31
- end
32
-
33
- def system *command
34
- @commands << command
35
- self.action ? self.action[command.join(' ')] : true
36
- end
37
-
38
- def popen4 *command
39
- @commands << command
40
-
41
- @input = StringIO.new
42
- out = StringIO.new @output.shift.to_s
43
- err = StringIO.new @error.shift.to_s
44
-
45
- raise if block_given?
46
-
47
- status = self.action ? self.action[command.join(' ')] : 0
48
- Process.expected Status.new(status)
49
-
50
- return 42, @input, out, err
51
- end
52
-
53
- def select reads, writes, errs, timeout
54
- [reads, writes, errs]
55
- end
56
-
57
- end
58
-
59
- class VladTestCase < MiniTest::Unit::TestCase
60
- def setup
61
- @vlad = Rake::RemoteTask
62
- @vlad.reset
63
- Rake.application.clear
64
- @task_count = Rake.application.tasks.size
65
- @vlad.set :domain, "example.com"
66
- end
67
-
68
- def util_set_hosts
69
- @vlad.host "app.example.com", :app
70
- @vlad.host "db.example.com", :db
71
- end
72
- end