From b4043f8d63dd003fddf3f7d0f7623129d63f177a Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 16 Oct 2014 14:41:44 +0530 Subject: [PATCH 01/33] Rename Scm modules to OhlohScm --- lib/ohloh_scm/adapters/svn/commits.rb | 2 +- lib/ohloh_scm/commit.rb | 2 +- lib/ohloh_scm/diff.rb | 8 ++-- lib/ohloh_scm/parsers/bzr_parser.rb | 8 ++-- lib/ohloh_scm/parsers/bzr_xml_parser.rb | 26 ++++++------ lib/ohloh_scm/parsers/cvs_parser.rb | 2 +- lib/ohloh_scm/parsers/git_parser.rb | 4 +- lib/ohloh_scm/parsers/git_styled_parser.rb | 4 +- lib/ohloh_scm/parsers/hg_parser.rb | 4 +- lib/ohloh_scm/parsers/hg_styled_parser.rb | 4 +- lib/ohloh_scm/parsers/svn_parser.rb | 4 +- lib/ohloh_scm/parsers/svn_xml_parser.rb | 4 +- lib/ohloh_scm/scratch_dir.rb | 2 +- lib/ohloh_scm/version.rb | 2 +- ohloh_scm.gemspec | 2 +- test/test_helper.rb | 4 +- test/unit/abstract_adapter_test.rb | 8 ++-- test/unit/adapter_factory_test.rb | 14 +++---- test/unit/array_writer_test.rb | 2 +- test/unit/bzr_cat_file_test.rb | 24 +++++------ test/unit/bzr_commits_test.rb | 24 +++++------ test/unit/bzr_head_test.rb | 2 +- test/unit/bzr_misc_test.rb | 4 +- test/unit/bzr_parser_test.rb | 10 ++--- test/unit/bzr_pull_test.rb | 4 +- test/unit/bzr_push_test.rb | 4 +- test/unit/bzr_validation_test.rb | 6 +-- test/unit/bzr_xml_parser_test.rb | 40 +++++++++---------- test/unit/bzrlib_cat_file_test.rb | 20 +++++----- test/unit/bzrlib_head_test.rb | 2 +- test/unit/cvs_branch_number_test.rb | 2 +- test/unit/cvs_commits_test.rb | 2 +- test/unit/cvs_convert_test.rb | 4 +- test/unit/cvs_misc_test.rb | 2 +- test/unit/cvs_parser_test.rb | 2 +- test/unit/cvs_validation_test.rb | 2 +- test/unit/git_cat_file_test.rb | 4 +- test/unit/git_commit_all_test.rb | 6 +-- test/unit/git_commits_test.rb | 2 +- test/unit/git_head_test.rb | 2 +- test/unit/git_log_parser_test.rb | 4 +- test/unit/git_misc_test.rb | 8 ++-- test/unit/git_parser_test.rb | 2 +- test/unit/git_patch_test.rb | 2 +- test/unit/git_pull_test.rb | 4 +- test/unit/git_push_test.rb | 6 +-- test/unit/git_rev_list_test.rb | 2 +- test/unit/git_styled_parser_test.rb | 8 ++-- test/unit/git_token_test.rb | 12 +++--- test/unit/git_validation_test.rb | 2 +- test/unit/hg_cat_file_test.rb | 12 +++--- test/unit/hg_commits_test.rb | 2 +- test/unit/hg_head_test.rb | 2 +- test/unit/hg_misc_test.rb | 4 +- test/unit/hg_parser_test.rb | 2 +- test/unit/hg_patch_test.rb | 2 +- test/unit/hg_pull_test.rb | 4 +- test/unit/hg_push_test.rb | 4 +- test/unit/hg_rev_list_test.rb | 2 +- test/unit/hg_validation_test.rb | 2 +- test/unit/hglib_cat_file_test.rb | 12 +++--- test/unit/hglib_head_test.rb | 2 +- test/unit/ohlog_command_line_test.rb | 2 +- test/unit/shellout_test.rb | 2 +- test/unit/string_encoder_command_line_test.rb | 2 +- test/unit/svn_cat_file_test.rb | 6 +-- test/unit/svn_chain_cat_file_test.rb | 6 +-- test/unit/svn_chain_commits_test.rb | 2 +- test/unit/svn_chain_test.rb | 4 +- test/unit/svn_commits_test.rb | 30 +++++++------- test/unit/svn_convert_test.rb | 4 +- test/unit/svn_head_test.rb | 2 +- test/unit/svn_misc_test.rb | 4 +- test/unit/svn_parser_test.rb | 2 +- test/unit/svn_patch_test.rb | 2 +- test/unit/svn_pull_test.rb | 10 ++--- test/unit/svn_push_test.rb | 6 +-- test/unit/svn_validation_test.rb | 6 +-- test/unit/svn_xml_parser_test.rb | 4 +- 79 files changed, 234 insertions(+), 234 deletions(-) diff --git a/lib/ohloh_scm/adapters/svn/commits.rb b/lib/ohloh_scm/adapters/svn/commits.rb index 64530cc6..216497ad 100644 --- a/lib/ohloh_scm/adapters/svn/commits.rb +++ b/lib/ohloh_scm/adapters/svn/commits.rb @@ -96,7 +96,7 @@ def deepen_diff(diff, rev) if (diff.action == 'D' or diff.action == 'A') && is_directory?(diff.path, recurse_rev) # Deleting or adding a directory. Expand it out to show every file. recurse_files(diff.path, recurse_rev).collect do |f| - Scm::Diff.new(:action => diff.action, :path => File.join(diff.path, f)) + OhlohScm::Diff.new(:action => diff.action, :path => File.join(diff.path, f)) end else # An ordinary file action. Just return the diff. diff --git a/lib/ohloh_scm/commit.rb b/lib/ohloh_scm/commit.rb index ddb9fa13..2a8e12f0 100644 --- a/lib/ohloh_scm/commit.rb +++ b/lib/ohloh_scm/commit.rb @@ -1,4 +1,4 @@ -module Scm +module OhlohScm # A commit is a collection of diffs united by a single timestamp, author, and # message. # diff --git a/lib/ohloh_scm/diff.rb b/lib/ohloh_scm/diff.rb index 1263cb96..83169185 100644 --- a/lib/ohloh_scm/diff.rb +++ b/lib/ohloh_scm/diff.rb @@ -1,10 +1,10 @@ -module Scm +module OhlohScm # A +Diff+ represents a change to a single file. It can represent the addition or # deletion of a file, or it can represent a modification of the file contents. - # + # # Ohloh does not track filename changes. If a file is renamed, Ohloh treats this # as the deletion of one file and the creation of another. - # + # # Ohloh does not track directories, only the files within directories. # # Don't confuse our use of the word "Diff" with a patch file or the output of the @@ -22,7 +22,7 @@ class Diff # 'M' modified # 'D' deleted attr_accessor :action - + # The SHA1 hash of the file contents both before and after the change. # These must be computed using the same method as Git. attr_accessor :parent_sha1, :sha1 diff --git a/lib/ohloh_scm/parsers/bzr_parser.rb b/lib/ohloh_scm/parsers/bzr_parser.rb index 9a879e49..acc79bba 100644 --- a/lib/ohloh_scm/parsers/bzr_parser.rb +++ b/lib/ohloh_scm/parsers/bzr_parser.rb @@ -30,7 +30,7 @@ def self.internal_parse(buffer, opts) e.diffs = remove_dupes(e.diffs) yield e end - e = Scm::Commit.new + e = OhlohScm::Commit.new e.diffs = [] next_state = :data when /^#{indent}revno:\s+(\d+)$/ @@ -98,10 +98,10 @@ def self.parse_diffs(action, line) # Note that is possible to be renamed to the empty string! # This happens when a subdirectory is moved to become the root. before, after = line.scan(/(.+) => ?(.*)/).first - [ Scm::Diff.new(:action => 'D', :path => before), - Scm::Diff.new(:action => 'A', :path => after || '' )] + [ OhlohScm::Diff.new(:action => 'D', :path => before), + OhlohScm::Diff.new(:action => 'A', :path => after || '' )] else - [Scm::Diff.new(:action => action, :path => line)] + [OhlohScm::Diff.new(:action => action, :path => line)] end.each do |d| d.path = strip_trailing_asterisk(d.path) end diff --git a/lib/ohloh_scm/parsers/bzr_xml_parser.rb b/lib/ohloh_scm/parsers/bzr_xml_parser.rb index 32a926c0..325e25e4 100644 --- a/lib/ohloh_scm/parsers/bzr_xml_parser.rb +++ b/lib/ohloh_scm/parsers/bzr_xml_parser.rb @@ -18,7 +18,7 @@ def initialize(callback) def tag_start(name, attrs) case name when 'log' - @commit = Scm::Commit.new + @commit = OhlohScm::Commit.new @commit.diffs = [] when 'affected-files' @diffs = [] @@ -87,18 +87,18 @@ def parse_diff(action, path, before_path) case action # A rename action requires two diffs: one to remove the old filename, # another to add the new filename. - # + # # Note that is possible to be renamed to the empty string! # This happens when a subdirectory is moved to become the root. when 'renamed' - diffs = [ Scm::Diff.new(:action => 'D', :path => before_path), - Scm::Diff.new(:action => 'A', :path => path || '')] + diffs = [ OhlohScm::Diff.new(:action => 'D', :path => before_path), + OhlohScm::Diff.new(:action => 'A', :path => path || '')] when 'added' - diffs = [Scm::Diff.new(:action => 'A', :path => path)] + diffs = [OhlohScm::Diff.new(:action => 'A', :path => path)] when 'modified' - diffs = [Scm::Diff.new(:action => 'M', :path => path)] + diffs = [OhlohScm::Diff.new(:action => 'M', :path => path)] when 'removed' - diffs = [Scm::Diff.new(:action => 'D', :path => path)] + diffs = [OhlohScm::Diff.new(:action => 'D', :path => path)] end diffs.each do |d| d.path = strip_trailing_asterisk(d.path) @@ -108,11 +108,11 @@ def parse_diff(action, path, before_path) def strip_trailing_asterisk(path) path[-1..-1] == '*' ? path[0..-2] : path - end + end def remove_dupes(diffs) BzrXmlParser.remove_dupes(diffs) - end + end end @@ -133,14 +133,14 @@ def self.scm def self.remove_dupes(diffs) # Bazaar may report that a file was added and modified in a single commit. # Reduce these cases to a single 'A' action. - diffs.delete_if do |d| + diffs.delete_if do |d| d.action == 'M' && diffs.select { |x| x.path == d.path && x.action == 'A' }.any? - end + end # Bazaar may report that a file was both deleted and added in a single commit. # Reduce these cases to a single 'M' action. - diffs.each do |d| - d.action = 'M' if diffs.select { |x| x.path == d.path }.size > 1 + diffs.each do |d| + d.action = 'M' if diffs.select { |x| x.path == d.path }.size > 1 end.uniq end diff --git a/lib/ohloh_scm/parsers/cvs_parser.rb b/lib/ohloh_scm/parsers/cvs_parser.rb index a8d86b20..99a49816 100644 --- a/lib/ohloh_scm/parsers/cvs_parser.rb +++ b/lib/ohloh_scm/parsers/cvs_parser.rb @@ -139,7 +139,7 @@ def self.read_commit(io, filename, commit_number, should_yield) should_yield = false if commit_number == '1.1' and state == 'dead' message = read_message(io) if should_yield - commit = Scm::Commit.new + commit = OhlohScm::Commit.new commit.token = committer_date[0..18] commit.committer_date = Time.parse(committer_date[0..18] + ' +0000').utc commit.committer_name = committer_name diff --git a/lib/ohloh_scm/parsers/git_parser.rb b/lib/ohloh_scm/parsers/git_parser.rb index 9b2a8ee7..8a48a46d 100644 --- a/lib/ohloh_scm/parsers/git_parser.rb +++ b/lib/ohloh_scm/parsers/git_parser.rb @@ -27,7 +27,7 @@ def self.internal_parse(io, opts) when /^commit ([a-z0-9]{40,40})$/ sha1 = $1 yield e if e - e = Scm::Commit.new + e = OhlohScm::Commit.new e.diffs = [] e.token = sha1 e.author_name = ANONYMOUS @@ -53,7 +53,7 @@ def self.internal_parse(io, opts) elsif state == :diffs if line =~ /^([ADM])\t(.+)$/ - e.diffs << Scm::Diff.new( :action => $1, :path => $2) + e.diffs << OhlohScm::Diff.new( :action => $1, :path => $2) end else diff --git a/lib/ohloh_scm/parsers/git_styled_parser.rb b/lib/ohloh_scm/parsers/git_styled_parser.rb index fba110e0..beec97ba 100644 --- a/lib/ohloh_scm/parsers/git_styled_parser.rb +++ b/lib/ohloh_scm/parsers/git_styled_parser.rb @@ -35,7 +35,7 @@ def self.internal_parse(io, opts) if line =~ /^Commit: ([a-z0-9]+)$/ sha1 = $1 yield e if e - e = Scm::Commit.new + e = OhlohScm::Commit.new e.diffs = [] e.token = sha1 e.author_name = ANONYMOUS @@ -70,7 +70,7 @@ def self.internal_parse(io, opts) elsif line =~ /:([0-9]+) ([0-9]+) ([a-z0-9]+) ([a-z0-9]+) ([A-Z])\t"?(.+[^"])"?$/ # Submodules have a file mode of '160000', which indicates a "gitlink" # We ignore submodules completely. - e.diffs << Scm::Diff.new( :action => $5, :path => $6, :sha1 => $4, :parent_sha1 => $3 ) unless $1=='160000' || $2=='160000' + e.diffs << OhlohScm::Diff.new( :action => $5, :path => $6, :sha1 => $4, :parent_sha1 => $3 ) unless $1=='160000' || $2=='160000' end else diff --git a/lib/ohloh_scm/parsers/hg_parser.rb b/lib/ohloh_scm/parsers/hg_parser.rb index ea753f28..48cf9cee 100644 --- a/lib/ohloh_scm/parsers/hg_parser.rb +++ b/lib/ohloh_scm/parsers/hg_parser.rb @@ -17,7 +17,7 @@ def self.internal_parse(buffer, opts) case l when /^changeset:\s+\d+:([0-9a-f]+)/ yield e if e && block_given? - e = Scm::Commit.new + e = OhlohScm::Commit.new e.diffs = [] e.token = $1 when /^user:\s+(.+?)(\s+<(.+)>)?$/ @@ -27,7 +27,7 @@ def self.internal_parse(buffer, opts) e.committer_date = Time.parse($1).utc when /^files:\s+(.+)/ ($1 || '').split(' ').each do |file| - e.diffs << Scm::Diff.new(:action => '?', :path => file) + e.diffs << OhlohScm::Diff.new(:action => '?', :path => file) end when /^summary:\s+(.+)/ e.message = $1 diff --git a/lib/ohloh_scm/parsers/hg_styled_parser.rb b/lib/ohloh_scm/parsers/hg_styled_parser.rb index 811d8975..2dc6e753 100644 --- a/lib/ohloh_scm/parsers/hg_styled_parser.rb +++ b/lib/ohloh_scm/parsers/hg_styled_parser.rb @@ -25,7 +25,7 @@ def self.internal_parse(buffer, opts) if state == :data case l when /^changeset:\s+([0-9a-f]+)/ - e = Scm::Commit.new + e = OhlohScm::Commit.new e.diffs = [] e.token = $1 when /^user:\s+(.+?)(\s+<(.+)>)?$/ @@ -46,7 +46,7 @@ def self.internal_parse(buffer, opts) if l == "__END_FILES__\n" next_state = :data elsif l =~ /^([MAD]) (.+)$/ - e.diffs << Scm::Diff.new(:action => $1, :path => $2) + e.diffs << OhlohScm::Diff.new(:action => $1, :path => $2) end elsif state == :long_comment diff --git a/lib/ohloh_scm/parsers/svn_parser.rb b/lib/ohloh_scm/parsers/svn_parser.rb index 5fc65b2b..7977649f 100644 --- a/lib/ohloh_scm/parsers/svn_parser.rb +++ b/lib/ohloh_scm/parsers/svn_parser.rb @@ -13,7 +13,7 @@ def self.internal_parse(buffer, opts) next_state = state if state == :data if l =~ /^r(\d+) \| (.*) \| (\d+-\d+-\d+ .*) \(.*\) \| .*/ - e = Scm::Commit.new + e = OhlohScm::Commit.new e.token = $1.to_i e.committer_name = $2 e.committer_date = Time.parse($3).utc @@ -26,7 +26,7 @@ def self.internal_parse(buffer, opts) elsif state == :diffs if l =~ /^ (\w) ([^\(\)]+)( \(from (.+):(\d+)\))?$/ e.diffs ||= [] - e.diffs << Scm::Diff.new(:action => $1, :path => $2, :from_path => $4, :from_revision => $5.to_i) + e.diffs << OhlohScm::Diff.new(:action => $1, :path => $2, :from_path => $4, :from_revision => $5.to_i) else next_state = :comment end diff --git a/lib/ohloh_scm/parsers/svn_xml_parser.rb b/lib/ohloh_scm/parsers/svn_xml_parser.rb index 6eae2954..bfac5854 100644 --- a/lib/ohloh_scm/parsers/svn_xml_parser.rb +++ b/lib/ohloh_scm/parsers/svn_xml_parser.rb @@ -15,11 +15,11 @@ def initialize(callback) def tag_start(name, attrs) case name when 'logentry' - @commit = Scm::Commit.new + @commit = OhlohScm::Commit.new @commit.diffs = [] @commit.token = attrs['revision'].to_i when 'path' - @diff = Scm::Diff.new(:action => attrs['action'], + @diff = OhlohScm::Diff.new(:action => attrs['action'], :from_path => attrs['copyfrom-path'], :from_revision => attrs['copyfrom-rev'].to_i) end diff --git a/lib/ohloh_scm/scratch_dir.rb b/lib/ohloh_scm/scratch_dir.rb index 4eaa06a5..b68c4fb4 100644 --- a/lib/ohloh_scm/scratch_dir.rb +++ b/lib/ohloh_scm/scratch_dir.rb @@ -1,7 +1,7 @@ require 'fileutils' # A utility class to manage the creation and automatic cleanup of temporary directories. -module Scm +module OhlohScm class ScratchDir attr_reader :path diff --git a/lib/ohloh_scm/version.rb b/lib/ohloh_scm/version.rb index 2868efe2..3e692ad5 100644 --- a/lib/ohloh_scm/version.rb +++ b/lib/ohloh_scm/version.rb @@ -1,4 +1,4 @@ -module Scm +module OhlohScm module Version STRING = '2.0.0' end diff --git a/ohloh_scm.gemspec b/ohloh_scm.gemspec index aaa3b7ba..0de6e165 100644 --- a/ohloh_scm.gemspec +++ b/ohloh_scm.gemspec @@ -4,7 +4,7 @@ require 'ohloh_scm/version' Gem::Specification.new do |gem| gem.name = 'ohloh_scm' - gem.version = Scm::Version::STRING + gem.version = OhlohScm::Version::STRING gem.authors = ["BlackDuck Software"] gem.email = ["info@openhub.net"] gem.summary = %[Source Control Management] diff --git a/test/test_helper.rb b/test/test_helper.rb index f8ddbba7..cfd4d926 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,7 +17,7 @@ DATA_DIR = File.expand_path(File.join(TEST_DIR, 'data')) end -class Scm::Test < Test::Unit::TestCase +class OhlohScm::Test < Test::Unit::TestCase # For reasons unknown, the base class defines a default_test method to throw a failure. # We override it with a no-op to prevent this 'helpful' feature. def default_test @@ -48,7 +48,7 @@ def assert_buffers_equal(expected, actual) end def with_repository(type, name) - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| if Dir.entries(REPO_DIR).include?(name) `cp -R #{File.join(REPO_DIR, name)} #{dir}` elsif Dir.entries(REPO_DIR).include?(name + '.tgz') diff --git a/test/unit/abstract_adapter_test.rb b/test/unit/abstract_adapter_test.rb index 4e5c5be7..762ad3a3 100644 --- a/test/unit/abstract_adapter_test.rb +++ b/test/unit/abstract_adapter_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class AbstractAdapterTest < Scm::Test + class AbstractAdapterTest < OhlohScm::Test def test_simple_validation scm = AbstractAdapter.new() assert !scm.valid? @@ -74,7 +74,7 @@ def test_shellout stdout = AbstractAdapter.run(cmd) assert_equal "Hello World\n", stdout end - + def test_shellout_with_stderr cmd = %q( ruby -e" t = 'Hello World'; STDOUT.puts t; STDERR.puts t " ) stdout, stderr, status = AbstractAdapter.run_with_err(cmd) @@ -82,7 +82,7 @@ def test_shellout_with_stderr assert_equal "Hello World\n", stdout assert_equal "Hello World\n", stderr end - + def test_shellout_large_output cat = 'ruby -e" puts Array.new(65536){ 42 } "' stdout = AbstractAdapter.run(cat) @@ -91,7 +91,7 @@ def test_shellout_large_output def test_shellout_error cmd = "false" - assert_raise RuntimeError do + assert_raise RuntimeError do stdout = AbstractAdapter.run(cmd) end end diff --git a/test/unit/adapter_factory_test.rb b/test/unit/adapter_factory_test.rb index 977d0557..a298ff5f 100644 --- a/test/unit/adapter_factory_test.rb +++ b/test/unit/adapter_factory_test.rb @@ -1,10 +1,10 @@ require_relative '../test_helper' module OhlohScm::Adapters - class FactoryTest < Scm::Test + class FactoryTest < OhlohScm::Test def test_factory_hg - Scm::ScratchDir.new do |path| + OhlohScm::ScratchDir.new do |path| `cd #{path} && hg init` hg = Factory.from_path(path) assert hg.is_a?(HgAdapter) @@ -13,7 +13,7 @@ def test_factory_hg end def test_factory_bzr - Scm::ScratchDir.new do |path| + OhlohScm::ScratchDir.new do |path| `cd #{path} && bzr init` bzr = Factory.from_path(path) assert bzr.is_a?(BzrAdapter) @@ -22,7 +22,7 @@ def test_factory_bzr end def test_factory_git - Scm::ScratchDir.new do |path| + OhlohScm::ScratchDir.new do |path| `cd #{path} && git init` git = Factory.from_path(path) assert git.is_a?(GitAdapter) @@ -31,7 +31,7 @@ def test_factory_git end def test_factory_svn - Scm::ScratchDir.new do |path| + OhlohScm::ScratchDir.new do |path| `cd #{path} && svnadmin create foo` svn = Factory.from_path(File.join(path, 'foo')) assert svn.is_a?(SvnAdapter) @@ -40,7 +40,7 @@ def test_factory_svn end def test_factory_svn_checkout - Scm::ScratchDir.new do |path| + OhlohScm::ScratchDir.new do |path| `cd #{path} && svnadmin create foo` `cd #{path} && svn co file://#{File.expand_path(File.join(path, 'foo'))} bar` svn = Factory.from_path(File.join(path, 'bar')) @@ -53,7 +53,7 @@ def test_factory_svn_checkout def test_factory_from_cvs_checkout with_cvs_repository('cvs', 'simple') do |cvs| - Scm::ScratchDir.new do |path| + OhlohScm::ScratchDir.new do |path| `cd #{path} && cvsnt -d #{File.expand_path(cvs.url)} co simple 2> /dev/null` factory_response = Factory.from_path(File.join(path, 'simple')) assert factory_response.is_a?(CvsAdapter) diff --git a/test/unit/array_writer_test.rb b/test/unit/array_writer_test.rb index 037843c2..86a3d32b 100644 --- a/test/unit/array_writer_test.rb +++ b/test/unit/array_writer_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class ArrayWriterTest < Scm::Test + class ArrayWriterTest < OhlohScm::Test def test_basic diff --git a/test/unit/bzr_cat_file_test.rb b/test/unit/bzr_cat_file_test.rb index 58bd4169..f7b08d88 100644 --- a/test/unit/bzr_cat_file_test.rb +++ b/test/unit/bzr_cat_file_test.rb @@ -2,7 +2,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrCatFileTest < Scm::Test + class BzrCatFileTest < OhlohScm::Test def test_cat_file with_bzr_repository('bzr') do |bzr| @@ -11,12 +11,12 @@ def test_cat_file second line EXPECTED assert_equal expected, - bzr.cat_file(Scm::Commit::new(:token => 6), - Scm::Diff.new(:path => "file1.txt")) + bzr.cat_file(OhlohScm::Commit::new(:token => 6), + OhlohScm::Diff.new(:path => "file1.txt")) # file2.txt has been removed in commit #5 assert_equal nil, bzr.cat_file(bzr.head, - Scm::Diff.new(:path => "file2.txt")) + OhlohScm::Diff.new(:path => "file2.txt")) end end @@ -27,10 +27,10 @@ def test_cat_file_non_ascii_name second line EXPECTED assert_equal expected, - bzr.cat_file(Scm::Commit::new(:token => 7), - Scm::Diff.new(:path => "Cédric.txt")) - end - end + bzr.cat_file(OhlohScm::Commit::new(:token => 7), + OhlohScm::Diff.new(:path => "Cédric.txt")) + end + end def test_cat_file_parent with_bzr_repository('bzr') do |bzr| @@ -39,16 +39,16 @@ def test_cat_file_parent second line EXPECTED assert_equal expected, - bzr.cat_file_parent(Scm::Commit::new(:token => 6), - Scm::Diff.new(:path => "file1.txt")) + bzr.cat_file_parent(OhlohScm::Commit::new(:token => 6), + OhlohScm::Diff.new(:path => "file1.txt")) # file2.txt has been removed in commit #5 expected = <<-EXPECTED another file EXPECTED assert_equal expected, - bzr.cat_file_parent(Scm::Commit.new(:token => 5), - Scm::Diff.new(:path => "file2.txt")) + bzr.cat_file_parent(OhlohScm::Commit.new(:token => 5), + OhlohScm::Diff.new(:path => "file2.txt")) end end diff --git a/test/unit/bzr_commits_test.rb b/test/unit/bzr_commits_test.rb index fa912a50..755ebcd8 100644 --- a/test/unit/bzr_commits_test.rb +++ b/test/unit/bzr_commits_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrCommitsTest < Scm::Test + class BzrCommitsTest < OhlohScm::Test def test_commit_count with_bzr_repository('bzr') do |bzr| @@ -63,7 +63,7 @@ def test_commit_tokens_trunk_only_false assert_equal [ 'test@example.com-20090206214301-s93cethy9atcqu9h', 'test@example.com-20090206214451-lzjngefdyw3vmgms', - 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit + 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit 'test@example.com-20090206214515-21lkfj3dbocao5pr' # merge commit ], bzr.commit_tokens(:trunk_only => false) end @@ -95,8 +95,8 @@ def test_nested_branches_commit_tokens_trunk_only_false 'test@example.com-20110803170648-o0xcbni7lwp97azj', 'test@example.com-20110803170818-v44umypquqg8migo' ], bzr.commit_tokens(:trunk_only => false) - end - end + end + end def test_nested_branches_commit_tokens_trunk_only_true with_bzr_repository('bzr_with_nested_branches') do |bzr| @@ -109,15 +109,15 @@ def test_nested_branches_commit_tokens_trunk_only_true 'obnox@samba.org-20090204004942-73rnw0izen42f154', 'test@example.com-20110803170818-v44umypquqg8migo' ], bzr.commit_tokens(:trunk_only => true) - end - end + end + end def test_commits_trunk_only_false with_bzr_repository('bzr_with_branch') do |bzr| assert_equal [ 'test@example.com-20090206214301-s93cethy9atcqu9h', 'test@example.com-20090206214451-lzjngefdyw3vmgms', - 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit + 'test@example.com-20090206214350-rqhdpz92l11eoq2t', # branch commit 'test@example.com-20090206214515-21lkfj3dbocao5pr' # merge commit ], bzr.commits(:trunk_only => false).map { |c| c.token } end @@ -163,8 +163,8 @@ def test_nested_branches_commits_trunk_only_false 'test@example.com-20110803170648-o0xcbni7lwp97azj', 'test@example.com-20110803170818-v44umypquqg8migo' ], bzr.commits(:trunk_only => false).map { |c| c.token } - end - end + end + end def test_nested_branches_commits_trunk_only_true with_bzr_repository('bzr_with_nested_branches') do |bzr| @@ -177,8 +177,8 @@ def test_nested_branches_commits_trunk_only_true 'obnox@samba.org-20090204004942-73rnw0izen42f154', 'test@example.com-20110803170818-v44umypquqg8migo' ], bzr.commits(:trunk_only => true).map { |c| c.token } - end - end + end + end def test_commits with_bzr_repository('bzr') do |bzr| @@ -345,7 +345,7 @@ def test_committer_and_author_name assert_equal 'Abhay Mujumdar', commits[0].committer_name assert_equal nil, commits[0].author_name assert_equal nil, commits[0].author_email - + assert_equal 'Updated.', commits[1].message assert_equal 'Abhay Mujumdar', commits[1].committer_name assert_equal 'John Doe', commits[1].author_name diff --git a/test/unit/bzr_head_test.rb b/test/unit/bzr_head_test.rb index c718b5d9..47e7a809 100644 --- a/test/unit/bzr_head_test.rb +++ b/test/unit/bzr_head_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrHeadTest < Scm::Test + class BzrHeadTest < OhlohScm::Test def test_head_and_parents with_bzr_repository('bzr') do |bzr| diff --git a/test/unit/bzr_misc_test.rb b/test/unit/bzr_misc_test.rb index acd769aa..ec2fcf6a 100644 --- a/test/unit/bzr_misc_test.rb +++ b/test/unit/bzr_misc_test.rb @@ -2,7 +2,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrMiscTest < Scm::Test + class BzrMiscTest < OhlohScm::Test def test_exist save_bzr = nil @@ -26,7 +26,7 @@ def test_ls_tree def test_export with_bzr_repository('bzr') do |bzr| - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| bzr.export(dir) assert_equal ['.', '..', 'Cédric.txt', 'file1.txt', 'file3.txt', 'file4.txt', 'file5.txt'], Dir.entries(dir).sort end diff --git a/test/unit/bzr_parser_test.rb b/test/unit/bzr_parser_test.rb index b67d4c81..c52ea2df 100644 --- a/test/unit/bzr_parser_test.rb +++ b/test/unit/bzr_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class BzrParserTest < Scm::Test + class BzrParserTest < OhlohScm::Test def test_empty_array assert_equal([], BzrParser.parse('')) @@ -305,8 +305,8 @@ def test_rename end def test_remove_dupes_add_remove - diffs = BzrParser.remove_dupes([ Scm::Diff.new(:action => "A", :path => "foo"), - Scm::Diff.new(:action => "D", :path => "foo") ]) + diffs = BzrParser.remove_dupes([ OhlohScm::Diff.new(:action => "A", :path => "foo"), + OhlohScm::Diff.new(:action => "D", :path => "foo") ]) assert_equal 1, diffs.size assert_equal 'M', diffs.first.action assert_equal 'foo', diffs.first.path @@ -378,9 +378,9 @@ def test_comment_that_contains_dashes This is a tricky commit message to confirm fix to Ticket 5. We're including a line of dashes in the message that resembles a log delimiter. - + ------------------------------------------------------------ - + Happy parsing! added: goodbyeworld.c diff --git a/test/unit/bzr_pull_test.rb b/test/unit/bzr_pull_test.rb index 1d05f76d..4f0bbd0c 100644 --- a/test/unit/bzr_pull_test.rb +++ b/test/unit/bzr_pull_test.rb @@ -1,11 +1,11 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrPullTest < Scm::Test + class BzrPullTest < OhlohScm::Test def test_pull with_bzr_repository('bzr') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = BzrAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/bzr_push_test.rb b/test/unit/bzr_push_test.rb index ef162284..1b1df3d5 100644 --- a/test/unit/bzr_push_test.rb +++ b/test/unit/bzr_push_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrPushTest < Scm::Test + class BzrPushTest < OhlohScm::Test def test_hostname assert !BzrAdapter.new.hostname @@ -36,7 +36,7 @@ def test_bzr_path def test_push with_bzr_repository('bzr') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = BzrAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/bzr_validation_test.rb b/test/unit/bzr_validation_test.rb index 10e488dc..c4f2d201 100644 --- a/test/unit/bzr_validation_test.rb +++ b/test/unit/bzr_validation_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrValidationTest < Scm::Test + class BzrValidationTest < OhlohScm::Test def test_rejected_urls [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", "www.selenic.com/repo/hello", # missing a protool prefix @@ -21,8 +21,8 @@ def test_accepted_urls "http://www.selenic.com:80/repo/hello", "https://www.selenic.com/repo/hello", "bzr://www.selenic.com/repo/hello", - "lp:foobar", - "lp:~foobar/bar", + "lp:foobar", + "lp:~foobar/bar", ].each do |url| bzr = BzrAdapter.new(:url => url, :public_urls_only => true) assert !bzr.validate_url diff --git a/test/unit/bzr_xml_parser_test.rb b/test/unit/bzr_xml_parser_test.rb index 9a50e3fc..04049cd8 100644 --- a/test/unit/bzr_xml_parser_test.rb +++ b/test/unit/bzr_xml_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class BzrXmlParserTest < Scm::Test + class BzrXmlParserTest < OhlohScm::Test def test_empty_array assert_equal([], BzrXmlParser.parse('')) @@ -10,7 +10,7 @@ def test_empty_array def test_empty_xml assert_equal("\n\n\n", BzrXmlParser.parse('', :writer => XmlWriter.new)) end - + def test_basic_xml xml = <<-XML @@ -31,7 +31,7 @@ def test_basic_xml commits = BzrXmlParser.parse(xml) assert_equal 1, commits.size c = commits.first - assert_equal 0, c.diffs.size + assert_equal 0, c.diffs.size assert_equal "Renamed test1.txt to subdir/test_b.txt, removed test2.txt and added test_a.txt.", c.message assert_equal "test@example.com-20110725174345-brbpkwumeh07aoh8", c.token end @@ -71,7 +71,7 @@ def test_verbose_xml assert_equal "test2.txt", c.diffs[0].path assert_equal "D", c.diffs[0].action - + assert_equal "test_a.txt", c.diffs[1].path assert_equal "A", c.diffs[1].action @@ -83,9 +83,9 @@ def test_verbose_xml end # When an directory is deleted, bzr outputs one delete entry - # per file and one for the directory. For empty dirs, there - # is only one directory remove entry. - # Ohloh keeps file delete entries but ignores directory + # per file and one for the directory. For empty dirs, there + # is only one directory remove entry. + # Ohloh keeps file delete entries but ignores directory # delete entry. def test_ignore_dir_delete_xml xml = <<-XML @@ -114,7 +114,7 @@ def test_ignore_dir_delete_xml XML commits = BzrXmlParser.parse(xml) assert_equal 1, commits.size - + c = commits.first assert_equal 1, c.diffs.size assert_equal "uspace/lib/net/include/nil_interface.h", c.diffs.first.path @@ -243,12 +243,12 @@ def test_different_author_and_committer assert_equal "test", c.committer_name assert_equal "test@example.com", c.committer_email assert_equal nil, c.author_name - assert_equal nil, c.author_email + assert_equal nil, c.author_email end def test_rename xml = <<-XML - + 10 test@example.com-20110725174345-brbpkwumeh07aoh8 @@ -265,7 +265,7 @@ def test_rename - + XML commits = BzrXmlParser.parse(xml) assert_equal 1, commits.size @@ -278,21 +278,21 @@ def test_rename end def test_remove_dupes_add_remove - diffs = BzrXmlParser.remove_dupes([ Scm::Diff.new(:action => "A", :path => "foo"), - Scm::Diff.new(:action => "D", :path => "foo") ]) + diffs = BzrXmlParser.remove_dupes([ OhlohScm::Diff.new(:action => "A", :path => "foo"), + OhlohScm::Diff.new(:action => "D", :path => "foo") ]) assert_equal 1, diffs.size assert_equal 'M', diffs.first.action assert_equal 'foo', diffs.first.path - end + end - # A complex delete/rename/modify test. - # Removed test_a.txt, Renamed test3.txt to test_a.txt, edited test_a.txt - # + # A complex delete/rename/modify test. + # Removed test_a.txt, Renamed test3.txt to test_a.txt, edited test_a.txt + # # This is what Ohloh expects to see: - # - # D test3.txt + # + # D test3.txt # M test_a.txt - # + # def test_complex_rename xml = <<-XML diff --git a/test/unit/bzrlib_cat_file_test.rb b/test/unit/bzrlib_cat_file_test.rb index 2d02329d..3579606b 100644 --- a/test/unit/bzrlib_cat_file_test.rb +++ b/test/unit/bzrlib_cat_file_test.rb @@ -2,7 +2,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrlibCatFileTest < Scm::Test + class BzrlibCatFileTest < OhlohScm::Test def test_cat_file with_bzrlib_repository('bzr') do |bzr| @@ -11,12 +11,12 @@ def test_cat_file second line EXPECTED assert_equal expected, - bzr.cat_file(Scm::Commit::new(:token => 6), - Scm::Diff.new(:path => "file1.txt")) + bzr.cat_file(OhlohScm::Commit::new(:token => 6), + OhlohScm::Diff.new(:path => "file1.txt")) # file2.txt has been removed in commit #5 assert_equal nil, bzr.cat_file(bzr.head, - Scm::Diff.new(:path => "file2.txt")) + OhlohScm::Diff.new(:path => "file2.txt")) end end @@ -27,8 +27,8 @@ def test_cat_file_non_ascii_name second line EXPECTED assert_equal expected, - bzr.cat_file(Scm::Commit::new(:token => 7), - Scm::Diff.new(:path => "Cédric.txt")) + bzr.cat_file(OhlohScm::Commit::new(:token => 7), + OhlohScm::Diff.new(:path => "Cédric.txt")) end end @@ -39,16 +39,16 @@ def test_cat_file_parent second line EXPECTED assert_equal expected, - bzr.cat_file_parent(Scm::Commit::new(:token => 6), - Scm::Diff.new(:path => "file1.txt")) + bzr.cat_file_parent(OhlohScm::Commit::new(:token => 6), + OhlohScm::Diff.new(:path => "file1.txt")) # file2.txt has been removed in commit #5 expected = <<-EXPECTED another file EXPECTED assert_equal expected, - bzr.cat_file_parent(Scm::Commit.new(:token => 5), - Scm::Diff.new(:path => "file2.txt")) + bzr.cat_file_parent(OhlohScm::Commit.new(:token => 5), + OhlohScm::Diff.new(:path => "file2.txt")) end end diff --git a/test/unit/bzrlib_head_test.rb b/test/unit/bzrlib_head_test.rb index a9831dc6..12e4268d 100644 --- a/test/unit/bzrlib_head_test.rb +++ b/test/unit/bzrlib_head_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class BzrBzrlibHeadTest < Scm::Test + class BzrBzrlibHeadTest < OhlohScm::Test def test_head_and_parents with_bzrlib_repository('bzr') do |bzr| diff --git a/test/unit/cvs_branch_number_test.rb b/test/unit/cvs_branch_number_test.rb index 17cf3aea..4b5df6ee 100644 --- a/test/unit/cvs_branch_number_test.rb +++ b/test/unit/cvs_branch_number_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class CvsBranchNumberTest < Scm::Test + class CvsBranchNumberTest < OhlohScm::Test def test_basic assert_equal [1,1], BranchNumber.new('1.1').to_a assert_equal [1234,1234], BranchNumber.new('1234.1234').to_a diff --git a/test/unit/cvs_commits_test.rb b/test/unit/cvs_commits_test.rb index 4a2e92f7..b2013804 100644 --- a/test/unit/cvs_commits_test.rb +++ b/test/unit/cvs_commits_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class CvsCommitsTest < Scm::Test + class CvsCommitsTest < OhlohScm::Test def test_commits with_cvs_repository('cvs', 'simple') do |cvs| diff --git a/test/unit/cvs_convert_test.rb b/test/unit/cvs_convert_test.rb index 80550928..4f8550b1 100644 --- a/test/unit/cvs_convert_test.rb +++ b/test/unit/cvs_convert_test.rb @@ -1,11 +1,11 @@ require_relative '../test_helper' module OhlohScm::Adapters - class CvsConvertTest < Scm::Test + class CvsConvertTest < OhlohScm::Test def test_basic_convert with_cvs_repository('cvs', 'simple') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = GitAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/cvs_misc_test.rb b/test/unit/cvs_misc_test.rb index fa6d2d03..a2d202ec 100644 --- a/test/unit/cvs_misc_test.rb +++ b/test/unit/cvs_misc_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class CvsMiscTest < Scm::Test + class CvsMiscTest < OhlohScm::Test def test_local_directory_trim r = CvsAdapter.new(:url => "/Users/robin/cvs_repo/", :module_name => "simple") assert_equal "/Users/robin/cvs_repo/simple/foo.rb", r.trim_directory('/Users/robin/cvs_repo/simple/foo.rb') diff --git a/test/unit/cvs_parser_test.rb b/test/unit/cvs_parser_test.rb index 33dc473b..2af1c97d 100644 --- a/test/unit/cvs_parser_test.rb +++ b/test/unit/cvs_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class CvsParserTest < Scm::Test + class CvsParserTest < OhlohScm::Test def test_basic assert_convert(CvsParser, DATA_DIR + '/basic.rlog', DATA_DIR + '/basic.ohlog') diff --git a/test/unit/cvs_validation_test.rb b/test/unit/cvs_validation_test.rb index 6d12c43f..1f04a63b 100644 --- a/test/unit/cvs_validation_test.rb +++ b/test/unit/cvs_validation_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class CvsValidationTest < Scm::Test + class CvsValidationTest < OhlohScm::Test def test_rejected_urls [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", ":pserver", # that's not enough diff --git a/test/unit/git_cat_file_test.rb b/test/unit/git_cat_file_test.rb index 7186af27..900c8561 100644 --- a/test/unit/git_cat_file_test.rb +++ b/test/unit/git_cat_file_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitCatFileTest < Scm::Test + class GitCatFileTest < OhlohScm::Test def test_cat_file with_git_repository('git') do |git| @@ -13,7 +13,7 @@ def test_cat_file printf("Hello, World!\\n"); } EXPECTED - assert_equal expected, git.cat_file(nil, Scm::Diff.new(:sha1 => '4c734ad53b272c9b3d719f214372ac497ff6c068')) + assert_equal expected, git.cat_file(nil, OhlohScm::Diff.new(:sha1 => '4c734ad53b272c9b3d719f214372ac497ff6c068')) end end diff --git a/test/unit/git_commit_all_test.rb b/test/unit/git_commit_all_test.rb index cf1e766c..e9944eee 100644 --- a/test/unit/git_commit_all_test.rb +++ b/test/unit/git_commit_all_test.rb @@ -1,10 +1,10 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitCommitAllTest < Scm::Test + class GitCommitAllTest < OhlohScm::Test def test_commit_all - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| git = GitAdapter.new(:url => dir).normalize git.init_db @@ -13,7 +13,7 @@ def test_commit_all File.open(File.join(dir, 'README'), 'w') {} assert git.anything_to_commit? - c = Scm::Commit.new + c = OhlohScm::Commit.new c.author_name = "John Q. Developer" c.message = "Initial checkin." git.commit_all(c) diff --git a/test/unit/git_commits_test.rb b/test/unit/git_commits_test.rb index 96008088..e12f0e22 100644 --- a/test/unit/git_commits_test.rb +++ b/test/unit/git_commits_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitCommitsTest < Scm::Test + class GitCommitsTest < OhlohScm::Test def test_commit_count with_git_repository('git') do |git| diff --git a/test/unit/git_head_test.rb b/test/unit/git_head_test.rb index 93c5f44d..e193bd99 100644 --- a/test/unit/git_head_test.rb +++ b/test/unit/git_head_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitHeadTest < Scm::Test + class GitHeadTest < OhlohScm::Test def test_head_and_parents with_git_repository('git') do |git| diff --git a/test/unit/git_log_parser_test.rb b/test/unit/git_log_parser_test.rb index 477e1724..f1f3554b 100644 --- a/test/unit/git_log_parser_test.rb +++ b/test/unit/git_log_parser_test.rb @@ -2,7 +2,7 @@ require 'date' module OhlohScm::Parsers - class GitStyledParserTest < Scm::Test + class GitStyledParserTest < OhlohScm::Test def test_basic commits = [] @@ -187,7 +187,7 @@ def test_use_email_when_names_are_missing __BEGIN_COMMIT__ Commit: fa3ee9d4cefc2db81adadf36da9cacbe92ce96f1 -Author: +Author: AuthorEmail: mickeyl@openembedded.org Date: Wed, 11 Jun 2008 00:37:06 +0000 __BEGIN_COMMENT__ diff --git a/test/unit/git_misc_test.rb b/test/unit/git_misc_test.rb index 377949ab..9b74de35 100644 --- a/test/unit/git_misc_test.rb +++ b/test/unit/git_misc_test.rb @@ -1,11 +1,11 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitMiscTest < Scm::Test + class GitMiscTest < OhlohScm::Test def test_export with_git_repository('git') do |git| - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| git.export(dir) assert_equal ['.','..','.gitignore','COPYING','README','helloworld.c','makefile','ohloh_token'], Dir.entries(dir).sort end @@ -27,8 +27,8 @@ def test_ls_tree def test_is_merge_commit with_git_repository('git_walk') do |git| - assert git.is_merge_commit?(Scm::Commit.new(:token => 'f264fb40c340a415b305ac1f0b8f12502aa2788f')) - assert !git.is_merge_commit?(Scm::Commit.new(:token => 'd067161caae2eeedbd74976aeff5c4d8f1ccc946')) + assert git.is_merge_commit?(OhlohScm::Commit.new(:token => 'f264fb40c340a415b305ac1f0b8f12502aa2788f')) + assert !git.is_merge_commit?(OhlohScm::Commit.new(:token => 'd067161caae2eeedbd74976aeff5c4d8f1ccc946')) end end diff --git a/test/unit/git_parser_test.rb b/test/unit/git_parser_test.rb index d37d04dc..5e029c69 100644 --- a/test/unit/git_parser_test.rb +++ b/test/unit/git_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class GitParserTest < Scm::Test + class GitParserTest < OhlohScm::Test def test_empty_array assert_equal([], GitParser.parse('')) diff --git a/test/unit/git_patch_test.rb b/test/unit/git_patch_test.rb index 65d0283c..bdcda499 100644 --- a/test/unit/git_patch_test.rb +++ b/test/unit/git_patch_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitPatchTest < Scm::Test + class GitPatchTest < OhlohScm::Test def test_patch_for_commit with_git_repository('git') do |repo| commit = repo.verbose_commit('b6e9220c3cabe53a4ed7f32952aeaeb8a822603d') diff --git a/test/unit/git_pull_test.rb b/test/unit/git_pull_test.rb index 780e7a1b..21d0bfea 100644 --- a/test/unit/git_pull_test.rb +++ b/test/unit/git_pull_test.rb @@ -1,11 +1,11 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitPullTest < Scm::Test + class GitPullTest < OhlohScm::Test def test_basic_pull with_git_repository('git') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = GitAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/git_push_test.rb b/test/unit/git_push_test.rb index 45d58ee6..973992c3 100644 --- a/test/unit/git_push_test.rb +++ b/test/unit/git_push_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitPushTest < Scm::Test + class GitPushTest < OhlohScm::Test def test_hostname assert_equal "foo", GitAdapter.new(:url => 'foo:/bar').hostname @@ -23,7 +23,7 @@ def test_local def test_basic_push with_git_repository('git') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = GitAdapter.new(:url => dest_dir).normalize assert !dest.exist? @@ -34,7 +34,7 @@ def test_basic_push # Now push again. This tests a different code path! File.open(File.join(src.url, 'foo'), 'w') { } - src.commit_all(Scm::Commit.new) + src.commit_all(OhlohScm::Commit.new) src.push(dest) assert dest.exist? diff --git a/test/unit/git_rev_list_test.rb b/test/unit/git_rev_list_test.rb index 8034026f..e4c6ed77 100644 --- a/test/unit/git_rev_list_test.rb +++ b/test/unit/git_rev_list_test.rb @@ -7,7 +7,7 @@ module OhlohScm::Adapters # / \ \ # A -> B -> C -> D -> master # - class GitRevListTest < Scm::Test + class GitRevListTest < OhlohScm::Test def test_rev_list with_git_repository('git_walk') do |git| diff --git a/test/unit/git_styled_parser_test.rb b/test/unit/git_styled_parser_test.rb index 5d630dc1..afe9fdc6 100644 --- a/test/unit/git_styled_parser_test.rb +++ b/test/unit/git_styled_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class GitStyledParserTest < Scm::Test + class GitStyledParserTest < OhlohScm::Test def test_empty_array assert_equal([], GitStyledParser.parse('')) @@ -13,13 +13,13 @@ def test_log_parser_nil_date Commit: 1df547800dcd168e589bb9b26b4039bff3a7f7e4 Author: Jason Allen AuthorEmail: jason@ohloh.net -Date: +Date: __BEGIN_COMMENT__ moving COPYING __END_COMMENT__ SAMPLE - + commits = GitStyledParser.parse(sample_log) assert_equal 1, commits.size assert_equal Time.utc(1970,1,1,0,0,0), commits[0].author_date @@ -37,7 +37,7 @@ def test_log_parser_bogus_date __END_COMMENT__ SAMPLE - + commits = GitStyledParser.parse(sample_log) assert_equal 1, commits.size assert_equal Time.utc(1970,1,1,0,0,0), commits[0].author_date diff --git a/test/unit/git_token_test.rb b/test/unit/git_token_test.rb index 6d5c41bf..5161a4cc 100644 --- a/test/unit/git_token_test.rb +++ b/test/unit/git_token_test.rb @@ -1,10 +1,10 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitTokenTest < Scm::Test + class GitTokenTest < OhlohScm::Test def test_no_token_returns_nil - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| git = GitAdapter.new(:url => dir).normalize assert !git.read_token git.init_db @@ -13,21 +13,21 @@ def test_no_token_returns_nil end def test_write_and_read_token - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| git = GitAdapter.new(:url => dir).normalize git.init_db git.write_token("FOO") assert !git.read_token # Token not valid until committed - git.commit_all(Scm::Commit.new) + git.commit_all(OhlohScm::Commit.new) assert_equal "FOO", git.read_token end end def test_commit_all_includes_write_token - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| git = GitAdapter.new(:url => dir).normalize git.init_db - c = Scm::Commit.new + c = OhlohScm::Commit.new c.token = "BAR" git.commit_all(c) assert_equal c.token, git.read_token diff --git a/test/unit/git_validation_test.rb b/test/unit/git_validation_test.rb index 8b526f4f..b7492e8d 100644 --- a/test/unit/git_validation_test.rb +++ b/test/unit/git_validation_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class GitValidationTest < Scm::Test + class GitValidationTest < OhlohScm::Test def test_rejected_urls [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", "kernel.org/linux/linux.git", # missing a protocol prefix diff --git a/test/unit/hg_cat_file_test.rb b/test/unit/hg_cat_file_test.rb index c85d6e82..efc374d6 100644 --- a/test/unit/hg_cat_file_test.rb +++ b/test/unit/hg_cat_file_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgCatFileTest < Scm::Test + class HgCatFileTest < OhlohScm::Test def test_cat_file with_hg_repository('hg') do |hg| @@ -21,15 +21,15 @@ def test_cat_file EXPECTED # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. - assert_equal nil, hg.cat_file(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, hg.cat_file_parent(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, hg.cat_file(Scm::Commit.new(:token => '468336c6671c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal nil, hg.cat_file(OhlohScm::Commit.new(:token => '75532c1e1f1d'), OhlohScm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, hg.cat_file_parent(OhlohScm::Commit.new(:token => '75532c1e1f1d'), OhlohScm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, hg.cat_file(OhlohScm::Commit.new(:token => '468336c6671c'), OhlohScm::Diff.new(:path => 'helloworld.c')) end end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename def test_funny_file_name_chars - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '#|file_name` $(&\'")#' File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } @@ -39,7 +39,7 @@ def test_funny_file_name_chars # Confirm that we can read the file back hg = HgAdapter.new(:url => dir).normalize - assert_equal "contents", hg.cat_file(hg.head, Scm::Diff.new(:path => funny_name)) + assert_equal "contents", hg.cat_file(hg.head, OhlohScm::Diff.new(:path => funny_name)) end end diff --git a/test/unit/hg_commits_test.rb b/test/unit/hg_commits_test.rb index 86fdc4b3..bff9ad3c 100644 --- a/test/unit/hg_commits_test.rb +++ b/test/unit/hg_commits_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgCommitsTest < Scm::Test + class HgCommitsTest < OhlohScm::Test def test_commit_count with_hg_repository('hg') do |hg| diff --git a/test/unit/hg_head_test.rb b/test/unit/hg_head_test.rb index cefccbd6..915168ee 100644 --- a/test/unit/hg_head_test.rb +++ b/test/unit/hg_head_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgHeadTest < Scm::Test + class HgHeadTest < OhlohScm::Test def test_head_and_parents with_hg_repository('hg') do |hg| diff --git a/test/unit/hg_misc_test.rb b/test/unit/hg_misc_test.rb index 2916e403..53fccf1c 100644 --- a/test/unit/hg_misc_test.rb +++ b/test/unit/hg_misc_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgMiscTest < Scm::Test + class HgMiscTest < OhlohScm::Test def test_exist save_hg = nil @@ -20,7 +20,7 @@ def test_ls_tree def test_export with_hg_repository('hg') do |hg| - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| hg.export(dir) assert_equal ['.', '..', 'README', 'makefile'], Dir.entries(dir).sort end diff --git a/test/unit/hg_parser_test.rb b/test/unit/hg_parser_test.rb index f7230ca9..93cdf8e9 100644 --- a/test/unit/hg_parser_test.rb +++ b/test/unit/hg_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class HgParserTest < Scm::Test + class HgParserTest < OhlohScm::Test def test_empty_array assert_equal([], HgParser.parse('')) diff --git a/test/unit/hg_patch_test.rb b/test/unit/hg_patch_test.rb index 95745390..8673244f 100644 --- a/test/unit/hg_patch_test.rb +++ b/test/unit/hg_patch_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgPatchTest < Scm::Test + class HgPatchTest < OhlohScm::Test def test_patch_for_commit with_hg_repository('hg') do |repo| commit = repo.verbose_commit(1) diff --git a/test/unit/hg_pull_test.rb b/test/unit/hg_pull_test.rb index 475d8ff1..33bafdb2 100644 --- a/test/unit/hg_pull_test.rb +++ b/test/unit/hg_pull_test.rb @@ -1,11 +1,11 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgPullTest < Scm::Test + class HgPullTest < OhlohScm::Test def test_pull with_hg_repository('hg') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = HgAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/hg_push_test.rb b/test/unit/hg_push_test.rb index f2e898b5..65069c84 100644 --- a/test/unit/hg_push_test.rb +++ b/test/unit/hg_push_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgPushTest < Scm::Test + class HgPushTest < OhlohScm::Test def test_hostname assert !HgAdapter.new.hostname @@ -36,7 +36,7 @@ def test_hg_path def test_push with_hg_repository('hg') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = HgAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/hg_rev_list_test.rb b/test/unit/hg_rev_list_test.rb index 7d699131..6529a74b 100644 --- a/test/unit/hg_rev_list_test.rb +++ b/test/unit/hg_rev_list_test.rb @@ -7,7 +7,7 @@ module OhlohScm::Adapters # / \ \ # A -> B -> C -> D -> tip # - class HgRevListTest < Scm::Test + class HgRevListTest < OhlohScm::Test def test_rev_list with_hg_repository('hg_walk') do |hg| diff --git a/test/unit/hg_validation_test.rb b/test/unit/hg_validation_test.rb index ea257179..517d5490 100644 --- a/test/unit/hg_validation_test.rb +++ b/test/unit/hg_validation_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgValidationTest < Scm::Test + class HgValidationTest < OhlohScm::Test def test_rejected_urls [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", "www.selenic.com/repo/hello", # missing a protool prefix diff --git a/test/unit/hglib_cat_file_test.rb b/test/unit/hglib_cat_file_test.rb index dcb194a5..19fa4f08 100644 --- a/test/unit/hglib_cat_file_test.rb +++ b/test/unit/hglib_cat_file_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HglibCatFileTest < Scm::Test + class HglibCatFileTest < OhlohScm::Test def test_cat_file with_hglib_repository('hg') do |hg| @@ -21,15 +21,15 @@ def test_cat_file EXPECTED # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. - assert_equal nil, hg.cat_file(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, hg.cat_file_parent(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, hg.cat_file(Scm::Commit.new(:token => '468336c6671c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal nil, hg.cat_file(OhlohScm::Commit.new(:token => '75532c1e1f1d'), OhlohScm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, hg.cat_file_parent(OhlohScm::Commit.new(:token => '75532c1e1f1d'), OhlohScm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, hg.cat_file(OhlohScm::Commit.new(:token => '468336c6671c'), OhlohScm::Diff.new(:path => 'helloworld.c')) end end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename def test_funny_file_name_chars - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '#|file_name` $(&\'")#' File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } @@ -39,7 +39,7 @@ def test_funny_file_name_chars # Confirm that we can read the file back hg = HglibAdapter.new(:url => dir).normalize - assert_equal "contents", hg.cat_file(hg.head, Scm::Diff.new(:path => funny_name)) + assert_equal "contents", hg.cat_file(hg.head, OhlohScm::Diff.new(:path => funny_name)) end end diff --git a/test/unit/hglib_head_test.rb b/test/unit/hglib_head_test.rb index e7c85541..12aea8a1 100644 --- a/test/unit/hglib_head_test.rb +++ b/test/unit/hglib_head_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class HgHeadTest < Scm::Test + class HgHeadTest < OhlohScm::Test def test_head_and_parents with_hglib_repository('hg') do |hg| diff --git a/test/unit/ohlog_command_line_test.rb b/test/unit/ohlog_command_line_test.rb index 48fa9402..34f3724e 100644 --- a/test/unit/ohlog_command_line_test.rb +++ b/test/unit/ohlog_command_line_test.rb @@ -1,5 +1,5 @@ module OhlohScm::Parsers - class CommandLineTest < Scm::Test + class CommandLineTest < OhlohScm::Test def test_cvs_from_file result = `#{File.dirname(__FILE__) + '/../../bin/ohlog'} --xml --cvs #{DATA_DIR + '/basic.rlog'}` assert_equal 0, $? diff --git a/test/unit/shellout_test.rb b/test/unit/shellout_test.rb index dd8d4f27..c007d9a5 100644 --- a/test/unit/shellout_test.rb +++ b/test/unit/shellout_test.rb @@ -1,6 +1,6 @@ require_relative '../test_helper' -class ShelloutTest < Scm::Test +class ShelloutTest < OhlohScm::Test def test_execute_must_pipe_the_results_accurately status, out, err = Shellout.execute("ruby -e 'puts %[hello world]; STDERR.puts(%[some error])'") diff --git a/test/unit/string_encoder_command_line_test.rb b/test/unit/string_encoder_command_line_test.rb index 5db7538d..adecd81d 100644 --- a/test/unit/string_encoder_command_line_test.rb +++ b/test/unit/string_encoder_command_line_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class StringEncoderCommandLineTest < Scm::Test + class StringEncoderCommandLineTest < OhlohScm::Test def test_length_of_content_unchanged file_path = File.expand_path('../../data/sample-content', __FILE__) original_content_length = File.size(file_path) diff --git a/test/unit/svn_cat_file_test.rb b/test/unit/svn_cat_file_test.rb index f65c0ee6..b82cafc9 100644 --- a/test/unit/svn_cat_file_test.rb +++ b/test/unit/svn_cat_file_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnCatFileTest < Scm::Test + class SvnCatFileTest < OhlohScm::Test def test_cat_file with_svn_repository('svn') do |svn| @@ -13,9 +13,9 @@ def test_cat_file printf("Hello, World!\\n"); } EXPECTED - assert_equal expected, svn.cat_file(Scm::Commit.new(:token => 1), Scm::Diff.new(:path => "trunk/helloworld.c")) + assert_equal expected, svn.cat_file(OhlohScm::Commit.new(:token => 1), OhlohScm::Diff.new(:path => "trunk/helloworld.c")) - assert_equal nil, svn.cat_file(Scm::Commit.new(:token => 1), Scm::Diff.new(:path => "file not found")) + assert_equal nil, svn.cat_file(OhlohScm::Commit.new(:token => 1), OhlohScm::Diff.new(:path => "file not found")) end end end diff --git a/test/unit/svn_chain_cat_file_test.rb b/test/unit/svn_chain_cat_file_test.rb index 08e6139c..9dc1137e 100644 --- a/test/unit/svn_chain_cat_file_test.rb +++ b/test/unit/svn_chain_cat_file_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnChainCatFileTest < Scm::Test + class SvnChainCatFileTest < OhlohScm::Test def test_cat_file_with_chaining goodbye = <<-EXPECTED @@ -13,11 +13,11 @@ def test_cat_file_with_chaining EXPECTED with_svn_chain_repository('svn_with_branching', '/trunk') do |svn| # The first case asks for the file on the HEAD, so it should easily be found - assert_equal goodbye, svn.cat_file(Scm::Commit.new(:token => 8), Scm::Diff.new(:path => "goodbyeworld.c")) + assert_equal goodbye, svn.cat_file(OhlohScm::Commit.new(:token => 8), OhlohScm::Diff.new(:path => "goodbyeworld.c")) # The next test asks for the file as it appeared before /branches/development was moved to /trunk, # so this request requires traversal up the chain to the parent SvnAdapter. - assert_equal goodbye, svn.cat_file(Scm::Commit.new(:token => 5), Scm::Diff.new(:path => "goodbyeworld.c")) + assert_equal goodbye, svn.cat_file(OhlohScm::Commit.new(:token => 5), OhlohScm::Diff.new(:path => "goodbyeworld.c")) end end end diff --git a/test/unit/svn_chain_commits_test.rb b/test/unit/svn_chain_commits_test.rb index 52e9d0c7..5a17f7eb 100644 --- a/test/unit/svn_chain_commits_test.rb +++ b/test/unit/svn_chain_commits_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class SvnChainTest < Scm::Test + class SvnChainTest < OhlohScm::Test def test_chained_commit_tokens with_svn_chain_repository('svn_with_branching', '/trunk') do |svn| diff --git a/test/unit/svn_chain_test.rb b/test/unit/svn_chain_test.rb index d646e73a..bf15b627 100644 --- a/test/unit/svn_chain_test.rb +++ b/test/unit/svn_chain_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class SvnChainTest < Scm::Test + class SvnChainTest < OhlohScm::Test def test_chain with_svn_chain_repository('svn_with_branching', '/trunk') do |svn| @@ -54,7 +54,7 @@ def test_parent_svn def test_parent_branch_name svn = OhlohScm::Adapters::SvnChainAdapter.new(:branch_name => "/trunk") - assert_equal "/branches/b", svn.parent_branch_name(Scm::Diff.new(:action => 'A', + assert_equal "/branches/b", svn.parent_branch_name(OhlohScm::Diff.new(:action => 'A', :path => "/trunk", :from_revision => 1, :from_path => "/branches/b")) end diff --git a/test/unit/svn_commits_test.rb b/test/unit/svn_commits_test.rb index 2deb521d..c6758594 100644 --- a/test/unit/svn_commits_test.rb +++ b/test/unit/svn_commits_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnCommitsTest < Scm::Test + class SvnCommitsTest < OhlohScm::Test def test_commits with_svn_repository('svn') do |svn| @@ -32,8 +32,8 @@ def test_sha1 # Given a commit with diffs, fill in all of the SHA1 values. def test_populate_sha1 with_svn_repository('svn') do |svn| - c = Scm::Commit.new(:token => 3) - c.diffs = [Scm::Diff.new(:path => "/trunk/helloworld.c", :action => "M")] + c = OhlohScm::Commit.new(:token => 3) + c.diffs = [OhlohScm::Diff.new(:path => "/trunk/helloworld.c", :action => "M")] svn.populate_commit_sha1s!(c) assert_equal 'f6adcae4447809b651c787c078d255b2b4e963c5', c.diffs.first.sha1 assert_equal '4c734ad53b272c9b3d719f214372ac497ff6c068', c.diffs.first.parent_sha1 @@ -42,7 +42,7 @@ def test_populate_sha1 def test_strip_commit_branch svn = SvnAdapter.new(:branch_name => "/trunk") - commit = Scm::Commit.new + commit = OhlohScm::Commit.new # nil diffs before => nil diffs after assert !svn.strip_commit_branch(commit).diffs @@ -52,19 +52,19 @@ def test_strip_commit_branch assert_equal [], svn.strip_commit_branch(commit).diffs commit.diffs = [ - Scm::Diff.new(:path => "/trunk"), - Scm::Diff.new(:path => "/trunk/helloworld.c"), - Scm::Diff.new(:path => "/branches/a") + OhlohScm::Diff.new(:path => "/trunk"), + OhlohScm::Diff.new(:path => "/trunk/helloworld.c"), + OhlohScm::Diff.new(:path => "/branches/a") ] assert_equal ['', '/helloworld.c'], svn.strip_commit_branch(commit).diffs.collect { |d| d.path }.sort end def test_strip_diff_branch svn = SvnAdapter.new(:branch_name => "/trunk") - assert !svn.strip_diff_branch(Scm::Diff.new) - assert !svn.strip_diff_branch(Scm::Diff.new(:path => "/branches/b")) - assert_equal '', svn.strip_diff_branch(Scm::Diff.new(:path => "/trunk")).path - assert_equal '/helloworld.c', svn.strip_diff_branch(Scm::Diff.new(:path => "/trunk/helloworld.c")).path + assert !svn.strip_diff_branch(OhlohScm::Diff.new) + assert !svn.strip_diff_branch(OhlohScm::Diff.new(:path => "/branches/b")) + assert_equal '', svn.strip_diff_branch(OhlohScm::Diff.new(:path => "/trunk")).path + assert_equal '/helloworld.c', svn.strip_diff_branch(OhlohScm::Diff.new(:path => "/trunk/helloworld.c")).path end def test_strip_path_branch @@ -88,8 +88,8 @@ def test_strip_path_branch_with_special_chars def test_remove_dupes_add_modify svn = SvnAdapter.new - c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "A", :path => "foo"), - Scm::Diff.new(:action => "M", :path => "foo") ]) + c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "A", :path => "foo"), + OhlohScm::Diff.new(:action => "M", :path => "foo") ]) svn.remove_dupes(c) assert_equal 1, c.diffs.size @@ -98,8 +98,8 @@ def test_remove_dupes_add_modify def test_remove_dupes_add_replace svn = SvnAdapter.new - c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "R", :path => "foo"), - Scm::Diff.new(:action => "A", :path => "foo") ]) + c = OhlohScm::Commit.new(:diffs => [ OhlohScm::Diff.new(:action => "R", :path => "foo"), + OhlohScm::Diff.new(:action => "A", :path => "foo") ]) svn.remove_dupes(c) assert_equal 1, c.diffs.size diff --git a/test/unit/svn_convert_test.rb b/test/unit/svn_convert_test.rb index 08a3fca1..a8153d76 100644 --- a/test/unit/svn_convert_test.rb +++ b/test/unit/svn_convert_test.rb @@ -1,10 +1,10 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnConvertTest < Scm::Test + class SvnConvertTest < OhlohScm::Test def test_basic_convert with_svn_repository('svn') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = GitAdapter.new(:url => dest_dir).normalize assert !dest.exist? diff --git a/test/unit/svn_head_test.rb b/test/unit/svn_head_test.rb index 30499ff3..2b94e782 100644 --- a/test/unit/svn_head_test.rb +++ b/test/unit/svn_head_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnHeadTest < Scm::Test + class SvnHeadTest < OhlohScm::Test def test_head_and_parents with_svn_repository('svn') do |svn| diff --git a/test/unit/svn_misc_test.rb b/test/unit/svn_misc_test.rb index 3f3cece8..0894f765 100644 --- a/test/unit/svn_misc_test.rb +++ b/test/unit/svn_misc_test.rb @@ -1,11 +1,11 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnMiscTest < Scm::Test + class SvnMiscTest < OhlohScm::Test def test_export with_svn_repository('svn') do |svn| - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| svn.export(dir) assert_equal ['.','..','branches','tags','trunk'], Dir.entries(dir).sort end diff --git a/test/unit/svn_parser_test.rb b/test/unit/svn_parser_test.rb index c50cafa6..83609fa4 100644 --- a/test/unit/svn_parser_test.rb +++ b/test/unit/svn_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class SvnParserTest < Scm::Test + class SvnParserTest < OhlohScm::Test def test_basic assert_convert(SvnParser, DATA_DIR + '/simple.svn_log', DATA_DIR + '/simple.ohlog') diff --git a/test/unit/svn_patch_test.rb b/test/unit/svn_patch_test.rb index eda5b35e..301aea05 100644 --- a/test/unit/svn_patch_test.rb +++ b/test/unit/svn_patch_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnPatchTest < Scm::Test + class SvnPatchTest < OhlohScm::Test def test_patch_for_commit with_svn_repository('svn') do |repo| commit = repo.verbose_commit(2) diff --git a/test/unit/svn_pull_test.rb b/test/unit/svn_pull_test.rb index 7341f21d..91985079 100644 --- a/test/unit/svn_pull_test.rb +++ b/test/unit/svn_pull_test.rb @@ -2,10 +2,10 @@ require 'socket' module OhlohScm::Adapters - class SvnPullTest < Scm::Test + class SvnPullTest < OhlohScm::Test def test_svnadmin_create - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| url = File.join(dir, "my_svn_repo") svn = SvnAdapter.new(:url => url).normalize @@ -22,7 +22,7 @@ def test_svnadmin_create def test_basic_pull_using_svnsync with_svn_repository('svn') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = SvnAdapter.new(:url => dest_dir).normalize assert !dest.exist? @@ -36,7 +36,7 @@ def test_basic_pull_using_svnsync end def test_svnadmin_create_local - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| svn = SvnAdapter.new(:url => "file://#{dir}") svn.svnadmin_create_local assert svn.exist? @@ -47,7 +47,7 @@ def test_svnadmin_create_local end def test_svnadmin_create_remote - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| svn = SvnAdapter.new(:url => "svn+ssh://#{Socket.gethostname}#{dir}") svn.svnadmin_create_remote assert svn.exist? diff --git a/test/unit/svn_push_test.rb b/test/unit/svn_push_test.rb index fa59ec99..98594265 100644 --- a/test/unit/svn_push_test.rb +++ b/test/unit/svn_push_test.rb @@ -2,11 +2,11 @@ require 'socket' module OhlohScm::Adapters - class SvnPushTest < Scm::Test + class SvnPushTest < OhlohScm::Test def test_basic_push_using_svnsync with_svn_repository('svn') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = SvnAdapter.new(:url => dest_dir).normalize assert !dest.exist? @@ -23,7 +23,7 @@ def test_basic_push_using_svnsync # Simulates pushing to another server in our cluster. def test_ssh_push_using_svnsync with_svn_repository('svn') do |src| - Scm::ScratchDir.new do |dest_dir| + OhlohScm::ScratchDir.new do |dest_dir| dest = SvnAdapter.new(:url => "svn+ssh://#{Socket.gethostname}#{File.expand_path(dest_dir)}").normalize assert !dest.exist? diff --git a/test/unit/svn_validation_test.rb b/test/unit/svn_validation_test.rb index 274b8cfe..f8dc8cf2 100644 --- a/test/unit/svn_validation_test.rb +++ b/test/unit/svn_validation_test.rb @@ -1,13 +1,13 @@ require_relative '../test_helper' module OhlohScm::Adapters - class SvnValidationTest < Scm::Test + class SvnValidationTest < OhlohScm::Test def test_valid_usernames [nil,'','joe_36','a'*32,'robin@ohloh.net'].each do |username| assert !SvnAdapter.new(:username => username).validate_username end end - + def test_for_blank_svn_urls svn = SvnAdapter.new(:url =>"") assert_nil svn.path_to_file_url(svn.url) @@ -167,7 +167,7 @@ def test_strip_trailing_whack_from_branch_name end def test_empty_branch_name_with_file_system - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| svn = SvnAdapter.new(:url => dir).normalize assert_equal '', svn.branch_name end diff --git a/test/unit/svn_xml_parser_test.rb b/test/unit/svn_xml_parser_test.rb index a2bd9f58..ccb9c066 100644 --- a/test/unit/svn_xml_parser_test.rb +++ b/test/unit/svn_xml_parser_test.rb @@ -1,7 +1,7 @@ require_relative '../test_helper' module OhlohScm::Parsers - class SvnXmlParserTest < Scm::Test + class SvnXmlParserTest < OhlohScm::Test def test_basic assert_convert(SvnXmlParser, DATA_DIR + '/simple.svn_xml_log', DATA_DIR + '/simple.ohlog') @@ -14,7 +14,7 @@ def test_empty_array def test_empty_xml assert_equal("\n\n\n", SvnXmlParser.parse('', :writer => XmlWriter.new)) end - + def test_copy_from xml = <<-XML From 7da779e67ba8490de24a64b8ef85af59758f0d4f Mon Sep 17 00:00:00 2001 From: Peter Degen-Portnoy Date: Thu, 16 Oct 2014 11:57:22 +0000 Subject: [PATCH 02/33] Update to version 2.0.1 --- lib/ohloh_scm/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ohloh_scm/version.rb b/lib/ohloh_scm/version.rb index 3e692ad5..37048918 100644 --- a/lib/ohloh_scm/version.rb +++ b/lib/ohloh_scm/version.rb @@ -1,5 +1,5 @@ module OhlohScm module Version - STRING = '2.0.0' + STRING = '2.0.1' end end From 30641e2cfb98db7dc4bfbc868fa6bb394f5d0446 Mon Sep 17 00:00:00 2001 From: santhanakarthikeyan Date: Tue, 12 Apr 2016 00:33:10 +0530 Subject: [PATCH 03/33] Replaced Open3 with Posix-spawn to reduce more process memory usage --- README.md | 7 +++++++ lib/ohloh_scm/shellout.rb | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e9a3adf4..28d9c2a1 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,17 @@ hg 1.1.2 If you are using CVS instead of CVSNT, you can potentially try creating a shell alias or symlink mapping 'cvsnt' to 'cvs'. +Ohloh SCM uses [posix-spawn](https://github.com/rtomayko/posix-spawn) to +execute commands so ensure *posix-spawn* gem is installed + +``gem install posix-spawn`` + + ## Usage with Bundler ``` gem 'ohloh_scm', git: 'https://github.com/blackducksw/ohloh_scm/', require: 'scm' +gem 'posix-spawn' ``` ## Running diff --git a/lib/ohloh_scm/shellout.rb b/lib/ohloh_scm/shellout.rb index 7c49ab38..68fe3775 100644 --- a/lib/ohloh_scm/shellout.rb +++ b/lib/ohloh_scm/shellout.rb @@ -1,6 +1,6 @@ require 'rubygems' require 'stringio' -require 'open3' +require 'posix/spawn' class Shellout @@ -9,9 +9,9 @@ def self.relay src, dst end def self.execute(cmd) - out, err, exit_status = Open3.capture3(cmd) + posix_spawn = POSIX::Spawn::Child.new(cmd) - return exit_status, out, err + return posix_spawn.status, posix_spawn.out, posix_spawn.err end def run(cmd) From 86eb16debec8ce24e459dd8f98b686178c181944 Mon Sep 17 00:00:00 2001 From: santhanakarthikeyan Date: Tue, 12 Apr 2016 19:33:05 +0530 Subject: [PATCH 04/33] Added travis.yml file for installing gem dependencies --- .ruby-version | 1 + .travis.yml | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .ruby-version create mode 100644 .travis.yml diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..227cea21 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.0.0 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..bb0275e7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +language: ruby +install: gem install posix-spawn From bfda2ba1764a2e3a230f6f6b6f01fca9a1077d80 Mon Sep 17 00:00:00 2001 From: santhanakarthikeyan Date: Tue, 12 Apr 2016 19:49:03 +0530 Subject: [PATCH 05/33] Replaced Open4 with posix-spawn gem --- lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb | 4 ++-- lib/ohloh_scm/adapters/hglib/client.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb b/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb index aece32f7..f4ffb2f9 100644 --- a/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb +++ b/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb @@ -1,5 +1,5 @@ require 'rubygems' -require 'open4' +require 'posix/spawn' class BzrPipeClient def initialize(repository_url) @@ -8,7 +8,7 @@ def initialize(repository_url) end def start - @pid, @stdin, @stdout, @stderr = Open4::popen4 "python #{@py_script}" + @pid, @stdin, @stdout, @stderr = POSIX::Spawn::popen4 "python #{@py_script}" open_repository end diff --git a/lib/ohloh_scm/adapters/hglib/client.rb b/lib/ohloh_scm/adapters/hglib/client.rb index 65c414c9..c15a6b9e 100644 --- a/lib/ohloh_scm/adapters/hglib/client.rb +++ b/lib/ohloh_scm/adapters/hglib/client.rb @@ -1,5 +1,5 @@ require 'rubygems' -require 'open4' +require 'posix/spawn' class HglibClient def initialize(repository_url) @@ -8,7 +8,7 @@ def initialize(repository_url) end def start - @pid, @stdin, @stdout, @stderr = Open4::popen4 "python #{@py_script}" + @pid, @stdin, @stdout, @stderr = POSIX::Spawn::popen4 "python #{@py_script}" open_repository end From 8732a56b1a489583a2880dfae7c748e382c95710 Mon Sep 17 00:00:00 2001 From: santhanakarthikeyan Date: Tue, 12 Apr 2016 20:07:30 +0530 Subject: [PATCH 06/33] Added script to install dependencies like xmloutput plugin --- .install_dependencies.sh | 13 +++++++++++++ .travis.yml | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 .install_dependencies.sh diff --git a/.install_dependencies.sh b/.install_dependencies.sh new file mode 100755 index 00000000..bcec6f01 --- /dev/null +++ b/.install_dependencies.sh @@ -0,0 +1,13 @@ +#/usr/bin/env sh + +bazaar_plugins_path=`bzr --version | awk '/bzrlib:/ {print $2}'` + +cd "$bazaar_plugins_path/plugins" + +sudo bzr branch lp:bzr-xmloutput + +sudo mv bzr-xmloutput xmloutput + +cd xmloutput + +python setup.py build_ext -i diff --git a/.travis.yml b/.travis.yml index bb0275e7..eeac2080 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,4 @@ language: ruby -install: gem install posix-spawn +install: + - gem install posix-spawn + - sh .install_dependencies.sh From 26e57ff244488a13f523d97dfea17c56b428d9b6 Mon Sep 17 00:00:00 2001 From: santhanakarthikeyan Date: Wed, 13 Apr 2016 13:20:52 +0530 Subject: [PATCH 07/33] Added posix-spawn gem dependency --- ohloh_scm.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ohloh_scm.gemspec b/ohloh_scm.gemspec index 0de6e165..74ee9d8a 100644 --- a/ohloh_scm.gemspec +++ b/ohloh_scm.gemspec @@ -16,4 +16,6 @@ Gem::Specification.new do |gem| gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = %w(lib) + + gem.add_runtime_dependency 'posix-spawn', '~> 0.3' end From 581e6f2472ef900d8b558937257099465aa49d6c Mon Sep 17 00:00:00 2001 From: arun Date: Mon, 23 May 2016 21:51:03 +0530 Subject: [PATCH 08/33] Fix for file descriptor leaks --- lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb | 6 ++++-- lib/ohloh_scm/adapters/bzrlib_adapter.rb | 8 ++++---- lib/ohloh_scm/adapters/hglib/client.rb | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb b/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb index f4ffb2f9..d200c056 100644 --- a/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb +++ b/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb @@ -6,7 +6,7 @@ def initialize(repository_url) @repository_url = repository_url @py_script = File.dirname(__FILE__) + '/bzrlib_pipe_server.py' end - + def start @pid, @stdin, @stdout, @stderr = POSIX::Spawn::popen4 "python #{@py_script}" open_repository @@ -27,8 +27,9 @@ def send_command(cmd) # send the command @stdin.puts cmd @stdin.flush + return if cmd == "QUIT" - # get status on stderr, first letter indicates state, + # get status on stderr, first letter indicates state, # remaing value indicates length of the file content status = @stderr.read(10) flag = status[0,1] @@ -46,6 +47,7 @@ def send_command(cmd) def shutdown send_command("QUIT") + [@stdout, @stdin, @stderr].each { |io| io.close unless io.closed? } Process.waitpid(@pid, Process::WNOHANG) end end diff --git a/lib/ohloh_scm/adapters/bzrlib_adapter.rb b/lib/ohloh_scm/adapters/bzrlib_adapter.rb index 512cd937..bde29fa5 100644 --- a/lib/ohloh_scm/adapters/bzrlib_adapter.rb +++ b/lib/ohloh_scm/adapters/bzrlib_adapter.rb @@ -5,13 +5,13 @@ module OhlohScm::Adapters class BzrlibAdapter < BzrAdapter def setup - @bzr_client = BzrPipeClient.new(url) - @bzr_client.start + bzr_client = BzrPipeClient.new(url) + bzr_client.start + bzr_client end def bzr_client - setup unless @bzr_client - return @bzr_client + @bzr_client ||= setup end def cleanup diff --git a/lib/ohloh_scm/adapters/hglib/client.rb b/lib/ohloh_scm/adapters/hglib/client.rb index c15a6b9e..e3d8733b 100644 --- a/lib/ohloh_scm/adapters/hglib/client.rb +++ b/lib/ohloh_scm/adapters/hglib/client.rb @@ -36,6 +36,7 @@ def send_command(cmd) # send the command @stdin.puts cmd @stdin.flush + return if cmd == "QUIT" # get status on stderr, first letter indicates state, # remaing value indicates length of the file content @@ -55,6 +56,7 @@ def send_command(cmd) def shutdown send_command("QUIT") + [@stdout, @stdin, @stderr].each { |io| io.close unless io.closed? } Process.waitpid(@pid, Process::WNOHANG) end end From 1af22dc7ae5da035952761069b267d85259945a6 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Tue, 7 Jun 2016 18:27:28 +0530 Subject: [PATCH 09/33] Version bump --- lib/ohloh_scm/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ohloh_scm/version.rb b/lib/ohloh_scm/version.rb index 37048918..e9f6ffc1 100644 --- a/lib/ohloh_scm/version.rb +++ b/lib/ohloh_scm/version.rb @@ -1,5 +1,5 @@ module OhlohScm module Version - STRING = '2.0.1' + STRING = '2.1.0' end end From 6699a6db7001b3fb5cf49cba606e7b3306ed1c40 Mon Sep 17 00:00:00 2001 From: arun Date: Fri, 10 Jun 2016 20:40:00 +0530 Subject: [PATCH 10/33] OTWO-4267 Workaround to resolve 'git push fails:refusing to update checked out branch' --- lib/ohloh_scm/adapters/git/push.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ohloh_scm/adapters/git/push.rb b/lib/ohloh_scm/adapters/git/push.rb index bae4e69a..a8c8493a 100644 --- a/lib/ohloh_scm/adapters/git/push.rb +++ b/lib/ohloh_scm/adapters/git/push.rb @@ -10,7 +10,9 @@ def push(to) if to.exist? ENV['GIT_COMMITTER_NAME'] = COMMITTER_NAME + run "cd '#{to.url}' && git checkout -b tmp" run "cd '#{self.url}' && git push '#{to.url}' #{self.branch_name}:#{to.branch_name}" + run "cd '#{to.url}' && git checkout master && git branch -d tmp" else if to.local? # Create a new repo on the same local machine. Just use existing pull code in reverse. From 2ea0d4fc5ccf691d0656d72d1b3456dec82ede27 Mon Sep 17 00:00:00 2001 From: arun Date: Fri, 10 Jun 2016 15:29:16 +0530 Subject: [PATCH 11/33] OTWO-4267 Added dependencies configuration and resolved failing test cases --- .travis.yml | 4 ++++ lib/ohloh_scm/adapters/bzr/misc.rb | 4 +++- lib/ohloh_scm/adapters/hg/cat_file.rb | 4 +++- test/unit/cvs_commits_test.rb | 22 +++++++++++----------- test/unit/hg_cat_file_test.rb | 2 +- test/unit/hglib_cat_file_test.rb | 2 +- test/unit/shellout_test.rb | 1 + 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index eeac2080..f2f095b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: ruby +before_install: + - sudo apt-get install -y cvs + - sudo ln -s /usr/bin/cvs /usr/bin/cvsnt + - sudo apt-get install -y subversion install: - gem install posix-spawn - sh .install_dependencies.sh diff --git a/lib/ohloh_scm/adapters/bzr/misc.rb b/lib/ohloh_scm/adapters/bzr/misc.rb index 12f5b9a5..3b24c5fc 100644 --- a/lib/ohloh_scm/adapters/bzr/misc.rb +++ b/lib/ohloh_scm/adapters/bzr/misc.rb @@ -10,7 +10,9 @@ def exist? end def ls_tree(token) - run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n") + run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n").map!{ |file_name| + file_name.force_encoding(Encoding::UTF_8) + } end def to_rev_param(r=nil) diff --git a/lib/ohloh_scm/adapters/hg/cat_file.rb b/lib/ohloh_scm/adapters/hg/cat_file.rb index e8caf7d6..1620d8eb 100644 --- a/lib/ohloh_scm/adapters/hg/cat_file.rb +++ b/lib/ohloh_scm/adapters/hg/cat_file.rb @@ -1,3 +1,5 @@ +require 'shellwords' + module OhlohScm::Adapters class HgAdapter < AbstractAdapter def cat_file(commit, diff) @@ -20,7 +22,7 @@ def cat(revision, path) # Example: # "Foo Bar & Baz" => "Foo\ Bar\ \&\ Baz" def escape(path) - path.gsub(/[ `'"&()<>|#\$]/) { |c| '\\' + c } + path.shellescape end end end diff --git a/test/unit/cvs_commits_test.rb b/test/unit/cvs_commits_test.rb index b2013804..575bdca4 100644 --- a/test/unit/cvs_commits_test.rb +++ b/test/unit/cvs_commits_test.rb @@ -6,19 +6,19 @@ class CvsCommitsTest < OhlohScm::Test def test_commits with_cvs_repository('cvs', 'simple') do |cvs| - assert_equal ['2006/06/29 16:21:07', - '2006/06/29 18:14:47', - '2006/06/29 18:45:29', - '2006/06/29 18:48:54', - '2006/06/29 18:52:23'], cvs.commits.collect { |c| c.token } - - assert_equal ['2006/06/29 18:48:54', - '2006/06/29 18:52:23'], - cvs.commits(:after => '2006/06/29 18:45:29').collect { |c| c.token } + assert_equal ['2006-06-29 16:21:07', + '2006-06-29 18:14:47', + '2006-06-29 18:45:29', + '2006-06-29 18:48:54', + '2006-06-29 18:52:23'], cvs.commits.collect { |c| c.token } # Make sure we are date format agnostic (2008/01/01 is the same as 2008-01-01) - assert_equal ['2006/06/29 18:48:54', - '2006/06/29 18:52:23'], + assert_equal ['2006-06-29 18:48:54', + '2006-06-29 18:52:23'], + cvs.commits(:after => '2006/06/29 18:45:29').collect { |c| c.token } + + assert_equal ['2006-06-29 18:48:54', + '2006-06-29 18:52:23'], cvs.commits(:after => '2006-06-29 18:45:29').collect { |c| c.token } assert_equal [], cvs.commits(:after => '2006/06/29 18:52:23').collect { |c| c.token } diff --git a/test/unit/hg_cat_file_test.rb b/test/unit/hg_cat_file_test.rb index efc374d6..0b36820e 100644 --- a/test/unit/hg_cat_file_test.rb +++ b/test/unit/hg_cat_file_test.rb @@ -35,7 +35,7 @@ def test_funny_file_name_chars File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } # Add it to an hg repository - `cd #{dir} && hg init && hg add * && hg commit -m test` + `cd #{dir} && hg init && hg add * && hg commit -u tester -m test` # Confirm that we can read the file back hg = HgAdapter.new(:url => dir).normalize diff --git a/test/unit/hglib_cat_file_test.rb b/test/unit/hglib_cat_file_test.rb index 19fa4f08..3b0be631 100644 --- a/test/unit/hglib_cat_file_test.rb +++ b/test/unit/hglib_cat_file_test.rb @@ -35,7 +35,7 @@ def test_funny_file_name_chars File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } # Add it to an hg repository - `cd #{dir} && hg init && hg add * && hg commit -m test` + `cd #{dir} && hg init && hg add * && hg commit -u tester -m test` # Confirm that we can read the file back hg = HglibAdapter.new(:url => dir).normalize diff --git a/test/unit/shellout_test.rb b/test/unit/shellout_test.rb index c007d9a5..108ebaf2 100644 --- a/test/unit/shellout_test.rb +++ b/test/unit/shellout_test.rb @@ -1,4 +1,5 @@ require_relative '../test_helper' +require 'timeout' class ShelloutTest < OhlohScm::Test def test_execute_must_pipe_the_results_accurately From 83fe15a10c9e3cbd77c32b6600683af7be7e1636 Mon Sep 17 00:00:00 2001 From: Peter Degen-Portnoy Date: Thu, 16 Jun 2016 13:28:33 -0400 Subject: [PATCH 12/33] Add Travis CI badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28d9c2a1..3d55cd28 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Ohloh SCM on Ohloh](https://www.ohloh.net/p/ohloh_scm/widgets/project_partner_badge.gif)](https://www.ohloh.net/p/ohloh_scm) +[![Ohloh SCM on Ohloh](https://www.ohloh.net/p/ohloh_scm/widgets/project_partner_badge.gif)](https://www.ohloh.net/p/ohloh_scm) [![Build Status](https://travis-ci.org/blackducksoftware/ohloh_scm.svg?branch=master)](https://travis-ci.org/blackducksoftware/ohloh_scm) # Ohloh SCM From 5a66f7d801fac7d6d8ef6bd5eb0a66f03a417a81 Mon Sep 17 00:00:00 2001 From: arun Date: Fri, 10 Jun 2016 20:54:19 +0530 Subject: [PATCH 13/33] OTWO-4267 Configured installation of multiple SCMs in travis builds --- .install_multiple_scms.sh | 8 ++++++++ .travis.yml | 4 +--- lib/ohloh_scm/adapters/hglib_adapter.rb | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .install_multiple_scms.sh diff --git a/.install_multiple_scms.sh b/.install_multiple_scms.sh new file mode 100644 index 00000000..df06cca9 --- /dev/null +++ b/.install_multiple_scms.sh @@ -0,0 +1,8 @@ +sudo apt-get install -y cvs +sudo ln -s /usr/bin/cvs /usr/bin/cvsnt +sudo apt-get install -y bzr +sudo apt-get install -y mercurial +sudo sh -c 'echo "deb http://opensource.wandisco.com/ubuntu precise svn18" >> /etc/apt/sources.list.d/subversion18.list' +sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | sudo apt-key add - +sudo apt-get update +sudo apt-get install -y subversion diff --git a/.travis.yml b/.travis.yml index f2f095b7..d6e8c773 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: ruby before_install: - - sudo apt-get install -y cvs - - sudo ln -s /usr/bin/cvs /usr/bin/cvsnt - - sudo apt-get install -y subversion + - sh .install_multiple_scms.sh install: - gem install posix-spawn - sh .install_dependencies.sh diff --git a/lib/ohloh_scm/adapters/hglib_adapter.rb b/lib/ohloh_scm/adapters/hglib_adapter.rb index f0eb6ac6..f9dca0e3 100644 --- a/lib/ohloh_scm/adapters/hglib_adapter.rb +++ b/lib/ohloh_scm/adapters/hglib_adapter.rb @@ -21,5 +21,5 @@ def cleanup end end -require_relative 'hglib/cat_file' require_relative 'hglib/head' +require_relative 'hglib/cat_file' From 535d2d50f32a675a597ee0c9ccc41b5fa22fa571 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Tue, 21 Jun 2016 15:02:25 +0530 Subject: [PATCH 14/33] OTWO-4267 Avoid changing encoding for processed data If ohloh_scm changes the encoding, original characters might be lost. Users might be aware of the correct encoding and may wish to handle it accordingly. --- lib/ohloh_scm/adapters/bzr/misc.rb | 4 +--- test/unit/bzr_misc_test.rb | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ohloh_scm/adapters/bzr/misc.rb b/lib/ohloh_scm/adapters/bzr/misc.rb index 3b24c5fc..5f30aa14 100644 --- a/lib/ohloh_scm/adapters/bzr/misc.rb +++ b/lib/ohloh_scm/adapters/bzr/misc.rb @@ -10,9 +10,7 @@ def exist? end def ls_tree(token) - run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n").map!{ |file_name| - file_name.force_encoding(Encoding::UTF_8) - } + run("cd #{path} && bzr ls -V -r #{to_rev_param(token)}").split("\n") end def to_rev_param(r=nil) diff --git a/test/unit/bzr_misc_test.rb b/test/unit/bzr_misc_test.rb index ec2fcf6a..44e788ff 100644 --- a/test/unit/bzr_misc_test.rb +++ b/test/unit/bzr_misc_test.rb @@ -20,7 +20,8 @@ def test_ls_tree 'file3.txt', 'file4.txt', 'file5.txt'], - bzr.ls_tree(bzr.head_token).sort + bzr.ls_tree(bzr.head_token).sort.map { |filename| + filename.force_encoding(Encoding::UTF_8) } end end From 91181b62d87c0f3dbb156f490c5fa021e2c160c8 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Wed, 22 Jun 2016 13:29:22 +0530 Subject: [PATCH 15/33] OTWO-4267 Use a bare git repo for git push test Undid previous lib changes made just to make test pass on travis. --- lib/ohloh_scm/adapters/git/push.rb | 2 -- test/unit/git_push_test.rb | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/ohloh_scm/adapters/git/push.rb b/lib/ohloh_scm/adapters/git/push.rb index a8c8493a..bae4e69a 100644 --- a/lib/ohloh_scm/adapters/git/push.rb +++ b/lib/ohloh_scm/adapters/git/push.rb @@ -10,9 +10,7 @@ def push(to) if to.exist? ENV['GIT_COMMITTER_NAME'] = COMMITTER_NAME - run "cd '#{to.url}' && git checkout -b tmp" run "cd '#{self.url}' && git push '#{to.url}' #{self.branch_name}:#{to.branch_name}" - run "cd '#{to.url}' && git checkout master && git branch -d tmp" else if to.local? # Create a new repo on the same local machine. Just use existing pull code in reverse. diff --git a/test/unit/git_push_test.rb b/test/unit/git_push_test.rb index 973992c3..8f4b5712 100644 --- a/test/unit/git_push_test.rb +++ b/test/unit/git_push_test.rb @@ -24,7 +24,6 @@ def test_local def test_basic_push with_git_repository('git') do |src| OhlohScm::ScratchDir.new do |dest_dir| - dest = GitAdapter.new(:url => dest_dir).normalize assert !dest.exist? @@ -36,10 +35,10 @@ def test_basic_push File.open(File.join(src.url, 'foo'), 'w') { } src.commit_all(OhlohScm::Commit.new) + system("cd #{ dest_dir } && git config --bool core.bare true && git config receive.denyCurrentBranch refuse") src.push(dest) assert dest.exist? assert_equal src.log, dest.log - end end end From 8346b299b9c2d04ece579e36bd4f558df8ae0bdf Mon Sep 17 00:00:00 2001 From: arun Date: Wed, 22 Jun 2016 16:38:37 +0530 Subject: [PATCH 16/33] OTWO-4281 Configured travis ssh setup and its dependencies --- .travis.yml | 10 ++++++++-- .../.install_dependencies.sh | 0 .../.install_multiple_scms.sh | 7 ++----- .travis/.travis_ssh_setup.sh | 3 +++ 4 files changed, 13 insertions(+), 7 deletions(-) rename .install_dependencies.sh => .travis/.install_dependencies.sh (100%) rename .install_multiple_scms.sh => .travis/.install_multiple_scms.sh (68%) create mode 100644 .travis/.travis_ssh_setup.sh diff --git a/.travis.yml b/.travis.yml index d6e8c773..664b1b74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,12 @@ language: ruby +env: + - TRAVIS_CONFIG_DIR=.travis before_install: - - sh .install_multiple_scms.sh + - cd $TRAVIS_CONFIG_DIR + - sh .travis_ssh_setup.sh install: - - gem install posix-spawn + - sh .install_multiple_scms.sh - sh .install_dependencies.sh + - gem install posix-spawn +before_script: + - cd $TRAVIS_BUILD_DIR diff --git a/.install_dependencies.sh b/.travis/.install_dependencies.sh similarity index 100% rename from .install_dependencies.sh rename to .travis/.install_dependencies.sh diff --git a/.install_multiple_scms.sh b/.travis/.install_multiple_scms.sh similarity index 68% rename from .install_multiple_scms.sh rename to .travis/.install_multiple_scms.sh index df06cca9..2344896e 100644 --- a/.install_multiple_scms.sh +++ b/.travis/.install_multiple_scms.sh @@ -1,8 +1,5 @@ -sudo apt-get install -y cvs -sudo ln -s /usr/bin/cvs /usr/bin/cvsnt -sudo apt-get install -y bzr -sudo apt-get install -y mercurial sudo sh -c 'echo "deb http://opensource.wandisco.com/ubuntu precise svn18" >> /etc/apt/sources.list.d/subversion18.list' sudo wget -q http://opensource.wandisco.com/wandisco-debian.gpg -O- | sudo apt-key add - sudo apt-get update -sudo apt-get install -y subversion +sudo apt-get install -y subversion cvs bzr mercurial +sudo ln -s /usr/bin/cvs /usr/bin/cvsnt diff --git a/.travis/.travis_ssh_setup.sh b/.travis/.travis_ssh_setup.sh new file mode 100644 index 00000000..8b560541 --- /dev/null +++ b/.travis/.travis_ssh_setup.sh @@ -0,0 +1,3 @@ +ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q +cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +ssh-keyscan -t rsa `hostname` >> ~/.ssh/known_hosts From 41d2d1f2f0f22fc4816a34a83bd4e90efa350e29 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 3 Nov 2010 23:20:39 -0700 Subject: [PATCH 17/33] initial files for darcs support based on hg --- lib/ohloh_scm/adapters/factory.rb | 3 + lib/scm.rb | 40 ++++ lib/scm/adapters/darcs/cat_file.rb | 26 +++ lib/scm/adapters/darcs/commits.rb | 86 ++++++++ lib/scm/adapters/darcs/head.rb | 28 +++ lib/scm/adapters/darcs/misc.rb | 22 +++ lib/scm/adapters/darcs/patch.rb | 9 + lib/scm/adapters/darcs/pull.rb | 22 +++ lib/scm/adapters/darcs/push.rb | 51 +++++ lib/scm/adapters/darcs/validation.rb | 26 +++ lib/scm/adapters/darcs_adapter.rb | 16 ++ lib/scm/parsers/darcs_parser.rb | 63 ++++++ test/repositories/darcs/_darcs/.gitattributes | 1 + test/repositories/darcs/_darcs/format | 2 + .../darcs/_darcs/hashed_inventory | 0 test/repositories/darcs/_darcs/prefs/binaries | 30 +++ test/repositories/darcs/_darcs/prefs/boring | 113 +++++++++++ test/repositories/darcs/_darcs/prefs/motd | 0 ...c8996fb92427ae41e4649b934ca495991b7852b855 | Bin 0 -> 20 bytes test/test_helper.rb | 4 + test/unit/adapter_factory_test.rb | 9 + test/unit/darcs_cat_file_test.rb | 47 +++++ test/unit/darcs_commits_test.rb | 63 ++++++ test/unit/darcs_head_test.rb | 18 ++ test/unit/darcs_misc_test.rb | 31 +++ test/unit/darcs_parser_test.rb | 184 ++++++++++++++++++ test/unit/darcs_patch_test.rb | 13 ++ test/unit/darcs_pull_test.rb | 29 +++ test/unit/darcs_push_test.rb | 59 ++++++ test/unit/darcs_rev_list_test.rb | 63 ++++++ test/unit/darcs_validation_test.rb | 60 ++++++ test/unit/ohlog_command_line_test.rb | 3 + 32 files changed, 1121 insertions(+) create mode 100644 lib/scm.rb create mode 100644 lib/scm/adapters/darcs/cat_file.rb create mode 100644 lib/scm/adapters/darcs/commits.rb create mode 100644 lib/scm/adapters/darcs/head.rb create mode 100644 lib/scm/adapters/darcs/misc.rb create mode 100644 lib/scm/adapters/darcs/patch.rb create mode 100644 lib/scm/adapters/darcs/pull.rb create mode 100644 lib/scm/adapters/darcs/push.rb create mode 100644 lib/scm/adapters/darcs/validation.rb create mode 100644 lib/scm/adapters/darcs_adapter.rb create mode 100644 lib/scm/parsers/darcs_parser.rb create mode 100644 test/repositories/darcs/_darcs/.gitattributes create mode 100644 test/repositories/darcs/_darcs/format create mode 100644 test/repositories/darcs/_darcs/hashed_inventory create mode 100644 test/repositories/darcs/_darcs/prefs/binaries create mode 100644 test/repositories/darcs/_darcs/prefs/boring create mode 100644 test/repositories/darcs/_darcs/prefs/motd create mode 100644 test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 create mode 100644 test/unit/darcs_cat_file_test.rb create mode 100644 test/unit/darcs_commits_test.rb create mode 100644 test/unit/darcs_head_test.rb create mode 100644 test/unit/darcs_misc_test.rb create mode 100644 test/unit/darcs_parser_test.rb create mode 100644 test/unit/darcs_patch_test.rb create mode 100644 test/unit/darcs_pull_test.rb create mode 100644 test/unit/darcs_push_test.rb create mode 100644 test/unit/darcs_rev_list_test.rb create mode 100644 test/unit/darcs_validation_test.rb diff --git a/lib/ohloh_scm/adapters/factory.rb b/lib/ohloh_scm/adapters/factory.rb index 920aad81..27e1e0c5 100644 --- a/lib/ohloh_scm/adapters/factory.rb +++ b/lib/ohloh_scm/adapters/factory.rb @@ -11,6 +11,9 @@ def self.from_path(path) elsif FileTest.exist?(File.join(path, '.hg')) HgAdapter.new(:url => File.expand_path(path)).normalize + elsif FileTest.exist?(File.join(path, '_darcs')) + DarcsAdapter.new(:url => File.expand_path(path)).normalize + elsif FileTest.exist?(File.join(path, '.bzr')) BzrAdapter.new(:url => File.expand_path(path)).normalize diff --git a/lib/scm.rb b/lib/scm.rb new file mode 100644 index 00000000..5252dcef --- /dev/null +++ b/lib/scm.rb @@ -0,0 +1,40 @@ +module Scm +end + +require 'rbconfig' + +$: << File.join(File.dirname(__FILE__),"..") + +require 'lib/scm/shellout' +require 'lib/scm/scratch_dir' +require 'lib/scm/commit' +require 'lib/scm/diff' + +require 'lib/scm/adapters/abstract_adapter' +require 'lib/scm/adapters/cvs_adapter' +require 'lib/scm/adapters/svn_adapter' +require 'lib/scm/adapters/svn_chain_adapter' +require 'lib/scm/adapters/git_adapter' +require 'lib/scm/adapters/hg_adapter' +require 'lib/scm/adapters/hglib_adapter' +require 'lib/scm/adapters/bzr_adapter' +require 'lib/scm/adapters/bzrlib_adapter' +require 'lib/scm/adapters/darcs_adapter' +require 'lib/scm/adapters/factory' + +require 'lib/scm/parsers/parser' +require 'lib/scm/parsers/branch_number' +require 'lib/scm/parsers/cvs_parser' +require 'lib/scm/parsers/svn_parser' +require 'lib/scm/parsers/svn_xml_parser' +require 'lib/scm/parsers/git_parser' +require 'lib/scm/parsers/git_styled_parser' +require 'lib/scm/parsers/hg_parser' +require 'lib/scm/parsers/hg_styled_parser' +require 'lib/scm/parsers/bzr_xml_parser' +require 'lib/scm/parsers/bzr_parser' +require 'lib/scm/parsers/darcs_parser' + +require 'lib/scm/parsers/array_writer' +require 'lib/scm/parsers/xml_writer' +require 'lib/scm/parsers/human_writer' diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/scm/adapters/darcs/cat_file.rb new file mode 100644 index 00000000..ff771e89 --- /dev/null +++ b/lib/scm/adapters/darcs/cat_file.rb @@ -0,0 +1,26 @@ +module Scm::Adapters + class DarcsAdapter < 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}' && darcs cat -r #{revision} #{escape(path)}") + return nil if err =~ /No such file in rev/ + 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 diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb new file mode 100644 index 00000000..2a251b8f --- /dev/null +++ b/lib/scm/adapters/darcs/commits.rb @@ -0,0 +1,86 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + + # Return the number of commits in the repository following +since+. + def commit_count(since=0) + commit_tokens(since || 0).size + end + + # Return the list of commit tokens following +since+. + def commit_tokens(since=0, up_to='tip') + # We reverse the final result in Ruby, rather than passing the --reverse flag to darcs. + # That's because the -f (follow) flag doesn't behave the same in both directions. + # Basically, we're trying very hard to make this act just like Git. The darcs_rev_list_test checks this. + tokens = run("cd '#{self.url}' && darcs log -f -r #{up_to || 'tip'}:#{since || 0} --template='{node}\\n'").split("\n").reverse + + # Darcs returns everything after *and including* since. + # We want to exclude it. + if tokens.any? && tokens.first == since + tokens[1..-1] + else + tokens + end + end + + # Returns a list of shallow commits (i.e., the diffs are not populated). + # Not including the diffs is meant to be a memory savings when we encounter massive repositories. + # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit + # in memory at a time. + def commits(since=0) + log = run("cd '#{self.url}' && darcs log -f -v -r tip:#{since || 0} --style #{Scm::Parsers::DarcsStyledParser.style_path}") + a = Scm::Parsers::DarcsStyledParser.parse(log).reverse + + if a.any? && a.first.token == since + a[1..-1] + else + a + end + end + + # Returns a single commit, including its diffs + def verbose_commit(token) + log = run("cd '#{self.url}' && darcs log -v -r #{token} --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") + Scm::Parsers::DarcsStyledParser.parse(log).first + end + + # Yields each commit after +since+, including its diffs. + # The log is stored in a temporary file. + # This is designed to prevent excessive RAM usage when we encounter a massive repository. + # Only a single commit is ever held in memory at once. + def each_commit(since=0) + open_log_file(since) do |io| + Scm::Parsers::DarcsStyledParser.parse(io) do |commit| + yield commit if block_given? && commit.token != since + end + end + end + + # Not used by Ohloh proper, but handy for debugging and testing + def log(since=0) + run "cd '#{url}' && darcs log -f -v -r tip:#{since}" + end + + # Returns a file handle to the log. + # In our standard, the log should include everything AFTER +since+. However, darcs doesn't work that way; + # it returns everything after and INCLUDING +since+. Therefore, consumers of this file should check for + # and reject the duplicate commit. + def open_log_file(since=0) + begin + if since == head_token # There are no new commits + # As a time optimization, just create an empty file rather than fetch a log we know will be empty. + File.open(log_filename, 'w') { } + else + run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path} > #{log_filename}" + end + File.open(log_filename, 'r') { |io| yield io } + ensure + File.delete(log_filename) if FileTest.exist?(log_filename) + end + end + + def log_filename + File.join('/tmp', (self.url).gsub(/\W/,'') + '.log') + end + + end +end diff --git a/lib/scm/adapters/darcs/head.rb b/lib/scm/adapters/darcs/head.rb new file mode 100644 index 00000000..2e777b22 --- /dev/null +++ b/lib/scm/adapters/darcs/head.rb @@ -0,0 +1,28 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def head_token + # This only returns first 12 characters. + # How can we make it return the entire hash? + token = run("darcs id -q #{url}").strip + + # Recent versions of Darcs now somtimes append a '+' char to the token. + # I believe this signifies pending changes... but we don't care. + # Strip the trailing '+', if any. + token = token[0..-2] if token[-1..-1] == '+' + + token + end + + def head + verbose_commit(head_token) + end + + def parent_tokens(commit) + run("cd '#{url}' && darcs parents -r #{commit.token} --template '{node}\\n'").split("\n") + end + + def parents(commit) + parent_tokens(commit).collect { |token| verbose_commit(token) } + end + end +end diff --git a/lib/scm/adapters/darcs/misc.rb b/lib/scm/adapters/darcs/misc.rb new file mode 100644 index 00000000..63da9052 --- /dev/null +++ b/lib/scm/adapters/darcs/misc.rb @@ -0,0 +1,22 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def exist? + begin + !!(head_token) + rescue + logger.debug { $! } + false + end + end + + def ls_tree(token) + run("cd '#{path}' && darcs manifest -r #{token}").split("\n") + end + + def export(dest_dir, token='tip') + run("cd '#{path}' && darcs archive -r #{token} '#{dest_dir}'") + # Darcs leaves a little cookie crumb in the export directory. Remove it. + File.delete(File.join(dest_dir, '.darcs_archival.txt')) if File.exist?(File.join(dest_dir, '.darcs_archival.txt')) + end + end +end diff --git a/lib/scm/adapters/darcs/patch.rb b/lib/scm/adapters/darcs/patch.rb new file mode 100644 index 00000000..5fe004cc --- /dev/null +++ b/lib/scm/adapters/darcs/patch.rb @@ -0,0 +1,9 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def patch_for_commit(commit) + parent_tokens(commit).map {|token| + run("darcs -R '#{url}' diff --git -r#{token} -r#{commit.token}") + }.join("\n") + end + end +end diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/scm/adapters/darcs/pull.rb new file mode 100644 index 00000000..cecfbabf --- /dev/null +++ b/lib/scm/adapters/darcs/pull.rb @@ -0,0 +1,22 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + + def pull(from, &block) + raise ArgumentError.new("Cannot pull from #{from.inspect}") unless from.is_a?(DarcsAdapter) + logger.info { "Pulling #{from.url}" } + + yield(0,1) if block_given? # Progress bar callback + + unless self.exist? + run "mkdir -p '#{self.url}'" + run "rm -rf '#{self.url}'" + run "darcs clone -U '#{from.url}' '#{self.url}'" + else + run "cd '#{self.url}' && darcs revert --all && darcs pull -u -y '#{from.url}'" + end + + yield(1,1) if block_given? # Progress bar callback + end + + end +end diff --git a/lib/scm/adapters/darcs/push.rb b/lib/scm/adapters/darcs/push.rb new file mode 100644 index 00000000..721609cf --- /dev/null +++ b/lib/scm/adapters/darcs/push.rb @@ -0,0 +1,51 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + + def push(to, &block) + raise ArgumentError.new("Cannot push to #{to.inspect}") unless to.is_a?(DarcsAdapter) + logger.info { "Pushing to #{to.url}" } + + yield(0,1) if block_given? # Progress bar callback + + unless to.exist? + if to.local? + # Create a new repo on the same local machine. Just use existing pull code in reverse. + to.pull(self) + else + run "ssh #{to.hostname} 'mkdir -p #{to.path}'" + run "scp -rpqB #{darcs_path} #{to.hostname}:#{to.path}" + end + else + run "cd '#{self.url}' && darcs push -f -y '#{to.url}'" + end + + yield(1,1) if block_given? # Progress bar callback + end + + def local? + return true if hostname == Socket.gethostname + return true if url =~ /^file:\/\// + return true if url !~ /:/ + false + end + + def hostname + $1 if url =~ /^ssh:\/\/([^\/]+)/ + end + + def path + case url + when /^file:\/\/(.+)$/ + $1 + when /^ssh:\/\/[^\/]+(\/.+)$/ + $1 + when /^[^:]*$/ + url + end + end + + def darcs_path + path && File.join(path, '.darcs') + end + end +end diff --git a/lib/scm/adapters/darcs/validation.rb b/lib/scm/adapters/darcs/validation.rb new file mode 100644 index 00000000..e265f6ef --- /dev/null +++ b/lib/scm/adapters/darcs/validation.rb @@ -0,0 +1,26 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def self.url_regex + /^((http|https|ssh|file):\/\/((\w+@)?[A-Za-z0-9_\-\.]+(:\d+)?\/)?)?[A-Za-z0-9_\-\.\/\~\+]*$/ + end + + def self.public_url_regex + /^(http|https):\/\/(\w+@)?[A-Za-z0-9_\-\.]+(:\d+)?\/[A-Za-z0-9_\-\.\/\~\+]*$/ + end + + def validate_server_connection + return unless valid? + @errors << [:failed, "The server did not respond to the 'darcs id' command. Is the URL correct?"] unless self.exist? + end + + def guess_forge + u = @url =~ /:\/\/(.*\.?darcs\.)?([^\/^:]+)(:\d+)?\// ? $2 : nil + case u + when /(sourceforge\.net$)/ + $1 + else + u + end + end + end +end diff --git a/lib/scm/adapters/darcs_adapter.rb b/lib/scm/adapters/darcs_adapter.rb new file mode 100644 index 00000000..58ab0aed --- /dev/null +++ b/lib/scm/adapters/darcs_adapter.rb @@ -0,0 +1,16 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def english_name + "Darcs" + end + end +end + +require 'lib/scm/adapters/darcs/validation' +require 'lib/scm/adapters/darcs/cat_file' +require 'lib/scm/adapters/darcs/commits' +require 'lib/scm/adapters/darcs/misc' +require 'lib/scm/adapters/darcs/pull' +require 'lib/scm/adapters/darcs/push' +require 'lib/scm/adapters/darcs/head' +require 'lib/scm/adapters/darcs/patch' diff --git a/lib/scm/parsers/darcs_parser.rb b/lib/scm/parsers/darcs_parser.rb new file mode 100644 index 00000000..accb6369 --- /dev/null +++ b/lib/scm/parsers/darcs_parser.rb @@ -0,0 +1,63 @@ +module Scm::Parsers + # This parser can process the default darcs logs, with or without the --verbose flag. + # It is handy for debugging but is not detailed enough for Ohloh analysis. + # See the DarcsStyledParser. + class DarcsParser < Parser + def self.scm + 'darcs' + end + + def self.internal_parse(buffer, opts) + e = nil + state = :data + + buffer.each_line do |l| + next_state = state + if state == :data + case l + when /^changeset:\s+\d+:([0-9a-f]+)/ + yield e if e && block_given? + e = Scm::Commit.new + e.diffs = [] + e.token = $1 + when /^user:\s+(.+?)(\s+<(.+)>)?$/ + e.committer_name = $1 + e.committer_email = $3 + when /^date:\s+(.+)/ + e.committer_date = Time.parse($1).utc + when /^files:\s+(.+)/ + ($1 || '').split(' ').each do |file| + e.diffs << Scm::Diff.new(:action => '?', :path => file) + end + when /^summary:\s+(.+)/ + e.message = $1 + when /^description:/ + next_state = :long_comment + end + + elsif state == :long_comment + if l == "\n" + next_state = :long_comment_following_blank + else + e.message ||= '' + e.message << l + end + + elsif state == :long_comment_following_blank + if l == "\n" # A second blank line in a row terminates the comment. + yield e if block_given? + e = nil + next_state = :data + else # Otherwise resume parsing comments. + e.message << "\n" + e.message << l + next_state = :long_comment + end + end + state = next_state + end + yield e if e && block_given? + end + + end +end diff --git a/test/repositories/darcs/_darcs/.gitattributes b/test/repositories/darcs/_darcs/.gitattributes new file mode 100644 index 00000000..bd2de00c --- /dev/null +++ b/test/repositories/darcs/_darcs/.gitattributes @@ -0,0 +1 @@ +* -text -whitespace diff --git a/test/repositories/darcs/_darcs/format b/test/repositories/darcs/_darcs/format new file mode 100644 index 00000000..58f777b5 --- /dev/null +++ b/test/repositories/darcs/_darcs/format @@ -0,0 +1,2 @@ +hashed +darcs-2 diff --git a/test/repositories/darcs/_darcs/hashed_inventory b/test/repositories/darcs/_darcs/hashed_inventory new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs/_darcs/prefs/binaries b/test/repositories/darcs/_darcs/prefs/binaries new file mode 100644 index 00000000..ac206487 --- /dev/null +++ b/test/repositories/darcs/_darcs/prefs/binaries @@ -0,0 +1,30 @@ +# This file contains a list of extended regular expressions, one per +# line. A file path matching any of these expressions is assumed to +# contain binary data (not text). The entries in ~/.darcs/binaries (if +# it exists) supplement those in this file. +# +# Blank lines, and lines beginning with an octothorpe (#) are ignored. +# See regex(7) for a description of extended regular expressions. +\.(a|A)$ +\.(bmp|BMP)$ +\.(bz2|BZ2)$ +\.(doc|DOC)$ +\.(elc|ELC)$ +\.(exe|EXE)$ +\.(gif|GIF)$ +\.(gz|GZ)$ +\.(iso|ISO)$ +\.(jar|JAR)$ +\.(jpe?g|JPE?G)$ +\.(mng|MNG)$ +\.(mpe?g|MPE?G)$ +\.(p[nbgp]m|P[NBGP]M)$ +\.(pdf|PDF)$ +\.(png|PNG)$ +\.(pyc|PYC)$ +\.(so|SO)$ +\.(tar|TAR)$ +\.(tgz|TGZ)$ +\.(tiff?|TIFF?)$ +\.(z|Z)$ +\.(zip|ZIP)$ diff --git a/test/repositories/darcs/_darcs/prefs/boring b/test/repositories/darcs/_darcs/prefs/boring new file mode 100644 index 00000000..5969e686 --- /dev/null +++ b/test/repositories/darcs/_darcs/prefs/boring @@ -0,0 +1,113 @@ +# Boring file regexps: + +### compiler and interpreter intermediate files +# haskell (ghc) interfaces +\.hi$ +\.hi-boot$ +\.o-boot$ +# object files +\.o$ +\.o\.cmd$ +# profiling haskell +\.p_hi$ +\.p_o$ +# haskell program coverage resp. profiling info +\.tix$ +\.prof$ +# fortran module files +\.mod$ +# linux kernel +\.ko\.cmd$ +\.mod\.c$ +(^|/)\.tmp_versions($|/) +# *.ko files aren't boring by default because they might +# be Korean translations rather than kernel modules +# \.ko$ +# python, emacs, java byte code +\.py[co]$ +\.elc$ +\.class$ +# objects and libraries; lo and la are libtool things +\.(obj|a|exe|so|lo|la)$ +# compiled zsh configuration files +\.zwc$ +# Common LISP output files for CLISP and CMUCL +\.(fas|fasl|sparcf|x86f)$ + +### build and packaging systems +# cabal intermediates +\.installed-pkg-config +\.setup-config +# standard cabal build dir, might not be boring for everybody +# ^dist(/|$) +# autotools +(^|/)autom4te\.cache($|/) +(^|/)config\.(log|status)$ +# microsoft web expression, visual studio metadata directories +\_vti_cnf$ +\_vti_pvt$ +# gentoo tools +\.revdep-rebuild.* +# generated dependencies +^\.depend$ + +### version control systems +# cvs +(^|/)CVS($|/) +\.cvsignore$ +# cvs, emacs locks +^\.# +# rcs +(^|/)RCS($|/) +,v$ +# subversion +(^|/)\.svn($|/) +# mercurial +(^|/)\.hg($|/) +# git +(^|/)\.git($|/) +# bzr +\.bzr$ +# sccs +(^|/)SCCS($|/) +# darcs +(^|/)_darcs($|/) +(^|/)\.darcsrepo($|/) +^\.darcs-temp-mail$ +-darcs-backup[[:digit:]]+$ +# gnu arch +(^|/)(\+|,) +(^|/)vssver\.scc$ +\.swp$ +(^|/)MT($|/) +(^|/)\{arch\}($|/) +(^|/).arch-ids($|/) +# bitkeeper +(^|/)BitKeeper($|/) +(^|/)ChangeSet($|/) + +### miscellaneous +# backup files +~$ +\.bak$ +\.BAK$ +# patch originals and rejects +\.orig$ +\.rej$ +# X server +\..serverauth.* +# image spam +\# +(^|/)Thumbs\.db$ +# vi, emacs tags +(^|/)(tags|TAGS)$ +#(^|/)\.[^/] +# core dumps +(^|/|\.)core$ +# partial broken files (KIO copy operations) +\.part$ +# waf files, see http://code.google.com/p/waf/ +(^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/) +(^|/)\.lock-wscript$ +# mac os finder +(^|/)\.DS_Store$ diff --git a/test/repositories/darcs/_darcs/prefs/motd b/test/repositories/darcs/_darcs/prefs/motd new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000000000000000000000000000000000..229151a5a27ab0cc4661f529cc0eda27e3c03e10 GIT binary patch literal 20 Rcmb2|=3oE=W@ZQtBmoVe0J#7F literal 0 HcmV?d00001 diff --git a/test/test_helper.rb b/test/test_helper.rb index cfd4d926..e8db0540 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -120,4 +120,8 @@ def with_bzr_repository(name) def with_bzrlib_repository(name) with_repository(OhlohScm::Adapters::BzrlibAdapter, name) { |bzr| yield bzr } end + + def with_darcs_repository(name) + with_repository(OhlohScm::Adapters::DarcsAdapter, name) { |darcs| yield darcs } + end end diff --git a/test/unit/adapter_factory_test.rb b/test/unit/adapter_factory_test.rb index a298ff5f..90d8c9a8 100644 --- a/test/unit/adapter_factory_test.rb +++ b/test/unit/adapter_factory_test.rb @@ -3,6 +3,15 @@ module OhlohScm::Adapters class FactoryTest < OhlohScm::Test + def test_factory_darcs + Scm::ScratchDir.new do |path| + `cd #{path} && darcs init` + darcs = Factory.from_path(path) + assert darcs.is_a?(DarcsAdapter) + assert_equal darcs.url, path + end + end + def test_factory_hg OhlohScm::ScratchDir.new do |path| `cd #{path} && hg init` diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb new file mode 100644 index 00000000..67b6213f --- /dev/null +++ b/test/unit/darcs_cat_file_test.rb @@ -0,0 +1,47 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsCatFileTest < Scm::Test + + def test_cat_file + with_darcs_repository('darcs') do |darcs| +expected = <<-EXPECTED +/* Hello, World! */ + +/* + * This file is not covered by any license, especially not + * the GNU General Public License (GPL). Have fun! + */ + +#include +main() +{ + printf("Hello, World!\\n"); +} +EXPECTED + + # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. + assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => '468336c6671c'), Scm::Diff.new(:path => 'helloworld.c')) + end + end + + # Ensure that we escape bash-significant characters like ' and & when they appear in the filename + def test_funny_file_name_chars + Scm::ScratchDir.new do |dir| + # Make a file with a problematic filename + funny_name = '|file_name (&\'")' + File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } + + # Add it to an darcs repository + `cd #{dir} && darcs init && darcs add * && darcs commit -m test` + + # Confirm that we can read the file back + darcs = DarcsAdapter.new(:url => dir).normalize + assert_equal "contents", darcs.cat_file(darcs.head, Scm::Diff.new(:path => funny_name)) + end + end + + end +end diff --git a/test/unit/darcs_commits_test.rb b/test/unit/darcs_commits_test.rb new file mode 100644 index 00000000..f65418e2 --- /dev/null +++ b/test/unit/darcs_commits_test.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsCommitsTest < Scm::Test + + def test_commit + with_darcs_repository('darcs') do |darcs| + assert_equal 4, darcs.commit_count + assert_equal 2, darcs.commit_count('b14fa4692f949940bd1e28da6fb4617de2615484') + assert_equal 0, darcs.commit_count('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + + assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', + 'b14fa4692f949940bd1e28da6fb4617de2615484', + '468336c6671cbc58237a259d1b7326866afc2817', + '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commit_tokens + + assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], + darcs.commit_tokens('468336c6671cbc58237a259d1b7326866afc2817') + + assert_equal [], darcs.commit_tokens('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + + assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', + 'b14fa4692f949940bd1e28da6fb4617de2615484', + '468336c6671cbc58237a259d1b7326866afc2817', + '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commits.collect { |c| c.token } + + assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], + darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').collect { |c| c.token } + + # Check that the diffs are not populated + assert_equal [], darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').first.diffs + + assert_equal [], darcs.commits('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + end + end + + def test_each_commit + commits = [] + with_darcs_repository('darcs') do |darcs| + darcs.each_commit do |c| + assert c.token.length == 40 + assert c.committer_name + assert c.committer_date.is_a?(Time) + assert c.message.length > 0 + assert c.diffs.any? + # Check that the diffs are populated + c.diffs.each do |d| + assert d.action =~ /^[MAD]$/ + assert d.path.length > 0 + end + commits << c + end + assert !FileTest.exist?(darcs.log_filename) # Make sure we cleaned up after ourselves + + # Verify that we got the commits in forward chronological order + assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', + 'b14fa4692f949940bd1e28da6fb4617de2615484', + '468336c6671cbc58237a259d1b7326866afc2817', + '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], commits.collect { |c| c.token } + end + end + end +end diff --git a/test/unit/darcs_head_test.rb b/test/unit/darcs_head_test.rb new file mode 100644 index 00000000..3d1b748d --- /dev/null +++ b/test/unit/darcs_head_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsHeadTest < Scm::Test + + def test_head_and_parents + with_darcs_repository('darcs') do |darcs| + assert_equal '75532c1e1f1d', darcs.head_token + assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', darcs.head.token + assert darcs.head.diffs.any? # diffs should be populated + + assert_equal '468336c6671cbc58237a259d1b7326866afc2817', darcs.parents(darcs.head).first.token + assert darcs.parents(darcs.head).first.diffs.any? + end + end + + end +end diff --git a/test/unit/darcs_misc_test.rb b/test/unit/darcs_misc_test.rb new file mode 100644 index 00000000..a68c7ad2 --- /dev/null +++ b/test/unit/darcs_misc_test.rb @@ -0,0 +1,31 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsMiscTest < Scm::Test + + def test_exist + save_darcs = nil + with_darcs_repository('darcs') do |darcs| + save_darcs = darcs + assert save_darcs.exist? + end + assert !save_darcs.exist? + end + + def test_ls_tree + with_darcs_repository('darcs') do |darcs| + assert_equal ['README','makefile'], darcs.ls_tree(darcs.head_token).sort + end + end + + def test_export + with_darcs_repository('darcs') do |darcs| + Scm::ScratchDir.new do |dir| + darcs.export(dir) + assert_equal ['.', '..', 'README', 'makefile'], Dir.entries(dir).sort + end + end + end + + end +end diff --git a/test/unit/darcs_parser_test.rb b/test/unit/darcs_parser_test.rb new file mode 100644 index 00000000..64051005 --- /dev/null +++ b/test/unit/darcs_parser_test.rb @@ -0,0 +1,184 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Parsers + class DarcsParserTest < Scm::Test + + def test_empty_array + assert_equal([], DarcsParser.parse('')) + end + + def test_log_parser_default +sample_log = < +date: Tue, Jan 20 2009 11:33:17 -0800 +summary: added makefile + + +changeset: 0:01101d8ef3ce +user: Robin Luckey +date: Tue, Jan 20 2009 11:32:54 -0800 +summary: Initial Checkin + +SAMPLE + + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + assert_equal 'b14fa4692f94', commits[0].token + assert_equal 'Jason Allen', commits[0].committer_name + assert_equal 'jason@ohloh.net', commits[0].committer_email + assert_equal "added makefile", commits[0].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 0, commits[0].diffs.size + + assert_equal '01101d8ef3ce', commits[1].token + assert_equal 'Robin Luckey', commits[1].committer_name + assert_equal 'robin@ohloh.net', commits[1].committer_email + assert_equal "Initial Checkin", commits[1].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 0, commits[1].diffs.size + end + + def test_log_parser_default_partial_user_name +sample_log = < +date: Tue, Jan 20 2009 11:33:17 -0800 + + +changeset: 0:01101d8ef3ce +user: Robin Luckey +date: Tue, Jan 20 2009 11:32:54 -0800 + +SAMPLE + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + assert_equal 'b14fa4692f94', commits[0].token + assert_equal 'Jason Allen', commits[0].committer_name + assert_equal 'jason@ohloh.net', commits[0].committer_email + assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 0, commits[0].diffs.size + + assert_equal '01101d8ef3ce', commits[1].token + assert_equal 'Robin Luckey', commits[1].committer_name + assert_equal 'robin@ohloh.net', commits[1].committer_email + assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 0, commits[1].diffs.size + end + + def test_log_parser_verbose +sample_log = < +date: Tue, Jan 20 2009 11:33:17 -0800 +files: makefile +description: +added makefile + + +changeset: 0:01101d8ef3ce +user: Robin Luckey +date: Tue, Jan 20 2009 11:32:54 -0800 +files: helloworld.c +description: +Initial Checkin + + +SAMPLE + + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + assert_equal 'b14fa4692f94', commits[0].token + assert_equal 'Jason Allen', commits[0].committer_name + assert_equal 'jason@ohloh.net', commits[0].committer_email + assert_equal "added makefile\n", commits[0].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 1, commits[0].diffs.size + assert_equal 'makefile', commits[0].diffs[0].path + + assert_equal '01101d8ef3ce', commits[1].token + assert_equal 'Robin Luckey', commits[1].committer_name + assert_equal 'robin@ohloh.net', commits[1].committer_email + assert_equal "Initial Checkin\n", commits[1].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 1, commits[1].diffs.size + assert_equal 'helloworld.c', commits[1].diffs[0].path + end + + def test_styled_parser + with_darcs_repository('darcs') do |darcs| + assert FileTest.exist?(DarcsStyledParser.style_path) + log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.style_path}") + commits = Scm::Parsers::DarcsStyledParser.parse(log) + assert_styled_commits(commits, false) + + assert FileTest.exist?(DarcsStyledParser.verbose_style_path) + log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") + commits = Scm::Parsers::DarcsStyledParser.parse(log) + assert_styled_commits(commits, true) + end + end + + protected + + def assert_styled_commits(commits, with_diffs=false) + assert_equal 4, commits.size + + assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', commits[0].token + assert_equal 'Robin Luckey', commits[0].committer_name + assert_equal 'robin@ohloh.net', commits[0].committer_email + assert Time.utc(2009,1,20,19,34,53) - commits[0].committer_date < 1 # Don't care about milliseconds + assert_equal "deleted helloworld.c\n", commits[0].message + + if with_diffs + assert_equal 1, commits[0].diffs.size + assert_equal 'D', commits[0].diffs[0].action + assert_equal 'helloworld.c', commits[0].diffs[0].path + else + assert_equal [], commits[0].diffs + end + + assert_equal '468336c6671cbc58237a259d1b7326866afc2817', commits[1].token + assert Time.utc(2009, 1,20,19,34,04) - commits[1].committer_date < 1 + + if with_diffs + assert_equal 2, commits[1].diffs.size + assert_equal 'M', commits[1].diffs[0].action + assert_equal 'helloworld.c', commits[1].diffs[0].path + assert_equal 'A', commits[1].diffs[1].action + assert_equal 'README', commits[1].diffs[1].path + else + assert_equal [], commits[0].diffs + end + end + end +end diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb new file mode 100644 index 00000000..65d517ce --- /dev/null +++ b/test/unit/darcs_patch_test.rb @@ -0,0 +1,13 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsPatchTest < Scm::Test + def test_patch_for_commit + with_darcs_repository('darcs') do |repo| + commit = repo.verbose_commit(1) + data = File.read(File.join(DATA_DIR, 'darcs_patch.diff')) + assert_equal data, repo.patch_for_commit(commit) + end + end + end +end diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb new file mode 100644 index 00000000..fad9251b --- /dev/null +++ b/test/unit/darcs_pull_test.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsPullTest < Scm::Test + + def test_pull + with_darcs_repository('darcs') do |src| + Scm::ScratchDir.new do |dest_dir| + + dest = DarcsAdapter.new(:url => dest_dir).normalize + assert !dest.exist? + + dest.pull(src) + assert dest.exist? + + assert_equal src.log, dest.log + + # Commit some new code on the original and pull again + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" + assert_equal "test\n", src.commits.last.message + + dest.pull(src) + assert_equal src.log, dest.log + end + end + end + + end +end diff --git a/test/unit/darcs_push_test.rb b/test/unit/darcs_push_test.rb new file mode 100644 index 00000000..e72bfef6 --- /dev/null +++ b/test/unit/darcs_push_test.rb @@ -0,0 +1,59 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsPushTest < Scm::Test + + def test_hostname + assert !DarcsAdapter.new.hostname + assert !DarcsAdapter.new(:url => "http://www.ohloh.net/test").hostname + assert !DarcsAdapter.new(:url => "/Users/robin/foo").hostname + assert_equal "foo", DarcsAdapter.new(:url => 'ssh://foo/bar').hostname + end + + def test_local + assert !DarcsAdapter.new(:url => "foo:/bar").local? # Assuming your machine is not named "foo" :-) + assert !DarcsAdapter.new(:url => "http://www.ohloh.net/foo").local? + assert !DarcsAdapter.new(:url => "ssh://host/Users/robin/src").local? + assert DarcsAdapter.new(:url => "src").local? + assert DarcsAdapter.new(:url => "/Users/robin/src").local? + assert DarcsAdapter.new(:url => "file:///Users/robin/src").local? + assert DarcsAdapter.new(:url => "ssh://#{Socket.gethostname}/Users/robin/src").local? + end + + def test_path + assert_equal nil, DarcsAdapter.new().path + assert_equal nil, DarcsAdapter.new(:url => "http://ohloh.net/foo").path + assert_equal nil, DarcsAdapter.new(:url => "https://ohloh.net/foo").path + assert_equal "/Users/robin/foo", DarcsAdapter.new(:url => "file:///Users/robin/foo").path + assert_equal "/Users/robin/foo", DarcsAdapter.new(:url => "ssh://localhost/Users/robin/foo").path + assert_equal "/Users/robin/foo", DarcsAdapter.new(:url => "/Users/robin/foo").path + end + + def test_darcs_path + assert_equal nil, DarcsAdapter.new().darcs_path + assert_equal "/Users/robin/src/.darcs", DarcsAdapter.new(:url => "/Users/robin/src").darcs_path + end + + def test_push + with_darcs_repository('darcs') do |src| + Scm::ScratchDir.new do |dest_dir| + + dest = DarcsAdapter.new(:url => dest_dir).normalize + assert !dest.exist? + + src.push(dest) + assert dest.exist? + assert_equal src.log, dest.log + + # Commit some new code on the original and pull again + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" + assert_equal "test\n", src.commits.last.message + + src.push(dest) + assert_equal src.log, dest.log + end + end + end + + end +end diff --git a/test/unit/darcs_rev_list_test.rb b/test/unit/darcs_rev_list_test.rb new file mode 100644 index 00000000..c7cb83b8 --- /dev/null +++ b/test/unit/darcs_rev_list_test.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + # Repository darcs_walk has the following structure: + # + # G -> H -> I + # / \ \ + # A -> B -> C -> D -> tip + # + class DarcsRevListTest < Scm::Test + + def test_rev_list + with_darcs_repository('darcs_walk') do |darcs| + # Full history to a commit + assert_equal [:A], rev_list_helper(darcs, nil, :A) + assert_equal [:A, :B], rev_list_helper(darcs, nil, :B) + assert_equal [:A, :B, :G, :H, :C], rev_list_helper(darcs, nil, :C) + assert_equal [:A, :B, :G, :H, :C, :I, :D], rev_list_helper(darcs, nil, :D) + assert_equal [:A, :G], rev_list_helper(darcs, nil, :G) + assert_equal [:A, :G, :H], rev_list_helper(darcs, nil, :H) + assert_equal [:A, :G, :H, :I], rev_list_helper(darcs, nil, :I) + + # Limited history from one commit to another + assert_equal [], rev_list_helper(darcs, :A, :A) + assert_equal [:B], rev_list_helper(darcs, :A, :B) + assert_equal [:B, :G, :H, :C], rev_list_helper(darcs, :A, :C) + assert_equal [:B, :G, :H, :C, :I, :D], rev_list_helper(darcs, :A, :D) + assert_equal [:G, :H, :C, :I, :D], rev_list_helper(darcs, :B, :D) + assert_equal [:I, :D], rev_list_helper(darcs, :C, :D) + end + end + + protected + + def rev_list_helper(darcs, from, to) + to_labels(darcs.commit_tokens(from_label(from), from_label(to))) + end + + def commit_labels + { '4bfbf836feeebb236492199fbb0d1474e26f69d9' => :A, + '23edb79d0d06c8c315d8b9e7456098823335377d' => :B, + '7e33b9fde56a6e3576753868d08fa143e4e8a9cf' => :C, + '8daa1aefa228d3ee5f9a0f685d696826e88266fb' => :D, + 'e43cf1bb4b80d8ae70a695ec070ce017fdc529f3' => :G, + 'dca215d8a3e4dd3e472379932f1dd9c909230331' => :H, + '3a1495175e40b1c983441d6a8e8e627d2bd672b6' => :I + } + end + + def to_label(sha1) + commit_labels[sha1.to_s] + end + + def to_labels(sha1s) + sha1s.collect { |sha1| to_label(sha1) } + end + + def from_label(l) + commit_labels.each_pair { |k,v| return k if v.to_s == l.to_s } + nil + end + end +end diff --git a/test/unit/darcs_validation_test.rb b/test/unit/darcs_validation_test.rb new file mode 100644 index 00000000..71a664f6 --- /dev/null +++ b/test/unit/darcs_validation_test.rb @@ -0,0 +1,60 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsValidationTest < Scm::Test + def test_rejected_urls + [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", + "www.selenic.com/repo/hello", # missing a protool prefix + "http://www.selenic.com/repo/hello%20world", # no encoded strings allowed + "http://www.selenic.com/repo/hello world", # no spaces allowed + "git://www.selenic.com/repo/hello", # git protocol not allowed + "svn://www.selenic.com/repo/hello" # svn protocol not allowed + ].each do |url| + darcs = DarcsAdapter.new(:url => url, :public_urls_only => true) + assert darcs.validate_url.any? + end + end + + def test_accepted_urls + [ "http://www.selenic.com/repo/hello", + "http://www.selenic.com:80/repo/hello", + "https://www.selenic.com/repo/hello", + ].each do |url| + darcs = DarcsAdapter.new(:url => url, :public_urls_only => true) + assert !darcs.validate_url + end + end + + # These urls are not available to the public + def test_rejected_public_urls + [ "file:///home/robin/darcs", + "/home/robin/darcs", + "ssh://robin@localhost/home/robin/darcs", + "ssh://localhost/home/robin/darcs" + ].each do |url| + darcs = DarcsAdapter.new(:url => url, :public_urls_only => true) + assert darcs.validate_url + + darcs = DarcsAdapter.new(:url => url) + assert !darcs.validate_url + end + end + + def test_guess_forge + darcs = DarcsAdapter.new(:url => nil) + assert_equal nil, darcs.guess_forge + + darcs = DarcsAdapter.new(:url => "/home/robin/darcs") + assert_equal nil, darcs.guess_forge + + darcs = DarcsAdapter.new( :url => 'http://www.selenic.com/repo/hello') + assert_equal 'www.selenic.com', darcs.guess_forge + + darcs = DarcsAdapter.new( :url => 'http://algoc.darcs.sourceforge.net:8000/darcsroot/algoc') + assert_equal 'sourceforge.net', darcs.guess_forge + + darcs = DarcsAdapter.new( :url => 'http://poliqarp.sourceforge.net/darcs/poliqarp/') + assert_equal 'sourceforge.net', darcs.guess_forge + end + end +end diff --git a/test/unit/ohlog_command_line_test.rb b/test/unit/ohlog_command_line_test.rb index 34f3724e..a6e459ee 100644 --- a/test/unit/ohlog_command_line_test.rb +++ b/test/unit/ohlog_command_line_test.rb @@ -27,6 +27,9 @@ def test_svn_xml_from_file def test_hg_from_file end + #def test_darcs_from_file + #end + def test_help result = `#{File.dirname(__FILE__) + '/../../bin/ohlog'} -?` assert_equal 0, $? From 7828a98ab2953d3d057e2d8e8aa6432b0cfa7b14 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 03:14:38 -0700 Subject: [PATCH 18/33] ignore emacs TAGS files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d411dd7f..13456823 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.pyc pkg/ *.cache +TAGS From c7cd724b32ffcbb24e966fddc71ec0282fe4b5fd Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 05:30:16 -0700 Subject: [PATCH 19/33] changes parser, human-readable output --- lib/scm/parsers/darcs_parser.rb | 83 ++++++++----- test/unit/darcs_parser_test.rb | 206 ++++++++++++-------------------- 2 files changed, 125 insertions(+), 164 deletions(-) diff --git a/lib/scm/parsers/darcs_parser.rb b/lib/scm/parsers/darcs_parser.rb index accb6369..286dec88 100644 --- a/lib/scm/parsers/darcs_parser.rb +++ b/lib/scm/parsers/darcs_parser.rb @@ -1,7 +1,5 @@ module Scm::Parsers - # This parser can process the default darcs logs, with or without the --verbose flag. - # It is handy for debugging but is not detailed enough for Ohloh analysis. - # See the DarcsStyledParser. + # This parser can process the default darcs changes output #, with or without the --verbose flag. class DarcsParser < Parser def self.scm 'darcs' @@ -9,50 +7,69 @@ def self.scm def self.internal_parse(buffer, opts) e = nil - state = :data + state = :patch buffer.each_line do |l| + #print "\n#{state}" next_state = state - if state == :data + if state == :patch case l - when /^changeset:\s+\d+:([0-9a-f]+)/ + when /^([^ ]...........................) (.*)$/ yield e if e && block_given? e = Scm::Commit.new - e.diffs = [] - e.token = $1 - when /^user:\s+(.+?)(\s+<(.+)>)?$/ - e.committer_name = $1 - e.committer_email = $3 - when /^date:\s+(.+)/ - e.committer_date = Time.parse($1).utc - when /^files:\s+(.+)/ - ($1 || '').split(' ').each do |file| - e.diffs << Scm::Diff.new(:action => '?', :path => file) + e.author_date = Time.parse($1).utc + nameemail = $2 + case nameemail + when /^([^<]*) <(.*)>$/ + e.author_name = $1 + e.author_email = $2 + when /^([^@]*)$/ + e.author_name = $1 + e.author_email = nil + else + e.author_name = nil + e.author_email = nameemail end - when /^summary:\s+(.+)/ - e.message = $1 - when /^description:/ - next_state = :long_comment + e.diffs = [] + when /^ \* (.*)/ + e.token = ($1 || '') + next_state = :long_comment_or_prims end - elsif state == :long_comment - if l == "\n" - next_state = :long_comment_following_blank + elsif state == :long_comment_or_prims + case l + when /^ addfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'A', :path => $1) + next_state = :prims + when /^ rmfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'D', :path => $1) + next_state = :prims + when /^ hunk\s+(.+)\s+([0-9]+)$/ + e.diffs << Scm::Diff.new(:action => 'M', :path => $1) + # e.sha1, e.parent_sha1 = ... + next_state = :prims + when /^$/ + next_state = :patch else e.message ||= '' - e.message << l + e.message << l.sub(/^ /,'') end - elsif state == :long_comment_following_blank - if l == "\n" # A second blank line in a row terminates the comment. - yield e if block_given? - e = nil - next_state = :data - else # Otherwise resume parsing comments. - e.message << "\n" - e.message << l - next_state = :long_comment + elsif state == :prims + case l + when /^ addfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'A', :path => $1) + when /^ rmfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'D', :path => $1) + when /^ hunk\s+(.+)\s+([0-9]+)$/ + e.diffs << Scm::Diff.new(:action => 'M', :path => $1) + # e.sha1, e.parent_sha1 = ... + when /^$/ + next_state = :patch + else + # ignore hunk details end + end state = next_state end diff --git a/test/unit/darcs_parser_test.rb b/test/unit/darcs_parser_test.rb index 64051005..7d691831 100644 --- a/test/unit/darcs_parser_test.rb +++ b/test/unit/darcs_parser_test.rb @@ -9,16 +9,11 @@ def test_empty_array def test_log_parser_default sample_log = < -date: Tue, Jan 20 2009 11:33:17 -0800 -summary: added makefile +Wed Nov 3 15:55:25 PDT 2010 Simon Michael + * remove helloworld.c - -changeset: 0:01101d8ef3ce -user: Robin Luckey -date: Tue, Jan 20 2009 11:32:54 -0800 -summary: Initial Checkin +Wed Nov 3 15:49:53 PDT 2010 Simon Michael + * add helloworld.c SAMPLE @@ -27,89 +22,80 @@ def test_log_parser_default assert commits assert_equal 2, commits.size - assert_equal 'b14fa4692f94', commits[0].token - assert_equal 'Jason Allen', commits[0].committer_name - assert_equal 'jason@ohloh.net', commits[0].committer_email - assert_equal "added makefile", commits[0].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 'remove helloworld.c', commits[0].token + assert_equal 'Simon Michael', commits[0].author_name + assert_equal 'simon@joyful.com', commits[0].author_email + assert_equal nil, commits[0].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,55,25), commits[0].author_date assert_equal 0, commits[0].diffs.size - assert_equal '01101d8ef3ce', commits[1].token - assert_equal 'Robin Luckey', commits[1].committer_name - assert_equal 'robin@ohloh.net', commits[1].committer_email - assert_equal "Initial Checkin", commits[1].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 'add helloworld.c', commits[1].token + assert_equal 'Simon Michael', commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email + assert_equal nil, commits[1].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,49,53), commits[1].author_date assert_equal 0, commits[1].diffs.size end def test_log_parser_default_partial_user_name sample_log = < -date: Tue, Jan 20 2009 11:33:17 -0800 +Wed Nov 3 15:55:25 PDT 2010 Simon Michael + * name only - -changeset: 0:01101d8ef3ce -user: Robin Luckey -date: Tue, Jan 20 2009 11:32:54 -0800 +Wed Nov 3 15:49:53 PDT 2010 simon@joyful.com + * email only SAMPLE + commits = DarcsParser.parse(sample_log) assert commits assert_equal 2, commits.size - assert_equal 'b14fa4692f94', commits[0].token - assert_equal 'Jason Allen', commits[0].committer_name - assert_equal 'jason@ohloh.net', commits[0].committer_email - assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date - assert_equal 0, commits[0].diffs.size + assert_equal 'name only', commits[0].token + assert_equal 'Simon Michael', commits[0].author_name + assert !commits[0].author_email - assert_equal '01101d8ef3ce', commits[1].token - assert_equal 'Robin Luckey', commits[1].committer_name - assert_equal 'robin@ohloh.net', commits[1].committer_email - assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date - assert_equal 0, commits[1].diffs.size + assert_equal 'email only', commits[1].token + assert !commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email end def test_log_parser_verbose sample_log = < -date: Tue, Jan 20 2009 11:33:17 -0800 -files: makefile -description: -added makefile - - -changeset: 0:01101d8ef3ce -user: Robin Luckey -date: Tue, Jan 20 2009 11:32:54 -0800 -files: helloworld.c -description: -Initial Checkin - - +Wed Nov 3 15:55:25 PDT 2010 Simon Michael + * remove helloworld.c + hunk ./helloworld.c 1 + -/* Hello, World! */ + - + -/* + - * This file is not covered by any license, especially not + - * the GNU General Public License (GPL). Have fun! + - */ + - + -#include + -main() + -{ + - printf("Hello, World!\\n"); + -} + rmfile ./helloworld.c + +Wed Nov 3 15:49:53 PDT 2010 Simon Michael + * add helloworld.c + addfile ./helloworld.c + hunk ./helloworld.c 1 + +/* Hello, World! */ + + + +/* + + * This file is not covered by any license, especially not + + * the GNU General Public License (GPL). Have fun! + + */ + + + +#include + +main() + +{ + + printf("Hello, World!\\n"); + +} SAMPLE commits = DarcsParser.parse(sample_log) @@ -117,68 +103,26 @@ def test_log_parser_verbose assert commits assert_equal 2, commits.size - assert_equal 'b14fa4692f94', commits[0].token - assert_equal 'Jason Allen', commits[0].committer_name - assert_equal 'jason@ohloh.net', commits[0].committer_email - assert_equal "added makefile\n", commits[0].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date - assert_equal 1, commits[0].diffs.size - assert_equal 'makefile', commits[0].diffs[0].path - - assert_equal '01101d8ef3ce', commits[1].token - assert_equal 'Robin Luckey', commits[1].committer_name - assert_equal 'robin@ohloh.net', commits[1].committer_email - assert_equal "Initial Checkin\n", commits[1].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date - assert_equal 1, commits[1].diffs.size - assert_equal 'helloworld.c', commits[1].diffs[0].path - end - - def test_styled_parser - with_darcs_repository('darcs') do |darcs| - assert FileTest.exist?(DarcsStyledParser.style_path) - log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.style_path}") - commits = Scm::Parsers::DarcsStyledParser.parse(log) - assert_styled_commits(commits, false) - - assert FileTest.exist?(DarcsStyledParser.verbose_style_path) - log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") - commits = Scm::Parsers::DarcsStyledParser.parse(log) - assert_styled_commits(commits, true) - end + assert_equal 'remove helloworld.c', commits[0].token + assert_equal 'Simon Michael', commits[0].author_name + assert_equal 'simon@joyful.com', commits[0].author_email + assert_equal nil, commits[0].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,55,25), commits[0].author_date + assert_equal 2, commits[0].diffs.size + assert_equal './helloworld.c', commits[0].diffs[0].path + assert_equal './helloworld.c', commits[0].diffs[1].path + + assert_equal 'add helloworld.c', commits[1].token + assert_equal 'Simon Michael', commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email + assert_equal nil, commits[1].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,49,53), commits[1].author_date + assert_equal 2, commits[0].diffs.size + assert_equal './helloworld.c', commits[0].diffs[0].path + assert_equal './helloworld.c', commits[0].diffs[1].path end protected - def assert_styled_commits(commits, with_diffs=false) - assert_equal 4, commits.size - - assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', commits[0].token - assert_equal 'Robin Luckey', commits[0].committer_name - assert_equal 'robin@ohloh.net', commits[0].committer_email - assert Time.utc(2009,1,20,19,34,53) - commits[0].committer_date < 1 # Don't care about milliseconds - assert_equal "deleted helloworld.c\n", commits[0].message - - if with_diffs - assert_equal 1, commits[0].diffs.size - assert_equal 'D', commits[0].diffs[0].action - assert_equal 'helloworld.c', commits[0].diffs[0].path - else - assert_equal [], commits[0].diffs - end - - assert_equal '468336c6671cbc58237a259d1b7326866afc2817', commits[1].token - assert Time.utc(2009, 1,20,19,34,04) - commits[1].committer_date < 1 - - if with_diffs - assert_equal 2, commits[1].diffs.size - assert_equal 'M', commits[1].diffs[0].action - assert_equal 'helloworld.c', commits[1].diffs[0].path - assert_equal 'A', commits[1].diffs[1].action - assert_equal 'README', commits[1].diffs[1].path - else - assert_equal [], commits[0].diffs - end - end end end From d1d0a382833911e5572e1a8ac1ab862e93aad333 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 05:32:04 -0700 Subject: [PATCH 20/33] make head tests pass --- lib/ohloh_scm/commit.rb | 3 +++ lib/scm/adapters/darcs/cat_file.rb | 7 ++++--- lib/scm/adapters/darcs/commits.rb | 14 ++++++------- lib/scm/adapters/darcs/head.rb | 19 +++++++----------- .../darcs/_darcs/hashed_inventory | 11 ++++++++++ test/repositories/darcs/_darcs/index | Bin 0 -> 128 bytes test/repositories/darcs/_darcs/index_invalid | 0 ...52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 | Bin 0 -> 181 bytes ...c03cde5912cf131713f44fa36d870bd9880f70381c | Bin 0 -> 257 bytes ...0fe1f1d19c1432b366cc35f7eb06cd311543b4798e | Bin 0 -> 291 bytes ...250914ee9ad12c03e18f7acc2e30a9de83fde76a1c | Bin 0 -> 293 bytes .../repositories/darcs/_darcs/patches/pending | 2 ++ .../darcs/_darcs/patches/pending.tentative | 2 ++ ...f53384c3fd72d5eb0f37c5a1588f151412b65a9552 | Bin 0 -> 92 bytes ...5ed2289ba958415616d46901035ce3a6809034167f | Bin 0 -> 177 bytes .../darcs/_darcs/tentative_pristine | 1 + test/unit/darcs_cat_file_test.rb | 10 ++++----- test/unit/darcs_head_test.rb | 6 +++--- 18 files changed, 45 insertions(+), 30 deletions(-) create mode 100644 test/repositories/darcs/_darcs/index create mode 100644 test/repositories/darcs/_darcs/index_invalid create mode 100644 test/repositories/darcs/_darcs/inventories/0000000199-b4681395aad3d7e60338fc52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 create mode 100644 test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c create mode 100644 test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e create mode 100644 test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c create mode 100644 test/repositories/darcs/_darcs/patches/pending create mode 100644 test/repositories/darcs/_darcs/patches/pending.tentative create mode 100644 test/repositories/darcs/_darcs/pristine.hashed/47fa61da8145efedd19f2df53384c3fd72d5eb0f37c5a1588f151412b65a9552 create mode 100644 test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f create mode 100644 test/repositories/darcs/_darcs/tentative_pristine diff --git a/lib/ohloh_scm/commit.rb b/lib/ohloh_scm/commit.rb index 2a8e12f0..e87212ac 100644 --- a/lib/ohloh_scm/commit.rb +++ b/lib/ohloh_scm/commit.rb @@ -15,6 +15,8 @@ module OhlohScm # the near future, it is the job of the adapter to make the Git commit chain # appear as much like a single array as possible. # + # For Darcs, it is assumed the repo's patch ordering is never changed. + # class Commit # This object supports the idea of distinct authors and committers, a la # Git. However, Ohloh will retain only one of them in its database. It @@ -32,6 +34,7 @@ class Commit # For Git, the token is the commit SHA1 hash. # For CVS, which does not support atomic commits with unique IDs, we use # the approximate timestamp of the change. + # For Darcs, the token is the patch name, and it may not be unique. XXX attr_accessor :token # A pointer back to the adapter that contains this commit. diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/scm/adapters/darcs/cat_file.rb index ff771e89..7a01c1a0 100644 --- a/lib/scm/adapters/darcs/cat_file.rb +++ b/lib/scm/adapters/darcs/cat_file.rb @@ -10,9 +10,10 @@ def cat_file_parent(commit, diff) end def cat(revision, path) - out, err = run_with_err("cd '#{url}' && darcs cat -r #{revision} #{escape(path)}") - return nil if err =~ /No such file in rev/ - raise RuntimeError.new(err) unless err.to_s == '' + out, err = run_with_err("cd '#{url}' && darcs show contents -p #{revision} #{escape(path)}") + # darcs show contents gives no error for non-existent paths + return nil #if err =~ /No such file in rev/ + # raise RuntimeError.new(err) unless err.to_s == '' out end diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb index 2a251b8f..9215142f 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/scm/adapters/darcs/commits.rb @@ -27,9 +27,9 @@ def commit_tokens(since=0, up_to='tip') # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit # in memory at a time. def commits(since=0) - log = run("cd '#{self.url}' && darcs log -f -v -r tip:#{since || 0} --style #{Scm::Parsers::DarcsStyledParser.style_path}") - a = Scm::Parsers::DarcsStyledParser.parse(log).reverse - + count = run("cd '#{self.url}' && darcs changes --count") + log = run("cd '#{self.url}' && darcs changes --last #{count-since}") + a = Scm::Parsers::DarcsParser.parse(log).reverse if a.any? && a.first.token == since a[1..-1] else @@ -39,8 +39,8 @@ def commits(since=0) # Returns a single commit, including its diffs def verbose_commit(token) - log = run("cd '#{self.url}' && darcs log -v -r #{token} --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") - Scm::Parsers::DarcsStyledParser.parse(log).first + log = run("cd '#{self.url}' && darcs changes -v -p #{token}") + Scm::Parsers::DarcsParser.parse(log).first end # Yields each commit after +since+, including its diffs. @@ -49,7 +49,7 @@ def verbose_commit(token) # Only a single commit is ever held in memory at once. def each_commit(since=0) open_log_file(since) do |io| - Scm::Parsers::DarcsStyledParser.parse(io) do |commit| + Scm::Parsers::DarcsParser.parse(io) do |commit| yield commit if block_given? && commit.token != since end end @@ -70,7 +70,7 @@ def open_log_file(since=0) # As a time optimization, just create an empty file rather than fetch a log we know will be empty. File.open(log_filename, 'w') { } else - run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path} > #{log_filename}" + run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsParser.verbose_style_path} > #{log_filename}" end File.open(log_filename, 'r') { |io| yield io } ensure diff --git a/lib/scm/adapters/darcs/head.rb b/lib/scm/adapters/darcs/head.rb index 2e777b22..5ef26701 100644 --- a/lib/scm/adapters/darcs/head.rb +++ b/lib/scm/adapters/darcs/head.rb @@ -1,16 +1,7 @@ module Scm::Adapters class DarcsAdapter < AbstractAdapter def head_token - # This only returns first 12 characters. - # How can we make it return the entire hash? - token = run("darcs id -q #{url}").strip - - # Recent versions of Darcs now somtimes append a '+' char to the token. - # I believe this signifies pending changes... but we don't care. - # Strip the trailing '+', if any. - token = token[0..-2] if token[-1..-1] == '+' - - token + string_to_patch_names(run("cd '#{url}' && darcs changes --last 1"))[0] end def head @@ -18,11 +9,15 @@ def head end def parent_tokens(commit) - run("cd '#{url}' && darcs parents -r #{commit.token} --template '{node}\\n'").split("\n") + string_to_patch_names(run("cd '#{url}' && darcs changes --to-patch #{commit.token}"))[1..-1] end def parents(commit) - parent_tokens(commit).collect { |token| verbose_commit(token) } + parent_tokens(commit).map {|token| verbose_commit(token)} + end + + def string_to_patch_names(s) + s.split(/\n/).select {|s| s =~ /^ \* /}.map {|s| s.sub(/^ \* /,'')} end end end diff --git a/test/repositories/darcs/_darcs/hashed_inventory b/test/repositories/darcs/_darcs/hashed_inventory index e69de29b..42dfb941 100644 --- a/test/repositories/darcs/_darcs/hashed_inventory +++ b/test/repositories/darcs/_darcs/hashed_inventory @@ -0,0 +1,11 @@ +pristine:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +[add helloworld.c +Simon Michael **20101103224953 + Ignore-this: 3861470344267bb74c710a8dad01e92a +] +hash: 0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e +[remove helloworld.c +Simon Michael **20101103225525 + Ignore-this: c54c3cf6bebc6a9545effff28e1c785c +] +hash: 0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c diff --git a/test/repositories/darcs/_darcs/index b/test/repositories/darcs/_darcs/index new file mode 100644 index 0000000000000000000000000000000000000000..f14d6e02e39b15eb094cf5dd316e67996336e3db GIT binary patch literal 128 zcmeYW_B3IDf(9tf45S}#IN~(pkBrEy-(OD5%-^Y^zRvMU%IwKLOQz10t_a!@>Y@i# aj70Gvv2iioGE#GL^2_s!a#Hk?frOkr@eO$4PvLs*06?sUzx;*hzCJ5Qzh! z{(V*Pws%gdww2z;Yuvl;#C$E+akHmIS}NUstp7b+#&3Q0os8?}X5#<>5y&||2Qv2f za~t=veY9oWTbd$z2J+rT&Y8V1LYg!wV3}Pq-`2FWw!MWnV%S1O0m>{%(Q#A?IXHq^ ju%hBD=*eY@QG`O}k|Bx`V(^qb&r>mf%T)=<#{d8T1Eo}7 literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c b/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c new file mode 100644 index 0000000000000000000000000000000000000000..f992b1b89e133afbdf23920cce0e2c10baead91f GIT binary patch literal 257 zcmV+c0sj6UiwFP!000001D(&kPD3#aK;iv9MdnJaVmpbG3L#boCdP`vaU5=|+eT{n z5pPc`HpIl)&iL)5H8#ob+Q`*0Xv{e9W!INq;T=)nVc zLJTF+%0U^tXSACh=FS0l5N_Z?KnQ{|B@In{*q`6O4?Jks!2)= z(fT#a2Ff|=9}-+k7YJFdAZFB(tQ11P=nDk1a`RoK2D!7SqLG)*f~3J HkpTbzSDShN literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e b/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e new file mode 100644 index 0000000000000000000000000000000000000000..6a9429af00c71158b747d7b6429da021e7769aea GIT binary patch literal 291 zcmV+;0o?u{iwFP!0000016`0!PlG@ZhR^P=nAQuh6B5+`SuH;YCxZ`U>L3oF!=(CrLCtO_0`x0ggs(~60#1s=|C%irp6gy zeL$hO*4;2RW}5n%tS5oW0+hse4W6&o7ERbX;-)006<{hbsU8 literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c b/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c new file mode 100644 index 0000000000000000000000000000000000000000..b4a49fb71844189e6a46797d90c3c895d585eb38 GIT binary patch literal 293 zcmV+=0owi_iwFP!00000165E>Ps1<_J(FMIjZ0T8-P$cAYI={!RAs48pVUSTOo!%f|fw;#4ES{eB^*=u9Mr7J8xd8t#uHQa_x1{vD=ZYtgLsz>N5X*x5O_YKtlnSk|q=Y literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f b/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f new file mode 100644 index 0000000000000000000000000000000000000000..cf274f8ab54fa03042855cfb4bd3645156a16f21 GIT binary patch literal 177 zcmV;i08alOiwFP!00000167W@4uU`sMQi6PF4_Pw@&OuKD2$=d*w8G?5H=ZS4ZD~S zxz$lMrl&m}&K|Qr^8i${Ow5$)=29>!p`biV|R##4~OdVqvV(0v3*wfWG fO*4AX;x;;seY*TR+cdh&w)CVItO2=D#sB~S(CtrG literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/tentative_pristine b/test/repositories/darcs/_darcs/tentative_pristine new file mode 100644 index 00000000..a72624e3 --- /dev/null +++ b/test/repositories/darcs/_darcs/tentative_pristine @@ -0,0 +1 @@ +pristine:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 67b6213f..845d164c 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -20,15 +20,15 @@ def test_cat_file } EXPECTED - # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. - assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => '468336c6671c'), Scm::Diff.new(:path => 'helloworld.c')) + # The file was deleted by the "remove..." patch. Check that it does not exist now, but existed in parent. + assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => 'remove helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => 'remove helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => 'add helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) end end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename - def test_funny_file_name_chars + def Xtest_funny_file_name_chars Scm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '|file_name (&\'")' diff --git a/test/unit/darcs_head_test.rb b/test/unit/darcs_head_test.rb index 3d1b748d..05891d48 100644 --- a/test/unit/darcs_head_test.rb +++ b/test/unit/darcs_head_test.rb @@ -5,11 +5,11 @@ class DarcsHeadTest < Scm::Test def test_head_and_parents with_darcs_repository('darcs') do |darcs| - assert_equal '75532c1e1f1d', darcs.head_token - assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', darcs.head.token + assert_equal 'remove helloworld.c', darcs.head_token + assert_equal 'remove helloworld.c', darcs.head.token assert darcs.head.diffs.any? # diffs should be populated - assert_equal '468336c6671cbc58237a259d1b7326866afc2817', darcs.parents(darcs.head).first.token + assert_equal 'add helloworld.c', darcs.parents(darcs.head).first.token assert darcs.parents(darcs.head).first.diffs.any? end end From 7aef1a89f9960af05f3228d933c79d69f31b33ec Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 13:47:58 -0700 Subject: [PATCH 21/33] make cat_file tests pass --- lib/scm/adapters/darcs/cat_file.rb | 9 +++++---- lib/scm/adapters/darcs/commits.rb | 2 +- test/unit/darcs_cat_file_test.rb | 11 ++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/scm/adapters/darcs/cat_file.rb index 7a01c1a0..6157ad8a 100644 --- a/lib/scm/adapters/darcs/cat_file.rb +++ b/lib/scm/adapters/darcs/cat_file.rb @@ -10,10 +10,11 @@ def cat_file_parent(commit, diff) end def cat(revision, path) - out, err = run_with_err("cd '#{url}' && darcs show contents -p #{revision} #{escape(path)}") - # darcs show contents gives no error for non-existent paths - return nil #if err =~ /No such file in rev/ - # raise RuntimeError.new(err) unless err.to_s == '' + out, err = run_with_err("cd '#{url}' && darcs show contents -p '#{revision}' #{escape(path)}") + # show contents gives no error for non-existent paths + #return nil if err =~ /No such file in rev/ + raise RuntimeError.new(err) unless err.to_s == '' + return nil if out == '' out end diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb index 9215142f..eb025844 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/scm/adapters/darcs/commits.rb @@ -39,7 +39,7 @@ def commits(since=0) # Returns a single commit, including its diffs def verbose_commit(token) - log = run("cd '#{self.url}' && darcs changes -v -p #{token}") + log = run("cd '#{self.url}' && darcs changes -v -p '#{token}'") Scm::Parsers::DarcsParser.parse(log).first end diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 845d164c..714f4beb 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -16,7 +16,7 @@ def test_cat_file #include main() { - printf("Hello, World!\\n"); + printf("Hello, World!\\\\n"); } EXPECTED @@ -28,17 +28,18 @@ def test_cat_file end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename - def Xtest_funny_file_name_chars + # NB only works with --reserved-ok, otherwise darcs rejects with "invalid under Windows" + def test_funny_file_name_chars Scm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '|file_name (&\'")' File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } - # Add it to an darcs repository - `cd #{dir} && darcs init && darcs add * && darcs commit -m test` + # Add it to a darcs repository + darcs = DarcsAdapter.new(:url => dir).normalize + darcs.run("cd #{dir} && darcs init && darcs add --reserved-ok * && darcs record -a -m test") # Confirm that we can read the file back - darcs = DarcsAdapter.new(:url => dir).normalize assert_equal "contents", darcs.cat_file(darcs.head, Scm::Diff.new(:path => funny_name)) end end From 4d8094d9500338de013131c630929cb0fddab807 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 20:03:18 -0700 Subject: [PATCH 22/33] make commits tests pass --- lib/scm/adapters/darcs/commits.rb | 33 ++++++++++----------- test/unit/darcs_commits_test.rb | 48 ++++++++++--------------------- 2 files changed, 32 insertions(+), 49 deletions(-) diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb index eb025844..306cb31e 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/scm/adapters/darcs/commits.rb @@ -2,16 +2,15 @@ module Scm::Adapters class DarcsAdapter < AbstractAdapter # Return the number of commits in the repository following +since+. - def commit_count(since=0) - commit_tokens(since || 0).size + def commit_count(since=nil) + commit_tokens(since).size end # Return the list of commit tokens following +since+. - def commit_tokens(since=0, up_to='tip') - # We reverse the final result in Ruby, rather than passing the --reverse flag to darcs. - # That's because the -f (follow) flag doesn't behave the same in both directions. - # Basically, we're trying very hard to make this act just like Git. The darcs_rev_list_test checks this. - tokens = run("cd '#{self.url}' && darcs log -f -r #{up_to || 'tip'}:#{since || 0} --template='{node}\\n'").split("\n").reverse + def commit_tokens(since=nil, up_to=nil) + from = since ? " --from-patch #{since}" : "" + to = up_to ? " --to-patch #{up_to}" : "" + tokens = string_to_patch_names(run("cd '#{self.url}' && darcs changes#{from}#{to}")).reverse # Darcs returns everything after *and including* since. # We want to exclude it. @@ -26,10 +25,10 @@ def commit_tokens(since=0, up_to='tip') # Not including the diffs is meant to be a memory savings when we encounter massive repositories. # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit # in memory at a time. - def commits(since=0) - count = run("cd '#{self.url}' && darcs changes --count") - log = run("cd '#{self.url}' && darcs changes --last #{count-since}") - a = Scm::Parsers::DarcsParser.parse(log).reverse + def commits(since=nil) + from = since ? " --from-patch #{since}" : "" + log = run("cd '#{self.url}' && darcs changes#{from} --reverse") + a = Scm::Parsers::DarcsParser.parse(log) if a.any? && a.first.token == since a[1..-1] else @@ -47,7 +46,7 @@ def verbose_commit(token) # The log is stored in a temporary file. # This is designed to prevent excessive RAM usage when we encounter a massive repository. # Only a single commit is ever held in memory at once. - def each_commit(since=0) + def each_commit(since=nil) open_log_file(since) do |io| Scm::Parsers::DarcsParser.parse(io) do |commit| yield commit if block_given? && commit.token != since @@ -56,21 +55,23 @@ def each_commit(since=0) end # Not used by Ohloh proper, but handy for debugging and testing - def log(since=0) - run "cd '#{url}' && darcs log -f -v -r tip:#{since}" + def log(since=nil) + from = since ? " --from-patch #{since}" : "" + run "cd '#{url}' && darcs changes -s#{from}" end # Returns a file handle to the log. # In our standard, the log should include everything AFTER +since+. However, darcs doesn't work that way; # it returns everything after and INCLUDING +since+. Therefore, consumers of this file should check for # and reject the duplicate commit. - def open_log_file(since=0) + def open_log_file(since=nil) begin if since == head_token # There are no new commits # As a time optimization, just create an empty file rather than fetch a log we know will be empty. File.open(log_filename, 'w') { } else - run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsParser.verbose_style_path} > #{log_filename}" + from = since ? " --from-patch #{since}" : "" + run "cd '#{url}' && darcs changes --reverse -v#{from} > #{log_filename}" end File.open(log_filename, 'r') { |io| yield io } ensure diff --git a/test/unit/darcs_commits_test.rb b/test/unit/darcs_commits_test.rb index f65418e2..85b3e9c9 100644 --- a/test/unit/darcs_commits_test.rb +++ b/test/unit/darcs_commits_test.rb @@ -5,32 +5,18 @@ class DarcsCommitsTest < Scm::Test def test_commit with_darcs_repository('darcs') do |darcs| - assert_equal 4, darcs.commit_count - assert_equal 2, darcs.commit_count('b14fa4692f949940bd1e28da6fb4617de2615484') - assert_equal 0, darcs.commit_count('75532c1e1f1de55c2271f6fd29d98efbe35397c4') - - assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', - 'b14fa4692f949940bd1e28da6fb4617de2615484', - '468336c6671cbc58237a259d1b7326866afc2817', - '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commit_tokens - - assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], - darcs.commit_tokens('468336c6671cbc58237a259d1b7326866afc2817') - - assert_equal [], darcs.commit_tokens('75532c1e1f1de55c2271f6fd29d98efbe35397c4') - - assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', - 'b14fa4692f949940bd1e28da6fb4617de2615484', - '468336c6671cbc58237a259d1b7326866afc2817', - '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commits.collect { |c| c.token } - - assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], - darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').collect { |c| c.token } - + assert_equal 2, darcs.commit_count + assert_equal 1, darcs.commit_count('add helloworld.c') + assert_equal 0, darcs.commit_count('remove helloworld.c') + assert_equal ['add helloworld.c', 'remove helloworld.c'], darcs.commit_tokens + assert_equal ['remove helloworld.c'], darcs.commit_tokens('add helloworld.c') + assert_equal [], darcs.commit_tokens('remove helloworld.c') + assert_equal ['add helloworld.c', + 'remove helloworld.c'], darcs.commits.collect { |c| c.token } + assert_equal ['remove helloworld.c'], darcs.commits('add helloworld.c').collect { |c| c.token } # Check that the diffs are not populated - assert_equal [], darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').first.diffs - - assert_equal [], darcs.commits('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + assert_equal [], darcs.commits('add helloworld.c').first.diffs + assert_equal [], darcs.commits('remove helloworld.c') end end @@ -38,10 +24,8 @@ def test_each_commit commits = [] with_darcs_repository('darcs') do |darcs| darcs.each_commit do |c| - assert c.token.length == 40 - assert c.committer_name - assert c.committer_date.is_a?(Time) - assert c.message.length > 0 + assert c.author_name + assert c.author_date.is_a?(Time) assert c.diffs.any? # Check that the diffs are populated c.diffs.each do |d| @@ -53,10 +37,8 @@ def test_each_commit assert !FileTest.exist?(darcs.log_filename) # Make sure we cleaned up after ourselves # Verify that we got the commits in forward chronological order - assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', - 'b14fa4692f949940bd1e28da6fb4617de2615484', - '468336c6671cbc58237a259d1b7326866afc2817', - '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], commits.collect { |c| c.token } + assert_equal ['add helloworld.c', + 'remove helloworld.c'], commits.map {|c| c.token} end end end From 88dccb4cebd2c4f9cb62d2eb028465ee7486226c Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 20:15:38 -0700 Subject: [PATCH 23/33] make misc tests pass --- lib/scm/adapters/darcs/misc.rb | 9 ++++----- test/unit/darcs_misc_test.rb | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/scm/adapters/darcs/misc.rb b/lib/scm/adapters/darcs/misc.rb index 63da9052..aaabb31d 100644 --- a/lib/scm/adapters/darcs/misc.rb +++ b/lib/scm/adapters/darcs/misc.rb @@ -10,13 +10,12 @@ def exist? end def ls_tree(token) - run("cd '#{path}' && darcs manifest -r #{token}").split("\n") + run("cd '#{path}' && darcs show files -p '#{token}'").split("\n") end - def export(dest_dir, token='tip') - run("cd '#{path}' && darcs archive -r #{token} '#{dest_dir}'") - # Darcs leaves a little cookie crumb in the export directory. Remove it. - File.delete(File.join(dest_dir, '.darcs_archival.txt')) if File.exist?(File.join(dest_dir, '.darcs_archival.txt')) + def export(dest_dir, token=nil) + p = token ? " -p '#{token}'" : "" + run("cd '#{path}' && darcs dist#{p} && mv darcs.tar.gz '#{dest_dir}'") end end end diff --git a/test/unit/darcs_misc_test.rb b/test/unit/darcs_misc_test.rb index a68c7ad2..231b03a2 100644 --- a/test/unit/darcs_misc_test.rb +++ b/test/unit/darcs_misc_test.rb @@ -14,15 +14,15 @@ def test_exist def test_ls_tree with_darcs_repository('darcs') do |darcs| - assert_equal ['README','makefile'], darcs.ls_tree(darcs.head_token).sort + assert_equal ['.','./helloworld.c'], darcs.ls_tree('add helloworld.c').sort end end def test_export with_darcs_repository('darcs') do |darcs| Scm::ScratchDir.new do |dir| - darcs.export(dir) - assert_equal ['.', '..', 'README', 'makefile'], Dir.entries(dir).sort + darcs.export(dir, 'add helloworld.c') + assert_equal ['.', '..', 'darcs.tar.gz'], Dir.entries(dir).sort end end end From f546e4282ae330e25e9c6430c9e819b8f1495d60 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 21:50:10 -0700 Subject: [PATCH 24/33] make patch tests pass --- lib/scm/adapters/darcs/patch.rb | 4 +--- test/data/darcs_patch.diff | 16 ++++++++++++++++ test/unit/darcs_patch_test.rb | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 test/data/darcs_patch.diff diff --git a/lib/scm/adapters/darcs/patch.rb b/lib/scm/adapters/darcs/patch.rb index 5fe004cc..ec3a624e 100644 --- a/lib/scm/adapters/darcs/patch.rb +++ b/lib/scm/adapters/darcs/patch.rb @@ -1,9 +1,7 @@ module Scm::Adapters class DarcsAdapter < AbstractAdapter def patch_for_commit(commit) - parent_tokens(commit).map {|token| - run("darcs -R '#{url}' diff --git -r#{token} -r#{commit.token}") - }.join("\n") + run("cd '#{url}' && darcs changes -p'#{commit.token}' -v") end end end diff --git a/test/data/darcs_patch.diff b/test/data/darcs_patch.diff new file mode 100644 index 00000000..f5316e68 --- /dev/null +++ b/test/data/darcs_patch.diff @@ -0,0 +1,16 @@ +Wed Nov 3 15:49:53 PDT 2010 Simon Michael + * add helloworld.c + addfile ./helloworld.c + hunk ./helloworld.c 1 + +/* Hello, World! */ + + + +/* + + * This file is not covered by any license, especially not + + * the GNU General Public License (GPL). Have fun! + + */ + + + +#include + +main() + +{ + + printf("Hello, World!\\n"); + +} diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb index 65d517ce..578ed3fd 100644 --- a/test/unit/darcs_patch_test.rb +++ b/test/unit/darcs_patch_test.rb @@ -4,7 +4,7 @@ module Scm::Adapters class DarcsPatchTest < Scm::Test def test_patch_for_commit with_darcs_repository('darcs') do |repo| - commit = repo.verbose_commit(1) + commit = repo.verbose_commit('add helloworld.c') data = File.read(File.join(DATA_DIR, 'darcs_patch.diff')) assert_equal data, repo.patch_for_commit(commit) end From 997cdc140b8368c7c81bdd6c8fb2777e12e1c60a Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 21:55:48 -0700 Subject: [PATCH 25/33] make pull test pass --- lib/scm/adapters/darcs/pull.rb | 5 +++-- test/unit/darcs_pull_test.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/scm/adapters/darcs/pull.rb index cecfbabf..7aa6c01a 100644 --- a/lib/scm/adapters/darcs/pull.rb +++ b/lib/scm/adapters/darcs/pull.rb @@ -10,9 +10,10 @@ def pull(from, &block) unless self.exist? run "mkdir -p '#{self.url}'" run "rm -rf '#{self.url}'" - run "darcs clone -U '#{from.url}' '#{self.url}'" + run "darcs get '#{from.url}' '#{self.url}'" else - run "cd '#{self.url}' && darcs revert --all && darcs pull -u -y '#{from.url}'" + # might also need to unpull for an exact copy + run "cd '#{self.url}' && darcs revert --all && darcs pull -a '#{from.url}'" end yield(1,1) if block_given? # Progress bar callback diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb index fad9251b..70effdc3 100644 --- a/test/unit/darcs_pull_test.rb +++ b/test/unit/darcs_pull_test.rb @@ -16,7 +16,7 @@ def test_pull assert_equal src.log, dest.log # Commit some new code on the original and pull again - src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" assert_equal "test\n", src.commits.last.message dest.pull(src) From 978ae913f7ce29a3b5c2bc1af1c1454873065aa2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 22:01:35 -0700 Subject: [PATCH 26/33] make push tests pass --- lib/scm/adapters/darcs/push.rb | 5 ++--- test/unit/darcs_push_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/scm/adapters/darcs/push.rb b/lib/scm/adapters/darcs/push.rb index 721609cf..1988a4d7 100644 --- a/lib/scm/adapters/darcs/push.rb +++ b/lib/scm/adapters/darcs/push.rb @@ -12,11 +12,10 @@ def push(to, &block) # Create a new repo on the same local machine. Just use existing pull code in reverse. to.pull(self) else - run "ssh #{to.hostname} 'mkdir -p #{to.path}'" - run "scp -rpqB #{darcs_path} #{to.hostname}:#{to.path}" + run "cd '#{self.url}' && darcs put #{to.hostname}:#{to.path}" end else - run "cd '#{self.url}' && darcs push -f -y '#{to.url}'" + run "cd '#{self.url}' && darcs push -a '#{to.url}'" end yield(1,1) if block_given? # Progress bar callback diff --git a/test/unit/darcs_push_test.rb b/test/unit/darcs_push_test.rb index e72bfef6..843c8c06 100644 --- a/test/unit/darcs_push_test.rb +++ b/test/unit/darcs_push_test.rb @@ -46,8 +46,8 @@ def test_push assert_equal src.log, dest.log # Commit some new code on the original and pull again - src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" - assert_equal "test\n", src.commits.last.message + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" + assert_equal "test", src.commits.last.token src.push(dest) assert_equal src.log, dest.log From c73741bece3b2bdaa9a837fcc008ec431dab741b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 22:22:51 -0700 Subject: [PATCH 27/33] make rev_list tests pass --- test/repositories/darcs_walk/A | 0 test/repositories/darcs_walk/B | 0 test/repositories/darcs_walk/C | 0 test/repositories/darcs_walk/D | 0 test/repositories/darcs_walk/E | 0 .../darcs_walk/_darcs/.gitattributes | 1 + test/repositories/darcs_walk/_darcs/format | 2 + .../darcs_walk/_darcs/hashed_inventory | 26 ++++ test/repositories/darcs_walk/_darcs/index | Bin 0 -> 284 bytes .../darcs_walk/_darcs/index_invalid | 0 ...ddba010c991016fa3380d0849fb4927ce7d0c329c1 | Bin 0 -> 171 bytes ...e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c | Bin 0 -> 245 bytes ...62809cfc1f579d4f0176f3cdc20ca3efc39006d766 | Bin 0 -> 309 bytes ...a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 | Bin 0 -> 376 bytes ...b7b68c41fe659b7aa8cebacce52507998aac85fdb2 | Bin 0 -> 440 bytes ...d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 | Bin 0 -> 125 bytes ...0839eb238e27372a3edd550e0097491168ab71442e | Bin 0 -> 128 bytes ...41d00b5d43da90be1d5d55540f61d22420172ea0fa | Bin 0 -> 128 bytes ...975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 | Bin 0 -> 127 bytes ...1a64605d9c72fdbef99dbeedb503c66548052692e0 | Bin 0 -> 127 bytes .../darcs_walk/_darcs/patches/pending | 2 + .../_darcs/patches/pending.tentative | 2 + .../darcs_walk/_darcs/prefs/binaries | 30 +++++ .../darcs_walk/_darcs/prefs/boring | 113 ++++++++++++++++++ .../repositories/darcs_walk/_darcs/prefs/motd | 0 ...24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 | Bin 0 -> 90 bytes ...0b3cc263477c4403af180d2113e0f954fd3869dbda | Bin 0 -> 94 bytes ...69d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 | Bin 0 -> 97 bytes ...b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c | Bin 0 -> 81 bytes ...f9dd26fcb11b14378071e255da2e62c043020d277b | Bin 0 -> 100 bytes ...c8996fb92427ae41e4649b934ca495991b7852b855 | Bin 0 -> 20 bytes .../darcs_walk/_darcs/tentative_pristine | 1 + test/unit/darcs_rev_list_test.rb | 58 ++------- 33 files changed, 187 insertions(+), 48 deletions(-) create mode 100644 test/repositories/darcs_walk/A create mode 100644 test/repositories/darcs_walk/B create mode 100644 test/repositories/darcs_walk/C create mode 100644 test/repositories/darcs_walk/D create mode 100644 test/repositories/darcs_walk/E create mode 100644 test/repositories/darcs_walk/_darcs/.gitattributes create mode 100644 test/repositories/darcs_walk/_darcs/format create mode 100644 test/repositories/darcs_walk/_darcs/hashed_inventory create mode 100644 test/repositories/darcs_walk/_darcs/index create mode 100644 test/repositories/darcs_walk/_darcs/index_invalid create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000368-79230da93a2f69dadf7df4e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 create mode 100644 test/repositories/darcs_walk/_darcs/patches/pending create mode 100644 test/repositories/darcs_walk/_darcs/patches/pending.tentative create mode 100644 test/repositories/darcs_walk/_darcs/prefs/binaries create mode 100644 test/repositories/darcs_walk/_darcs/prefs/boring create mode 100644 test/repositories/darcs_walk/_darcs/prefs/motd create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 create mode 100644 test/repositories/darcs_walk/_darcs/tentative_pristine diff --git a/test/repositories/darcs_walk/A b/test/repositories/darcs_walk/A new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/B b/test/repositories/darcs_walk/B new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/C b/test/repositories/darcs_walk/C new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/D b/test/repositories/darcs_walk/D new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/E b/test/repositories/darcs_walk/E new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/_darcs/.gitattributes b/test/repositories/darcs_walk/_darcs/.gitattributes new file mode 100644 index 00000000..bd2de00c --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/.gitattributes @@ -0,0 +1 @@ +* -text -whitespace diff --git a/test/repositories/darcs_walk/_darcs/format b/test/repositories/darcs_walk/_darcs/format new file mode 100644 index 00000000..58f777b5 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/format @@ -0,0 +1,2 @@ +hashed +darcs-2 diff --git a/test/repositories/darcs_walk/_darcs/hashed_inventory b/test/repositories/darcs_walk/_darcs/hashed_inventory new file mode 100644 index 00000000..7f73a4b4 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/hashed_inventory @@ -0,0 +1,26 @@ +pristine:dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b +[A +Simon Michael **20101105050558 + Ignore-this: 5bd1c52f9c7bd77d62ea0054db2d270a +] +hash: 0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 +[B +Simon Michael **20101105050612 + Ignore-this: 3e8e6c2038387eb0dbabf3264560312f +] +hash: 0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e +[C +Simon Michael **20101105050616 + Ignore-this: dbcc2fcc273925ffc86fe213e309a8f +] +hash: 0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 +[D +Simon Michael **20101105050618 + Ignore-this: ab9f04d0e28d346d14ca5f5375da7e0b +] +hash: 0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa +[E +Simon Michael **20101105050621 + Ignore-this: 12c991491d6b5693d3b90622958a985c +] +hash: 0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 diff --git a/test/repositories/darcs_walk/_darcs/index b/test/repositories/darcs_walk/_darcs/index new file mode 100644 index 0000000000000000000000000000000000000000..a14b024022f365a032e01a4cf2ded2fedd657766 GIT binary patch literal 284 zcmeYW_B3ID0vSdKgBeJj_BG`XNV%B(f98bDn_pKP5MAkLacwWx?YRFJx9#%g`{AMo z)5XAWYQkk75D%p9@rEN#Gycek%=-Q1#LWDiD(dSTpQOy5?6YL*OzDcC9ieV62z@6= W(dUfNcZ3vuP6&M)NYUrWzyJWg6J!Vg literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/index_invalid b/test/repositories/darcs_walk/_darcs/index_invalid new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 b/test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 new file mode 100644 index 0000000000000000000000000000000000000000..084626c2c372c16ba9303af7ccc116483422cb7c GIT binary patch literal 171 zcmV;c095}UiwFP!0000010{^T3c@fHM)y2LW}$L(&AmyAh>i|Uj^dDCTWK4xI{5as z_#HTKmhW~F*M6*%y!5g2d64^g&EvCv%V*feIvzF~1O-X~t&kP+{Fv%1H}9^WTS+0Q zNLXAnAsLexvj-rZ0wy%z#a)Wd&s{6wKc%p7Hdrido$=9UovmRwb!{rNlqeA z@b+9phiI6QMw({y&HiC{nNQ1ke4gu6{5alTuJ!(H`Rbp?o4TCtHXDQhApl)XI*d<; z^YZT7k7>T_MzR(vVb4{pi8Mwp0F;_xLxD29j>A+g({6+xg@D_vrr24tlv+Hw3TMJl zI5ALLr?5Bkp7WaCj38EKN(zLW(P7v>{*Rjj{^E|V&J`hQRB?l5#d<_e#1I4aKe^Xm v1XdiCq)RUALjwkl*$tyQN)#;7TO$Go$dYmhti>dxgg$%&V6({`Z~*`S#jtN6 literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 b/test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 new file mode 100644 index 0000000000000000000000000000000000000000..b25438ba6742de2c1b8e73c083034d089ff998fe GIT binary patch literal 309 zcmV-50m}X#iwFP!000001C^1xN`yfSh5P?0{#sZ`GLy@Qh?mO3%5t%onPl7*b-~rb zw|B%&Y)nWX&EY#a+pFb%|8jU;@AiFH<9R(lexH|5htKixeA*8$7bhnK2#CPn&9iVDEl8#yV|+;cv7)ut$YCml z39DoQ_9;cfTZ~fX4sQ&pi*Pnzl0pH?_WFO^g7k|!g@ts2WXUudc&lwBlFR}LY5d7O zeKE8eWUNC=oemoaSSrydS&$~Bn!=qK0-$Ivh+?%V=1j3{Z~n_Izqq~iPGgRyLOez{ z89|sLL8jwo!)oF HCjtNfpu3Vw literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 b/test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 new file mode 100644 index 0000000000000000000000000000000000000000..7ff9ebc14dbffd32ac2b78f061d2f70680eb7378 GIT binary patch literal 376 zcmV-;0f+t{iwFP!000001C^4$kJB*>#rN-D(fOnz+llSugb=?L1}4Ue!HykTba#~~ z4E*<`VmozdqFBoE^m*_3@L~IQdOpAGzMjU>@@e<>a{a#ldHy^9JiQs`=XVbe1PF-0 z*UN3&efjZn{+0XR$J6C;#~wJCW*_RI8bWCRT*E0y!M5+a?P!|+L?&XWYEvd0i?Y0~`2(;4Esk9_5N>(z084{pt?TFIM6>Fv34xjGjmRH>2W6)er zODCRlG?__QvOu?X3mf;XIQJ$?%@jq#kQQ^`w6@A~pr)%l4o;{z>j>0_3N=)?r3a^?zC WFo^2n(CZRT+x`Ip{EHyp0ssI3c)nEt literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 b/test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 new file mode 100644 index 0000000000000000000000000000000000000000..76e9f8127e676739b1b6385e3c564a10152e52c4 GIT binary patch literal 440 zcmV;p0Z0BHiwFP!000001C^3Ji<~hGg!}hbY<+M+k}cUfj*!nHMXHob3d@qR8}4o) zmlXN;@se)YW^HURnBkcj?cZ z_`JDqyDvXpPQT**_u=^Zuw!$aOsTV(x8_1I0Jyr5Q-iU6-))ESdU)8u|Ak2R+O1Pc z*EZ&e8oh}!;gBl8zN9GKB30KNZVY9LaP7b(N&(yc!)@GxbirMshfIRfOK)M|HY^KC zWr2c}SGkuj1{*=0TQ(ibp@Bdz8b+lDwbE#maA$@9&{h>u`mlzzQf&K=w{pt`x7(bQ z>$IZ8nX^j4#0S!1cFfUNc?Q(mDvzB5DrTLItz(1gD-wW- z+y2w7*q386Omhjsiq10cqV7A zkb+KB7e_k}VUBJ8`9^NS3vQ&TimOEzW6|QpbbTY`KD6_^%H3dsC9CpG&z@%3Bz1Z1 isn$zC%wkBMEYp{@nP3wOOzv~J-2MSwbQ7DG0{{R6Xx^v* literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 b/test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 new file mode 100644 index 0000000000000000000000000000000000000000..31b4b2e99312833366361bb3115c31787b6b8087 GIT binary patch literal 125 zcmb2|=3oE==I*j*T<6Z5Js{a|_(&ys0TekG@@bL2R z^7=GhICG)L`=GI{{(g{a|_(&ys0TekG@@bL2R z^7=GhICG)H`=GI{{(gXG^X!ciXO3Js gbKu4Wjb80AMMG6pU1Rl7NB{er47MzGi3LE50X7Ra7XSbN literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa b/test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa new file mode 100644 index 0000000000000000000000000000000000000000..5191b93cf85fe5f3b5074f544cc9fae2fb97b04d GIT binary patch literal 128 zcmb2|=3oE==I*kGT<6Z5Js{a|_(&ys0TekG@@bL2R z^7=GhICG)N`=GI{{(gU&r|TtOwLG5%~7x^25}v-@+;FybM%t)bM3UW zj0_A73=IuTfzZszkW0ZcJukl~RktJ~v)D?(&?wo`($K`xFvTp%)XdU2#W=|lsLaUH h)FRQ+!ZevHRv|GZB`q^2RY6bR6#y{a|_(&ys0TekG@@bL2R z^7=SlxYFc((AZXgzeebG73Ix0ybhXZ9yPdmMdPf|O&iUlcWjQH(J;Mu;J_6X)sq@W fPux+Ms2!$gsH&=KtRCv0-(JBl{PiF literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/patches/pending b/test/repositories/darcs_walk/_darcs/patches/pending new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/patches/pending @@ -0,0 +1,2 @@ +{ +} diff --git a/test/repositories/darcs_walk/_darcs/patches/pending.tentative b/test/repositories/darcs_walk/_darcs/patches/pending.tentative new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/patches/pending.tentative @@ -0,0 +1,2 @@ +{ +} diff --git a/test/repositories/darcs_walk/_darcs/prefs/binaries b/test/repositories/darcs_walk/_darcs/prefs/binaries new file mode 100644 index 00000000..ac206487 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/prefs/binaries @@ -0,0 +1,30 @@ +# This file contains a list of extended regular expressions, one per +# line. A file path matching any of these expressions is assumed to +# contain binary data (not text). The entries in ~/.darcs/binaries (if +# it exists) supplement those in this file. +# +# Blank lines, and lines beginning with an octothorpe (#) are ignored. +# See regex(7) for a description of extended regular expressions. +\.(a|A)$ +\.(bmp|BMP)$ +\.(bz2|BZ2)$ +\.(doc|DOC)$ +\.(elc|ELC)$ +\.(exe|EXE)$ +\.(gif|GIF)$ +\.(gz|GZ)$ +\.(iso|ISO)$ +\.(jar|JAR)$ +\.(jpe?g|JPE?G)$ +\.(mng|MNG)$ +\.(mpe?g|MPE?G)$ +\.(p[nbgp]m|P[NBGP]M)$ +\.(pdf|PDF)$ +\.(png|PNG)$ +\.(pyc|PYC)$ +\.(so|SO)$ +\.(tar|TAR)$ +\.(tgz|TGZ)$ +\.(tiff?|TIFF?)$ +\.(z|Z)$ +\.(zip|ZIP)$ diff --git a/test/repositories/darcs_walk/_darcs/prefs/boring b/test/repositories/darcs_walk/_darcs/prefs/boring new file mode 100644 index 00000000..5969e686 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/prefs/boring @@ -0,0 +1,113 @@ +# Boring file regexps: + +### compiler and interpreter intermediate files +# haskell (ghc) interfaces +\.hi$ +\.hi-boot$ +\.o-boot$ +# object files +\.o$ +\.o\.cmd$ +# profiling haskell +\.p_hi$ +\.p_o$ +# haskell program coverage resp. profiling info +\.tix$ +\.prof$ +# fortran module files +\.mod$ +# linux kernel +\.ko\.cmd$ +\.mod\.c$ +(^|/)\.tmp_versions($|/) +# *.ko files aren't boring by default because they might +# be Korean translations rather than kernel modules +# \.ko$ +# python, emacs, java byte code +\.py[co]$ +\.elc$ +\.class$ +# objects and libraries; lo and la are libtool things +\.(obj|a|exe|so|lo|la)$ +# compiled zsh configuration files +\.zwc$ +# Common LISP output files for CLISP and CMUCL +\.(fas|fasl|sparcf|x86f)$ + +### build and packaging systems +# cabal intermediates +\.installed-pkg-config +\.setup-config +# standard cabal build dir, might not be boring for everybody +# ^dist(/|$) +# autotools +(^|/)autom4te\.cache($|/) +(^|/)config\.(log|status)$ +# microsoft web expression, visual studio metadata directories +\_vti_cnf$ +\_vti_pvt$ +# gentoo tools +\.revdep-rebuild.* +# generated dependencies +^\.depend$ + +### version control systems +# cvs +(^|/)CVS($|/) +\.cvsignore$ +# cvs, emacs locks +^\.# +# rcs +(^|/)RCS($|/) +,v$ +# subversion +(^|/)\.svn($|/) +# mercurial +(^|/)\.hg($|/) +# git +(^|/)\.git($|/) +# bzr +\.bzr$ +# sccs +(^|/)SCCS($|/) +# darcs +(^|/)_darcs($|/) +(^|/)\.darcsrepo($|/) +^\.darcs-temp-mail$ +-darcs-backup[[:digit:]]+$ +# gnu arch +(^|/)(\+|,) +(^|/)vssver\.scc$ +\.swp$ +(^|/)MT($|/) +(^|/)\{arch\}($|/) +(^|/).arch-ids($|/) +# bitkeeper +(^|/)BitKeeper($|/) +(^|/)ChangeSet($|/) + +### miscellaneous +# backup files +~$ +\.bak$ +\.BAK$ +# patch originals and rejects +\.orig$ +\.rej$ +# X server +\..serverauth.* +# image spam +\# +(^|/)Thumbs\.db$ +# vi, emacs tags +(^|/)(tags|TAGS)$ +#(^|/)\.[^/] +# core dumps +(^|/|\.)core$ +# partial broken files (KIO copy operations) +\.part$ +# waf files, see http://code.google.com/p/waf/ +(^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/) +(^|/)\.lock-wscript$ +# mac os finder +(^|/)\.DS_Store$ diff --git a/test/repositories/darcs_walk/_darcs/prefs/motd b/test/repositories/darcs_walk/_darcs/prefs/motd new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 b/test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 new file mode 100644 index 0000000000000000000000000000000000000000..705f11392fc7b9a1810d188671daac5860b6d7e7 GIT binary patch literal 90 zcmb2|=3oE==A~yg@-`UoupF?vEb!UyPss+)oSQ;Izps0&Ilx;`YG1i!^V4_H3{IVm;CLI^W}W^b`sD?04fzEi~s-t literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda b/test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda new file mode 100644 index 0000000000000000000000000000000000000000..0726896b0523dfc58dddcc0a73d29b1ef4d8e057 GIT binary patch literal 94 zcmb2|=3oE==Cx-w@-`UoupF?vEb!U$Psst5jj7%qZ{n3VGTmXAeqA>DruUj{77ACs xyb_(0$r-+Bd7wfvTh@Z+W1@Bk-NK}A9oe#VQhv!F(Yf~*v&RH|+IJghEC9#5C-DFP literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 b/test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 new file mode 100644 index 0000000000000000000000000000000000000000..19c12c5edd6eebb8e7ffdd68e5a320c91268434c GIT binary patch literal 97 zcmb2|=3oE==Cx-|@-`UoupFpgb@1e~h&q|xBhz#hFaDSA6ieWmu_G`3^0YlKk{q6K z2n!dqvE@wAog%r@zuiJ=h0X@fu%Ipdvr4bbder-E|Dwn1U;L4?eLksuq6#Ae0{~u{ BDh>bu literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c b/test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c new file mode 100644 index 0000000000000000000000000000000000000000..e5a5fa87d36f6be14b66250fa679decfea2d031e GIT binary patch literal 81 zcmb2|=3oE=X4Zonc@G$HupGE|ndQ%onq56f0v;1L)z95sw}01h literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b b/test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b new file mode 100644 index 0000000000000000000000000000000000000000..53d9e6f8f8c8ad55ad627bcfbbeb8ff31a0fa8f3 GIT binary patch literal 100 zcmb2|=3oE==Cx-|@-`UoupFpgrFiaHL|shlkuV*_i~prN#ZHJA)Y&KVMoV~#Gq;@8 zjbhoo`mj`FjOK(}?2jB6r*d99=;O9lw|m>1=K70v+E!_<&)2;8CBN5Z23un;BLf2f D7GfrZ literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000000000000000000000000000000000..229151a5a27ab0cc4661f529cc0eda27e3c03e10 GIT binary patch literal 20 Rcmb2|=3oE=W@ZQtBmoVe0J#7F literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/tentative_pristine b/test/repositories/darcs_walk/_darcs/tentative_pristine new file mode 100644 index 00000000..0411d1a5 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/tentative_pristine @@ -0,0 +1 @@ +pristine:dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b diff --git a/test/unit/darcs_rev_list_test.rb b/test/unit/darcs_rev_list_test.rb index c7cb83b8..849c42f3 100644 --- a/test/unit/darcs_rev_list_test.rb +++ b/test/unit/darcs_rev_list_test.rb @@ -3,61 +3,23 @@ module Scm::Adapters # Repository darcs_walk has the following structure: # - # G -> H -> I - # / \ \ - # A -> B -> C -> D -> tip + # A -> B -> C -> D -> E # class DarcsRevListTest < Scm::Test def test_rev_list with_darcs_repository('darcs_walk') do |darcs| # Full history to a commit - assert_equal [:A], rev_list_helper(darcs, nil, :A) - assert_equal [:A, :B], rev_list_helper(darcs, nil, :B) - assert_equal [:A, :B, :G, :H, :C], rev_list_helper(darcs, nil, :C) - assert_equal [:A, :B, :G, :H, :C, :I, :D], rev_list_helper(darcs, nil, :D) - assert_equal [:A, :G], rev_list_helper(darcs, nil, :G) - assert_equal [:A, :G, :H], rev_list_helper(darcs, nil, :H) - assert_equal [:A, :G, :H, :I], rev_list_helper(darcs, nil, :I) - - # Limited history from one commit to another - assert_equal [], rev_list_helper(darcs, :A, :A) - assert_equal [:B], rev_list_helper(darcs, :A, :B) - assert_equal [:B, :G, :H, :C], rev_list_helper(darcs, :A, :C) - assert_equal [:B, :G, :H, :C, :I, :D], rev_list_helper(darcs, :A, :D) - assert_equal [:G, :H, :C, :I, :D], rev_list_helper(darcs, :B, :D) - assert_equal [:I, :D], rev_list_helper(darcs, :C, :D) + assert_equal ["A"], darcs.commit_tokens(nil, "A") + assert_equal ["A","B"], darcs.commit_tokens(nil, "B") + assert_equal ["A","B","C","D","E"], darcs.commit_tokens(nil, "E") + assert_equal ["A","B","C","D","E"], darcs.commit_tokens(nil, nil) + + # # Limited history from one commit to another + assert_equal [], darcs.commit_tokens("A", "A") + assert_equal ["B"], darcs.commit_tokens("A", "B") + assert_equal ["B","C","D"], darcs.commit_tokens("A", "D") end end - - protected - - def rev_list_helper(darcs, from, to) - to_labels(darcs.commit_tokens(from_label(from), from_label(to))) - end - - def commit_labels - { '4bfbf836feeebb236492199fbb0d1474e26f69d9' => :A, - '23edb79d0d06c8c315d8b9e7456098823335377d' => :B, - '7e33b9fde56a6e3576753868d08fa143e4e8a9cf' => :C, - '8daa1aefa228d3ee5f9a0f685d696826e88266fb' => :D, - 'e43cf1bb4b80d8ae70a695ec070ce017fdc529f3' => :G, - 'dca215d8a3e4dd3e472379932f1dd9c909230331' => :H, - '3a1495175e40b1c983441d6a8e8e627d2bd672b6' => :I - } - end - - def to_label(sha1) - commit_labels[sha1.to_s] - end - - def to_labels(sha1s) - sha1s.collect { |sha1| to_label(sha1) } - end - - def from_label(l) - commit_labels.each_pair { |k,v| return k if v.to_s == l.to_s } - nil - end end end From 1e969d22aa3c346132e9ae6ca17be22469e5ecc6 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 22:36:36 -0700 Subject: [PATCH 28/33] fix a breakage --- test/unit/darcs_pull_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb index 70effdc3..e34f5060 100644 --- a/test/unit/darcs_pull_test.rb +++ b/test/unit/darcs_pull_test.rb @@ -17,7 +17,7 @@ def test_pull # Commit some new code on the original and pull again src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" - assert_equal "test\n", src.commits.last.message + assert_equal "test", src.commits.last.token dest.pull(src) assert_equal src.log, dest.log From fe7c8ca36f5f5ed5379f3677faa086956079f1df Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 23:16:12 -0700 Subject: [PATCH 29/33] do not pull from repos with unresolved conflicts --- lib/scm/adapters/darcs/pull.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/scm/adapters/darcs/pull.rb index 7aa6c01a..299ebf23 100644 --- a/lib/scm/adapters/darcs/pull.rb +++ b/lib/scm/adapters/darcs/pull.rb @@ -13,7 +13,7 @@ def pull(from, &block) run "darcs get '#{from.url}' '#{self.url}'" else # might also need to unpull for an exact copy - run "cd '#{self.url}' && darcs revert --all && darcs pull -a '#{from.url}'" + run "cd '#{self.url}' && darcs revert --all && darcs pull --dont-allow-conflicts -a '#{from.url}'" end yield(1,1) if block_given? # Progress bar callback From 39728ef083825d1b4b03433578e64f165bc0950f Mon Sep 17 00:00:00 2001 From: Peter Degen-Portnoy Date: Tue, 14 Oct 2014 23:22:36 +0000 Subject: [PATCH 30/33] Merge simonmichael-topic/darcs --- lib/ohloh_scm/adapters/svn/misc.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ohloh_scm/adapters/svn/misc.rb b/lib/ohloh_scm/adapters/svn/misc.rb index ad8eebc1..d047b69c 100644 --- a/lib/ohloh_scm/adapters/svn/misc.rb +++ b/lib/ohloh_scm/adapters/svn/misc.rb @@ -133,10 +133,8 @@ def opt_auth " #{opt_password} --no-auth-cache " end - class << self - def has_conflicts?(working_copy_url) - system("cd '#{ working_copy_url }' && svn status | grep 'Summary of conflicts'") - end + def self.has_conflicts?(working_copy_url) + system("cd '#{ working_copy_url }' && svn status | grep 'Summary of conflicts'") end end end From 06318c44a2ec3de45f6b10e5b6b8aa2d60aafb83 Mon Sep 17 00:00:00 2001 From: Peter Degen-Portnoy Date: Wed, 15 Oct 2014 21:53:46 +0000 Subject: [PATCH 31/33] Resolved namespacing issues --- lib/ohloh_scm.rb | 2 ++ .../adapters/darcs/cat_file.rb | 2 +- lib/{scm => ohloh_scm}/adapters/darcs/commits.rb | 8 ++++---- lib/{scm => ohloh_scm}/adapters/darcs/head.rb | 2 +- lib/{scm => ohloh_scm}/adapters/darcs/misc.rb | 2 +- lib/{scm => ohloh_scm}/adapters/darcs/patch.rb | 2 +- lib/{scm => ohloh_scm}/adapters/darcs/pull.rb | 2 +- lib/{scm => ohloh_scm}/adapters/darcs/push.rb | 2 +- .../adapters/darcs/validation.rb | 2 +- lib/ohloh_scm/adapters/darcs_adapter.rb | 16 ++++++++++++++++ lib/{scm => ohloh_scm}/parsers/darcs_parser.rb | 2 +- lib/scm/adapters/darcs_adapter.rb | 16 ---------------- test/unit/darcs_cat_file_test.rb | 4 ++-- test/unit/darcs_commits_test.rb | 4 ++-- test/unit/darcs_head_test.rb | 4 ++-- test/unit/darcs_misc_test.rb | 4 ++-- test/unit/darcs_parser_test.rb | 4 ++-- test/unit/darcs_patch_test.rb | 4 ++-- test/unit/darcs_pull_test.rb | 4 ++-- test/unit/darcs_push_test.rb | 4 ++-- test/unit/darcs_rev_list_test.rb | 4 ++-- test/unit/darcs_validation_test.rb | 4 ++-- 22 files changed, 50 insertions(+), 48 deletions(-) rename lib/{scm => ohloh_scm}/adapters/darcs/cat_file.rb (96%) rename lib/{scm => ohloh_scm}/adapters/darcs/commits.rb (93%) rename lib/{scm => ohloh_scm}/adapters/darcs/head.rb (95%) rename lib/{scm => ohloh_scm}/adapters/darcs/misc.rb (93%) rename lib/{scm => ohloh_scm}/adapters/darcs/patch.rb (85%) rename lib/{scm => ohloh_scm}/adapters/darcs/pull.rb (96%) rename lib/{scm => ohloh_scm}/adapters/darcs/push.rb (97%) rename lib/{scm => ohloh_scm}/adapters/darcs/validation.rb (96%) create mode 100644 lib/ohloh_scm/adapters/darcs_adapter.rb rename lib/{scm => ohloh_scm}/parsers/darcs_parser.rb (98%) delete mode 100644 lib/scm/adapters/darcs_adapter.rb diff --git a/lib/ohloh_scm.rb b/lib/ohloh_scm.rb index cf0c9299..2493308e 100644 --- a/lib/ohloh_scm.rb +++ b/lib/ohloh_scm.rb @@ -19,6 +19,7 @@ module OhlohScm require_relative 'ohloh_scm/adapters/hglib_adapter' require_relative 'ohloh_scm/adapters/bzr_adapter' require_relative 'ohloh_scm/adapters/bzrlib_adapter' +require_relative 'ohloh_scm/adapters/darcs_adapter' require_relative 'ohloh_scm/adapters/factory' require_relative 'ohloh_scm/parsers/parser' @@ -32,6 +33,7 @@ module OhlohScm require_relative 'ohloh_scm/parsers/hg_styled_parser' require_relative 'ohloh_scm/parsers/bzr_xml_parser' require_relative 'ohloh_scm/parsers/bzr_parser' +require_relative 'ohloh_scm/parsers/darcs_parser' require_relative 'ohloh_scm/parsers/array_writer' require_relative 'ohloh_scm/parsers/xml_writer' diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/ohloh_scm/adapters/darcs/cat_file.rb similarity index 96% rename from lib/scm/adapters/darcs/cat_file.rb rename to lib/ohloh_scm/adapters/darcs/cat_file.rb index 6157ad8a..25b75c6f 100644 --- a/lib/scm/adapters/darcs/cat_file.rb +++ b/lib/ohloh_scm/adapters/darcs/cat_file.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def cat_file(commit, diff) cat(commit.token, diff.path) diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/ohloh_scm/adapters/darcs/commits.rb similarity index 93% rename from lib/scm/adapters/darcs/commits.rb rename to lib/ohloh_scm/adapters/darcs/commits.rb index 306cb31e..230c38d7 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/ohloh_scm/adapters/darcs/commits.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter # Return the number of commits in the repository following +since+. @@ -28,7 +28,7 @@ def commit_tokens(since=nil, up_to=nil) def commits(since=nil) from = since ? " --from-patch #{since}" : "" log = run("cd '#{self.url}' && darcs changes#{from} --reverse") - a = Scm::Parsers::DarcsParser.parse(log) + a = OhlohScm::Parsers::DarcsParser.parse(log) if a.any? && a.first.token == since a[1..-1] else @@ -39,7 +39,7 @@ def commits(since=nil) # Returns a single commit, including its diffs def verbose_commit(token) log = run("cd '#{self.url}' && darcs changes -v -p '#{token}'") - Scm::Parsers::DarcsParser.parse(log).first + OhlohScm::Parsers::DarcsParser.parse(log).first end # Yields each commit after +since+, including its diffs. @@ -48,7 +48,7 @@ def verbose_commit(token) # Only a single commit is ever held in memory at once. def each_commit(since=nil) open_log_file(since) do |io| - Scm::Parsers::DarcsParser.parse(io) do |commit| + OhlohScm::Parsers::DarcsParser.parse(io) do |commit| yield commit if block_given? && commit.token != since end end diff --git a/lib/scm/adapters/darcs/head.rb b/lib/ohloh_scm/adapters/darcs/head.rb similarity index 95% rename from lib/scm/adapters/darcs/head.rb rename to lib/ohloh_scm/adapters/darcs/head.rb index 5ef26701..787b4c3c 100644 --- a/lib/scm/adapters/darcs/head.rb +++ b/lib/ohloh_scm/adapters/darcs/head.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def head_token string_to_patch_names(run("cd '#{url}' && darcs changes --last 1"))[0] diff --git a/lib/scm/adapters/darcs/misc.rb b/lib/ohloh_scm/adapters/darcs/misc.rb similarity index 93% rename from lib/scm/adapters/darcs/misc.rb rename to lib/ohloh_scm/adapters/darcs/misc.rb index aaabb31d..9d516743 100644 --- a/lib/scm/adapters/darcs/misc.rb +++ b/lib/ohloh_scm/adapters/darcs/misc.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def exist? begin diff --git a/lib/scm/adapters/darcs/patch.rb b/lib/ohloh_scm/adapters/darcs/patch.rb similarity index 85% rename from lib/scm/adapters/darcs/patch.rb rename to lib/ohloh_scm/adapters/darcs/patch.rb index ec3a624e..4c962a00 100644 --- a/lib/scm/adapters/darcs/patch.rb +++ b/lib/ohloh_scm/adapters/darcs/patch.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def patch_for_commit(commit) run("cd '#{url}' && darcs changes -p'#{commit.token}' -v") diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/ohloh_scm/adapters/darcs/pull.rb similarity index 96% rename from lib/scm/adapters/darcs/pull.rb rename to lib/ohloh_scm/adapters/darcs/pull.rb index 299ebf23..48fda1a8 100644 --- a/lib/scm/adapters/darcs/pull.rb +++ b/lib/ohloh_scm/adapters/darcs/pull.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def pull(from, &block) diff --git a/lib/scm/adapters/darcs/push.rb b/lib/ohloh_scm/adapters/darcs/push.rb similarity index 97% rename from lib/scm/adapters/darcs/push.rb rename to lib/ohloh_scm/adapters/darcs/push.rb index 1988a4d7..a5e35729 100644 --- a/lib/scm/adapters/darcs/push.rb +++ b/lib/ohloh_scm/adapters/darcs/push.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def push(to, &block) diff --git a/lib/scm/adapters/darcs/validation.rb b/lib/ohloh_scm/adapters/darcs/validation.rb similarity index 96% rename from lib/scm/adapters/darcs/validation.rb rename to lib/ohloh_scm/adapters/darcs/validation.rb index e265f6ef..f9adc1fe 100644 --- a/lib/scm/adapters/darcs/validation.rb +++ b/lib/ohloh_scm/adapters/darcs/validation.rb @@ -1,4 +1,4 @@ -module Scm::Adapters +module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def self.url_regex /^((http|https|ssh|file):\/\/((\w+@)?[A-Za-z0-9_\-\.]+(:\d+)?\/)?)?[A-Za-z0-9_\-\.\/\~\+]*$/ diff --git a/lib/ohloh_scm/adapters/darcs_adapter.rb b/lib/ohloh_scm/adapters/darcs_adapter.rb new file mode 100644 index 00000000..0fdb7f3c --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs_adapter.rb @@ -0,0 +1,16 @@ +module OhlohScm::Adapters + class DarcsAdapter < AbstractAdapter + def english_name + "Darcs" + end + end +end + +require_relative 'darcs/validation' +require_relative 'darcs/cat_file' +require_relative 'darcs/commits' +require_relative 'darcs/misc' +require_relative 'darcs/pull' +require_relative 'darcs/push' +require_relative 'darcs/head' +require_relative 'darcs/patch' diff --git a/lib/scm/parsers/darcs_parser.rb b/lib/ohloh_scm/parsers/darcs_parser.rb similarity index 98% rename from lib/scm/parsers/darcs_parser.rb rename to lib/ohloh_scm/parsers/darcs_parser.rb index 286dec88..e267d508 100644 --- a/lib/scm/parsers/darcs_parser.rb +++ b/lib/ohloh_scm/parsers/darcs_parser.rb @@ -1,4 +1,4 @@ -module Scm::Parsers +module OhlohScm::Parsers # This parser can process the default darcs changes output #, with or without the --verbose flag. class DarcsParser < Parser def self.scm diff --git a/lib/scm/adapters/darcs_adapter.rb b/lib/scm/adapters/darcs_adapter.rb deleted file mode 100644 index 58ab0aed..00000000 --- a/lib/scm/adapters/darcs_adapter.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Scm::Adapters - class DarcsAdapter < AbstractAdapter - def english_name - "Darcs" - end - end -end - -require 'lib/scm/adapters/darcs/validation' -require 'lib/scm/adapters/darcs/cat_file' -require 'lib/scm/adapters/darcs/commits' -require 'lib/scm/adapters/darcs/misc' -require 'lib/scm/adapters/darcs/pull' -require 'lib/scm/adapters/darcs/push' -require 'lib/scm/adapters/darcs/head' -require 'lib/scm/adapters/darcs/patch' diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 714f4beb..5f50479f 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsCatFileTest < Scm::Test +module OhlohScm::Adapters + class DarcsCatFileTest < OhlohScm::Test def test_cat_file with_darcs_repository('darcs') do |darcs| diff --git a/test/unit/darcs_commits_test.rb b/test/unit/darcs_commits_test.rb index 85b3e9c9..7d456862 100644 --- a/test/unit/darcs_commits_test.rb +++ b/test/unit/darcs_commits_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsCommitsTest < Scm::Test +module OhlohScm::Adapters + class DarcsCommitsTest < OhlohScm::Test def test_commit with_darcs_repository('darcs') do |darcs| diff --git a/test/unit/darcs_head_test.rb b/test/unit/darcs_head_test.rb index 05891d48..6f157374 100644 --- a/test/unit/darcs_head_test.rb +++ b/test/unit/darcs_head_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsHeadTest < Scm::Test +module OhlohScm::Adapters + class DarcsHeadTest < OhlohScm::Test def test_head_and_parents with_darcs_repository('darcs') do |darcs| diff --git a/test/unit/darcs_misc_test.rb b/test/unit/darcs_misc_test.rb index 231b03a2..31dc59b9 100644 --- a/test/unit/darcs_misc_test.rb +++ b/test/unit/darcs_misc_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsMiscTest < Scm::Test +module OhlohScm::Adapters + class DarcsMiscTest < OhlohScm::Test def test_exist save_darcs = nil diff --git a/test/unit/darcs_parser_test.rb b/test/unit/darcs_parser_test.rb index 7d691831..5f388d6a 100644 --- a/test/unit/darcs_parser_test.rb +++ b/test/unit/darcs_parser_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Parsers - class DarcsParserTest < Scm::Test +module OhlohScm::Parsers + class DarcsParserTest < OhlohScm::Test def test_empty_array assert_equal([], DarcsParser.parse('')) diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb index 578ed3fd..e8080051 100644 --- a/test/unit/darcs_patch_test.rb +++ b/test/unit/darcs_patch_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsPatchTest < Scm::Test +module OhlohScm::Adapters + class DarcsPatchTest < OhlohScm::Test def test_patch_for_commit with_darcs_repository('darcs') do |repo| commit = repo.verbose_commit('add helloworld.c') diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb index e34f5060..9a385ec7 100644 --- a/test/unit/darcs_pull_test.rb +++ b/test/unit/darcs_pull_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsPullTest < Scm::Test +module OhlohScm::Adapters + class DarcsPullTest < OhlohScm::Test def test_pull with_darcs_repository('darcs') do |src| diff --git a/test/unit/darcs_push_test.rb b/test/unit/darcs_push_test.rb index 843c8c06..9ec2d81b 100644 --- a/test/unit/darcs_push_test.rb +++ b/test/unit/darcs_push_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsPushTest < Scm::Test +module OhlohScm::Adapters + class DarcsPushTest < OhlohScm::Test def test_hostname assert !DarcsAdapter.new.hostname diff --git a/test/unit/darcs_rev_list_test.rb b/test/unit/darcs_rev_list_test.rb index 849c42f3..f0b0e640 100644 --- a/test/unit/darcs_rev_list_test.rb +++ b/test/unit/darcs_rev_list_test.rb @@ -1,11 +1,11 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters +module OhlohScm::Adapters # Repository darcs_walk has the following structure: # # A -> B -> C -> D -> E # - class DarcsRevListTest < Scm::Test + class DarcsRevListTest < OhlohScm::Test def test_rev_list with_darcs_repository('darcs_walk') do |darcs| diff --git a/test/unit/darcs_validation_test.rb b/test/unit/darcs_validation_test.rb index 71a664f6..b7363197 100644 --- a/test/unit/darcs_validation_test.rb +++ b/test/unit/darcs_validation_test.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../test_helper' -module Scm::Adapters - class DarcsValidationTest < Scm::Test +module OhlohScm::Adapters + class DarcsValidationTest < OhlohScm::Test def test_rejected_urls [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", "www.selenic.com/repo/hello", # missing a protool prefix From 96de1cb4a48fb47563ba46730d8925ed25206656 Mon Sep 17 00:00:00 2001 From: Andreas Wagner Date: Sun, 22 Feb 2015 12:02:52 -0500 Subject: [PATCH 32/33] Darcs Support: Parses logs of newer version of darcs. Use hashes as tokens instead of patch names. --- lib/ohloh_scm/adapters/darcs/cat_file.rb | 2 +- lib/ohloh_scm/adapters/darcs/commits.rb | 45 ++++++++++----------- lib/ohloh_scm/adapters/darcs/head.rb | 8 ++-- lib/ohloh_scm/adapters/darcs/misc.rb | 4 +- lib/ohloh_scm/adapters/darcs/patch.rb | 2 +- lib/ohloh_scm/commit.rb | 2 +- lib/ohloh_scm/parsers/darcs_parser.rb | 29 ++++++++------ test/data/darcs_patch.diff | 4 +- test/unit/darcs_cat_file_test.rb | 6 +-- test/unit/darcs_commits_test.rb | 24 ++++++------ test/unit/darcs_head_test.rb | 6 +-- test/unit/darcs_misc_test.rb | 4 +- test/unit/darcs_parser_test.rb | 50 ++++++++++++++---------- test/unit/darcs_patch_test.rb | 2 +- test/unit/darcs_pull_test.rb | 2 +- test/unit/darcs_push_test.rb | 2 +- test/unit/darcs_rev_list_test.rb | 42 ++++++++++++++++---- 17 files changed, 139 insertions(+), 95 deletions(-) diff --git a/lib/ohloh_scm/adapters/darcs/cat_file.rb b/lib/ohloh_scm/adapters/darcs/cat_file.rb index 25b75c6f..4017cfc4 100644 --- a/lib/ohloh_scm/adapters/darcs/cat_file.rb +++ b/lib/ohloh_scm/adapters/darcs/cat_file.rb @@ -10,7 +10,7 @@ def cat_file_parent(commit, diff) end def cat(revision, path) - out, err = run_with_err("cd '#{url}' && darcs show contents -p '#{revision}' #{escape(path)}") + out, err = run_with_err("cd '#{url}' && darcs show contents -h '#{revision}' #{escape(path)}") # show contents gives no error for non-existent paths #return nil if err =~ /No such file in rev/ raise RuntimeError.new(err) unless err.to_s == '' diff --git a/lib/ohloh_scm/adapters/darcs/commits.rb b/lib/ohloh_scm/adapters/darcs/commits.rb index 230c38d7..a047b01c 100644 --- a/lib/ohloh_scm/adapters/darcs/commits.rb +++ b/lib/ohloh_scm/adapters/darcs/commits.rb @@ -2,19 +2,19 @@ module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter # Return the number of commits in the repository following +since+. - def commit_count(since=nil) - commit_tokens(since).size + def commit_count(opts={}) + commit_tokens(opts).size end # Return the list of commit tokens following +since+. - def commit_tokens(since=nil, up_to=nil) - from = since ? " --from-patch #{since}" : "" - to = up_to ? " --to-patch #{up_to}" : "" - tokens = string_to_patch_names(run("cd '#{self.url}' && darcs changes#{from}#{to}")).reverse + def commit_tokens(opts={}) + after = opts[:after] ? " --from-match 'hash #{opts[:after]}'" : "" + up_to = opts[:up_to] ? " --to-match 'hash #{opts[:up_to]}'" : "" + tokens = string_to_patch_tokens(run("cd '#{self.url}' && darcs changes#{after}#{up_to}")).reverse # Darcs returns everything after *and including* since. # We want to exclude it. - if tokens.any? && tokens.first == since + if tokens.any? && tokens.first == opts[:after] tokens[1..-1] else tokens @@ -25,11 +25,11 @@ def commit_tokens(since=nil, up_to=nil) # Not including the diffs is meant to be a memory savings when we encounter massive repositories. # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit # in memory at a time. - def commits(since=nil) - from = since ? " --from-patch #{since}" : "" - log = run("cd '#{self.url}' && darcs changes#{from} --reverse") + def commits(opts={}) + after = opts[:after] ? " --from-match 'hash #{opts[:after]}'" : "" + log = run("cd '#{self.url}' && darcs changes#{after} --reverse") a = OhlohScm::Parsers::DarcsParser.parse(log) - if a.any? && a.first.token == since + if a.any? && a.first.token == opts[:after] a[1..-1] else a @@ -38,7 +38,7 @@ def commits(since=nil) # Returns a single commit, including its diffs def verbose_commit(token) - log = run("cd '#{self.url}' && darcs changes -v -p '#{token}'") + log = run("cd '#{self.url}' && darcs changes -v -h '#{token}'") OhlohScm::Parsers::DarcsParser.parse(log).first end @@ -46,32 +46,33 @@ def verbose_commit(token) # The log is stored in a temporary file. # This is designed to prevent excessive RAM usage when we encounter a massive repository. # Only a single commit is ever held in memory at once. - def each_commit(since=nil) - open_log_file(since) do |io| + def each_commit(opts={}) + open_log_file(opts) do |io| OhlohScm::Parsers::DarcsParser.parse(io) do |commit| - yield commit if block_given? && commit.token != since + yield commit if block_given? && commit.token != opts[:after] end end end # Not used by Ohloh proper, but handy for debugging and testing - def log(since=nil) - from = since ? " --from-patch #{since}" : "" - run "cd '#{url}' && darcs changes -s#{from}" + def log(opts={}) + after = opts[:after] ? " --from-match 'hash #{opts[:after]}'" : "" + run "cd '#{url}' && darcs changes -s#{after}" end # Returns a file handle to the log. # In our standard, the log should include everything AFTER +since+. However, darcs doesn't work that way; # it returns everything after and INCLUDING +since+. Therefore, consumers of this file should check for # and reject the duplicate commit. - def open_log_file(since=nil) + def open_log_file(opts={}) + after = opts[:after] ? " --from-match 'hash #{opts[:after]}'" : '' begin - if since == head_token # There are no new commits + if opts[:after] == head_token # There are no new commits # As a time optimization, just create an empty file rather than fetch a log we know will be empty. File.open(log_filename, 'w') { } else - from = since ? " --from-patch #{since}" : "" - run "cd '#{url}' && darcs changes --reverse -v#{from} > #{log_filename}" + after = opts[:after] ? " --from-match 'hash #{opts[:after]}'" : "" + run "cd '#{url}' && darcs changes --reverse -v#{after} > #{log_filename}" end File.open(log_filename, 'r') { |io| yield io } ensure diff --git a/lib/ohloh_scm/adapters/darcs/head.rb b/lib/ohloh_scm/adapters/darcs/head.rb index 787b4c3c..8ebfbe3c 100644 --- a/lib/ohloh_scm/adapters/darcs/head.rb +++ b/lib/ohloh_scm/adapters/darcs/head.rb @@ -1,7 +1,7 @@ module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def head_token - string_to_patch_names(run("cd '#{url}' && darcs changes --last 1"))[0] + string_to_patch_tokens(run("cd '#{url}' && darcs changes --last 1"))[0] end def head @@ -9,15 +9,15 @@ def head end def parent_tokens(commit) - string_to_patch_names(run("cd '#{url}' && darcs changes --to-patch #{commit.token}"))[1..-1] + string_to_patch_tokens(run("cd '#{url}' && darcs changes --to-match 'hash #{commit.token}'"))[1..-1] end def parents(commit) parent_tokens(commit).map {|token| verbose_commit(token)} end - def string_to_patch_names(s) - s.split(/\n/).select {|s| s =~ /^ \* /}.map {|s| s.sub(/^ \* /,'')} + def string_to_patch_tokens(s) + s.split(/\n/).select {|s| s =~ /^patch /}.map {|s| s.sub(/^patch /,'')} end end end diff --git a/lib/ohloh_scm/adapters/darcs/misc.rb b/lib/ohloh_scm/adapters/darcs/misc.rb index 9d516743..49e87274 100644 --- a/lib/ohloh_scm/adapters/darcs/misc.rb +++ b/lib/ohloh_scm/adapters/darcs/misc.rb @@ -10,11 +10,11 @@ def exist? end def ls_tree(token) - run("cd '#{path}' && darcs show files -p '#{token}'").split("\n") + run("cd '#{path}' && darcs show files --no-pending -h '#{token}'").split("\n") end def export(dest_dir, token=nil) - p = token ? " -p '#{token}'" : "" + p = token ? " -h '#{token}'" : "" run("cd '#{path}' && darcs dist#{p} && mv darcs.tar.gz '#{dest_dir}'") end end diff --git a/lib/ohloh_scm/adapters/darcs/patch.rb b/lib/ohloh_scm/adapters/darcs/patch.rb index 4c962a00..84e19918 100644 --- a/lib/ohloh_scm/adapters/darcs/patch.rb +++ b/lib/ohloh_scm/adapters/darcs/patch.rb @@ -1,7 +1,7 @@ module OhlohScm::Adapters class DarcsAdapter < AbstractAdapter def patch_for_commit(commit) - run("cd '#{url}' && darcs changes -p'#{commit.token}' -v") + run("cd '#{url}' && darcs changes -h'#{commit.token}' -v") end end end diff --git a/lib/ohloh_scm/commit.rb b/lib/ohloh_scm/commit.rb index e87212ac..9439a308 100644 --- a/lib/ohloh_scm/commit.rb +++ b/lib/ohloh_scm/commit.rb @@ -34,7 +34,7 @@ class Commit # For Git, the token is the commit SHA1 hash. # For CVS, which does not support atomic commits with unique IDs, we use # the approximate timestamp of the change. - # For Darcs, the token is the patch name, and it may not be unique. XXX + # For Darcs, the hash will be used as the token here. attr_accessor :token # A pointer back to the adapter that contains this commit. diff --git a/lib/ohloh_scm/parsers/darcs_parser.rb b/lib/ohloh_scm/parsers/darcs_parser.rb index e267d508..5ce4279e 100644 --- a/lib/ohloh_scm/parsers/darcs_parser.rb +++ b/lib/ohloh_scm/parsers/darcs_parser.rb @@ -8,34 +8,37 @@ def self.scm def self.internal_parse(buffer, opts) e = nil state = :patch +# email_match = Regexp.new(Regexp.quote('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\x09 ])+|(?>[\x09 ]*\x0D\x0A)?[\x09 ]+)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD')) buffer.each_line do |l| #print "\n#{state}" next_state = state if state == :patch case l - when /^([^ ]...........................) (.*)$/ + when /^patch ([0-9a-f]*)/ yield e if e && block_given? e = Scm::Commit.new - e.author_date = Time.parse($1).utc - nameemail = $2 + e.diffs = [] + e.token = $1 + when /^Author: (.*)/ + nameemail = $1 case nameemail - when /^([^<]*) <(.*)>$/ - e.author_name = $1 - e.author_email = $2 + when /^(\b.*) <([^>]*)>/ + e.author_name = $1 + e.author_email = $2 when /^([^@]*)$/ - e.author_name = $1 - e.author_email = nil + e.author_name = $1 + e.author_email = nil else - e.author_name = nil - e.author_email = nameemail + e.author_name = nil + e.author_email = nameemail end - e.diffs = [] + when /^Date: ([^ ]...........................)/ + e.author_date = Time.parse($1).utc when /^ \* (.*)/ - e.token = ($1 || '') + e.message = ($1 || '') next_state = :long_comment_or_prims end - elsif state == :long_comment_or_prims case l when /^ addfile\s+(.+)/ diff --git a/test/data/darcs_patch.diff b/test/data/darcs_patch.diff index f5316e68..b64f8395 100644 --- a/test/data/darcs_patch.diff +++ b/test/data/darcs_patch.diff @@ -1,4 +1,6 @@ -Wed Nov 3 15:49:53 PDT 2010 Simon Michael +patch bd7e455d648b784ce4be2db26a4e62dfe734dd66 +Author: Simon Michael +Date: Wed Nov 3 18:49:53 EDT 2010 * add helloworld.c addfile ./helloworld.c hunk ./helloworld.c 1 diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 5f50479f..78b2b74a 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -21,9 +21,9 @@ def test_cat_file EXPECTED # The file was deleted by the "remove..." patch. Check that it does not exist now, but existed in parent. - assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => 'remove helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => 'remove helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => 'add helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => '1007b5ad4831769283213d47e1fd5f6d30ac97f0'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => '1007b5ad4831769283213d47e1fd5f6d30ac97f0'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66'), Scm::Diff.new(:path => 'helloworld.c')) end end diff --git a/test/unit/darcs_commits_test.rb b/test/unit/darcs_commits_test.rb index 7d456862..9a8029ed 100644 --- a/test/unit/darcs_commits_test.rb +++ b/test/unit/darcs_commits_test.rb @@ -6,17 +6,17 @@ class DarcsCommitsTest < OhlohScm::Test def test_commit with_darcs_repository('darcs') do |darcs| assert_equal 2, darcs.commit_count - assert_equal 1, darcs.commit_count('add helloworld.c') - assert_equal 0, darcs.commit_count('remove helloworld.c') - assert_equal ['add helloworld.c', 'remove helloworld.c'], darcs.commit_tokens - assert_equal ['remove helloworld.c'], darcs.commit_tokens('add helloworld.c') - assert_equal [], darcs.commit_tokens('remove helloworld.c') - assert_equal ['add helloworld.c', - 'remove helloworld.c'], darcs.commits.collect { |c| c.token } - assert_equal ['remove helloworld.c'], darcs.commits('add helloworld.c').collect { |c| c.token } + assert_equal 1, darcs.commit_count(:after => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66') + assert_equal 0, darcs.commit_count(:after => '1007b5ad4831769283213d47e1fd5f6d30ac97f0') + assert_equal ['bd7e455d648b784ce4be2db26a4e62dfe734dd66', '1007b5ad4831769283213d47e1fd5f6d30ac97f0'], darcs.commit_tokens + assert_equal ['1007b5ad4831769283213d47e1fd5f6d30ac97f0'], darcs.commit_tokens(:after => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66') + assert_equal [], darcs.commit_tokens(:after => '1007b5ad4831769283213d47e1fd5f6d30ac97f0') + assert_equal ['bd7e455d648b784ce4be2db26a4e62dfe734dd66', + '1007b5ad4831769283213d47e1fd5f6d30ac97f0'], darcs.commits.collect { |c| c.token } + assert_equal ['1007b5ad4831769283213d47e1fd5f6d30ac97f0'], darcs.commits(:after => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66').collect { |c| c.token } # Check that the diffs are not populated - assert_equal [], darcs.commits('add helloworld.c').first.diffs - assert_equal [], darcs.commits('remove helloworld.c') + assert_equal [], darcs.commits(:after => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66').first.diffs + assert_equal [], darcs.commits(:after => '1007b5ad4831769283213d47e1fd5f6d30ac97f0') end end @@ -37,8 +37,8 @@ def test_each_commit assert !FileTest.exist?(darcs.log_filename) # Make sure we cleaned up after ourselves # Verify that we got the commits in forward chronological order - assert_equal ['add helloworld.c', - 'remove helloworld.c'], commits.map {|c| c.token} + assert_equal ['bd7e455d648b784ce4be2db26a4e62dfe734dd66', + '1007b5ad4831769283213d47e1fd5f6d30ac97f0'], commits.map {|c| c.token} end end end diff --git a/test/unit/darcs_head_test.rb b/test/unit/darcs_head_test.rb index 6f157374..a791f2bd 100644 --- a/test/unit/darcs_head_test.rb +++ b/test/unit/darcs_head_test.rb @@ -5,11 +5,11 @@ class DarcsHeadTest < OhlohScm::Test def test_head_and_parents with_darcs_repository('darcs') do |darcs| - assert_equal 'remove helloworld.c', darcs.head_token - assert_equal 'remove helloworld.c', darcs.head.token + assert_equal '1007b5ad4831769283213d47e1fd5f6d30ac97f0', darcs.head_token + assert_equal '1007b5ad4831769283213d47e1fd5f6d30ac97f0', darcs.head.token assert darcs.head.diffs.any? # diffs should be populated - assert_equal 'add helloworld.c', darcs.parents(darcs.head).first.token + assert_equal 'bd7e455d648b784ce4be2db26a4e62dfe734dd66', darcs.parents(darcs.head).first.token assert darcs.parents(darcs.head).first.diffs.any? end end diff --git a/test/unit/darcs_misc_test.rb b/test/unit/darcs_misc_test.rb index 31dc59b9..f7a533bc 100644 --- a/test/unit/darcs_misc_test.rb +++ b/test/unit/darcs_misc_test.rb @@ -14,14 +14,14 @@ def test_exist def test_ls_tree with_darcs_repository('darcs') do |darcs| - assert_equal ['.','./helloworld.c'], darcs.ls_tree('add helloworld.c').sort + assert_equal ['.','./helloworld.c'], darcs.ls_tree('bd7e455d648b784ce4be2db26a4e62dfe734dd66').sort end end def test_export with_darcs_repository('darcs') do |darcs| Scm::ScratchDir.new do |dir| - darcs.export(dir, 'add helloworld.c') + darcs.export(dir, 'bd7e455d648b784ce4be2db26a4e62dfe734dd66') assert_equal ['.', '..', 'darcs.tar.gz'], Dir.entries(dir).sort end end diff --git a/test/unit/darcs_parser_test.rb b/test/unit/darcs_parser_test.rb index 5f388d6a..52e21b7b 100644 --- a/test/unit/darcs_parser_test.rb +++ b/test/unit/darcs_parser_test.rb @@ -9,12 +9,15 @@ def test_empty_array def test_log_parser_default sample_log = < +patch 1007b5ad4831769283213d47e1fd5f6d30ac97f0 +Author: Simon Michael +Date: Wed Nov 3 18:55:25 EDT 2010 * remove helloworld.c -Wed Nov 3 15:49:53 PDT 2010 Simon Michael +patch bd7e455d648b784ce4be2db26a4e62dfe734dd66 +Author: Simon Michael +Date: Wed Nov 3 18:49:53 EDT 2010 * add helloworld.c - SAMPLE commits = DarcsParser.parse(sample_log) @@ -22,29 +25,32 @@ def test_log_parser_default assert commits assert_equal 2, commits.size - assert_equal 'remove helloworld.c', commits[0].token + assert_equal '1007b5ad4831769283213d47e1fd5f6d30ac97f0', commits[0].token assert_equal 'Simon Michael', commits[0].author_name assert_equal 'simon@joyful.com', commits[0].author_email - assert_equal nil, commits[0].message # Note \n at end of comment + assert_equal 'remove helloworld.c', commits[0].message # Note \n at end of comment assert_equal Time.utc(2010,11,3,22,55,25), commits[0].author_date assert_equal 0, commits[0].diffs.size - assert_equal 'add helloworld.c', commits[1].token + assert_equal 'bd7e455d648b784ce4be2db26a4e62dfe734dd66', commits[1].token assert_equal 'Simon Michael', commits[1].author_name assert_equal 'simon@joyful.com', commits[1].author_email - assert_equal nil, commits[1].message # Note \n at end of comment + assert_equal 'add helloworld.c', commits[1].message # Note \n at end of comment assert_equal Time.utc(2010,11,3,22,49,53), commits[1].author_date assert_equal 0, commits[1].diffs.size end def test_log_parser_default_partial_user_name sample_log = < +patch 1007b5ad4831769283213d47e1fd5f6d30ac97f0 +Author: Simon Michael +Date: Wed Nov 3 18:55:25 EDT 2010 * remove helloworld.c hunk ./helloworld.c 1 -/* Hello, World! */ @@ -80,7 +88,9 @@ def test_log_parser_verbose -} rmfile ./helloworld.c -Wed Nov 3 15:49:53 PDT 2010 Simon Michael +patch bd7e455d648b784ce4be2db26a4e62dfe734dd66 +Author: Simon Michael +Date: Wed Nov 3 18:49:53 EDT 2010 * add helloworld.c addfile ./helloworld.c hunk ./helloworld.c 1 @@ -103,19 +113,19 @@ def test_log_parser_verbose assert commits assert_equal 2, commits.size - assert_equal 'remove helloworld.c', commits[0].token + assert_equal '1007b5ad4831769283213d47e1fd5f6d30ac97f0', commits[0].token assert_equal 'Simon Michael', commits[0].author_name assert_equal 'simon@joyful.com', commits[0].author_email - assert_equal nil, commits[0].message # Note \n at end of comment + assert_equal 'remove helloworld.c', commits[0].message # Note \n at end of comment assert_equal Time.utc(2010,11,3,22,55,25), commits[0].author_date assert_equal 2, commits[0].diffs.size assert_equal './helloworld.c', commits[0].diffs[0].path assert_equal './helloworld.c', commits[0].diffs[1].path - assert_equal 'add helloworld.c', commits[1].token + assert_equal 'bd7e455d648b784ce4be2db26a4e62dfe734dd66', commits[1].token assert_equal 'Simon Michael', commits[1].author_name assert_equal 'simon@joyful.com', commits[1].author_email - assert_equal nil, commits[1].message # Note \n at end of comment + assert_equal 'add helloworld.c', commits[1].message # Note \n at end of comment assert_equal Time.utc(2010,11,3,22,49,53), commits[1].author_date assert_equal 2, commits[0].diffs.size assert_equal './helloworld.c', commits[0].diffs[0].path diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb index e8080051..c43cfbb7 100644 --- a/test/unit/darcs_patch_test.rb +++ b/test/unit/darcs_patch_test.rb @@ -4,7 +4,7 @@ module OhlohScm::Adapters class DarcsPatchTest < OhlohScm::Test def test_patch_for_commit with_darcs_repository('darcs') do |repo| - commit = repo.verbose_commit('add helloworld.c') + commit = repo.verbose_commit('bd7e455d648b784ce4be2db26a4e62dfe734dd66') data = File.read(File.join(DATA_DIR, 'darcs_patch.diff')) assert_equal data, repo.patch_for_commit(commit) end diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb index 9a385ec7..065dad38 100644 --- a/test/unit/darcs_pull_test.rb +++ b/test/unit/darcs_pull_test.rb @@ -17,7 +17,7 @@ def test_pull # Commit some new code on the original and pull again src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" - assert_equal "test", src.commits.last.token + assert_equal "test", src.commits.last.message dest.pull(src) assert_equal src.log, dest.log diff --git a/test/unit/darcs_push_test.rb b/test/unit/darcs_push_test.rb index 9ec2d81b..3a46e39d 100644 --- a/test/unit/darcs_push_test.rb +++ b/test/unit/darcs_push_test.rb @@ -47,7 +47,7 @@ def test_push # Commit some new code on the original and pull again src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" - assert_equal "test", src.commits.last.token + assert_equal "test", src.commits.last.message src.push(dest) assert_equal src.log, dest.log diff --git a/test/unit/darcs_rev_list_test.rb b/test/unit/darcs_rev_list_test.rb index f0b0e640..5096258b 100644 --- a/test/unit/darcs_rev_list_test.rb +++ b/test/unit/darcs_rev_list_test.rb @@ -10,16 +10,44 @@ class DarcsRevListTest < OhlohScm::Test def test_rev_list with_darcs_repository('darcs_walk') do |darcs| # Full history to a commit - assert_equal ["A"], darcs.commit_tokens(nil, "A") - assert_equal ["A","B"], darcs.commit_tokens(nil, "B") - assert_equal ["A","B","C","D","E"], darcs.commit_tokens(nil, "E") - assert_equal ["A","B","C","D","E"], darcs.commit_tokens(nil, nil) + assert_equal [:A], rev_list_helper(darcs, nil, :A) + assert_equal [:A, :B], rev_list_helper(darcs, nil, :B) + assert_equal [:A, :B, :C, :D, :E], rev_list_helper(darcs, nil, :E) + assert_equal [:A, :B, :C, :D, :E], rev_list_helper(darcs, nil, nil) # # Limited history from one commit to another - assert_equal [], darcs.commit_tokens("A", "A") - assert_equal ["B"], darcs.commit_tokens("A", "B") - assert_equal ["B","C","D"], darcs.commit_tokens("A", "D") + assert_equal [], rev_list_helper(darcs, :A, :A) + assert_equal [:B], rev_list_helper(darcs, :A, :B) + assert_equal [:B, :C, :D], rev_list_helper(darcs, :A, :D) end end + + protected + + def rev_list_helper(darcs, from, to) + to_labels(darcs.commit_tokens(:after => from_label(from), :up_to => from_label(to))) + end + + def commit_labels + { '25b46d61afa639f268c929e6259f1271b7a43d6f' => :A, + '7a1b8ed05d56b7099a2c16157ec7a947bcab9c9a' => :B, + 'd50ee74be0f34fed3e23ec90346976024de40962' => :C, + '48dac48b9d5543895c409e81de18ff077f4dc1c3' => :D, + '3dbdfd7313c96379fd8a3ca4e6ebaf1bd12d46ae' => :E + } + end + + def to_label(sha1) + commit_labels[sha1.to_s] + end + + def to_labels(sha1s) + sha1s.collect { |sha1| to_label(sha1) } + end + + def from_label(l) + commit_labels.each_pair { |k,v| return k if v.to_s == l.to_s } + nil + end end end From 0700f920cf1e82a847365f50c9d738eaeff11446 Mon Sep 17 00:00:00 2001 From: Andreas Wagner Date: Sun, 31 Jul 2016 13:04:36 -0400 Subject: [PATCH 33/33] darcs_support: change Scm to OhlohScm --- lib/ohloh_scm/parsers/darcs_parser.rb | 14 +++++++------- test/unit/darcs_cat_file_test.rb | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/ohloh_scm/parsers/darcs_parser.rb b/lib/ohloh_scm/parsers/darcs_parser.rb index 5ce4279e..6fcfb2b8 100644 --- a/lib/ohloh_scm/parsers/darcs_parser.rb +++ b/lib/ohloh_scm/parsers/darcs_parser.rb @@ -17,7 +17,7 @@ def self.internal_parse(buffer, opts) case l when /^patch ([0-9a-f]*)/ yield e if e && block_given? - e = Scm::Commit.new + e = OhlohScm::Commit.new e.diffs = [] e.token = $1 when /^Author: (.*)/ @@ -42,13 +42,13 @@ def self.internal_parse(buffer, opts) elsif state == :long_comment_or_prims case l when /^ addfile\s+(.+)/ - e.diffs << Scm::Diff.new(:action => 'A', :path => $1) + e.diffs << OhlohScm::Diff.new(:action => 'A', :path => $1) next_state = :prims when /^ rmfile\s+(.+)/ - e.diffs << Scm::Diff.new(:action => 'D', :path => $1) + e.diffs << OhlohScm::Diff.new(:action => 'D', :path => $1) next_state = :prims when /^ hunk\s+(.+)\s+([0-9]+)$/ - e.diffs << Scm::Diff.new(:action => 'M', :path => $1) + e.diffs << OhlohScm::Diff.new(:action => 'M', :path => $1) # e.sha1, e.parent_sha1 = ... next_state = :prims when /^$/ @@ -61,11 +61,11 @@ def self.internal_parse(buffer, opts) elsif state == :prims case l when /^ addfile\s+(.+)/ - e.diffs << Scm::Diff.new(:action => 'A', :path => $1) + e.diffs << OhlohScm::Diff.new(:action => 'A', :path => $1) when /^ rmfile\s+(.+)/ - e.diffs << Scm::Diff.new(:action => 'D', :path => $1) + e.diffs << OhlohScm::Diff.new(:action => 'D', :path => $1) when /^ hunk\s+(.+)\s+([0-9]+)$/ - e.diffs << Scm::Diff.new(:action => 'M', :path => $1) + e.diffs << OhlohScm::Diff.new(:action => 'M', :path => $1) # e.sha1, e.parent_sha1 = ... when /^$/ next_state = :patch diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 78b2b74a..2c99bac8 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -21,16 +21,16 @@ def test_cat_file EXPECTED # The file was deleted by the "remove..." patch. Check that it does not exist now, but existed in parent. - assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => '1007b5ad4831769283213d47e1fd5f6d30ac97f0'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => '1007b5ad4831769283213d47e1fd5f6d30ac97f0'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal nil, darcs.cat_file(OhlohScm::Commit.new(:token => '1007b5ad4831769283213d47e1fd5f6d30ac97f0'), OhlohScm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file_parent(OhlohScm::Commit.new(:token => '1007b5ad4831769283213d47e1fd5f6d30ac97f0'), OhlohScm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file(OhlohScm::Commit.new(:token => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66'), OhlohScm::Diff.new(:path => 'helloworld.c')) end end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename # NB only works with --reserved-ok, otherwise darcs rejects with "invalid under Windows" def test_funny_file_name_chars - Scm::ScratchDir.new do |dir| + OhlohScm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '|file_name (&\'")' File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } @@ -40,7 +40,7 @@ def test_funny_file_name_chars darcs.run("cd #{dir} && darcs init && darcs add --reserved-ok * && darcs record -a -m test") # Confirm that we can read the file back - assert_equal "contents", darcs.cat_file(darcs.head, Scm::Diff.new(:path => funny_name)) + assert_equal "contents", darcs.cat_file(darcs.head, OhlohScm::Diff.new(:path => funny_name)) end end