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.2.13 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.12 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.11 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.10 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.9 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.8 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.7 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.6 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.5 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.4 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.3 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.2 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.1 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.2.0 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.1.0 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.0.1 lib/ohloh_scm/adapters/hg/push.rb
ohloh_scm-2.0.0 lib/ohloh_scm/adapters/hg/push.rb