Browse files

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

  • Loading branch information...
2 parents e112b81 + 0f25bca commit 830f069492d322981ab9c1e612530b8e2bbd423b Eric Kow committed Apr 24, 2009
Showing with 34 additions and 1 deletion.
  1. +9 −0 lib/scm/adapters/bzr/misc.rb
  2. +7 −1 lib/scm/adapters/hg/misc.rb
  3. +9 −0 test/unit/bzr_misc_test.rb
  4. +9 −0 test/unit/hg_misc_test.rb
View
9 lib/scm/adapters/bzr/misc.rb
@@ -31,5 +31,14 @@ def to_rev_param(r=nil)
def is_merge_commit?(commit)
parent_tokens(commit).size > 1
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
View
8 lib/scm/adapters/hg/misc.rb
@@ -10,7 +10,13 @@ def exist?
end
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
View
9 test/unit/bzr_misc_test.rb
@@ -22,5 +22,14 @@ def test_ls_tree
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
View
9 test/unit/hg_misc_test.rb
@@ -18,5 +18,14 @@ def test_ls_tree
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

0 comments on commit 830f069

Please sign in to comment.