Sha256: 0ca46741df4717dc25ba72fdc257049f108e514c2b2170ece966202211f64baf

Contents?: true

Size: 1.37 KB

Versions: 20

Compression:

Stored size: 1.37 KB

Contents

module OhlohScm::Adapters
	class BzrAdapter < AbstractAdapter
		def exist?
			begin
				head_token.to_s.length > 0
			rescue
				logger.debug { $! }
				false
			end
		end

		def ls_tree(token)
      run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n")
		end

		def to_rev_param(r=nil)
			case r
			when nil
				1
			when Fixnum
				r.to_s
			when /^\d+$/
				r
			else
        "'revid:#{r.to_s}'"
			end
		end

		def is_merge_commit?(commit)
			parent_tokens(commit).size > 1
		end

    def export_tag(dest_dir, tag_name)
      run "cd '#{path}' && bzr export -r tag:#{tag_name} #{dest_dir}"
    end

		def export(dest_dir, token=head_token)
			# Unlike other SCMs, Bzr doesn't simply place the contents into dest_dir.
			# It actually *creates* dest_dir. Since it should already exist at this point,
			# first we have to delete it.
			Dir.delete(dest_dir) if File.exist?(dest_dir)

			run "cd '#{url}' && bzr export --format=dir -r #{to_rev_param(token)} '#{dest_dir}'"
		end

    def tags
      tag_strings = run("cd '#{url}' && bzr tags").split(/\n/)
      tag_strings.map do |tag_string|
        tag_name, rev = tag_string.split(/\s+/)
        next if rev == '?' || tag_name == '....'
        time_string = run("cd '#{ url }' && bzr log -r #{ rev } | grep 'timestamp:' | sed 's/timestamp://'")
        [tag_name, rev, Time.parse(time_string)]
      end.compact
    end
	end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ohloh_scm-2.4.12 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.11 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.10 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.9 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.8 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.7 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.6 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.5 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.4 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.3 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.1 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.4.0 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.3.5 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.3.4 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.3.2 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.3.1 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.3.0 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.2.13 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.2.12 lib/ohloh_scm/adapters/bzr/misc.rb
ohloh_scm-2.2.11 lib/ohloh_scm/adapters/bzr/misc.rb