Sha256: 957abf68d99255712b22c7c8a610b459ba97aaff3e0196875bf988a503d2edb3

Contents?: true

Size: 653 Bytes

Versions: 34

Compression:

Stored size: 653 Bytes

Contents

require 'shellwords'

module OhlohScm::Adapters
	class HgAdapter < AbstractAdapter
		def cat_file(commit, diff)
			cat(commit.token, diff.path)
		end

		def cat_file_parent(commit, diff)
			p = parent_tokens(commit)
			cat(p.first, diff.path) if p.first
		end

		def cat(revision, path)
			out, err = run_with_err("cd '#{url}' && hg cat -r #{revision} #{escape(path)}")
			return nil if err =~ /No such file in rev/i
			raise RuntimeError.new(err) unless err.to_s == ''
			out
		end

		# Escape bash-significant characters in the filename
		# Example:
		#     "Foo Bar & Baz" => "Foo\ Bar\ \&\ Baz"
		def escape(path)
			path.shellescape
		end
	end
end

Version data entries

34 entries across 34 versions & 1 rubygems

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