Skip to content

Commit

Permalink
darcs_support: change Scm to OhlohScm
Browse files Browse the repository at this point in the history
  • Loading branch information
lowfatcomputing committed Jul 31, 2016
1 parent 3f89184 commit 89d7d75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions lib/ohloh_scm/parsers/darcs_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: (.*)/
Expand All @@ -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 /^$/
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/unit/darcs_cat_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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

Expand Down

0 comments on commit 89d7d75

Please sign in to comment.