Sha256: afd778f4dc7287df8e6acd3a795598cde7887fa77b85887569aebdac60449a26

Contents?: true

Size: 1.08 KB

Versions: 37

Compression:

Stored size: 1.08 KB

Contents

module OhlohScm::Adapters
	class BzrAdapter < AbstractAdapter

		def push(to, &block)
			raise ArgumentError.new("Cannot push to #{to.inspect}") unless to.is_a?(BzrAdapter)
			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 #{bzr_path} #{to.hostname}:#{to.path}"
				end
			else
				run "cd '#{self.url}' && bzr revert && bzr push '#{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 =~ /^bzr\+ssh:\/\/([^\/]+)/
		end

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

		def bzr_path
			path && File.join(path, '.bzr')
		end
	end
end

Version data entries

37 entries across 37 versions & 1 rubygems

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