Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/robinluckey/ohloh_scm
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Kow committed Apr 24, 2009
2 parents e112b81 + 0f25bca commit 830f069
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/scm/adapters/bzr/misc.rb
Expand Up @@ -31,5 +31,14 @@ def to_rev_param(r=nil)
def is_merge_commit?(commit) def is_merge_commit?(commit)
parent_tokens(commit).size > 1 parent_tokens(commit).size > 1
end end

def export(dest_dir, token=head_token)
# Unlike other SCMs, Bzr doesn't simply place the contents into dest_dir.
# It actually *creates* dest_dir. Since it should already exist at this point,
# first we have to delete it.
Dir.delete(dest_dir) if File.exist?(dest_dir)

run "cd '#{url}' && bzr export --format=dir -r #{to_rev_param(token)} '#{dest_dir}'"
end
end end
end end
8 changes: 7 additions & 1 deletion lib/scm/adapters/hg/misc.rb
Expand Up @@ -10,7 +10,13 @@ def exist?
end end


def ls_tree(token) def ls_tree(token)
run("cd #{path} && hg manifest -r #{token}").split("\n") run("cd '#{path}' && hg manifest -r #{token}").split("\n")
end

def export(dest_dir, token='tip')
run("cd '#{path}' && hg archive -r #{token} '#{dest_dir}'")
# Hg leaves a little cookie crumb in the export directory. Remove it.
File.delete(File.join(dest_dir, '.hg_archival.txt')) if File.exist?(File.join(dest_dir, '.hg_archival.txt'))
end end
end end
end end
9 changes: 9 additions & 0 deletions test/unit/bzr_misc_test.rb
Expand Up @@ -22,5 +22,14 @@ def test_ls_tree
end end
end end


def test_export
with_bzr_repository('bzr') do |bzr|
Scm::ScratchDir.new do |dir|
bzr.export(dir)
assert_equal ['.', '..', 'file1.txt', 'file3.txt', 'file4.txt', 'file5.txt'], Dir.entries(dir).sort
end
end
end

end end
end end
9 changes: 9 additions & 0 deletions test/unit/hg_misc_test.rb
Expand Up @@ -18,5 +18,14 @@ def test_ls_tree
end end
end end


def test_export
with_hg_repository('hg') do |hg|
Scm::ScratchDir.new do |dir|
hg.export(dir)
assert_equal ['.', '..', 'README', 'makefile'], Dir.entries(dir).sort
end
end
end

end end
end end

0 comments on commit 830f069

Please sign in to comment.