diff --git a/.gitignore b/.gitignore index d411dd7f..13456823 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.pyc pkg/ *.cache +TAGS 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..664b1b74 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: ruby +env: + - TRAVIS_CONFIG_DIR=.travis +before_install: + - cd $TRAVIS_CONFIG_DIR + - sh .travis_ssh_setup.sh +install: + - sh .install_multiple_scms.sh + - sh .install_dependencies.sh + - gem install posix-spawn +before_script: + - cd $TRAVIS_BUILD_DIR diff --git a/.travis/.install_dependencies.sh b/.travis/.install_dependencies.sh new file mode 100755 index 00000000..bcec6f01 --- /dev/null +++ b/.travis/.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/.install_multiple_scms.sh b/.travis/.install_multiple_scms.sh new file mode 100644 index 00000000..2344896e --- /dev/null +++ b/.travis/.install_multiple_scms.sh @@ -0,0 +1,5 @@ +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 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 diff --git a/README.md b/README.md index e9a3adf4..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 @@ -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.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/ohloh_scm/adapters/bzr/misc.rb b/lib/ohloh_scm/adapters/bzr/misc.rb index 12f5b9a5..5f30aa14 100644 --- a/lib/ohloh_scm/adapters/bzr/misc.rb +++ b/lib/ohloh_scm/adapters/bzr/misc.rb @@ -10,7 +10,7 @@ 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") end def to_rev_param(r=nil) diff --git a/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb b/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb index aece32f7..d200c056 100644 --- a/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb +++ b/lib/ohloh_scm/adapters/bzrlib/bzrlib_pipe_client.rb @@ -1,14 +1,14 @@ require 'rubygems' -require 'open4' +require 'posix/spawn' class BzrPipeClient def initialize(repository_url) @repository_url = repository_url @py_script = File.dirname(__FILE__) + '/bzrlib_pipe_server.py' 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 @@ -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/darcs/cat_file.rb b/lib/ohloh_scm/adapters/darcs/cat_file.rb new file mode 100644 index 00000000..4017cfc4 --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/cat_file.rb @@ -0,0 +1,28 @@ +module OhlohScm::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 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 == '' + return nil if out == '' + 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/ohloh_scm/adapters/darcs/commits.rb b/lib/ohloh_scm/adapters/darcs/commits.rb new file mode 100644 index 00000000..a047b01c --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/commits.rb @@ -0,0 +1,88 @@ +module OhlohScm::Adapters + class DarcsAdapter < AbstractAdapter + + # Return the number of commits in the repository following +since+. + def commit_count(opts={}) + commit_tokens(opts).size + end + + # Return the list of commit tokens following +since+. + 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 == opts[:after] + 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(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 == opts[:after] + a[1..-1] + else + a + end + end + + # Returns a single commit, including its diffs + def verbose_commit(token) + log = run("cd '#{self.url}' && darcs changes -v -h '#{token}'") + OhlohScm::Parsers::DarcsParser.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(opts={}) + open_log_file(opts) do |io| + OhlohScm::Parsers::DarcsParser.parse(io) do |commit| + 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(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(opts={}) + after = opts[:after] ? " --from-match 'hash #{opts[:after]}'" : '' + begin + 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 + 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 + 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/ohloh_scm/adapters/darcs/head.rb b/lib/ohloh_scm/adapters/darcs/head.rb new file mode 100644 index 00000000..8ebfbe3c --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/head.rb @@ -0,0 +1,23 @@ +module OhlohScm::Adapters + class DarcsAdapter < AbstractAdapter + def head_token + string_to_patch_tokens(run("cd '#{url}' && darcs changes --last 1"))[0] + end + + def head + verbose_commit(head_token) + end + + def parent_tokens(commit) + 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_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 new file mode 100644 index 00000000..49e87274 --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/misc.rb @@ -0,0 +1,21 @@ +module OhlohScm::Adapters + class DarcsAdapter < AbstractAdapter + def exist? + begin + !!(head_token) + rescue + logger.debug { $! } + false + end + end + + def ls_tree(token) + run("cd '#{path}' && darcs show files --no-pending -h '#{token}'").split("\n") + end + + def export(dest_dir, token=nil) + p = token ? " -h '#{token}'" : "" + run("cd '#{path}' && darcs dist#{p} && mv darcs.tar.gz '#{dest_dir}'") + end + end +end diff --git a/lib/ohloh_scm/adapters/darcs/patch.rb b/lib/ohloh_scm/adapters/darcs/patch.rb new file mode 100644 index 00000000..84e19918 --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/patch.rb @@ -0,0 +1,7 @@ +module OhlohScm::Adapters + class DarcsAdapter < AbstractAdapter + def patch_for_commit(commit) + run("cd '#{url}' && darcs changes -h'#{commit.token}' -v") + end + end +end diff --git a/lib/ohloh_scm/adapters/darcs/pull.rb b/lib/ohloh_scm/adapters/darcs/pull.rb new file mode 100644 index 00000000..48fda1a8 --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/pull.rb @@ -0,0 +1,23 @@ +module OhlohScm::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 get '#{from.url}' '#{self.url}'" + else + # might also need to unpull for an exact copy + 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 + end + + end +end diff --git a/lib/ohloh_scm/adapters/darcs/push.rb b/lib/ohloh_scm/adapters/darcs/push.rb new file mode 100644 index 00000000..a5e35729 --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/push.rb @@ -0,0 +1,50 @@ +module OhlohScm::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 "cd '#{self.url}' && darcs put #{to.hostname}:#{to.path}" + end + else + run "cd '#{self.url}' && darcs push -a '#{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/ohloh_scm/adapters/darcs/validation.rb b/lib/ohloh_scm/adapters/darcs/validation.rb new file mode 100644 index 00000000..f9adc1fe --- /dev/null +++ b/lib/ohloh_scm/adapters/darcs/validation.rb @@ -0,0 +1,26 @@ +module OhlohScm::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/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/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/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/lib/ohloh_scm/adapters/hglib/client.rb b/lib/ohloh_scm/adapters/hglib/client.rb index 65c414c9..e3d8733b 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 @@ -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 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' 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/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 diff --git a/lib/ohloh_scm/commit.rb b/lib/ohloh_scm/commit.rb index ddb9fa13..9439a308 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. # @@ -15,6 +15,8 @@ module Scm # 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 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/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/darcs_parser.rb b/lib/ohloh_scm/parsers/darcs_parser.rb new file mode 100644 index 00000000..6fcfb2b8 --- /dev/null +++ b/lib/ohloh_scm/parsers/darcs_parser.rb @@ -0,0 +1,83 @@ +module OhlohScm::Parsers + # This parser can process the default darcs changes output #, with or without the --verbose flag. + class DarcsParser < Parser + def self.scm + 'darcs' + end + + 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 /^patch ([0-9a-f]*)/ + yield e if e && block_given? + e = OhlohScm::Commit.new + e.diffs = [] + e.token = $1 + when /^Author: (.*)/ + nameemail = $1 + case nameemail + when /^(\b.*) <([^>]*)>/ + 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 /^Date: ([^ ]...........................)/ + e.author_date = Time.parse($1).utc + when /^ \* (.*)/ + e.message = ($1 || '') + next_state = :long_comment_or_prims + end + elsif state == :long_comment_or_prims + case l + when /^ addfile\s+(.+)/ + e.diffs << OhlohScm::Diff.new(:action => 'A', :path => $1) + next_state = :prims + when /^ rmfile\s+(.+)/ + e.diffs << OhlohScm::Diff.new(:action => 'D', :path => $1) + next_state = :prims + when /^ hunk\s+(.+)\s+([0-9]+)$/ + e.diffs << OhlohScm::Diff.new(:action => 'M', :path => $1) + # e.sha1, e.parent_sha1 = ... + next_state = :prims + when /^$/ + next_state = :patch + else + e.message ||= '' + e.message << l.sub(/^ /,'') + end + + elsif state == :prims + case l + when /^ addfile\s+(.+)/ + e.diffs << OhlohScm::Diff.new(:action => 'A', :path => $1) + when /^ rmfile\s+(.+)/ + e.diffs << OhlohScm::Diff.new(:action => 'D', :path => $1) + when /^ hunk\s+(.+)\s+([0-9]+)$/ + e.diffs << OhlohScm::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 + yield e if e && block_given? + end + + end +end 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/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) diff --git a/lib/ohloh_scm/version.rb b/lib/ohloh_scm/version.rb index 2868efe2..e9f6ffc1 100644 --- a/lib/ohloh_scm/version.rb +++ b/lib/ohloh_scm/version.rb @@ -1,5 +1,5 @@ -module Scm +module OhlohScm module Version - STRING = '2.0.0' + STRING = '2.1.0' end end 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/ohloh_scm.gemspec b/ohloh_scm.gemspec index aaa3b7ba..74ee9d8a 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] @@ -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 diff --git a/test/data/darcs_patch.diff b/test/data/darcs_patch.diff new file mode 100644 index 00000000..b64f8395 --- /dev/null +++ b/test/data/darcs_patch.diff @@ -0,0 +1,18 @@ +patch bd7e455d648b784ce4be2db26a4e62dfe734dd66 +Author: Simon Michael +Date: Wed Nov 3 18:49:53 EDT 2010 + * 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/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..42dfb941 --- /dev/null +++ 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 00000000..f14d6e02 Binary files /dev/null and b/test/repositories/darcs/_darcs/index differ diff --git a/test/repositories/darcs/_darcs/index_invalid b/test/repositories/darcs/_darcs/index_invalid new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs/_darcs/inventories/0000000199-b4681395aad3d7e60338fc52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 b/test/repositories/darcs/_darcs/inventories/0000000199-b4681395aad3d7e60338fc52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 new file mode 100644 index 00000000..66334a7b Binary files /dev/null and b/test/repositories/darcs/_darcs/inventories/0000000199-b4681395aad3d7e60338fc52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 differ diff --git a/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c b/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c new file mode 100644 index 00000000..f992b1b8 Binary files /dev/null and b/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c differ diff --git a/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e b/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e new file mode 100644 index 00000000..6a9429af Binary files /dev/null and b/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e differ diff --git a/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c b/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c new file mode 100644 index 00000000..b4a49fb7 Binary files /dev/null and b/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c differ diff --git a/test/repositories/darcs/_darcs/patches/pending b/test/repositories/darcs/_darcs/patches/pending new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/repositories/darcs/_darcs/patches/pending @@ -0,0 +1,2 @@ +{ +} diff --git a/test/repositories/darcs/_darcs/patches/pending.tentative b/test/repositories/darcs/_darcs/patches/pending.tentative new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/repositories/darcs/_darcs/patches/pending.tentative @@ -0,0 +1,2 @@ +{ +} 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/47fa61da8145efedd19f2df53384c3fd72d5eb0f37c5a1588f151412b65a9552 b/test/repositories/darcs/_darcs/pristine.hashed/47fa61da8145efedd19f2df53384c3fd72d5eb0f37c5a1588f151412b65a9552 new file mode 100644 index 00000000..8f6bee49 Binary files /dev/null and b/test/repositories/darcs/_darcs/pristine.hashed/47fa61da8145efedd19f2df53384c3fd72d5eb0f37c5a1588f151412b65a9552 differ diff --git a/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f b/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f new file mode 100644 index 00000000..cf274f8a Binary files /dev/null and b/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f differ diff --git a/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 00000000..229151a5 Binary files /dev/null and b/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 differ 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/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 00000000..a14b0240 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/index differ 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 00000000..084626c2 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 differ diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000368-79230da93a2f69dadf7df4e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c b/test/repositories/darcs_walk/_darcs/inventories/0000000368-79230da93a2f69dadf7df4e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c new file mode 100644 index 00000000..eebb927f Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/inventories/0000000368-79230da93a2f69dadf7df4e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c differ 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 00000000..b25438ba Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 differ 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 00000000..7ff9ebc1 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 differ 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 00000000..76e9f812 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 differ 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 00000000..31b4b2e9 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 differ diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e b/test/repositories/darcs_walk/_darcs/patches/0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e new file mode 100644 index 00000000..a9689852 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/patches/0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e differ 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 00000000..5191b93c Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa differ diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 b/test/repositories/darcs_walk/_darcs/patches/0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 new file mode 100644 index 00000000..18f1a93a Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/patches/0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 differ diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 b/test/repositories/darcs_walk/_darcs/patches/0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 new file mode 100644 index 00000000..fdb37828 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/patches/0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 differ 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 00000000..705f1139 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 differ 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 00000000..0726896b Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda differ 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 00000000..19c12c5e Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 differ 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 00000000..e5a5fa87 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c differ 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 00000000..53d9e6f8 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b differ 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 00000000..229151a5 Binary files /dev/null and b/test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 differ 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/test_helper.rb b/test/test_helper.rb index f8ddbba7..e8db0540 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') @@ -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/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..90d8c9a8 100644 --- a/test/unit/adapter_factory_test.rb +++ b/test/unit/adapter_factory_test.rb @@ -1,10 +1,19 @@ require_relative '../test_helper' module OhlohScm::Adapters - class FactoryTest < Scm::Test + class FactoryTest < OhlohScm::Test - def test_factory_hg + 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` hg = Factory.from_path(path) assert hg.is_a?(HgAdapter) @@ -13,7 +22,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 +31,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 +40,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 +49,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 +62,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..44e788ff 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 @@ -20,13 +20,14 @@ 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 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..575bdca4 100644 --- a/test/unit/cvs_commits_test.rb +++ b/test/unit/cvs_commits_test.rb @@ -1,24 +1,24 @@ 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| - 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/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/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb new file mode 100644 index 00000000..2c99bac8 --- /dev/null +++ b/test/unit/darcs_cat_file_test.rb @@ -0,0 +1,48 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + class DarcsCatFileTest < OhlohScm::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 by the "remove..." patch. Check that it does not exist now, but existed in parent. + 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 + 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" } + + # 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 + assert_equal "contents", darcs.cat_file(darcs.head, OhlohScm::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..9a8029ed --- /dev/null +++ b/test/unit/darcs_commits_test.rb @@ -0,0 +1,45 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + 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(: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(:after => 'bd7e455d648b784ce4be2db26a4e62dfe734dd66').first.diffs + assert_equal [], darcs.commits(:after => '1007b5ad4831769283213d47e1fd5f6d30ac97f0') + end + end + + def test_each_commit + commits = [] + with_darcs_repository('darcs') do |darcs| + darcs.each_commit do |c| + 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| + 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 ['bd7e455d648b784ce4be2db26a4e62dfe734dd66', + '1007b5ad4831769283213d47e1fd5f6d30ac97f0'], commits.map {|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..a791f2bd --- /dev/null +++ b/test/unit/darcs_head_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + class DarcsHeadTest < OhlohScm::Test + + def test_head_and_parents + with_darcs_repository('darcs') do |darcs| + assert_equal '1007b5ad4831769283213d47e1fd5f6d30ac97f0', darcs.head_token + assert_equal '1007b5ad4831769283213d47e1fd5f6d30ac97f0', darcs.head.token + assert darcs.head.diffs.any? # diffs should be populated + + assert_equal 'bd7e455d648b784ce4be2db26a4e62dfe734dd66', 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..f7a533bc --- /dev/null +++ b/test/unit/darcs_misc_test.rb @@ -0,0 +1,31 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + class DarcsMiscTest < OhlohScm::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 ['.','./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, 'bd7e455d648b784ce4be2db26a4e62dfe734dd66') + assert_equal ['.', '..', 'darcs.tar.gz'], 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..52e21b7b --- /dev/null +++ b/test/unit/darcs_parser_test.rb @@ -0,0 +1,138 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Parsers + class DarcsParserTest < OhlohScm::Test + + def test_empty_array + assert_equal([], DarcsParser.parse('')) + end + + def test_log_parser_default +sample_log = < +Date: Wed Nov 3 18:55:25 EDT 2010 + * remove helloworld.c + +patch bd7e455d648b784ce4be2db26a4e62dfe734dd66 +Author: Simon Michael +Date: Wed Nov 3 18:49:53 EDT 2010 + * add helloworld.c +SAMPLE + + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + 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 '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 'bd7e455d648b784ce4be2db26a4e62dfe734dd66', commits[1].token + assert_equal 'Simon Michael', commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email + 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 = < +Date: Wed Nov 3 18:55:25 EDT 2010 + * 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 + +patch bd7e455d648b784ce4be2db26a4e62dfe734dd66 +Author: Simon Michael +Date: Wed Nov 3 18:49:53 EDT 2010 + * 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) + + assert commits + assert_equal 2, commits.size + + 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 '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 'bd7e455d648b784ce4be2db26a4e62dfe734dd66', commits[1].token + assert_equal 'Simon Michael', commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email + 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 + assert_equal './helloworld.c', commits[0].diffs[1].path + end + + protected + + end +end diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb new file mode 100644 index 00000000..c43cfbb7 --- /dev/null +++ b/test/unit/darcs_patch_test.rb @@ -0,0 +1,13 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + class DarcsPatchTest < OhlohScm::Test + def test_patch_for_commit + with_darcs_repository('darcs') do |repo| + commit = repo.verbose_commit('bd7e455d648b784ce4be2db26a4e62dfe734dd66') + 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..065dad38 --- /dev/null +++ b/test/unit/darcs_pull_test.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + class DarcsPullTest < OhlohScm::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 record -a -m test" + assert_equal "test", 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..3a46e39d --- /dev/null +++ b/test/unit/darcs_push_test.rb @@ -0,0 +1,59 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + class DarcsPushTest < OhlohScm::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 record -a -m test" + assert_equal "test", 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..5096258b --- /dev/null +++ b/test/unit/darcs_rev_list_test.rb @@ -0,0 +1,53 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module OhlohScm::Adapters + # Repository darcs_walk has the following structure: + # + # A -> B -> C -> D -> E + # + class DarcsRevListTest < OhlohScm::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, :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 [], 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 diff --git a/test/unit/darcs_validation_test.rb b/test/unit/darcs_validation_test.rb new file mode 100644 index 00000000..b7363197 --- /dev/null +++ b/test/unit/darcs_validation_test.rb @@ -0,0 +1,60 @@ +require File.dirname(__FILE__) + '/../test_helper' + +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 + "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/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..8f4b5712 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,8 +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,12 +33,12 @@ 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) + 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 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..0b36820e 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,25 +21,25 @@ 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" } # 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 - 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..3b0be631 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,25 +21,25 @@ 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" } # 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 - 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..a6e459ee 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, $? @@ -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, $? diff --git a/test/unit/shellout_test.rb b/test/unit/shellout_test.rb index dd8d4f27..108ebaf2 100644 --- a/test/unit/shellout_test.rb +++ b/test/unit/shellout_test.rb @@ -1,6 +1,7 @@ require_relative '../test_helper' +require 'timeout' -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