Permalink
Browse files

Merge branch 'master' of git://github.com/robinluckey/ohloh_scm

  • Loading branch information...
2 parents f5da98d + e9598d7 commit c39077b6d58539c0f355df02642e7b656a15aad6 Lennon Day-Reynolds committed Feb 9, 2009
Showing with 45 additions and 5 deletions.
  1. +1 −1 lib/scm/adapters/bzr/cat_file.rb
  2. +21 −4 lib/scm/adapters/bzr/commits.rb
  3. +3 −0 test/repositories/bzr_with_subdirectories/.bzr/README
  4. +1 −0 test/repositories/bzr_with_subdirectories/.bzr/branch-format
  5. 0 test/repositories/bzr_with_subdirectories/.bzr/branch/branch.conf
  6. +1 −0 test/repositories/bzr_with_subdirectories/.bzr/branch/format
  7. +1 −0 test/repositories/bzr_with_subdirectories/.bzr/branch/last-revision
  8. 0 test/repositories/bzr_with_subdirectories/.bzr/branch/tags
  9. +1 −0 test/repositories/bzr_with_subdirectories/.bzr/checkout/conflicts
  10. BIN test/repositories/bzr_with_subdirectories/.bzr/checkout/dirstate
  11. +1 −0 test/repositories/bzr_with_subdirectories/.bzr/checkout/format
  12. +1 −0 test/repositories/bzr_with_subdirectories/.bzr/repository/format
  13. BIN ...repositories/bzr_with_subdirectories/.bzr/repository/indices/6eb92b11d9f811881dd08e0ca71e136d.iix
  14. BIN ...repositories/bzr_with_subdirectories/.bzr/repository/indices/6eb92b11d9f811881dd08e0ca71e136d.rix
  15. +5 −0 ...repositories/bzr_with_subdirectories/.bzr/repository/indices/6eb92b11d9f811881dd08e0ca71e136d.six
  16. BIN ...repositories/bzr_with_subdirectories/.bzr/repository/indices/6eb92b11d9f811881dd08e0ca71e136d.tix
  17. BIN test/repositories/bzr_with_subdirectories/.bzr/repository/pack-names
  18. BIN .../repositories/bzr_with_subdirectories/.bzr/repository/packs/6eb92b11d9f811881dd08e0ca71e136d.pack
  19. 0 test/repositories/bzr_with_subdirectories/foo/helloworld.c
  20. +9 −0 test/unit/bzr_commits_test.rb
@@ -10,7 +10,7 @@ def cat_file_parent(commit, diff)
end
def cat(revision, path)
- out, err = run_with_err("cd '#{url}' && bzr cat -r #{to_rev_param(revision)} #{escape(path)}")
+ out, err = run_with_err("cd '#{url}' && bzr cat --name-from-revision -r #{to_rev_param(revision)} #{escape(path)}")
return nil if err =~ / is not present in revision /
raise RuntimeError.new(err) unless err.to_s == ''
out
@@ -46,10 +46,10 @@ def verbose_commit(token)
# 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::BzrParser.parse(io) do |commit|
- yield remove_directories(commit) if block_given? && commit.token != since
+ yield remove_dupes(remove_directories(commit)) if block_given? && commit.token != since
end
end
end
@@ -61,6 +61,23 @@ def remove_directories(commit)
commit
end
+ # Bazaar may report that a file was both removed and added in the same commit.
+ # We're going to consider this to be simply a modification of the file.
+ # So we'll remove the 'D' action, and replace the 'A' with an 'M' action.
+ def remove_dupes(commit)
+ if commit.diffs
+ dupes = commit.diffs.collect do |d|
+ d if d.action == 'D' && commit.diffs.select { |x| x.action == 'A' and x.path == d.path }.any?
+ end.compact
+ dupes.each do |dupe|
+ commit.diffs.delete_if { |del| del.action == 'D' and del.path == dupe.path }
+ commit.diffs.each { |add| add.action = 'M' if add.path == dupe.path }
+ end
+ end
+ commit
+ end
+
+
# Not used by Ohloh proper, but handy for debugging and testing
def log(since=nil)
run "#{rev_list_command(since)} -v"
@@ -71,14 +88,14 @@ def log(since=nil)
# +since+. However, bzr 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 "#{rev_list_command} -v > #{log_filename}"
+ run "#{rev_list_command(since)} -v > #{log_filename}"
end
File.open(log_filename, 'r') { |io| yield io }
ensure
@@ -0,0 +1,3 @@
+This is a Bazaar control directory.
+Do not change any files in this directory.
+See http://bazaar-vcs.org/ for more information about Bazaar.
@@ -0,0 +1 @@
+Bazaar-NG meta directory, format 1
@@ -0,0 +1 @@
+Bazaar Branch Format 6 (bzr 0.15)
@@ -0,0 +1 @@
+1 test@example.com-20090206231214-d211b455ad50q6eh
@@ -0,0 +1 @@
+BZR conflict list format 1
@@ -0,0 +1 @@
+Bazaar Working Tree Format 4 (bzr 0.15)
@@ -0,0 +1 @@
+Bazaar pack repository format 1 (needs bzr 0.92)
@@ -0,0 +1,5 @@
+Bazaar Graph Index 1
+node_ref_lists=0
+key_elements=1
+len=0
+
@@ -63,6 +63,15 @@ def test_each_commit
end
end
+ def test_remove_dupes_add_remove
+ bzr = BzrAdapter.new
+ c = Scm::Commit.new(:diffs => [ Scm::Diff.new(:action => "A", :path => "foo"),
+ Scm::Diff.new(:action => "D", :path => "foo") ])
+ bzr.remove_dupes(c)
+ assert_equal 1, c.diffs.size
+ assert_equal 'M', c.diffs.first.action
+ end
+
# This bzr repository contains the following tree structure
# /foo/
# /foo/helloworld.c

0 comments on commit c39077b

Please sign in to comment.