Permalink
Browse files

Remember author substitition map

  • Loading branch information...
nominolo committed May 9, 2008
1 parent b5b6497 commit ca12ee3d7dcb4b64d2fb34c8dd23e88301cab1b4
Showing with 30 additions and 20 deletions.
  1. +2 −1 README.markdown
  2. +28 −19 darcs-to-git
View
@@ -44,4 +44,5 @@ Options
* `--author-map FILENAME`: Allows translations from darcs committer
name to Git committer name. The input is a YAML map. For an
- example see the output of `--author-map`.
+ example see the output of `--author-map`. The author map will be
+ stored in the repository and will be re-used for future imports.
View
@@ -19,6 +19,7 @@ require 'yaml'
# GIT_DARCS_BRANCH = "darcs_repo" # name of the branch we import to
GIT_PATCHES = ".git/darcs_patches"
+AUTHOR_MAP_FILE = ".git/darcs_author_substitutions"
OPTIONS = { :default_email => nil,
:list_authors => false,
@@ -77,25 +78,6 @@ if SRCREPO.nil? or not FileTest.exists?(SRCREPO + '/_darcs') then
exit(1)
end
-if OPTIONS[:author_map] then
- unless FileTest.exists?(OPTIONS[:author_map])
- STDERR.puts "File #{OPTIONS[:author_map]} does not exist"
- exit(1)
- end
- begin
- AUTHOR_MAP = (YAML.load_file(OPTIONS[:author_map]) or {})
- rescue
- STDERR.puts "Could not parse #{(OPTIONS[:author_map])}"
- exit(1)
- end
- unless AUTHOR_MAP.class == Hash
- STDERR.puts "Wrong file format for author file."
- exit(1)
- end
-else
- AUTHOR_MAP = {}
-end
-
def run(*args)
puts "Running: #{args.inspect}"
system(*args) || raise("Failed to run: #{args.inspect}")
@@ -334,6 +316,33 @@ unless FileTest.exists?("#{GIT_PATCHES}")
exit(1)
end
+if OPTIONS[:author_map] then
+ unless FileTest.exists?(OPTIONS[:author_map])
+ STDERR.puts "File #{OPTIONS[:author_map]} does not exist"
+ exit(1)
+ end
+ begin
+ AUTHOR_MAP = (YAML.load_file(OPTIONS[:author_map]) or {})
+ rescue
+ STDERR.puts "Could not parse #{(OPTIONS[:author_map])}"
+ exit(1)
+ end
+ unless AUTHOR_MAP.class == Hash
+ STDERR.puts "Wrong file format for author file."
+ exit(1)
+ end
+ File.open("#{AUTHOR_MAP_FILE}", File::WRONLY|File::CREAT) do |f|
+ YAML::dump(AUTHOR_MAP, f)
+ end
+else
+ #if FileTest.exists?(AUTHOR_MAP_FILE) then
+ begin
+ AUTHOR_MAP = AUTHOR_MAP = (YAML.load_file(AUTHOR_MAP_FILE) or {})
+ rescue
+ AUTHOR_MAP = {}
+ end
+end
+
patches = DarcsPatch.read_from_repo(SRCREPO)
if OPTIONS[:list_authors] then
extract_authors(patches)

0 comments on commit ca12ee3

Please sign in to comment.