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