Sha256: bba40f264c61fc8b30920d349f4c7910081f38eb20c4315305b12363da7d65d9
Contents?: true
Size: 660 Bytes
Versions: 3
Compression:
Stored size: 660 Bytes
Contents
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.gsub(/[ `'"&()<>|#\$]/) { |c| '\\' + c } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ohloh_scm-2.1.0 | lib/ohloh_scm/adapters/hg/cat_file.rb |
ohloh_scm-2.0.1 | lib/ohloh_scm/adapters/hg/cat_file.rb |
ohloh_scm-2.0.0 | lib/ohloh_scm/adapters/hg/cat_file.rb |