From 14d69caf78b106cb5386e54f28a7f52f56ff702d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 3 Nov 2010 23:20:39 -0700 Subject: [PATCH 01/13] initial files for darcs support based on hg --- lib/scm.rb | 2 + lib/scm/adapters/darcs/cat_file.rb | 26 +++ lib/scm/adapters/darcs/commits.rb | 86 ++++++++ lib/scm/adapters/darcs/head.rb | 28 +++ lib/scm/adapters/darcs/misc.rb | 22 +++ lib/scm/adapters/darcs/patch.rb | 9 + lib/scm/adapters/darcs/pull.rb | 22 +++ lib/scm/adapters/darcs/push.rb | 51 +++++ lib/scm/adapters/darcs/validation.rb | 26 +++ lib/scm/adapters/darcs_adapter.rb | 16 ++ lib/scm/adapters/factory.rb | 3 + lib/scm/parsers/darcs_parser.rb | 63 ++++++ test/repositories/darcs/_darcs/.gitattributes | 1 + test/repositories/darcs/_darcs/format | 2 + .../darcs/_darcs/hashed_inventory | 0 test/repositories/darcs/_darcs/prefs/binaries | 30 +++ test/repositories/darcs/_darcs/prefs/boring | 113 +++++++++++ test/repositories/darcs/_darcs/prefs/motd | 0 ...c8996fb92427ae41e4649b934ca495991b7852b855 | Bin 0 -> 20 bytes test/test_helper.rb | 3 + test/unit/adapter_factory_test.rb | 9 + test/unit/darcs_cat_file_test.rb | 47 +++++ test/unit/darcs_commits_test.rb | 63 ++++++ test/unit/darcs_head_test.rb | 18 ++ test/unit/darcs_misc_test.rb | 31 +++ test/unit/darcs_parser_test.rb | 184 ++++++++++++++++++ test/unit/darcs_patch_test.rb | 13 ++ test/unit/darcs_pull_test.rb | 29 +++ test/unit/darcs_push_test.rb | 59 ++++++ test/unit/darcs_rev_list_test.rb | 63 ++++++ test/unit/darcs_validation_test.rb | 60 ++++++ test/unit/ohlog_command_line_test.rb | 3 + 32 files changed, 1082 insertions(+) create mode 100644 lib/scm/adapters/darcs/cat_file.rb create mode 100644 lib/scm/adapters/darcs/commits.rb create mode 100644 lib/scm/adapters/darcs/head.rb create mode 100644 lib/scm/adapters/darcs/misc.rb create mode 100644 lib/scm/adapters/darcs/patch.rb create mode 100644 lib/scm/adapters/darcs/pull.rb create mode 100644 lib/scm/adapters/darcs/push.rb create mode 100644 lib/scm/adapters/darcs/validation.rb create mode 100644 lib/scm/adapters/darcs_adapter.rb create mode 100644 lib/scm/parsers/darcs_parser.rb create mode 100644 test/repositories/darcs/_darcs/.gitattributes create mode 100644 test/repositories/darcs/_darcs/format create mode 100644 test/repositories/darcs/_darcs/hashed_inventory create mode 100644 test/repositories/darcs/_darcs/prefs/binaries create mode 100644 test/repositories/darcs/_darcs/prefs/boring create mode 100644 test/repositories/darcs/_darcs/prefs/motd create mode 100644 test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 create mode 100644 test/unit/darcs_cat_file_test.rb create mode 100644 test/unit/darcs_commits_test.rb create mode 100644 test/unit/darcs_head_test.rb create mode 100644 test/unit/darcs_misc_test.rb create mode 100644 test/unit/darcs_parser_test.rb create mode 100644 test/unit/darcs_patch_test.rb create mode 100644 test/unit/darcs_pull_test.rb create mode 100644 test/unit/darcs_push_test.rb create mode 100644 test/unit/darcs_rev_list_test.rb create mode 100644 test/unit/darcs_validation_test.rb diff --git a/lib/scm.rb b/lib/scm.rb index 60b014c8..5252dcef 100644 --- a/lib/scm.rb +++ b/lib/scm.rb @@ -19,6 +19,7 @@ module Scm 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' @@ -32,6 +33,7 @@ module Scm 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' diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/scm/adapters/darcs/cat_file.rb new file mode 100644 index 00000000..ff771e89 --- /dev/null +++ b/lib/scm/adapters/darcs/cat_file.rb @@ -0,0 +1,26 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def cat_file(commit, diff) + cat(commit.token, diff.path) + end + + def cat_file_parent(commit, diff) + p = parent_tokens(commit) + cat(p.first, diff.path) if p.first + end + + def cat(revision, path) + out, err = run_with_err("cd '#{url}' && darcs cat -r #{revision} #{escape(path)}") + return nil if err =~ /No such file in rev/ + raise RuntimeError.new(err) unless err.to_s == '' + out + end + + # Escape bash-significant characters in the filename + # Example: + # "Foo Bar & Baz" => "Foo\ Bar\ \&\ Baz" + def escape(path) + path.gsub(/[ '"&()<>|]/) { |c| '\\' + c } + end + end +end diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb new file mode 100644 index 00000000..2a251b8f --- /dev/null +++ b/lib/scm/adapters/darcs/commits.rb @@ -0,0 +1,86 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + + # Return the number of commits in the repository following +since+. + def commit_count(since=0) + commit_tokens(since || 0).size + end + + # Return the list of commit tokens following +since+. + def commit_tokens(since=0, up_to='tip') + # We reverse the final result in Ruby, rather than passing the --reverse flag to darcs. + # That's because the -f (follow) flag doesn't behave the same in both directions. + # Basically, we're trying very hard to make this act just like Git. The darcs_rev_list_test checks this. + tokens = run("cd '#{self.url}' && darcs log -f -r #{up_to || 'tip'}:#{since || 0} --template='{node}\\n'").split("\n").reverse + + # Darcs returns everything after *and including* since. + # We want to exclude it. + if tokens.any? && tokens.first == since + tokens[1..-1] + else + tokens + end + end + + # Returns a list of shallow commits (i.e., the diffs are not populated). + # Not including the diffs is meant to be a memory savings when we encounter massive repositories. + # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit + # in memory at a time. + def commits(since=0) + log = run("cd '#{self.url}' && darcs log -f -v -r tip:#{since || 0} --style #{Scm::Parsers::DarcsStyledParser.style_path}") + a = Scm::Parsers::DarcsStyledParser.parse(log).reverse + + if a.any? && a.first.token == since + a[1..-1] + else + a + end + end + + # Returns a single commit, including its diffs + def verbose_commit(token) + log = run("cd '#{self.url}' && darcs log -v -r #{token} --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") + Scm::Parsers::DarcsStyledParser.parse(log).first + end + + # Yields each commit after +since+, including its diffs. + # The log is stored in a temporary file. + # This is designed to prevent excessive RAM usage when we encounter a massive repository. + # Only a single commit is ever held in memory at once. + def each_commit(since=0) + open_log_file(since) do |io| + Scm::Parsers::DarcsStyledParser.parse(io) do |commit| + yield commit if block_given? && commit.token != since + end + end + end + + # Not used by Ohloh proper, but handy for debugging and testing + def log(since=0) + run "cd '#{url}' && darcs log -f -v -r tip:#{since}" + end + + # Returns a file handle to the log. + # In our standard, the log should include everything AFTER +since+. However, darcs doesn't work that way; + # it returns everything after and INCLUDING +since+. Therefore, consumers of this file should check for + # and reject the duplicate commit. + def open_log_file(since=0) + begin + if since == head_token # There are no new commits + # As a time optimization, just create an empty file rather than fetch a log we know will be empty. + File.open(log_filename, 'w') { } + else + run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path} > #{log_filename}" + end + File.open(log_filename, 'r') { |io| yield io } + ensure + File.delete(log_filename) if FileTest.exist?(log_filename) + end + end + + def log_filename + File.join('/tmp', (self.url).gsub(/\W/,'') + '.log') + end + + end +end diff --git a/lib/scm/adapters/darcs/head.rb b/lib/scm/adapters/darcs/head.rb new file mode 100644 index 00000000..2e777b22 --- /dev/null +++ b/lib/scm/adapters/darcs/head.rb @@ -0,0 +1,28 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def head_token + # This only returns first 12 characters. + # How can we make it return the entire hash? + token = run("darcs id -q #{url}").strip + + # Recent versions of Darcs now somtimes append a '+' char to the token. + # I believe this signifies pending changes... but we don't care. + # Strip the trailing '+', if any. + token = token[0..-2] if token[-1..-1] == '+' + + token + end + + def head + verbose_commit(head_token) + end + + def parent_tokens(commit) + run("cd '#{url}' && darcs parents -r #{commit.token} --template '{node}\\n'").split("\n") + end + + def parents(commit) + parent_tokens(commit).collect { |token| verbose_commit(token) } + end + end +end diff --git a/lib/scm/adapters/darcs/misc.rb b/lib/scm/adapters/darcs/misc.rb new file mode 100644 index 00000000..63da9052 --- /dev/null +++ b/lib/scm/adapters/darcs/misc.rb @@ -0,0 +1,22 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def exist? + begin + !!(head_token) + rescue + logger.debug { $! } + false + end + end + + def ls_tree(token) + run("cd '#{path}' && darcs manifest -r #{token}").split("\n") + end + + def export(dest_dir, token='tip') + run("cd '#{path}' && darcs archive -r #{token} '#{dest_dir}'") + # Darcs leaves a little cookie crumb in the export directory. Remove it. + File.delete(File.join(dest_dir, '.darcs_archival.txt')) if File.exist?(File.join(dest_dir, '.darcs_archival.txt')) + end + end +end diff --git a/lib/scm/adapters/darcs/patch.rb b/lib/scm/adapters/darcs/patch.rb new file mode 100644 index 00000000..5fe004cc --- /dev/null +++ b/lib/scm/adapters/darcs/patch.rb @@ -0,0 +1,9 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def patch_for_commit(commit) + parent_tokens(commit).map {|token| + run("darcs -R '#{url}' diff --git -r#{token} -r#{commit.token}") + }.join("\n") + end + end +end diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/scm/adapters/darcs/pull.rb new file mode 100644 index 00000000..cecfbabf --- /dev/null +++ b/lib/scm/adapters/darcs/pull.rb @@ -0,0 +1,22 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + + def pull(from, &block) + raise ArgumentError.new("Cannot pull from #{from.inspect}") unless from.is_a?(DarcsAdapter) + logger.info { "Pulling #{from.url}" } + + yield(0,1) if block_given? # Progress bar callback + + unless self.exist? + run "mkdir -p '#{self.url}'" + run "rm -rf '#{self.url}'" + run "darcs clone -U '#{from.url}' '#{self.url}'" + else + run "cd '#{self.url}' && darcs revert --all && darcs pull -u -y '#{from.url}'" + end + + yield(1,1) if block_given? # Progress bar callback + end + + end +end diff --git a/lib/scm/adapters/darcs/push.rb b/lib/scm/adapters/darcs/push.rb new file mode 100644 index 00000000..721609cf --- /dev/null +++ b/lib/scm/adapters/darcs/push.rb @@ -0,0 +1,51 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + + def push(to, &block) + raise ArgumentError.new("Cannot push to #{to.inspect}") unless to.is_a?(DarcsAdapter) + logger.info { "Pushing to #{to.url}" } + + yield(0,1) if block_given? # Progress bar callback + + unless to.exist? + if to.local? + # Create a new repo on the same local machine. Just use existing pull code in reverse. + to.pull(self) + else + run "ssh #{to.hostname} 'mkdir -p #{to.path}'" + run "scp -rpqB #{darcs_path} #{to.hostname}:#{to.path}" + end + else + run "cd '#{self.url}' && darcs push -f -y '#{to.url}'" + end + + yield(1,1) if block_given? # Progress bar callback + end + + def local? + return true if hostname == Socket.gethostname + return true if url =~ /^file:\/\// + return true if url !~ /:/ + false + end + + def hostname + $1 if url =~ /^ssh:\/\/([^\/]+)/ + end + + def path + case url + when /^file:\/\/(.+)$/ + $1 + when /^ssh:\/\/[^\/]+(\/.+)$/ + $1 + when /^[^:]*$/ + url + end + end + + def darcs_path + path && File.join(path, '.darcs') + end + end +end diff --git a/lib/scm/adapters/darcs/validation.rb b/lib/scm/adapters/darcs/validation.rb new file mode 100644 index 00000000..e265f6ef --- /dev/null +++ b/lib/scm/adapters/darcs/validation.rb @@ -0,0 +1,26 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def self.url_regex + /^((http|https|ssh|file):\/\/((\w+@)?[A-Za-z0-9_\-\.]+(:\d+)?\/)?)?[A-Za-z0-9_\-\.\/\~\+]*$/ + end + + def self.public_url_regex + /^(http|https):\/\/(\w+@)?[A-Za-z0-9_\-\.]+(:\d+)?\/[A-Za-z0-9_\-\.\/\~\+]*$/ + end + + def validate_server_connection + return unless valid? + @errors << [:failed, "The server did not respond to the 'darcs id' command. Is the URL correct?"] unless self.exist? + end + + def guess_forge + u = @url =~ /:\/\/(.*\.?darcs\.)?([^\/^:]+)(:\d+)?\// ? $2 : nil + case u + when /(sourceforge\.net$)/ + $1 + else + u + end + end + end +end diff --git a/lib/scm/adapters/darcs_adapter.rb b/lib/scm/adapters/darcs_adapter.rb new file mode 100644 index 00000000..58ab0aed --- /dev/null +++ b/lib/scm/adapters/darcs_adapter.rb @@ -0,0 +1,16 @@ +module Scm::Adapters + class DarcsAdapter < AbstractAdapter + def english_name + "Darcs" + end + end +end + +require 'lib/scm/adapters/darcs/validation' +require 'lib/scm/adapters/darcs/cat_file' +require 'lib/scm/adapters/darcs/commits' +require 'lib/scm/adapters/darcs/misc' +require 'lib/scm/adapters/darcs/pull' +require 'lib/scm/adapters/darcs/push' +require 'lib/scm/adapters/darcs/head' +require 'lib/scm/adapters/darcs/patch' diff --git a/lib/scm/adapters/factory.rb b/lib/scm/adapters/factory.rb index b9e1e661..6d8fa41c 100644 --- a/lib/scm/adapters/factory.rb +++ b/lib/scm/adapters/factory.rb @@ -11,6 +11,9 @@ def self.from_path(path) elsif FileTest.exist?(File.join(path, '.hg')) HgAdapter.new(:url => File.expand_path(path)).normalize + elsif FileTest.exist?(File.join(path, '_darcs')) + DarcsAdapter.new(:url => File.expand_path(path)).normalize + elsif FileTest.exist?(File.join(path, '.bzr')) BzrAdapter.new(:url => File.expand_path(path)).normalize diff --git a/lib/scm/parsers/darcs_parser.rb b/lib/scm/parsers/darcs_parser.rb new file mode 100644 index 00000000..accb6369 --- /dev/null +++ b/lib/scm/parsers/darcs_parser.rb @@ -0,0 +1,63 @@ +module Scm::Parsers + # This parser can process the default darcs logs, with or without the --verbose flag. + # It is handy for debugging but is not detailed enough for Ohloh analysis. + # See the DarcsStyledParser. + class DarcsParser < Parser + def self.scm + 'darcs' + end + + def self.internal_parse(buffer, opts) + e = nil + state = :data + + buffer.each_line do |l| + next_state = state + if state == :data + case l + when /^changeset:\s+\d+:([0-9a-f]+)/ + yield e if e && block_given? + e = Scm::Commit.new + e.diffs = [] + e.token = $1 + when /^user:\s+(.+?)(\s+<(.+)>)?$/ + e.committer_name = $1 + e.committer_email = $3 + when /^date:\s+(.+)/ + e.committer_date = Time.parse($1).utc + when /^files:\s+(.+)/ + ($1 || '').split(' ').each do |file| + e.diffs << Scm::Diff.new(:action => '?', :path => file) + end + when /^summary:\s+(.+)/ + e.message = $1 + when /^description:/ + next_state = :long_comment + end + + elsif state == :long_comment + if l == "\n" + next_state = :long_comment_following_blank + else + e.message ||= '' + e.message << l + end + + elsif state == :long_comment_following_blank + if l == "\n" # A second blank line in a row terminates the comment. + yield e if block_given? + e = nil + next_state = :data + else # Otherwise resume parsing comments. + e.message << "\n" + e.message << l + next_state = :long_comment + end + end + state = next_state + end + yield e if e && block_given? + end + + end +end diff --git a/test/repositories/darcs/_darcs/.gitattributes b/test/repositories/darcs/_darcs/.gitattributes new file mode 100644 index 00000000..bd2de00c --- /dev/null +++ b/test/repositories/darcs/_darcs/.gitattributes @@ -0,0 +1 @@ +* -text -whitespace diff --git a/test/repositories/darcs/_darcs/format b/test/repositories/darcs/_darcs/format new file mode 100644 index 00000000..58f777b5 --- /dev/null +++ b/test/repositories/darcs/_darcs/format @@ -0,0 +1,2 @@ +hashed +darcs-2 diff --git a/test/repositories/darcs/_darcs/hashed_inventory b/test/repositories/darcs/_darcs/hashed_inventory new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs/_darcs/prefs/binaries b/test/repositories/darcs/_darcs/prefs/binaries new file mode 100644 index 00000000..ac206487 --- /dev/null +++ b/test/repositories/darcs/_darcs/prefs/binaries @@ -0,0 +1,30 @@ +# This file contains a list of extended regular expressions, one per +# line. A file path matching any of these expressions is assumed to +# contain binary data (not text). The entries in ~/.darcs/binaries (if +# it exists) supplement those in this file. +# +# Blank lines, and lines beginning with an octothorpe (#) are ignored. +# See regex(7) for a description of extended regular expressions. +\.(a|A)$ +\.(bmp|BMP)$ +\.(bz2|BZ2)$ +\.(doc|DOC)$ +\.(elc|ELC)$ +\.(exe|EXE)$ +\.(gif|GIF)$ +\.(gz|GZ)$ +\.(iso|ISO)$ +\.(jar|JAR)$ +\.(jpe?g|JPE?G)$ +\.(mng|MNG)$ +\.(mpe?g|MPE?G)$ +\.(p[nbgp]m|P[NBGP]M)$ +\.(pdf|PDF)$ +\.(png|PNG)$ +\.(pyc|PYC)$ +\.(so|SO)$ +\.(tar|TAR)$ +\.(tgz|TGZ)$ +\.(tiff?|TIFF?)$ +\.(z|Z)$ +\.(zip|ZIP)$ diff --git a/test/repositories/darcs/_darcs/prefs/boring b/test/repositories/darcs/_darcs/prefs/boring new file mode 100644 index 00000000..5969e686 --- /dev/null +++ b/test/repositories/darcs/_darcs/prefs/boring @@ -0,0 +1,113 @@ +# Boring file regexps: + +### compiler and interpreter intermediate files +# haskell (ghc) interfaces +\.hi$ +\.hi-boot$ +\.o-boot$ +# object files +\.o$ +\.o\.cmd$ +# profiling haskell +\.p_hi$ +\.p_o$ +# haskell program coverage resp. profiling info +\.tix$ +\.prof$ +# fortran module files +\.mod$ +# linux kernel +\.ko\.cmd$ +\.mod\.c$ +(^|/)\.tmp_versions($|/) +# *.ko files aren't boring by default because they might +# be Korean translations rather than kernel modules +# \.ko$ +# python, emacs, java byte code +\.py[co]$ +\.elc$ +\.class$ +# objects and libraries; lo and la are libtool things +\.(obj|a|exe|so|lo|la)$ +# compiled zsh configuration files +\.zwc$ +# Common LISP output files for CLISP and CMUCL +\.(fas|fasl|sparcf|x86f)$ + +### build and packaging systems +# cabal intermediates +\.installed-pkg-config +\.setup-config +# standard cabal build dir, might not be boring for everybody +# ^dist(/|$) +# autotools +(^|/)autom4te\.cache($|/) +(^|/)config\.(log|status)$ +# microsoft web expression, visual studio metadata directories +\_vti_cnf$ +\_vti_pvt$ +# gentoo tools +\.revdep-rebuild.* +# generated dependencies +^\.depend$ + +### version control systems +# cvs +(^|/)CVS($|/) +\.cvsignore$ +# cvs, emacs locks +^\.# +# rcs +(^|/)RCS($|/) +,v$ +# subversion +(^|/)\.svn($|/) +# mercurial +(^|/)\.hg($|/) +# git +(^|/)\.git($|/) +# bzr +\.bzr$ +# sccs +(^|/)SCCS($|/) +# darcs +(^|/)_darcs($|/) +(^|/)\.darcsrepo($|/) +^\.darcs-temp-mail$ +-darcs-backup[[:digit:]]+$ +# gnu arch +(^|/)(\+|,) +(^|/)vssver\.scc$ +\.swp$ +(^|/)MT($|/) +(^|/)\{arch\}($|/) +(^|/).arch-ids($|/) +# bitkeeper +(^|/)BitKeeper($|/) +(^|/)ChangeSet($|/) + +### miscellaneous +# backup files +~$ +\.bak$ +\.BAK$ +# patch originals and rejects +\.orig$ +\.rej$ +# X server +\..serverauth.* +# image spam +\# +(^|/)Thumbs\.db$ +# vi, emacs tags +(^|/)(tags|TAGS)$ +#(^|/)\.[^/] +# core dumps +(^|/|\.)core$ +# partial broken files (KIO copy operations) +\.part$ +# waf files, see http://code.google.com/p/waf/ +(^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/) +(^|/)\.lock-wscript$ +# mac os finder +(^|/)\.DS_Store$ diff --git a/test/repositories/darcs/_darcs/prefs/motd b/test/repositories/darcs/_darcs/prefs/motd new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/test/repositories/darcs/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000000000000000000000000000000000..229151a5a27ab0cc4661f529cc0eda27e3c03e10 GIT binary patch literal 20 Rcmb2|=3oE=W@ZQtBmoVe0J#7F literal 0 HcmV?d00001 diff --git a/test/test_helper.rb b/test/test_helper.rb index 797d2f69..6569ac5a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -103,5 +103,8 @@ def with_bzr_repository(name) def with_bzrlib_repository(name) with_repository(Scm::Adapters::BzrlibAdapter, name) { |bzr| yield bzr } + + def with_darcs_repository(name) + with_repository(Scm::Adapters::DarcsAdapter, name) { |darcs| yield darcs } end end diff --git a/test/unit/adapter_factory_test.rb b/test/unit/adapter_factory_test.rb index 71e28622..a3f5b3cb 100644 --- a/test/unit/adapter_factory_test.rb +++ b/test/unit/adapter_factory_test.rb @@ -3,6 +3,15 @@ module Scm::Adapters class FactoryTest < Scm::Test + def test_factory_darcs + Scm::ScratchDir.new do |path| + `cd #{path} && darcs init` + darcs = Factory.from_path(path) + assert darcs.is_a?(DarcsAdapter) + assert_equal darcs.url, path + end + end + def test_factory_hg Scm::ScratchDir.new do |path| `cd #{path} && hg init` diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb new file mode 100644 index 00000000..67b6213f --- /dev/null +++ b/test/unit/darcs_cat_file_test.rb @@ -0,0 +1,47 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsCatFileTest < Scm::Test + + def test_cat_file + with_darcs_repository('darcs') do |darcs| +expected = <<-EXPECTED +/* Hello, World! */ + +/* + * This file is not covered by any license, especially not + * the GNU General Public License (GPL). Have fun! + */ + +#include +main() +{ + printf("Hello, World!\\n"); +} +EXPECTED + + # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. + assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => '468336c6671c'), Scm::Diff.new(:path => 'helloworld.c')) + end + end + + # Ensure that we escape bash-significant characters like ' and & when they appear in the filename + def test_funny_file_name_chars + Scm::ScratchDir.new do |dir| + # Make a file with a problematic filename + funny_name = '|file_name (&\'")' + File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } + + # Add it to an darcs repository + `cd #{dir} && darcs init && darcs add * && darcs commit -m test` + + # Confirm that we can read the file back + darcs = DarcsAdapter.new(:url => dir).normalize + assert_equal "contents", darcs.cat_file(darcs.head, Scm::Diff.new(:path => funny_name)) + end + end + + end +end diff --git a/test/unit/darcs_commits_test.rb b/test/unit/darcs_commits_test.rb new file mode 100644 index 00000000..f65418e2 --- /dev/null +++ b/test/unit/darcs_commits_test.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsCommitsTest < Scm::Test + + def test_commit + with_darcs_repository('darcs') do |darcs| + assert_equal 4, darcs.commit_count + assert_equal 2, darcs.commit_count('b14fa4692f949940bd1e28da6fb4617de2615484') + assert_equal 0, darcs.commit_count('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + + assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', + 'b14fa4692f949940bd1e28da6fb4617de2615484', + '468336c6671cbc58237a259d1b7326866afc2817', + '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commit_tokens + + assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], + darcs.commit_tokens('468336c6671cbc58237a259d1b7326866afc2817') + + assert_equal [], darcs.commit_tokens('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + + assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', + 'b14fa4692f949940bd1e28da6fb4617de2615484', + '468336c6671cbc58237a259d1b7326866afc2817', + '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commits.collect { |c| c.token } + + assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], + darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').collect { |c| c.token } + + # Check that the diffs are not populated + assert_equal [], darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').first.diffs + + assert_equal [], darcs.commits('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + end + end + + def test_each_commit + commits = [] + with_darcs_repository('darcs') do |darcs| + darcs.each_commit do |c| + assert c.token.length == 40 + assert c.committer_name + assert c.committer_date.is_a?(Time) + assert c.message.length > 0 + assert c.diffs.any? + # Check that the diffs are populated + c.diffs.each do |d| + assert d.action =~ /^[MAD]$/ + assert d.path.length > 0 + end + commits << c + end + assert !FileTest.exist?(darcs.log_filename) # Make sure we cleaned up after ourselves + + # Verify that we got the commits in forward chronological order + assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', + 'b14fa4692f949940bd1e28da6fb4617de2615484', + '468336c6671cbc58237a259d1b7326866afc2817', + '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], commits.collect { |c| c.token } + end + end + end +end diff --git a/test/unit/darcs_head_test.rb b/test/unit/darcs_head_test.rb new file mode 100644 index 00000000..3d1b748d --- /dev/null +++ b/test/unit/darcs_head_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsHeadTest < Scm::Test + + def test_head_and_parents + with_darcs_repository('darcs') do |darcs| + assert_equal '75532c1e1f1d', darcs.head_token + assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', darcs.head.token + assert darcs.head.diffs.any? # diffs should be populated + + assert_equal '468336c6671cbc58237a259d1b7326866afc2817', darcs.parents(darcs.head).first.token + assert darcs.parents(darcs.head).first.diffs.any? + end + end + + end +end diff --git a/test/unit/darcs_misc_test.rb b/test/unit/darcs_misc_test.rb new file mode 100644 index 00000000..a68c7ad2 --- /dev/null +++ b/test/unit/darcs_misc_test.rb @@ -0,0 +1,31 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsMiscTest < Scm::Test + + def test_exist + save_darcs = nil + with_darcs_repository('darcs') do |darcs| + save_darcs = darcs + assert save_darcs.exist? + end + assert !save_darcs.exist? + end + + def test_ls_tree + with_darcs_repository('darcs') do |darcs| + assert_equal ['README','makefile'], darcs.ls_tree(darcs.head_token).sort + end + end + + def test_export + with_darcs_repository('darcs') do |darcs| + Scm::ScratchDir.new do |dir| + darcs.export(dir) + assert_equal ['.', '..', 'README', 'makefile'], Dir.entries(dir).sort + end + end + end + + end +end diff --git a/test/unit/darcs_parser_test.rb b/test/unit/darcs_parser_test.rb new file mode 100644 index 00000000..64051005 --- /dev/null +++ b/test/unit/darcs_parser_test.rb @@ -0,0 +1,184 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Parsers + class DarcsParserTest < Scm::Test + + def test_empty_array + assert_equal([], DarcsParser.parse('')) + end + + def test_log_parser_default +sample_log = < +date: Tue, Jan 20 2009 11:33:17 -0800 +summary: added makefile + + +changeset: 0:01101d8ef3ce +user: Robin Luckey +date: Tue, Jan 20 2009 11:32:54 -0800 +summary: Initial Checkin + +SAMPLE + + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + assert_equal 'b14fa4692f94', commits[0].token + assert_equal 'Jason Allen', commits[0].committer_name + assert_equal 'jason@ohloh.net', commits[0].committer_email + assert_equal "added makefile", commits[0].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 0, commits[0].diffs.size + + assert_equal '01101d8ef3ce', commits[1].token + assert_equal 'Robin Luckey', commits[1].committer_name + assert_equal 'robin@ohloh.net', commits[1].committer_email + assert_equal "Initial Checkin", commits[1].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 0, commits[1].diffs.size + end + + def test_log_parser_default_partial_user_name +sample_log = < +date: Tue, Jan 20 2009 11:33:17 -0800 + + +changeset: 0:01101d8ef3ce +user: Robin Luckey +date: Tue, Jan 20 2009 11:32:54 -0800 + +SAMPLE + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + assert_equal 'b14fa4692f94', commits[0].token + assert_equal 'Jason Allen', commits[0].committer_name + assert_equal 'jason@ohloh.net', commits[0].committer_email + assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 0, commits[0].diffs.size + + assert_equal '01101d8ef3ce', commits[1].token + assert_equal 'Robin Luckey', commits[1].committer_name + assert_equal 'robin@ohloh.net', commits[1].committer_email + assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 0, commits[1].diffs.size + end + + def test_log_parser_verbose +sample_log = < +date: Tue, Jan 20 2009 11:33:17 -0800 +files: makefile +description: +added makefile + + +changeset: 0:01101d8ef3ce +user: Robin Luckey +date: Tue, Jan 20 2009 11:32:54 -0800 +files: helloworld.c +description: +Initial Checkin + + +SAMPLE + + commits = DarcsParser.parse(sample_log) + + assert commits + assert_equal 2, commits.size + + assert_equal 'b14fa4692f94', commits[0].token + assert_equal 'Jason Allen', commits[0].committer_name + assert_equal 'jason@ohloh.net', commits[0].committer_email + assert_equal "added makefile\n", commits[0].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 1, commits[0].diffs.size + assert_equal 'makefile', commits[0].diffs[0].path + + assert_equal '01101d8ef3ce', commits[1].token + assert_equal 'Robin Luckey', commits[1].committer_name + assert_equal 'robin@ohloh.net', commits[1].committer_email + assert_equal "Initial Checkin\n", commits[1].message # Note \n at end of comment + assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 1, commits[1].diffs.size + assert_equal 'helloworld.c', commits[1].diffs[0].path + end + + def test_styled_parser + with_darcs_repository('darcs') do |darcs| + assert FileTest.exist?(DarcsStyledParser.style_path) + log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.style_path}") + commits = Scm::Parsers::DarcsStyledParser.parse(log) + assert_styled_commits(commits, false) + + assert FileTest.exist?(DarcsStyledParser.verbose_style_path) + log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") + commits = Scm::Parsers::DarcsStyledParser.parse(log) + assert_styled_commits(commits, true) + end + end + + protected + + def assert_styled_commits(commits, with_diffs=false) + assert_equal 4, commits.size + + assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', commits[0].token + assert_equal 'Robin Luckey', commits[0].committer_name + assert_equal 'robin@ohloh.net', commits[0].committer_email + assert Time.utc(2009,1,20,19,34,53) - commits[0].committer_date < 1 # Don't care about milliseconds + assert_equal "deleted helloworld.c\n", commits[0].message + + if with_diffs + assert_equal 1, commits[0].diffs.size + assert_equal 'D', commits[0].diffs[0].action + assert_equal 'helloworld.c', commits[0].diffs[0].path + else + assert_equal [], commits[0].diffs + end + + assert_equal '468336c6671cbc58237a259d1b7326866afc2817', commits[1].token + assert Time.utc(2009, 1,20,19,34,04) - commits[1].committer_date < 1 + + if with_diffs + assert_equal 2, commits[1].diffs.size + assert_equal 'M', commits[1].diffs[0].action + assert_equal 'helloworld.c', commits[1].diffs[0].path + assert_equal 'A', commits[1].diffs[1].action + assert_equal 'README', commits[1].diffs[1].path + else + assert_equal [], commits[0].diffs + end + end + end +end diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb new file mode 100644 index 00000000..65d517ce --- /dev/null +++ b/test/unit/darcs_patch_test.rb @@ -0,0 +1,13 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsPatchTest < Scm::Test + def test_patch_for_commit + with_darcs_repository('darcs') do |repo| + commit = repo.verbose_commit(1) + data = File.read(File.join(DATA_DIR, 'darcs_patch.diff')) + assert_equal data, repo.patch_for_commit(commit) + end + end + end +end diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb new file mode 100644 index 00000000..fad9251b --- /dev/null +++ b/test/unit/darcs_pull_test.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsPullTest < Scm::Test + + def test_pull + with_darcs_repository('darcs') do |src| + Scm::ScratchDir.new do |dest_dir| + + dest = DarcsAdapter.new(:url => dest_dir).normalize + assert !dest.exist? + + dest.pull(src) + assert dest.exist? + + assert_equal src.log, dest.log + + # Commit some new code on the original and pull again + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" + assert_equal "test\n", src.commits.last.message + + dest.pull(src) + assert_equal src.log, dest.log + end + end + end + + end +end diff --git a/test/unit/darcs_push_test.rb b/test/unit/darcs_push_test.rb new file mode 100644 index 00000000..e72bfef6 --- /dev/null +++ b/test/unit/darcs_push_test.rb @@ -0,0 +1,59 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsPushTest < Scm::Test + + def test_hostname + assert !DarcsAdapter.new.hostname + assert !DarcsAdapter.new(:url => "http://www.ohloh.net/test").hostname + assert !DarcsAdapter.new(:url => "/Users/robin/foo").hostname + assert_equal "foo", DarcsAdapter.new(:url => 'ssh://foo/bar').hostname + end + + def test_local + assert !DarcsAdapter.new(:url => "foo:/bar").local? # Assuming your machine is not named "foo" :-) + assert !DarcsAdapter.new(:url => "http://www.ohloh.net/foo").local? + assert !DarcsAdapter.new(:url => "ssh://host/Users/robin/src").local? + assert DarcsAdapter.new(:url => "src").local? + assert DarcsAdapter.new(:url => "/Users/robin/src").local? + assert DarcsAdapter.new(:url => "file:///Users/robin/src").local? + assert DarcsAdapter.new(:url => "ssh://#{Socket.gethostname}/Users/robin/src").local? + end + + def test_path + assert_equal nil, DarcsAdapter.new().path + assert_equal nil, DarcsAdapter.new(:url => "http://ohloh.net/foo").path + assert_equal nil, DarcsAdapter.new(:url => "https://ohloh.net/foo").path + assert_equal "/Users/robin/foo", DarcsAdapter.new(:url => "file:///Users/robin/foo").path + assert_equal "/Users/robin/foo", DarcsAdapter.new(:url => "ssh://localhost/Users/robin/foo").path + assert_equal "/Users/robin/foo", DarcsAdapter.new(:url => "/Users/robin/foo").path + end + + def test_darcs_path + assert_equal nil, DarcsAdapter.new().darcs_path + assert_equal "/Users/robin/src/.darcs", DarcsAdapter.new(:url => "/Users/robin/src").darcs_path + end + + def test_push + with_darcs_repository('darcs') do |src| + Scm::ScratchDir.new do |dest_dir| + + dest = DarcsAdapter.new(:url => dest_dir).normalize + assert !dest.exist? + + src.push(dest) + assert dest.exist? + assert_equal src.log, dest.log + + # Commit some new code on the original and pull again + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" + assert_equal "test\n", src.commits.last.message + + src.push(dest) + assert_equal src.log, dest.log + end + end + end + + end +end diff --git a/test/unit/darcs_rev_list_test.rb b/test/unit/darcs_rev_list_test.rb new file mode 100644 index 00000000..c7cb83b8 --- /dev/null +++ b/test/unit/darcs_rev_list_test.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + # Repository darcs_walk has the following structure: + # + # G -> H -> I + # / \ \ + # A -> B -> C -> D -> tip + # + class DarcsRevListTest < Scm::Test + + def test_rev_list + with_darcs_repository('darcs_walk') do |darcs| + # Full history to a commit + assert_equal [:A], rev_list_helper(darcs, nil, :A) + assert_equal [:A, :B], rev_list_helper(darcs, nil, :B) + assert_equal [:A, :B, :G, :H, :C], rev_list_helper(darcs, nil, :C) + assert_equal [:A, :B, :G, :H, :C, :I, :D], rev_list_helper(darcs, nil, :D) + assert_equal [:A, :G], rev_list_helper(darcs, nil, :G) + assert_equal [:A, :G, :H], rev_list_helper(darcs, nil, :H) + assert_equal [:A, :G, :H, :I], rev_list_helper(darcs, nil, :I) + + # Limited history from one commit to another + assert_equal [], rev_list_helper(darcs, :A, :A) + assert_equal [:B], rev_list_helper(darcs, :A, :B) + assert_equal [:B, :G, :H, :C], rev_list_helper(darcs, :A, :C) + assert_equal [:B, :G, :H, :C, :I, :D], rev_list_helper(darcs, :A, :D) + assert_equal [:G, :H, :C, :I, :D], rev_list_helper(darcs, :B, :D) + assert_equal [:I, :D], rev_list_helper(darcs, :C, :D) + end + end + + protected + + def rev_list_helper(darcs, from, to) + to_labels(darcs.commit_tokens(from_label(from), from_label(to))) + end + + def commit_labels + { '4bfbf836feeebb236492199fbb0d1474e26f69d9' => :A, + '23edb79d0d06c8c315d8b9e7456098823335377d' => :B, + '7e33b9fde56a6e3576753868d08fa143e4e8a9cf' => :C, + '8daa1aefa228d3ee5f9a0f685d696826e88266fb' => :D, + 'e43cf1bb4b80d8ae70a695ec070ce017fdc529f3' => :G, + 'dca215d8a3e4dd3e472379932f1dd9c909230331' => :H, + '3a1495175e40b1c983441d6a8e8e627d2bd672b6' => :I + } + end + + def to_label(sha1) + commit_labels[sha1.to_s] + end + + def to_labels(sha1s) + sha1s.collect { |sha1| to_label(sha1) } + end + + def from_label(l) + commit_labels.each_pair { |k,v| return k if v.to_s == l.to_s } + nil + end + end +end diff --git a/test/unit/darcs_validation_test.rb b/test/unit/darcs_validation_test.rb new file mode 100644 index 00000000..71a664f6 --- /dev/null +++ b/test/unit/darcs_validation_test.rb @@ -0,0 +1,60 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class DarcsValidationTest < Scm::Test + def test_rejected_urls + [ nil, "", "foo", "http:/", "http:://", "http://", "http://a", + "www.selenic.com/repo/hello", # missing a protool prefix + "http://www.selenic.com/repo/hello%20world", # no encoded strings allowed + "http://www.selenic.com/repo/hello world", # no spaces allowed + "git://www.selenic.com/repo/hello", # git protocol not allowed + "svn://www.selenic.com/repo/hello" # svn protocol not allowed + ].each do |url| + darcs = DarcsAdapter.new(:url => url, :public_urls_only => true) + assert darcs.validate_url.any? + end + end + + def test_accepted_urls + [ "http://www.selenic.com/repo/hello", + "http://www.selenic.com:80/repo/hello", + "https://www.selenic.com/repo/hello", + ].each do |url| + darcs = DarcsAdapter.new(:url => url, :public_urls_only => true) + assert !darcs.validate_url + end + end + + # These urls are not available to the public + def test_rejected_public_urls + [ "file:///home/robin/darcs", + "/home/robin/darcs", + "ssh://robin@localhost/home/robin/darcs", + "ssh://localhost/home/robin/darcs" + ].each do |url| + darcs = DarcsAdapter.new(:url => url, :public_urls_only => true) + assert darcs.validate_url + + darcs = DarcsAdapter.new(:url => url) + assert !darcs.validate_url + end + end + + def test_guess_forge + darcs = DarcsAdapter.new(:url => nil) + assert_equal nil, darcs.guess_forge + + darcs = DarcsAdapter.new(:url => "/home/robin/darcs") + assert_equal nil, darcs.guess_forge + + darcs = DarcsAdapter.new( :url => 'http://www.selenic.com/repo/hello') + assert_equal 'www.selenic.com', darcs.guess_forge + + darcs = DarcsAdapter.new( :url => 'http://algoc.darcs.sourceforge.net:8000/darcsroot/algoc') + assert_equal 'sourceforge.net', darcs.guess_forge + + darcs = DarcsAdapter.new( :url => 'http://poliqarp.sourceforge.net/darcs/poliqarp/') + assert_equal 'sourceforge.net', darcs.guess_forge + end + end +end diff --git a/test/unit/ohlog_command_line_test.rb b/test/unit/ohlog_command_line_test.rb index 2c630d0a..462d4d4f 100644 --- a/test/unit/ohlog_command_line_test.rb +++ b/test/unit/ohlog_command_line_test.rb @@ -27,6 +27,9 @@ def test_svn_xml_from_file def test_hg_from_file end + #def test_darcs_from_file + #end + def test_help result = `#{File.dirname(__FILE__) + '/../../bin/ohlog'} -?` assert_equal 0, $? From c0b5df5ae724f806caba2a2ccbf84801a440488d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 03:14:38 -0700 Subject: [PATCH 02/13] ignore emacs TAGS files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d411dd7f..13456823 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.pyc pkg/ *.cache +TAGS From 8e6669628acb0d38150bc7bdeb89f38aaa20ffc4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 05:30:16 -0700 Subject: [PATCH 03/13] changes parser, human-readable output --- lib/scm/parsers/darcs_parser.rb | 83 ++++++++----- test/unit/darcs_parser_test.rb | 206 ++++++++++++-------------------- 2 files changed, 125 insertions(+), 164 deletions(-) diff --git a/lib/scm/parsers/darcs_parser.rb b/lib/scm/parsers/darcs_parser.rb index accb6369..286dec88 100644 --- a/lib/scm/parsers/darcs_parser.rb +++ b/lib/scm/parsers/darcs_parser.rb @@ -1,7 +1,5 @@ module Scm::Parsers - # This parser can process the default darcs logs, with or without the --verbose flag. - # It is handy for debugging but is not detailed enough for Ohloh analysis. - # See the DarcsStyledParser. + # This parser can process the default darcs changes output #, with or without the --verbose flag. class DarcsParser < Parser def self.scm 'darcs' @@ -9,50 +7,69 @@ def self.scm def self.internal_parse(buffer, opts) e = nil - state = :data + state = :patch buffer.each_line do |l| + #print "\n#{state}" next_state = state - if state == :data + if state == :patch case l - when /^changeset:\s+\d+:([0-9a-f]+)/ + when /^([^ ]...........................) (.*)$/ yield e if e && block_given? e = Scm::Commit.new - e.diffs = [] - e.token = $1 - when /^user:\s+(.+?)(\s+<(.+)>)?$/ - e.committer_name = $1 - e.committer_email = $3 - when /^date:\s+(.+)/ - e.committer_date = Time.parse($1).utc - when /^files:\s+(.+)/ - ($1 || '').split(' ').each do |file| - e.diffs << Scm::Diff.new(:action => '?', :path => file) + e.author_date = Time.parse($1).utc + nameemail = $2 + case nameemail + when /^([^<]*) <(.*)>$/ + e.author_name = $1 + e.author_email = $2 + when /^([^@]*)$/ + e.author_name = $1 + e.author_email = nil + else + e.author_name = nil + e.author_email = nameemail end - when /^summary:\s+(.+)/ - e.message = $1 - when /^description:/ - next_state = :long_comment + e.diffs = [] + when /^ \* (.*)/ + e.token = ($1 || '') + next_state = :long_comment_or_prims end - elsif state == :long_comment - if l == "\n" - next_state = :long_comment_following_blank + elsif state == :long_comment_or_prims + case l + when /^ addfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'A', :path => $1) + next_state = :prims + when /^ rmfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'D', :path => $1) + next_state = :prims + when /^ hunk\s+(.+)\s+([0-9]+)$/ + e.diffs << Scm::Diff.new(:action => 'M', :path => $1) + # e.sha1, e.parent_sha1 = ... + next_state = :prims + when /^$/ + next_state = :patch else e.message ||= '' - e.message << l + e.message << l.sub(/^ /,'') end - elsif state == :long_comment_following_blank - if l == "\n" # A second blank line in a row terminates the comment. - yield e if block_given? - e = nil - next_state = :data - else # Otherwise resume parsing comments. - e.message << "\n" - e.message << l - next_state = :long_comment + elsif state == :prims + case l + when /^ addfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'A', :path => $1) + when /^ rmfile\s+(.+)/ + e.diffs << Scm::Diff.new(:action => 'D', :path => $1) + when /^ hunk\s+(.+)\s+([0-9]+)$/ + e.diffs << Scm::Diff.new(:action => 'M', :path => $1) + # e.sha1, e.parent_sha1 = ... + when /^$/ + next_state = :patch + else + # ignore hunk details end + end state = next_state end diff --git a/test/unit/darcs_parser_test.rb b/test/unit/darcs_parser_test.rb index 64051005..7d691831 100644 --- a/test/unit/darcs_parser_test.rb +++ b/test/unit/darcs_parser_test.rb @@ -9,16 +9,11 @@ def test_empty_array def test_log_parser_default sample_log = < -date: Tue, Jan 20 2009 11:33:17 -0800 -summary: added makefile +Wed Nov 3 15:55:25 PDT 2010 Simon Michael + * remove helloworld.c - -changeset: 0:01101d8ef3ce -user: Robin Luckey -date: Tue, Jan 20 2009 11:32:54 -0800 -summary: Initial Checkin +Wed Nov 3 15:49:53 PDT 2010 Simon Michael + * add helloworld.c SAMPLE @@ -27,89 +22,80 @@ def test_log_parser_default assert commits assert_equal 2, commits.size - assert_equal 'b14fa4692f94', commits[0].token - assert_equal 'Jason Allen', commits[0].committer_name - assert_equal 'jason@ohloh.net', commits[0].committer_email - assert_equal "added makefile", commits[0].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date + assert_equal 'remove helloworld.c', commits[0].token + assert_equal 'Simon Michael', commits[0].author_name + assert_equal 'simon@joyful.com', commits[0].author_email + assert_equal nil, commits[0].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,55,25), commits[0].author_date assert_equal 0, commits[0].diffs.size - assert_equal '01101d8ef3ce', commits[1].token - assert_equal 'Robin Luckey', commits[1].committer_name - assert_equal 'robin@ohloh.net', commits[1].committer_email - assert_equal "Initial Checkin", commits[1].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date + assert_equal 'add helloworld.c', commits[1].token + assert_equal 'Simon Michael', commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email + assert_equal nil, commits[1].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,49,53), commits[1].author_date assert_equal 0, commits[1].diffs.size end def test_log_parser_default_partial_user_name sample_log = < -date: Tue, Jan 20 2009 11:33:17 -0800 +Wed Nov 3 15:55:25 PDT 2010 Simon Michael + * name only - -changeset: 0:01101d8ef3ce -user: Robin Luckey -date: Tue, Jan 20 2009 11:32:54 -0800 +Wed Nov 3 15:49:53 PDT 2010 simon@joyful.com + * email only SAMPLE + commits = DarcsParser.parse(sample_log) assert commits assert_equal 2, commits.size - assert_equal 'b14fa4692f94', commits[0].token - assert_equal 'Jason Allen', commits[0].committer_name - assert_equal 'jason@ohloh.net', commits[0].committer_email - assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date - assert_equal 0, commits[0].diffs.size + assert_equal 'name only', commits[0].token + assert_equal 'Simon Michael', commits[0].author_name + assert !commits[0].author_email - assert_equal '01101d8ef3ce', commits[1].token - assert_equal 'Robin Luckey', commits[1].committer_name - assert_equal 'robin@ohloh.net', commits[1].committer_email - assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date - assert_equal 0, commits[1].diffs.size + assert_equal 'email only', commits[1].token + assert !commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email end def test_log_parser_verbose sample_log = < -date: Tue, Jan 20 2009 11:33:17 -0800 -files: makefile -description: -added makefile - - -changeset: 0:01101d8ef3ce -user: Robin Luckey -date: Tue, Jan 20 2009 11:32:54 -0800 -files: helloworld.c -description: -Initial Checkin - - +Wed Nov 3 15:55:25 PDT 2010 Simon Michael + * remove helloworld.c + hunk ./helloworld.c 1 + -/* Hello, World! */ + - + -/* + - * This file is not covered by any license, especially not + - * the GNU General Public License (GPL). Have fun! + - */ + - + -#include + -main() + -{ + - printf("Hello, World!\\n"); + -} + rmfile ./helloworld.c + +Wed Nov 3 15:49:53 PDT 2010 Simon Michael + * add helloworld.c + addfile ./helloworld.c + hunk ./helloworld.c 1 + +/* Hello, World! */ + + + +/* + + * This file is not covered by any license, especially not + + * the GNU General Public License (GPL). Have fun! + + */ + + + +#include + +main() + +{ + + printf("Hello, World!\\n"); + +} SAMPLE commits = DarcsParser.parse(sample_log) @@ -117,68 +103,26 @@ def test_log_parser_verbose assert commits assert_equal 2, commits.size - assert_equal 'b14fa4692f94', commits[0].token - assert_equal 'Jason Allen', commits[0].committer_name - assert_equal 'jason@ohloh.net', commits[0].committer_email - assert_equal "added makefile\n", commits[0].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,33,17), commits[0].committer_date - assert_equal 1, commits[0].diffs.size - assert_equal 'makefile', commits[0].diffs[0].path - - assert_equal '01101d8ef3ce', commits[1].token - assert_equal 'Robin Luckey', commits[1].committer_name - assert_equal 'robin@ohloh.net', commits[1].committer_email - assert_equal "Initial Checkin\n", commits[1].message # Note \n at end of comment - assert_equal Time.utc(2009,1,20,19,32,54), commits[1].committer_date - assert_equal 1, commits[1].diffs.size - assert_equal 'helloworld.c', commits[1].diffs[0].path - end - - def test_styled_parser - with_darcs_repository('darcs') do |darcs| - assert FileTest.exist?(DarcsStyledParser.style_path) - log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.style_path}") - commits = Scm::Parsers::DarcsStyledParser.parse(log) - assert_styled_commits(commits, false) - - assert FileTest.exist?(DarcsStyledParser.verbose_style_path) - log = darcs.run("cd #{darcs.url} && darcs log --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") - commits = Scm::Parsers::DarcsStyledParser.parse(log) - assert_styled_commits(commits, true) - end + assert_equal 'remove helloworld.c', commits[0].token + assert_equal 'Simon Michael', commits[0].author_name + assert_equal 'simon@joyful.com', commits[0].author_email + assert_equal nil, commits[0].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,55,25), commits[0].author_date + assert_equal 2, commits[0].diffs.size + assert_equal './helloworld.c', commits[0].diffs[0].path + assert_equal './helloworld.c', commits[0].diffs[1].path + + assert_equal 'add helloworld.c', commits[1].token + assert_equal 'Simon Michael', commits[1].author_name + assert_equal 'simon@joyful.com', commits[1].author_email + assert_equal nil, commits[1].message # Note \n at end of comment + assert_equal Time.utc(2010,11,3,22,49,53), commits[1].author_date + assert_equal 2, commits[0].diffs.size + assert_equal './helloworld.c', commits[0].diffs[0].path + assert_equal './helloworld.c', commits[0].diffs[1].path end protected - def assert_styled_commits(commits, with_diffs=false) - assert_equal 4, commits.size - - assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', commits[0].token - assert_equal 'Robin Luckey', commits[0].committer_name - assert_equal 'robin@ohloh.net', commits[0].committer_email - assert Time.utc(2009,1,20,19,34,53) - commits[0].committer_date < 1 # Don't care about milliseconds - assert_equal "deleted helloworld.c\n", commits[0].message - - if with_diffs - assert_equal 1, commits[0].diffs.size - assert_equal 'D', commits[0].diffs[0].action - assert_equal 'helloworld.c', commits[0].diffs[0].path - else - assert_equal [], commits[0].diffs - end - - assert_equal '468336c6671cbc58237a259d1b7326866afc2817', commits[1].token - assert Time.utc(2009, 1,20,19,34,04) - commits[1].committer_date < 1 - - if with_diffs - assert_equal 2, commits[1].diffs.size - assert_equal 'M', commits[1].diffs[0].action - assert_equal 'helloworld.c', commits[1].diffs[0].path - assert_equal 'A', commits[1].diffs[1].action - assert_equal 'README', commits[1].diffs[1].path - else - assert_equal [], commits[0].diffs - end - end end end From d436d6278e663e73a804d5ef9fd46dafec8a17bb Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 05:32:04 -0700 Subject: [PATCH 04/13] make head tests pass --- lib/scm/adapters/darcs/cat_file.rb | 7 ++++--- lib/scm/adapters/darcs/commits.rb | 14 ++++++------- lib/scm/adapters/darcs/head.rb | 19 +++++++----------- lib/scm/commit.rb | 3 +++ .../darcs/_darcs/hashed_inventory | 11 ++++++++++ test/repositories/darcs/_darcs/index | Bin 0 -> 128 bytes test/repositories/darcs/_darcs/index_invalid | 0 ...52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 | Bin 0 -> 181 bytes ...c03cde5912cf131713f44fa36d870bd9880f70381c | Bin 0 -> 257 bytes ...0fe1f1d19c1432b366cc35f7eb06cd311543b4798e | Bin 0 -> 291 bytes ...250914ee9ad12c03e18f7acc2e30a9de83fde76a1c | Bin 0 -> 293 bytes .../repositories/darcs/_darcs/patches/pending | 2 ++ .../darcs/_darcs/patches/pending.tentative | 2 ++ ...f53384c3fd72d5eb0f37c5a1588f151412b65a9552 | Bin 0 -> 92 bytes ...5ed2289ba958415616d46901035ce3a6809034167f | Bin 0 -> 177 bytes .../darcs/_darcs/tentative_pristine | 1 + test/unit/darcs_cat_file_test.rb | 10 ++++----- test/unit/darcs_head_test.rb | 6 +++--- 18 files changed, 45 insertions(+), 30 deletions(-) create mode 100644 test/repositories/darcs/_darcs/index create mode 100644 test/repositories/darcs/_darcs/index_invalid create mode 100644 test/repositories/darcs/_darcs/inventories/0000000199-b4681395aad3d7e60338fc52abcb28d37dbbb1776305220bd2fc8ca1df5edea1 create mode 100644 test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c create mode 100644 test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e create mode 100644 test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c create mode 100644 test/repositories/darcs/_darcs/patches/pending create mode 100644 test/repositories/darcs/_darcs/patches/pending.tentative create mode 100644 test/repositories/darcs/_darcs/pristine.hashed/47fa61da8145efedd19f2df53384c3fd72d5eb0f37c5a1588f151412b65a9552 create mode 100644 test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f create mode 100644 test/repositories/darcs/_darcs/tentative_pristine diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/scm/adapters/darcs/cat_file.rb index ff771e89..7a01c1a0 100644 --- a/lib/scm/adapters/darcs/cat_file.rb +++ b/lib/scm/adapters/darcs/cat_file.rb @@ -10,9 +10,10 @@ def cat_file_parent(commit, diff) end def cat(revision, path) - out, err = run_with_err("cd '#{url}' && darcs cat -r #{revision} #{escape(path)}") - return nil if err =~ /No such file in rev/ - raise RuntimeError.new(err) unless err.to_s == '' + out, err = run_with_err("cd '#{url}' && darcs show contents -p #{revision} #{escape(path)}") + # darcs show contents gives no error for non-existent paths + return nil #if err =~ /No such file in rev/ + # raise RuntimeError.new(err) unless err.to_s == '' out end diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb index 2a251b8f..9215142f 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/scm/adapters/darcs/commits.rb @@ -27,9 +27,9 @@ def commit_tokens(since=0, up_to='tip') # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit # in memory at a time. def commits(since=0) - log = run("cd '#{self.url}' && darcs log -f -v -r tip:#{since || 0} --style #{Scm::Parsers::DarcsStyledParser.style_path}") - a = Scm::Parsers::DarcsStyledParser.parse(log).reverse - + count = run("cd '#{self.url}' && darcs changes --count") + log = run("cd '#{self.url}' && darcs changes --last #{count-since}") + a = Scm::Parsers::DarcsParser.parse(log).reverse if a.any? && a.first.token == since a[1..-1] else @@ -39,8 +39,8 @@ def commits(since=0) # Returns a single commit, including its diffs def verbose_commit(token) - log = run("cd '#{self.url}' && darcs log -v -r #{token} --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path}") - Scm::Parsers::DarcsStyledParser.parse(log).first + log = run("cd '#{self.url}' && darcs changes -v -p #{token}") + Scm::Parsers::DarcsParser.parse(log).first end # Yields each commit after +since+, including its diffs. @@ -49,7 +49,7 @@ def verbose_commit(token) # Only a single commit is ever held in memory at once. def each_commit(since=0) open_log_file(since) do |io| - Scm::Parsers::DarcsStyledParser.parse(io) do |commit| + Scm::Parsers::DarcsParser.parse(io) do |commit| yield commit if block_given? && commit.token != since end end @@ -70,7 +70,7 @@ def open_log_file(since=0) # As a time optimization, just create an empty file rather than fetch a log we know will be empty. File.open(log_filename, 'w') { } else - run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsStyledParser.verbose_style_path} > #{log_filename}" + run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsParser.verbose_style_path} > #{log_filename}" end File.open(log_filename, 'r') { |io| yield io } ensure diff --git a/lib/scm/adapters/darcs/head.rb b/lib/scm/adapters/darcs/head.rb index 2e777b22..5ef26701 100644 --- a/lib/scm/adapters/darcs/head.rb +++ b/lib/scm/adapters/darcs/head.rb @@ -1,16 +1,7 @@ module Scm::Adapters class DarcsAdapter < AbstractAdapter def head_token - # This only returns first 12 characters. - # How can we make it return the entire hash? - token = run("darcs id -q #{url}").strip - - # Recent versions of Darcs now somtimes append a '+' char to the token. - # I believe this signifies pending changes... but we don't care. - # Strip the trailing '+', if any. - token = token[0..-2] if token[-1..-1] == '+' - - token + string_to_patch_names(run("cd '#{url}' && darcs changes --last 1"))[0] end def head @@ -18,11 +9,15 @@ def head end def parent_tokens(commit) - run("cd '#{url}' && darcs parents -r #{commit.token} --template '{node}\\n'").split("\n") + string_to_patch_names(run("cd '#{url}' && darcs changes --to-patch #{commit.token}"))[1..-1] end def parents(commit) - parent_tokens(commit).collect { |token| verbose_commit(token) } + parent_tokens(commit).map {|token| verbose_commit(token)} + end + + def string_to_patch_names(s) + s.split(/\n/).select {|s| s =~ /^ \* /}.map {|s| s.sub(/^ \* /,'')} end end end diff --git a/lib/scm/commit.rb b/lib/scm/commit.rb index ddb9fa13..55a0a546 100644 --- a/lib/scm/commit.rb +++ b/lib/scm/commit.rb @@ -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 token is the patch name, and it may not be unique. XXX attr_accessor :token # A pointer back to the adapter that contains this commit. diff --git a/test/repositories/darcs/_darcs/hashed_inventory b/test/repositories/darcs/_darcs/hashed_inventory index e69de29b..42dfb941 100644 --- a/test/repositories/darcs/_darcs/hashed_inventory +++ b/test/repositories/darcs/_darcs/hashed_inventory @@ -0,0 +1,11 @@ +pristine:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +[add helloworld.c +Simon Michael **20101103224953 + Ignore-this: 3861470344267bb74c710a8dad01e92a +] +hash: 0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e +[remove helloworld.c +Simon Michael **20101103225525 + Ignore-this: c54c3cf6bebc6a9545effff28e1c785c +] +hash: 0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c diff --git a/test/repositories/darcs/_darcs/index b/test/repositories/darcs/_darcs/index new file mode 100644 index 0000000000000000000000000000000000000000..f14d6e02e39b15eb094cf5dd316e67996336e3db GIT binary patch literal 128 zcmeYW_B3IDf(9tf45S}#IN~(pkBrEy-(OD5%-^Y^zRvMU%IwKLOQz10t_a!@>Y@i# aj70Gvv2iioGE#GL^2_s!a#Hk?frOkr@eO$4PvLs*06?sUzx;*hzCJ5Qzh! z{(V*Pws%gdww2z;Yuvl;#C$E+akHmIS}NUstp7b+#&3Q0os8?}X5#<>5y&||2Qv2f za~t=veY9oWTbd$z2J+rT&Y8V1LYg!wV3}Pq-`2FWw!MWnV%S1O0m>{%(Q#A?IXHq^ ju%hBD=*eY@QG`O}k|Bx`V(^qb&r>mf%T)=<#{d8T1Eo}7 literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c b/test/repositories/darcs/_darcs/inventories/0000000401-3618104098a23625a0ec77c03cde5912cf131713f44fa36d870bd9880f70381c new file mode 100644 index 0000000000000000000000000000000000000000..f992b1b89e133afbdf23920cce0e2c10baead91f GIT binary patch literal 257 zcmV+c0sj6UiwFP!000001D(&kPD3#aK;iv9MdnJaVmpbG3L#boCdP`vaU5=|+eT{n z5pPc`HpIl)&iL)5H8#ob+Q`*0Xv{e9W!INq;T=)nVc zLJTF+%0U^tXSACh=FS0l5N_Z?KnQ{|B@In{*q`6O4?Jks!2)= z(fT#a2Ff|=9}-+k7YJFdAZFB(tQ11P=nDk1a`RoK2D!7SqLG)*f~3J HkpTbzSDShN literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e b/test/repositories/darcs/_darcs/patches/0000000370-0f1c03b7cad1276d35b5230fe1f1d19c1432b366cc35f7eb06cd311543b4798e new file mode 100644 index 0000000000000000000000000000000000000000..6a9429af00c71158b747d7b6429da021e7769aea GIT binary patch literal 291 zcmV+;0o?u{iwFP!0000016`0!PlG@ZhR^P=nAQuh6B5+`SuH;YCxZ`U>L3oF!=(CrLCtO_0`x0ggs(~60#1s=|C%irp6gy zeL$hO*4;2RW}5n%tS5oW0+hse4W6&o7ERbX;-)006<{hbsU8 literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c b/test/repositories/darcs/_darcs/patches/0000000372-afa148a0f1772c96e99321250914ee9ad12c03e18f7acc2e30a9de83fde76a1c new file mode 100644 index 0000000000000000000000000000000000000000..b4a49fb71844189e6a46797d90c3c895d585eb38 GIT binary patch literal 293 zcmV+=0owi_iwFP!00000165E>Ps1<_J(FMIjZ0T8-P$cAYI={!RAs48pVUSTOo!%f|fw;#4ES{eB^*=u9Mr7J8xd8t#uHQa_x1{vD=ZYtgLsz>N5X*x5O_YKtlnSk|q=Y literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f b/test/repositories/darcs/_darcs/pristine.hashed/4cc3cd16f13015913718f15ed2289ba958415616d46901035ce3a6809034167f new file mode 100644 index 0000000000000000000000000000000000000000..cf274f8ab54fa03042855cfb4bd3645156a16f21 GIT binary patch literal 177 zcmV;i08alOiwFP!00000167W@4uU`sMQi6PF4_Pw@&OuKD2$=d*w8G?5H=ZS4ZD~S zxz$lMrl&m}&K|Qr^8i${Ow5$)=29>!p`biV|R##4~OdVqvV(0v3*wfWG fO*4AX;x;;seY*TR+cdh&w)CVItO2=D#sB~S(CtrG literal 0 HcmV?d00001 diff --git a/test/repositories/darcs/_darcs/tentative_pristine b/test/repositories/darcs/_darcs/tentative_pristine new file mode 100644 index 00000000..a72624e3 --- /dev/null +++ b/test/repositories/darcs/_darcs/tentative_pristine @@ -0,0 +1 @@ +pristine:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 67b6213f..845d164c 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -20,15 +20,15 @@ def test_cat_file } EXPECTED - # The file was deleted in revision 468336c6671c. Check that it does not exist now, but existed in parent. - assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => '75532c1e1f1d'), Scm::Diff.new(:path => 'helloworld.c')) - assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => '468336c6671c'), Scm::Diff.new(:path => 'helloworld.c')) + # The file was deleted by the "remove..." patch. Check that it does not exist now, but existed in parent. + assert_equal nil, darcs.cat_file(Scm::Commit.new(:token => 'remove helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file_parent(Scm::Commit.new(:token => 'remove helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) + assert_equal expected, darcs.cat_file(Scm::Commit.new(:token => 'add helloworld.c'), Scm::Diff.new(:path => 'helloworld.c')) end end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename - def test_funny_file_name_chars + def Xtest_funny_file_name_chars Scm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '|file_name (&\'")' diff --git a/test/unit/darcs_head_test.rb b/test/unit/darcs_head_test.rb index 3d1b748d..05891d48 100644 --- a/test/unit/darcs_head_test.rb +++ b/test/unit/darcs_head_test.rb @@ -5,11 +5,11 @@ class DarcsHeadTest < Scm::Test def test_head_and_parents with_darcs_repository('darcs') do |darcs| - assert_equal '75532c1e1f1d', darcs.head_token - assert_equal '75532c1e1f1de55c2271f6fd29d98efbe35397c4', darcs.head.token + assert_equal 'remove helloworld.c', darcs.head_token + assert_equal 'remove helloworld.c', darcs.head.token assert darcs.head.diffs.any? # diffs should be populated - assert_equal '468336c6671cbc58237a259d1b7326866afc2817', darcs.parents(darcs.head).first.token + assert_equal 'add helloworld.c', darcs.parents(darcs.head).first.token assert darcs.parents(darcs.head).first.diffs.any? end end From 4d7269bdd05f9e475e7d4cdfa9b66c0f3724f37b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 13:47:58 -0700 Subject: [PATCH 05/13] make cat_file tests pass --- lib/scm/adapters/darcs/cat_file.rb | 9 +++++---- lib/scm/adapters/darcs/commits.rb | 2 +- test/unit/darcs_cat_file_test.rb | 11 ++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/scm/adapters/darcs/cat_file.rb b/lib/scm/adapters/darcs/cat_file.rb index 7a01c1a0..6157ad8a 100644 --- a/lib/scm/adapters/darcs/cat_file.rb +++ b/lib/scm/adapters/darcs/cat_file.rb @@ -10,10 +10,11 @@ def cat_file_parent(commit, diff) end def cat(revision, path) - out, err = run_with_err("cd '#{url}' && darcs show contents -p #{revision} #{escape(path)}") - # darcs show contents gives no error for non-existent paths - return nil #if err =~ /No such file in rev/ - # raise RuntimeError.new(err) unless err.to_s == '' + out, err = run_with_err("cd '#{url}' && darcs show contents -p '#{revision}' #{escape(path)}") + # show contents gives no error for non-existent paths + #return nil if err =~ /No such file in rev/ + raise RuntimeError.new(err) unless err.to_s == '' + return nil if out == '' out end diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb index 9215142f..eb025844 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/scm/adapters/darcs/commits.rb @@ -39,7 +39,7 @@ def commits(since=0) # Returns a single commit, including its diffs def verbose_commit(token) - log = run("cd '#{self.url}' && darcs changes -v -p #{token}") + log = run("cd '#{self.url}' && darcs changes -v -p '#{token}'") Scm::Parsers::DarcsParser.parse(log).first end diff --git a/test/unit/darcs_cat_file_test.rb b/test/unit/darcs_cat_file_test.rb index 845d164c..714f4beb 100644 --- a/test/unit/darcs_cat_file_test.rb +++ b/test/unit/darcs_cat_file_test.rb @@ -16,7 +16,7 @@ def test_cat_file #include main() { - printf("Hello, World!\\n"); + printf("Hello, World!\\\\n"); } EXPECTED @@ -28,17 +28,18 @@ def test_cat_file end # Ensure that we escape bash-significant characters like ' and & when they appear in the filename - def Xtest_funny_file_name_chars + # NB only works with --reserved-ok, otherwise darcs rejects with "invalid under Windows" + def test_funny_file_name_chars Scm::ScratchDir.new do |dir| # Make a file with a problematic filename funny_name = '|file_name (&\'")' File.open(File.join(dir, funny_name), 'w') { |f| f.write "contents" } - # Add it to an darcs repository - `cd #{dir} && darcs init && darcs add * && darcs commit -m test` + # Add it to a darcs repository + darcs = DarcsAdapter.new(:url => dir).normalize + darcs.run("cd #{dir} && darcs init && darcs add --reserved-ok * && darcs record -a -m test") # Confirm that we can read the file back - darcs = DarcsAdapter.new(:url => dir).normalize assert_equal "contents", darcs.cat_file(darcs.head, Scm::Diff.new(:path => funny_name)) end end From 717c225fc4d85605b8226780bef60cabf12a26ce Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 20:03:18 -0700 Subject: [PATCH 06/13] make commits tests pass --- lib/scm/adapters/darcs/commits.rb | 33 ++++++++++----------- test/unit/darcs_commits_test.rb | 48 ++++++++++--------------------- 2 files changed, 32 insertions(+), 49 deletions(-) diff --git a/lib/scm/adapters/darcs/commits.rb b/lib/scm/adapters/darcs/commits.rb index eb025844..306cb31e 100644 --- a/lib/scm/adapters/darcs/commits.rb +++ b/lib/scm/adapters/darcs/commits.rb @@ -2,16 +2,15 @@ module Scm::Adapters class DarcsAdapter < AbstractAdapter # Return the number of commits in the repository following +since+. - def commit_count(since=0) - commit_tokens(since || 0).size + def commit_count(since=nil) + commit_tokens(since).size end # Return the list of commit tokens following +since+. - def commit_tokens(since=0, up_to='tip') - # We reverse the final result in Ruby, rather than passing the --reverse flag to darcs. - # That's because the -f (follow) flag doesn't behave the same in both directions. - # Basically, we're trying very hard to make this act just like Git. The darcs_rev_list_test checks this. - tokens = run("cd '#{self.url}' && darcs log -f -r #{up_to || 'tip'}:#{since || 0} --template='{node}\\n'").split("\n").reverse + def commit_tokens(since=nil, up_to=nil) + from = since ? " --from-patch #{since}" : "" + to = up_to ? " --to-patch #{up_to}" : "" + tokens = string_to_patch_names(run("cd '#{self.url}' && darcs changes#{from}#{to}")).reverse # Darcs returns everything after *and including* since. # We want to exclude it. @@ -26,10 +25,10 @@ def commit_tokens(since=0, up_to='tip') # Not including the diffs is meant to be a memory savings when we encounter massive repositories. # If you need all commits including diffs, you should use the each_commit() iterator, which only holds one commit # in memory at a time. - def commits(since=0) - count = run("cd '#{self.url}' && darcs changes --count") - log = run("cd '#{self.url}' && darcs changes --last #{count-since}") - a = Scm::Parsers::DarcsParser.parse(log).reverse + def commits(since=nil) + from = since ? " --from-patch #{since}" : "" + log = run("cd '#{self.url}' && darcs changes#{from} --reverse") + a = Scm::Parsers::DarcsParser.parse(log) if a.any? && a.first.token == since a[1..-1] else @@ -47,7 +46,7 @@ def verbose_commit(token) # The log is stored in a temporary file. # This is designed to prevent excessive RAM usage when we encounter a massive repository. # Only a single commit is ever held in memory at once. - def each_commit(since=0) + def each_commit(since=nil) open_log_file(since) do |io| Scm::Parsers::DarcsParser.parse(io) do |commit| yield commit if block_given? && commit.token != since @@ -56,21 +55,23 @@ def each_commit(since=0) end # Not used by Ohloh proper, but handy for debugging and testing - def log(since=0) - run "cd '#{url}' && darcs log -f -v -r tip:#{since}" + def log(since=nil) + from = since ? " --from-patch #{since}" : "" + run "cd '#{url}' && darcs changes -s#{from}" end # Returns a file handle to the log. # In our standard, the log should include everything AFTER +since+. However, darcs doesn't work that way; # it returns everything after and INCLUDING +since+. Therefore, consumers of this file should check for # and reject the duplicate commit. - def open_log_file(since=0) + def open_log_file(since=nil) begin if since == head_token # There are no new commits # As a time optimization, just create an empty file rather than fetch a log we know will be empty. File.open(log_filename, 'w') { } else - run "cd '#{url}' && darcs log --verbose -r #{since || 0}:tip --style #{Scm::Parsers::DarcsParser.verbose_style_path} > #{log_filename}" + from = since ? " --from-patch #{since}" : "" + run "cd '#{url}' && darcs changes --reverse -v#{from} > #{log_filename}" end File.open(log_filename, 'r') { |io| yield io } ensure diff --git a/test/unit/darcs_commits_test.rb b/test/unit/darcs_commits_test.rb index f65418e2..85b3e9c9 100644 --- a/test/unit/darcs_commits_test.rb +++ b/test/unit/darcs_commits_test.rb @@ -5,32 +5,18 @@ class DarcsCommitsTest < Scm::Test def test_commit with_darcs_repository('darcs') do |darcs| - assert_equal 4, darcs.commit_count - assert_equal 2, darcs.commit_count('b14fa4692f949940bd1e28da6fb4617de2615484') - assert_equal 0, darcs.commit_count('75532c1e1f1de55c2271f6fd29d98efbe35397c4') - - assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', - 'b14fa4692f949940bd1e28da6fb4617de2615484', - '468336c6671cbc58237a259d1b7326866afc2817', - '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commit_tokens - - assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], - darcs.commit_tokens('468336c6671cbc58237a259d1b7326866afc2817') - - assert_equal [], darcs.commit_tokens('75532c1e1f1de55c2271f6fd29d98efbe35397c4') - - assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', - 'b14fa4692f949940bd1e28da6fb4617de2615484', - '468336c6671cbc58237a259d1b7326866afc2817', - '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], darcs.commits.collect { |c| c.token } - - assert_equal ['75532c1e1f1de55c2271f6fd29d98efbe35397c4'], - darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').collect { |c| c.token } - + assert_equal 2, darcs.commit_count + assert_equal 1, darcs.commit_count('add helloworld.c') + assert_equal 0, darcs.commit_count('remove helloworld.c') + assert_equal ['add helloworld.c', 'remove helloworld.c'], darcs.commit_tokens + assert_equal ['remove helloworld.c'], darcs.commit_tokens('add helloworld.c') + assert_equal [], darcs.commit_tokens('remove helloworld.c') + assert_equal ['add helloworld.c', + 'remove helloworld.c'], darcs.commits.collect { |c| c.token } + assert_equal ['remove helloworld.c'], darcs.commits('add helloworld.c').collect { |c| c.token } # Check that the diffs are not populated - assert_equal [], darcs.commits('468336c6671cbc58237a259d1b7326866afc2817').first.diffs - - assert_equal [], darcs.commits('75532c1e1f1de55c2271f6fd29d98efbe35397c4') + assert_equal [], darcs.commits('add helloworld.c').first.diffs + assert_equal [], darcs.commits('remove helloworld.c') end end @@ -38,10 +24,8 @@ def test_each_commit commits = [] with_darcs_repository('darcs') do |darcs| darcs.each_commit do |c| - assert c.token.length == 40 - assert c.committer_name - assert c.committer_date.is_a?(Time) - assert c.message.length > 0 + assert c.author_name + assert c.author_date.is_a?(Time) assert c.diffs.any? # Check that the diffs are populated c.diffs.each do |d| @@ -53,10 +37,8 @@ def test_each_commit assert !FileTest.exist?(darcs.log_filename) # Make sure we cleaned up after ourselves # Verify that we got the commits in forward chronological order - assert_equal ['01101d8ef3cea7da9ac6e9a226d645f4418f05c9', - 'b14fa4692f949940bd1e28da6fb4617de2615484', - '468336c6671cbc58237a259d1b7326866afc2817', - '75532c1e1f1de55c2271f6fd29d98efbe35397c4'], commits.collect { |c| c.token } + assert_equal ['add helloworld.c', + 'remove helloworld.c'], commits.map {|c| c.token} end end end From 06fb6c488878cf99bb4fe4646e6eddc502672a94 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 20:15:38 -0700 Subject: [PATCH 07/13] make misc tests pass --- lib/scm/adapters/darcs/misc.rb | 9 ++++----- test/unit/darcs_misc_test.rb | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/scm/adapters/darcs/misc.rb b/lib/scm/adapters/darcs/misc.rb index 63da9052..aaabb31d 100644 --- a/lib/scm/adapters/darcs/misc.rb +++ b/lib/scm/adapters/darcs/misc.rb @@ -10,13 +10,12 @@ def exist? end def ls_tree(token) - run("cd '#{path}' && darcs manifest -r #{token}").split("\n") + run("cd '#{path}' && darcs show files -p '#{token}'").split("\n") end - def export(dest_dir, token='tip') - run("cd '#{path}' && darcs archive -r #{token} '#{dest_dir}'") - # Darcs leaves a little cookie crumb in the export directory. Remove it. - File.delete(File.join(dest_dir, '.darcs_archival.txt')) if File.exist?(File.join(dest_dir, '.darcs_archival.txt')) + def export(dest_dir, token=nil) + p = token ? " -p '#{token}'" : "" + run("cd '#{path}' && darcs dist#{p} && mv darcs.tar.gz '#{dest_dir}'") end end end diff --git a/test/unit/darcs_misc_test.rb b/test/unit/darcs_misc_test.rb index a68c7ad2..231b03a2 100644 --- a/test/unit/darcs_misc_test.rb +++ b/test/unit/darcs_misc_test.rb @@ -14,15 +14,15 @@ def test_exist def test_ls_tree with_darcs_repository('darcs') do |darcs| - assert_equal ['README','makefile'], darcs.ls_tree(darcs.head_token).sort + assert_equal ['.','./helloworld.c'], darcs.ls_tree('add helloworld.c').sort end end def test_export with_darcs_repository('darcs') do |darcs| Scm::ScratchDir.new do |dir| - darcs.export(dir) - assert_equal ['.', '..', 'README', 'makefile'], Dir.entries(dir).sort + darcs.export(dir, 'add helloworld.c') + assert_equal ['.', '..', 'darcs.tar.gz'], Dir.entries(dir).sort end end end From 40bb7fc99357b80c153f76d87da272133625a6d4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 21:50:10 -0700 Subject: [PATCH 08/13] make patch tests pass --- lib/scm/adapters/darcs/patch.rb | 4 +--- test/data/darcs_patch.diff | 16 ++++++++++++++++ test/unit/darcs_patch_test.rb | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 test/data/darcs_patch.diff diff --git a/lib/scm/adapters/darcs/patch.rb b/lib/scm/adapters/darcs/patch.rb index 5fe004cc..ec3a624e 100644 --- a/lib/scm/adapters/darcs/patch.rb +++ b/lib/scm/adapters/darcs/patch.rb @@ -1,9 +1,7 @@ module Scm::Adapters class DarcsAdapter < AbstractAdapter def patch_for_commit(commit) - parent_tokens(commit).map {|token| - run("darcs -R '#{url}' diff --git -r#{token} -r#{commit.token}") - }.join("\n") + run("cd '#{url}' && darcs changes -p'#{commit.token}' -v") end end end diff --git a/test/data/darcs_patch.diff b/test/data/darcs_patch.diff new file mode 100644 index 00000000..f5316e68 --- /dev/null +++ b/test/data/darcs_patch.diff @@ -0,0 +1,16 @@ +Wed Nov 3 15:49:53 PDT 2010 Simon Michael + * add helloworld.c + addfile ./helloworld.c + hunk ./helloworld.c 1 + +/* Hello, World! */ + + + +/* + + * This file is not covered by any license, especially not + + * the GNU General Public License (GPL). Have fun! + + */ + + + +#include + +main() + +{ + + printf("Hello, World!\\n"); + +} diff --git a/test/unit/darcs_patch_test.rb b/test/unit/darcs_patch_test.rb index 65d517ce..578ed3fd 100644 --- a/test/unit/darcs_patch_test.rb +++ b/test/unit/darcs_patch_test.rb @@ -4,7 +4,7 @@ module Scm::Adapters class DarcsPatchTest < Scm::Test def test_patch_for_commit with_darcs_repository('darcs') do |repo| - commit = repo.verbose_commit(1) + commit = repo.verbose_commit('add helloworld.c') data = File.read(File.join(DATA_DIR, 'darcs_patch.diff')) assert_equal data, repo.patch_for_commit(commit) end From d6cd6ba87a845cd8cdfd2b5632d4b5be3d5c93e4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 21:55:48 -0700 Subject: [PATCH 09/13] make pull test pass --- lib/scm/adapters/darcs/pull.rb | 5 +++-- test/unit/darcs_pull_test.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/scm/adapters/darcs/pull.rb index cecfbabf..7aa6c01a 100644 --- a/lib/scm/adapters/darcs/pull.rb +++ b/lib/scm/adapters/darcs/pull.rb @@ -10,9 +10,10 @@ def pull(from, &block) unless self.exist? run "mkdir -p '#{self.url}'" run "rm -rf '#{self.url}'" - run "darcs clone -U '#{from.url}' '#{self.url}'" + run "darcs get '#{from.url}' '#{self.url}'" else - run "cd '#{self.url}' && darcs revert --all && darcs pull -u -y '#{from.url}'" + # might also need to unpull for an exact copy + run "cd '#{self.url}' && darcs revert --all && darcs pull -a '#{from.url}'" end yield(1,1) if block_given? # Progress bar callback diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb index fad9251b..70effdc3 100644 --- a/test/unit/darcs_pull_test.rb +++ b/test/unit/darcs_pull_test.rb @@ -16,7 +16,7 @@ def test_pull assert_equal src.log, dest.log # Commit some new code on the original and pull again - src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" assert_equal "test\n", src.commits.last.message dest.pull(src) From d3133d8c49288ab0098321e55d3aba7b97188c67 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 22:01:35 -0700 Subject: [PATCH 10/13] make push tests pass --- lib/scm/adapters/darcs/push.rb | 5 ++--- test/unit/darcs_push_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/scm/adapters/darcs/push.rb b/lib/scm/adapters/darcs/push.rb index 721609cf..1988a4d7 100644 --- a/lib/scm/adapters/darcs/push.rb +++ b/lib/scm/adapters/darcs/push.rb @@ -12,11 +12,10 @@ def push(to, &block) # Create a new repo on the same local machine. Just use existing pull code in reverse. to.pull(self) else - run "ssh #{to.hostname} 'mkdir -p #{to.path}'" - run "scp -rpqB #{darcs_path} #{to.hostname}:#{to.path}" + run "cd '#{self.url}' && darcs put #{to.hostname}:#{to.path}" end else - run "cd '#{self.url}' && darcs push -f -y '#{to.url}'" + run "cd '#{self.url}' && darcs push -a '#{to.url}'" end yield(1,1) if block_given? # Progress bar callback diff --git a/test/unit/darcs_push_test.rb b/test/unit/darcs_push_test.rb index e72bfef6..843c8c06 100644 --- a/test/unit/darcs_push_test.rb +++ b/test/unit/darcs_push_test.rb @@ -46,8 +46,8 @@ def test_push assert_equal src.log, dest.log # Commit some new code on the original and pull again - src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs commit -u test -m test" - assert_equal "test\n", src.commits.last.message + src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" + assert_equal "test", src.commits.last.token src.push(dest) assert_equal src.log, dest.log From da47e7c1005aec279cefeba6eb30bf34b5666ffd Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 22:22:51 -0700 Subject: [PATCH 11/13] make rev_list tests pass --- test/repositories/darcs_walk/A | 0 test/repositories/darcs_walk/B | 0 test/repositories/darcs_walk/C | 0 test/repositories/darcs_walk/D | 0 test/repositories/darcs_walk/E | 0 .../darcs_walk/_darcs/.gitattributes | 1 + test/repositories/darcs_walk/_darcs/format | 2 + .../darcs_walk/_darcs/hashed_inventory | 26 ++++ test/repositories/darcs_walk/_darcs/index | Bin 0 -> 284 bytes .../darcs_walk/_darcs/index_invalid | 0 ...ddba010c991016fa3380d0849fb4927ce7d0c329c1 | Bin 0 -> 171 bytes ...e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c | Bin 0 -> 245 bytes ...62809cfc1f579d4f0176f3cdc20ca3efc39006d766 | Bin 0 -> 309 bytes ...a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 | Bin 0 -> 376 bytes ...b7b68c41fe659b7aa8cebacce52507998aac85fdb2 | Bin 0 -> 440 bytes ...d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 | Bin 0 -> 125 bytes ...0839eb238e27372a3edd550e0097491168ab71442e | Bin 0 -> 128 bytes ...41d00b5d43da90be1d5d55540f61d22420172ea0fa | Bin 0 -> 128 bytes ...975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 | Bin 0 -> 127 bytes ...1a64605d9c72fdbef99dbeedb503c66548052692e0 | Bin 0 -> 127 bytes .../darcs_walk/_darcs/patches/pending | 2 + .../_darcs/patches/pending.tentative | 2 + .../darcs_walk/_darcs/prefs/binaries | 30 +++++ .../darcs_walk/_darcs/prefs/boring | 113 ++++++++++++++++++ .../repositories/darcs_walk/_darcs/prefs/motd | 0 ...24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 | Bin 0 -> 90 bytes ...0b3cc263477c4403af180d2113e0f954fd3869dbda | Bin 0 -> 94 bytes ...69d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 | Bin 0 -> 97 bytes ...b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c | Bin 0 -> 81 bytes ...f9dd26fcb11b14378071e255da2e62c043020d277b | Bin 0 -> 100 bytes ...c8996fb92427ae41e4649b934ca495991b7852b855 | Bin 0 -> 20 bytes .../darcs_walk/_darcs/tentative_pristine | 1 + test/unit/darcs_rev_list_test.rb | 58 ++------- 33 files changed, 187 insertions(+), 48 deletions(-) create mode 100644 test/repositories/darcs_walk/A create mode 100644 test/repositories/darcs_walk/B create mode 100644 test/repositories/darcs_walk/C create mode 100644 test/repositories/darcs_walk/D create mode 100644 test/repositories/darcs_walk/E create mode 100644 test/repositories/darcs_walk/_darcs/.gitattributes create mode 100644 test/repositories/darcs_walk/_darcs/format create mode 100644 test/repositories/darcs_walk/_darcs/hashed_inventory create mode 100644 test/repositories/darcs_walk/_darcs/index create mode 100644 test/repositories/darcs_walk/_darcs/index_invalid create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000368-79230da93a2f69dadf7df4e422c39c3ea9b2a88a4f25efa7378704a9e4080b4c create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 create mode 100644 test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 create mode 100644 test/repositories/darcs_walk/_darcs/patches/0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 create mode 100644 test/repositories/darcs_walk/_darcs/patches/pending create mode 100644 test/repositories/darcs_walk/_darcs/patches/pending.tentative create mode 100644 test/repositories/darcs_walk/_darcs/prefs/binaries create mode 100644 test/repositories/darcs_walk/_darcs/prefs/boring create mode 100644 test/repositories/darcs_walk/_darcs/prefs/motd create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b create mode 100644 test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 create mode 100644 test/repositories/darcs_walk/_darcs/tentative_pristine diff --git a/test/repositories/darcs_walk/A b/test/repositories/darcs_walk/A new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/B b/test/repositories/darcs_walk/B new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/C b/test/repositories/darcs_walk/C new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/D b/test/repositories/darcs_walk/D new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/E b/test/repositories/darcs_walk/E new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/_darcs/.gitattributes b/test/repositories/darcs_walk/_darcs/.gitattributes new file mode 100644 index 00000000..bd2de00c --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/.gitattributes @@ -0,0 +1 @@ +* -text -whitespace diff --git a/test/repositories/darcs_walk/_darcs/format b/test/repositories/darcs_walk/_darcs/format new file mode 100644 index 00000000..58f777b5 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/format @@ -0,0 +1,2 @@ +hashed +darcs-2 diff --git a/test/repositories/darcs_walk/_darcs/hashed_inventory b/test/repositories/darcs_walk/_darcs/hashed_inventory new file mode 100644 index 00000000..7f73a4b4 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/hashed_inventory @@ -0,0 +1,26 @@ +pristine:dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b +[A +Simon Michael **20101105050558 + Ignore-this: 5bd1c52f9c7bd77d62ea0054db2d270a +] +hash: 0000000112-98b82f6897acae4e8769521a64605d9c72fdbef99dbeedb503c66548052692e0 +[B +Simon Michael **20101105050612 + Ignore-this: 3e8e6c2038387eb0dbabf3264560312f +] +hash: 0000000112-05450bae2857f79ad27b060839eb238e27372a3edd550e0097491168ab71442e +[C +Simon Michael **20101105050616 + Ignore-this: dbcc2fcc273925ffc86fe213e309a8f +] +hash: 0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 +[D +Simon Michael **20101105050618 + Ignore-this: ab9f04d0e28d346d14ca5f5375da7e0b +] +hash: 0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa +[E +Simon Michael **20101105050621 + Ignore-this: 12c991491d6b5693d3b90622958a985c +] +hash: 0000000112-70c0bf5995cfdf8fbb176f975d8f9b83e0ec3b12df56cdb93cf0bc130c58ce96 diff --git a/test/repositories/darcs_walk/_darcs/index b/test/repositories/darcs_walk/_darcs/index new file mode 100644 index 0000000000000000000000000000000000000000..a14b024022f365a032e01a4cf2ded2fedd657766 GIT binary patch literal 284 zcmeYW_B3ID0vSdKgBeJj_BG`XNV%B(f98bDn_pKP5MAkLacwWx?YRFJx9#%g`{AMo z)5XAWYQkk75D%p9@rEN#Gycek%=-Q1#LWDiD(dSTpQOy5?6YL*OzDcC9ieV62z@6= W(dUfNcZ3vuP6&M)NYUrWzyJWg6J!Vg literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/index_invalid b/test/repositories/darcs_walk/_darcs/index_invalid new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 b/test/repositories/darcs_walk/_darcs/inventories/0000000184-92eef20b519f4ccfe4990dddba010c991016fa3380d0849fb4927ce7d0c329c1 new file mode 100644 index 0000000000000000000000000000000000000000..084626c2c372c16ba9303af7ccc116483422cb7c GIT binary patch literal 171 zcmV;c095}UiwFP!0000010{^T3c@fHM)y2LW}$L(&AmyAh>i|Uj^dDCTWK4xI{5as z_#HTKmhW~F*M6*%y!5g2d64^g&EvCv%V*feIvzF~1O-X~t&kP+{Fv%1H}9^WTS+0Q zNLXAnAsLexvj-rZ0wy%z#a)Wd&s{6wKc%p7Hdrido$=9UovmRwb!{rNlqeA z@b+9phiI6QMw({y&HiC{nNQ1ke4gu6{5alTuJ!(H`Rbp?o4TCtHXDQhApl)XI*d<; z^YZT7k7>T_MzR(vVb4{pi8Mwp0F;_xLxD29j>A+g({6+xg@D_vrr24tlv+Hw3TMJl zI5ALLr?5Bkp7WaCj38EKN(zLW(P7v>{*Rjj{^E|V&J`hQRB?l5#d<_e#1I4aKe^Xm v1XdiCq)RUALjwkl*$tyQN)#;7TO$Go$dYmhti>dxgg$%&V6({`Z~*`S#jtN6 literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 b/test/repositories/darcs_walk/_darcs/inventories/0000000551-cdd7b8961aeede9a40431b62809cfc1f579d4f0176f3cdc20ca3efc39006d766 new file mode 100644 index 0000000000000000000000000000000000000000..b25438ba6742de2c1b8e73c083034d089ff998fe GIT binary patch literal 309 zcmV-50m}X#iwFP!000001C^1xN`yfSh5P?0{#sZ`GLy@Qh?mO3%5t%onPl7*b-~rb zw|B%&Y)nWX&EY#a+pFb%|8jU;@AiFH<9R(lexH|5htKixeA*8$7bhnK2#CPn&9iVDEl8#yV|+;cv7)ut$YCml z39DoQ_9;cfTZ~fX4sQ&pi*Pnzl0pH?_WFO^g7k|!g@ts2WXUudc&lwBlFR}LY5d7O zeKE8eWUNC=oemoaSSrydS&$~Bn!=qK0-$Ivh+?%V=1j3{Z~n_Izqq~iPGgRyLOez{ z89|sLL8jwo!)oF HCjtNfpu3Vw literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 b/test/repositories/darcs_walk/_darcs/inventories/0000000735-c231534c3e7fc9781e71a1a53dee4b0ca052c62ecc6a54a587c4fa15cf756e19 new file mode 100644 index 0000000000000000000000000000000000000000..7ff9ebc14dbffd32ac2b78f061d2f70680eb7378 GIT binary patch literal 376 zcmV-;0f+t{iwFP!000001C^4$kJB*>#rN-D(fOnz+llSugb=?L1}4Ue!HykTba#~~ z4E*<`VmozdqFBoE^m*_3@L~IQdOpAGzMjU>@@e<>a{a#ldHy^9JiQs`=XVbe1PF-0 z*UN3&efjZn{+0XR$J6C;#~wJCW*_RI8bWCRT*E0y!M5+a?P!|+L?&XWYEvd0i?Y0~`2(;4Esk9_5N>(z084{pt?TFIM6>Fv34xjGjmRH>2W6)er zODCRlG?__QvOu?X3mf;XIQJ$?%@jq#kQQ^`w6@A~pr)%l4o;{z>j>0_3N=)?r3a^?zC WFo^2n(CZRT+x`Ip{EHyp0ssI3c)nEt literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 b/test/repositories/darcs_walk/_darcs/inventories/0000000919-8b7174beef8c29ca14ae3bb7b68c41fe659b7aa8cebacce52507998aac85fdb2 new file mode 100644 index 0000000000000000000000000000000000000000..76e9f8127e676739b1b6385e3c564a10152e52c4 GIT binary patch literal 440 zcmV;p0Z0BHiwFP!000001C^3Ji<~hGg!}hbY<+M+k}cUfj*!nHMXHob3d@qR8}4o) zmlXN;@se)YW^HURnBkcj?cZ z_`JDqyDvXpPQT**_u=^Zuw!$aOsTV(x8_1I0Jyr5Q-iU6-))ESdU)8u|Ak2R+O1Pc z*EZ&e8oh}!;gBl8zN9GKB30KNZVY9LaP7b(N&(yc!)@GxbirMshfIRfOK)M|HY^KC zWr2c}SGkuj1{*=0TQ(ibp@Bdz8b+lDwbE#maA$@9&{h>u`mlzzQf&K=w{pt`x7(bQ z>$IZ8nX^j4#0S!1cFfUNc?Q(mDvzB5DrTLItz(1gD-wW- z+y2w7*q386Omhjsiq10cqV7A zkb+KB7e_k}VUBJ8`9^NS3vQ&TimOEzW6|QpbbTY`KD6_^%H3dsC9CpG&z@%3Bz1Z1 isn$zC%wkBMEYp{@nP3wOOzv~J-2MSwbQ7DG0{{R6Xx^v* literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 b/test/repositories/darcs_walk/_darcs/patches/0000000111-83b5986061a7166da12083d1fa8d1cb02877bd5d5e041f4cd1781704dabf00c1 new file mode 100644 index 0000000000000000000000000000000000000000..31b4b2e99312833366361bb3115c31787b6b8087 GIT binary patch literal 125 zcmb2|=3oE==I*j*T<6Z5Js{a|_(&ys0TekG@@bL2R z^7=GhICG)L`=GI{{(g{a|_(&ys0TekG@@bL2R z^7=GhICG)H`=GI{{(gXG^X!ciXO3Js gbKu4Wjb80AMMG6pU1Rl7NB{er47MzGi3LE50X7Ra7XSbN literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa b/test/repositories/darcs_walk/_darcs/patches/0000000112-16163f0db6fb931e965e2e41d00b5d43da90be1d5d55540f61d22420172ea0fa new file mode 100644 index 0000000000000000000000000000000000000000..5191b93cf85fe5f3b5074f544cc9fae2fb97b04d GIT binary patch literal 128 zcmb2|=3oE==I*kGT<6Z5Js{a|_(&ys0TekG@@bL2R z^7=GhICG)N`=GI{{(gU&r|TtOwLG5%~7x^25}v-@+;FybM%t)bM3UW zj0_A73=IuTfzZszkW0ZcJukl~RktJ~v)D?(&?wo`($K`xFvTp%)XdU2#W=|lsLaUH h)FRQ+!ZevHRv|GZB`q^2RY6bR6#y{a|_(&ys0TekG@@bL2R z^7=SlxYFc((AZXgzeebG73Ix0ybhXZ9yPdmMdPf|O&iUlcWjQH(J;Mu;J_6X)sq@W fPux+Ms2!$gsH&=KtRCv0-(JBl{PiF literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/patches/pending b/test/repositories/darcs_walk/_darcs/patches/pending new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/patches/pending @@ -0,0 +1,2 @@ +{ +} diff --git a/test/repositories/darcs_walk/_darcs/patches/pending.tentative b/test/repositories/darcs_walk/_darcs/patches/pending.tentative new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/patches/pending.tentative @@ -0,0 +1,2 @@ +{ +} diff --git a/test/repositories/darcs_walk/_darcs/prefs/binaries b/test/repositories/darcs_walk/_darcs/prefs/binaries new file mode 100644 index 00000000..ac206487 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/prefs/binaries @@ -0,0 +1,30 @@ +# This file contains a list of extended regular expressions, one per +# line. A file path matching any of these expressions is assumed to +# contain binary data (not text). The entries in ~/.darcs/binaries (if +# it exists) supplement those in this file. +# +# Blank lines, and lines beginning with an octothorpe (#) are ignored. +# See regex(7) for a description of extended regular expressions. +\.(a|A)$ +\.(bmp|BMP)$ +\.(bz2|BZ2)$ +\.(doc|DOC)$ +\.(elc|ELC)$ +\.(exe|EXE)$ +\.(gif|GIF)$ +\.(gz|GZ)$ +\.(iso|ISO)$ +\.(jar|JAR)$ +\.(jpe?g|JPE?G)$ +\.(mng|MNG)$ +\.(mpe?g|MPE?G)$ +\.(p[nbgp]m|P[NBGP]M)$ +\.(pdf|PDF)$ +\.(png|PNG)$ +\.(pyc|PYC)$ +\.(so|SO)$ +\.(tar|TAR)$ +\.(tgz|TGZ)$ +\.(tiff?|TIFF?)$ +\.(z|Z)$ +\.(zip|ZIP)$ diff --git a/test/repositories/darcs_walk/_darcs/prefs/boring b/test/repositories/darcs_walk/_darcs/prefs/boring new file mode 100644 index 00000000..5969e686 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/prefs/boring @@ -0,0 +1,113 @@ +# Boring file regexps: + +### compiler and interpreter intermediate files +# haskell (ghc) interfaces +\.hi$ +\.hi-boot$ +\.o-boot$ +# object files +\.o$ +\.o\.cmd$ +# profiling haskell +\.p_hi$ +\.p_o$ +# haskell program coverage resp. profiling info +\.tix$ +\.prof$ +# fortran module files +\.mod$ +# linux kernel +\.ko\.cmd$ +\.mod\.c$ +(^|/)\.tmp_versions($|/) +# *.ko files aren't boring by default because they might +# be Korean translations rather than kernel modules +# \.ko$ +# python, emacs, java byte code +\.py[co]$ +\.elc$ +\.class$ +# objects and libraries; lo and la are libtool things +\.(obj|a|exe|so|lo|la)$ +# compiled zsh configuration files +\.zwc$ +# Common LISP output files for CLISP and CMUCL +\.(fas|fasl|sparcf|x86f)$ + +### build and packaging systems +# cabal intermediates +\.installed-pkg-config +\.setup-config +# standard cabal build dir, might not be boring for everybody +# ^dist(/|$) +# autotools +(^|/)autom4te\.cache($|/) +(^|/)config\.(log|status)$ +# microsoft web expression, visual studio metadata directories +\_vti_cnf$ +\_vti_pvt$ +# gentoo tools +\.revdep-rebuild.* +# generated dependencies +^\.depend$ + +### version control systems +# cvs +(^|/)CVS($|/) +\.cvsignore$ +# cvs, emacs locks +^\.# +# rcs +(^|/)RCS($|/) +,v$ +# subversion +(^|/)\.svn($|/) +# mercurial +(^|/)\.hg($|/) +# git +(^|/)\.git($|/) +# bzr +\.bzr$ +# sccs +(^|/)SCCS($|/) +# darcs +(^|/)_darcs($|/) +(^|/)\.darcsrepo($|/) +^\.darcs-temp-mail$ +-darcs-backup[[:digit:]]+$ +# gnu arch +(^|/)(\+|,) +(^|/)vssver\.scc$ +\.swp$ +(^|/)MT($|/) +(^|/)\{arch\}($|/) +(^|/).arch-ids($|/) +# bitkeeper +(^|/)BitKeeper($|/) +(^|/)ChangeSet($|/) + +### miscellaneous +# backup files +~$ +\.bak$ +\.BAK$ +# patch originals and rejects +\.orig$ +\.rej$ +# X server +\..serverauth.* +# image spam +\# +(^|/)Thumbs\.db$ +# vi, emacs tags +(^|/)(tags|TAGS)$ +#(^|/)\.[^/] +# core dumps +(^|/|\.)core$ +# partial broken files (KIO copy operations) +\.part$ +# waf files, see http://code.google.com/p/waf/ +(^|/)\.waf-[[:digit:].]+-[[:digit:]]+($|/) +(^|/)\.lock-wscript$ +# mac os finder +(^|/)\.DS_Store$ diff --git a/test/repositories/darcs_walk/_darcs/prefs/motd b/test/repositories/darcs_walk/_darcs/prefs/motd new file mode 100644 index 00000000..e69de29b diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 b/test/repositories/darcs_walk/_darcs/pristine.hashed/33bbdb6496663754302d2c24df905a718c347fc55e0a9e3e84a4cd1cb90afc05 new file mode 100644 index 0000000000000000000000000000000000000000..705f11392fc7b9a1810d188671daac5860b6d7e7 GIT binary patch literal 90 zcmb2|=3oE==A~yg@-`UoupF?vEb!UyPss+)oSQ;Izps0&Ilx;`YG1i!^V4_H3{IVm;CLI^W}W^b`sD?04fzEi~s-t literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda b/test/repositories/darcs_walk/_darcs/pristine.hashed/c209c6bd4d6d35c742a5b30b3cc263477c4403af180d2113e0f954fd3869dbda new file mode 100644 index 0000000000000000000000000000000000000000..0726896b0523dfc58dddcc0a73d29b1ef4d8e057 GIT binary patch literal 94 zcmb2|=3oE==Cx-w@-`UoupF?vEb!U$Psst5jj7%qZ{n3VGTmXAeqA>DruUj{77ACs xyb_(0$r-+Bd7wfvTh@Z+W1@Bk-NK}A9oe#VQhv!F(Yf~*v&RH|+IJghEC9#5C-DFP literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 b/test/repositories/darcs_walk/_darcs/pristine.hashed/cb4d350f5064d16bff999069d9f5a8c015a94138d6bd0adb5effd1b6ba4b0ef8 new file mode 100644 index 0000000000000000000000000000000000000000..19c12c5edd6eebb8e7ffdd68e5a320c91268434c GIT binary patch literal 97 zcmb2|=3oE==Cx-|@-`UoupFpgb@1e~h&q|xBhz#hFaDSA6ieWmu_G`3^0YlKk{q6K z2n!dqvE@wAog%r@zuiJ=h0X@fu%Ipdvr4bbder-E|Dwn1U;L4?eLksuq6#Ae0{~u{ BDh>bu literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c b/test/repositories/darcs_walk/_darcs/pristine.hashed/d35ab98b6586baf33a7ee0b09b85ddcd3543b649d016df0a7c2ca5d0b22fea7c new file mode 100644 index 0000000000000000000000000000000000000000..e5a5fa87d36f6be14b66250fa679decfea2d031e GIT binary patch literal 81 zcmb2|=3oE=X4Zonc@G$HupGE|ndQ%onq56f0v;1L)z95sw}01h literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b b/test/repositories/darcs_walk/_darcs/pristine.hashed/dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b new file mode 100644 index 0000000000000000000000000000000000000000..53d9e6f8f8c8ad55ad627bcfbbeb8ff31a0fa8f3 GIT binary patch literal 100 zcmb2|=3oE==Cx-|@-`UoupFpgrFiaHL|shlkuV*_i~prN#ZHJA)Y&KVMoV~#Gq;@8 zjbhoo`mj`FjOK(}?2jB6r*d99=;O9lw|m>1=K70v+E!_<&)2;8CBN5Z23un;BLf2f D7GfrZ literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 b/test/repositories/darcs_walk/_darcs/pristine.hashed/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 new file mode 100644 index 0000000000000000000000000000000000000000..229151a5a27ab0cc4661f529cc0eda27e3c03e10 GIT binary patch literal 20 Rcmb2|=3oE=W@ZQtBmoVe0J#7F literal 0 HcmV?d00001 diff --git a/test/repositories/darcs_walk/_darcs/tentative_pristine b/test/repositories/darcs_walk/_darcs/tentative_pristine new file mode 100644 index 00000000..0411d1a5 --- /dev/null +++ b/test/repositories/darcs_walk/_darcs/tentative_pristine @@ -0,0 +1 @@ +pristine:dfd28add8431fa83db5053f9dd26fcb11b14378071e255da2e62c043020d277b diff --git a/test/unit/darcs_rev_list_test.rb b/test/unit/darcs_rev_list_test.rb index c7cb83b8..849c42f3 100644 --- a/test/unit/darcs_rev_list_test.rb +++ b/test/unit/darcs_rev_list_test.rb @@ -3,61 +3,23 @@ module Scm::Adapters # Repository darcs_walk has the following structure: # - # G -> H -> I - # / \ \ - # A -> B -> C -> D -> tip + # A -> B -> C -> D -> E # class DarcsRevListTest < Scm::Test def test_rev_list with_darcs_repository('darcs_walk') do |darcs| # Full history to a commit - assert_equal [:A], rev_list_helper(darcs, nil, :A) - assert_equal [:A, :B], rev_list_helper(darcs, nil, :B) - assert_equal [:A, :B, :G, :H, :C], rev_list_helper(darcs, nil, :C) - assert_equal [:A, :B, :G, :H, :C, :I, :D], rev_list_helper(darcs, nil, :D) - assert_equal [:A, :G], rev_list_helper(darcs, nil, :G) - assert_equal [:A, :G, :H], rev_list_helper(darcs, nil, :H) - assert_equal [:A, :G, :H, :I], rev_list_helper(darcs, nil, :I) - - # Limited history from one commit to another - assert_equal [], rev_list_helper(darcs, :A, :A) - assert_equal [:B], rev_list_helper(darcs, :A, :B) - assert_equal [:B, :G, :H, :C], rev_list_helper(darcs, :A, :C) - assert_equal [:B, :G, :H, :C, :I, :D], rev_list_helper(darcs, :A, :D) - assert_equal [:G, :H, :C, :I, :D], rev_list_helper(darcs, :B, :D) - assert_equal [:I, :D], rev_list_helper(darcs, :C, :D) + assert_equal ["A"], darcs.commit_tokens(nil, "A") + assert_equal ["A","B"], darcs.commit_tokens(nil, "B") + assert_equal ["A","B","C","D","E"], darcs.commit_tokens(nil, "E") + assert_equal ["A","B","C","D","E"], darcs.commit_tokens(nil, nil) + + # # Limited history from one commit to another + assert_equal [], darcs.commit_tokens("A", "A") + assert_equal ["B"], darcs.commit_tokens("A", "B") + assert_equal ["B","C","D"], darcs.commit_tokens("A", "D") end end - - protected - - def rev_list_helper(darcs, from, to) - to_labels(darcs.commit_tokens(from_label(from), from_label(to))) - end - - def commit_labels - { '4bfbf836feeebb236492199fbb0d1474e26f69d9' => :A, - '23edb79d0d06c8c315d8b9e7456098823335377d' => :B, - '7e33b9fde56a6e3576753868d08fa143e4e8a9cf' => :C, - '8daa1aefa228d3ee5f9a0f685d696826e88266fb' => :D, - 'e43cf1bb4b80d8ae70a695ec070ce017fdc529f3' => :G, - 'dca215d8a3e4dd3e472379932f1dd9c909230331' => :H, - '3a1495175e40b1c983441d6a8e8e627d2bd672b6' => :I - } - end - - def to_label(sha1) - commit_labels[sha1.to_s] - end - - def to_labels(sha1s) - sha1s.collect { |sha1| to_label(sha1) } - end - - def from_label(l) - commit_labels.each_pair { |k,v| return k if v.to_s == l.to_s } - nil - end end end From e76c7c448782d6fc9f949a13e4d7f14401d31db5 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 22:36:36 -0700 Subject: [PATCH 12/13] fix a breakage --- test/unit/darcs_pull_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/darcs_pull_test.rb b/test/unit/darcs_pull_test.rb index 70effdc3..e34f5060 100644 --- a/test/unit/darcs_pull_test.rb +++ b/test/unit/darcs_pull_test.rb @@ -17,7 +17,7 @@ def test_pull # Commit some new code on the original and pull again src.run "cd '#{src.url}' && touch foo && darcs add foo && darcs record -a -m test" - assert_equal "test\n", src.commits.last.message + assert_equal "test", src.commits.last.token dest.pull(src) assert_equal src.log, dest.log From 31c0334a77430880f8a0a7754eb74bdf7cd336a1 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 4 Nov 2010 23:16:12 -0700 Subject: [PATCH 13/13] do not pull from repos with unresolved conflicts --- lib/scm/adapters/darcs/pull.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scm/adapters/darcs/pull.rb b/lib/scm/adapters/darcs/pull.rb index 7aa6c01a..299ebf23 100644 --- a/lib/scm/adapters/darcs/pull.rb +++ b/lib/scm/adapters/darcs/pull.rb @@ -13,7 +13,7 @@ def pull(from, &block) run "darcs get '#{from.url}' '#{self.url}'" else # might also need to unpull for an exact copy - run "cd '#{self.url}' && darcs revert --all && darcs pull -a '#{from.url}'" + run "cd '#{self.url}' && darcs revert --all && darcs pull --dont-allow-conflicts -a '#{from.url}'" end yield(1,1) if block_given? # Progress bar callback