Sha256: 2632944dce92728db33cb4984fc24a930cbb6db0fb00c6c6dfe01d469e60cd04

Contents?: true

Size: 1.05 KB

Versions: 37

Compression:

Stored size: 1.05 KB

Contents

module OhlohScm::Adapters
	class HgAdapter < AbstractAdapter

		def push(to, &block)
			raise ArgumentError.new("Cannot push to #{to.inspect}") unless to.is_a?(HgAdapter)
			logger.info { "Pushing to #{to.url}" }

			yield(0,1) if block_given? # Progress bar callback

			unless to.exist?
				if to.local?
					# Create a new repo on the same local machine. Just use existing pull code in reverse.
					to.pull(self)
				else
					run "ssh #{to.hostname} 'mkdir -p #{to.path}'"
					run "scp -rpqB #{hg_path} #{to.hostname}:#{to.path}"
				end
			else
				run "cd '#{self.url}' && hg push -f -y '#{to.url}'"
			end

			yield(1,1) if block_given? # Progress bar callback
		end

		def local?
			return true if hostname == Socket.gethostname
			return true if url =~ /^file:\/\//
			return true if url !~ /:/
			false
		end

		def hostname
			$1 if url =~ /^ssh:\/\/([^\/]+)/
		end

		def path
			case url
			when /^file:\/\/(.+)$/
				$1
			when /^ssh:\/\/[^\/]+(\/.+)$/
				$1
			when /^[^:]*$/
				url
			end
		end

		def hg_path
			path && File.join(path, '.hg')
		end
	end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ohloh_scm-2.5.1 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.14 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.13 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.12 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.11 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.10 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.9 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.8 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.7 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.6 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.5 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.4 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.3 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.1 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.4.0 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.3.5 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.3.4 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.3.2 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.3.1 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.3.0 lib/ohloh_scm/adapters/hg/push.rb