Sha256: d249437ee1de5c7eb4299950b403b07aec486f62d4a4271a8807a75b9029880f

Contents?: true

Size: 781 Bytes

Versions: 37

Compression:

Stored size: 781 Bytes

Contents

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

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

		def cat(revision, path)
			out, err, status = run_with_err("cd '#{url}' && bzr cat --name-from-revision -r #{to_rev_param(revision)} '#{escape(path)}'")
			return nil if err =~ / is not present in revision /
			raise RuntimeError.new(err) unless status == 0
			out
		end

		# Bzr doesn't like it when the filename includes a colon
		# Also, fix the case where the filename includes a single quote
		def escape(path)
			path.gsub(/[:]/) { |c| '\\' + c }.gsub("'", "''")
		end
	end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ohloh_scm-2.2.13 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.12 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.11 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.10 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.9 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.8 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.7 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.6 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.5 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.4 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.3 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.2 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.1 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.2.0 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.1.0 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.0.1 lib/ohloh_scm/adapters/bzr/cat_file.rb
ohloh_scm-2.0.0 lib/ohloh_scm/adapters/bzr/cat_file.rb