Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8925

Show
Ignore:
Timestamp:
02/23/08 04:04:27 (4 months ago)
Author:
minam
Message:

Add support for password prompts for Mercurial SCM (closes #11187)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/CHANGELOG

    r8924 r8925  
    11*SVN* 
     2 
     3* Add support for password prompts from the Mercurial SCM [ches] 
    24 
    35* Add support for :max_hosts option in task definition or run() [Rob Holland <rob@inversepath.com>] 
  • tools/capistrano/lib/capistrano/recipes/deploy/scm/mercurial.rb

    r7114 r8925  
    7171          case text 
    7272          when /^user:/mi 
    73             if variable(:scm_user) 
    74               "#{variable(:scm_user)}\n" 
     73            # support :scm_user for backwards compatibility of this module 
     74            if user = variable(:scm_username) || variable(:scm_user) 
     75              "#{user}\n" 
    7576            else 
    76               raise "No variable :scm_user specified and Mercurial asked!\n" + 
     77              raise "No variable :scm_username specified and Mercurial asked!\n" + 
    7778                "Prompt was: #{text}" 
    7879            end 
    79           when /^password:/mi 
    80             if variable(:scm_password) 
    81               "#{variable(:scm_password)}\n" 
    82             else 
     80          when /\bpassword:/mi 
     81            unless pass = scm_password_or_prompt 
     82              # fall back on old behavior of erroring out with msg 
    8383              raise "No variable :scm_password specified and Mercurial asked!\n" + 
    8484                "Prompt was: #{text}" 
    8585            end 
     86            "#{pass}\n" 
    8687          when /yes\/no/i 
    8788            "yes\n" 
    8889          end 
    8990        end 
    90  
     91         
    9192        private 
    9293 
     
    123124          end 
    124125        end 
     126         
     127        # honor Cap 2.1+'s :scm_prefer_prompt if present 
     128        def scm_password_or_prompt 
     129          @scm_password_or_prompt ||= variable(:scm_password) || 
     130            (Capistrano::CLI.password_prompt("hg password: ") if variable(:scm_prefer_prompt)) 
     131        end 
    125132 
    126133      end