Skip to content

Commit

Permalink
Properly initialise conversion repo when converting old-format darcs …
Browse files Browse the repository at this point in the history
…repositories with darcs2 (thanks Samium Gromoff)
  • Loading branch information
purcell committed Nov 22, 2008
1 parent 1b5ea6a commit 11ffabe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions darcs-to-git
Expand Up @@ -373,21 +373,19 @@ end
# Pre-flight checks
# -------------------------------------------------------------------------------

def darcs_version
output_of(*%w(darcs -v)).scan(/(\d+)\.(\d+)\.(\d+)/).flatten.map {|v| v.to_i}
end
DARCS_VERSION = output_of(*%w(darcs -v)).scan(/(\d+)\.(\d+)\.(\d+)/).flatten.map {|v| v.to_i}

def darcs2_repo?(repo)
begin
output_of("darcs", "show", "repo", "--repodir=#{repo}") =~ /Format:.*darcs-2/
output_of("darcs", "show", "repo", "--repodir=#{repo}") =~ /Format:.*darcs-2/
rescue # darcs1 does not have a "show" command, so we get an exception
false
false
end
end

class Array; include Comparable; end

unless darcs_version > [1, 0, 7]
unless DARCS_VERSION > [1, 0, 7]
STDERR.write("WARNING: your darcs appears to be old, and may not work with this script\n")
end

Expand All @@ -400,7 +398,11 @@ unless File.directory?("_darcs")
puts "Initialising the working area."

darcs_init = %w(darcs init)
darcs_init.push("--darcs-2") if darcs2_repo?(SRCREPO)
if darcs2_repo?(SRCREPO)
darcs_init << "--darcs-2"
elsif DARCS_VERSION >= [2, 0, 0]
darcs_init << "--old-fashioned-inventory"
end
run(*darcs_init)

run("git", "init")
Expand Down

0 comments on commit 11ffabe

Please sign in to comment.