| commit 2: | 25fa32dd4450 |
| parent 1: | ccafcc450ef6 |
| branch: | default |
| tags: | tip |
Removed extension and added file header
Patches /
rails-add_hg_support_to_script_plugin.diff
| r2:25fa32dd4450 | 76 loc | 2.2 KB | embed / history / annotate / raw / |
|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | From 608c2bf79a7bc172b9d1046ede7d8ef7b46be411 Mon Sep 17 00:00:00 2001
From: Nicolas Cavigneaux <nico@bounga.org>
Date: Tue, 28 Oct 2008 14:42:24 +0100
Subject: [PATCH] Added Hg (Mercurial) support in script/plugin
---
railties/lib/commands/plugin.rb | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb
index 9ff4739..046f177 100644
--- a/railties/lib/commands/plugin.rb
+++ b/railties/lib/commands/plugin.rb
@@ -176,6 +176,16 @@ class Plugin
@uri =~ /^git:\/\// || @uri =~ /\.git$/
end
+ def hg_url?
+ # Check if hg is installed
+ if system('hg version')
+ # Test integrity of remote repo
+ ret = system("hg id -r 000000 #{@uri}")
+ return ret
+ end
+ false
+ end
+
def installed?
File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \
or rails_env.externals.detect{ |name, repo| self.uri == repo }
@@ -186,6 +196,7 @@ class Plugin
if :http == method
method = :export if svn_url?
method = :git if git_url?
+ method = :hg if hg_url?
end
uninstall if installed? and options[:force]
@@ -285,6 +296,27 @@ class Plugin
end
end
end
+
+ def install_using_hg(options = {})
+ root = rails_env.root
+ install_path = mkdir_p "#{root}/vendor/plugins/#{name}"
+ Dir.chdir install_path do
+ init_cmd = "hg init"
+ init_cmd += " -q" if options[:quiet] and not $verbose
+ puts init_cmd if $verbose
+ system(init_cmd)
+ base_cmd = "hg pull #{uri}"
+ base_cmd += " -q" if options[:quiet] and not $verbose
+ base_cmd += " -r #{options[:revision]}" if options[:revision]
+ puts base_cmd if $verbose
+ if system(base_cmd)
+ puts "removing: .hg" if $verbose
+ rm_rf ".hg"
+ else
+ rm_rf install_path
+ end
+ end
+ end
def svn_command(cmd, options = {})
root = rails_env.root
@@ -964,4 +996,4 @@ class RecursiveHTTPFetcher
end
end
-Commands::Plugin.parse!
+Commands::Plugin.parse!
\ No newline at end of file
--
1.6.0.1
|
