We'll be officially migrating mpd, mpc, libmpdclient to git in the near
future.  For now, here is a test repository I've created with git-svn
and git-filter-branch:

  git://musicpd.bogomips.org/normalperson/mpd.git

Please let me know if you notice any problems or inconsistencies.

Note: this is NOT the final URL; there'll most likely be:

  git://git.musicpd.org/$USERNAME/mpd.git

The usual mpd committers will be given push permissions to their
respective repositories.  Official releases will be tagged from my
repository (or Warren's if he decides to return).



Import/migration notes:

I took some extra time to preserve author/committer information and
include email addresses because the git-svn defaults are very ugly.
Additionally, the --authors-file option in git-svn won't parse commits
for authorship information (SVN doesn't distinguish between
author/committer).

So I wrote a script for git-filter-branch --commit-filter:
`mpd-filter-branch' that let me extract authorship information from the
commit messages and also allow me to avoid reimporting from
https://svn.musicpd.org.

The mpd-filter-branch (Ruby) script I used is attached


Commands used:

git filter-branch --commit-filter '~/mpd-filter-branch "$@"' \
   `git rev-parse --symbolic --all |grep ^refs/remotes/`

for i in `git for-each-ref --format '%(refname)' 'refs/remotes/*'`
do
        new=`echo $i |sed -e 's,/remotes/,/heads/,g'`
        git update-ref $new $i
done

for i in `git for-each-ref --format '%(refname)' 'refs/remotes/tags/*'`
do
        new=`echo $i |sed -e 's,/remotes/tags/,/tags/,g'`
        echo git update-ref $new $i
done

-- 
Eric Wong
#!/usr/bin/env ruby
# I hereby place this in the public domain - Eric Wong, 2008
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# This was used to filter an import of https://svn.musicpd.org/mpd,
# but may be adapted for other repositories.
#
# Usage:
#
#   git filter-branch --commit-filter '$0 "$@"' \
#       `git rev-parse --symbolic --all | grep ^refs/remotes`
#
# This script is used to cleanup an existing git repository imported
# by git-svn into a git repository.  It tries to parse the commit
# message for author information that could not be preserved when
# the patches initially went into SVN
#
# "git-svn-id:" lines are preserved for "git svn log" compatibility
# and to avoid having to maintain a separate lookup map (mailing
# lists, forums, and bug trackers have existing messages that refer
# to the SVN revision number).

SVN_UUID = "09075e82-0dd4-0310-85a5-a0d7c8717e4f".freeze
$KCODE = "u".freeze
ENV["LC_ALL"] = "en_US.UTF-8"

SVN_USERNAME_MAP = {
  "anarch" => [ "José Anarch", "[EMAIL PROTECTED]" ],
  "ancl" => [ "Andreas Claesson", "[EMAIL PROTECTED]" ],
  "jat" => [ "J. Alexander Treuman", "[EMAIL PROTECTED]" ],
  "lack" => [ "Jim Ramsay", "[EMAIL PROTECTED]" ],
  "normalperson" => [ "Eric Wong", "[EMAIL PROTECTED]" ],
  "pat" => [ "Patrik Weiskircher", "[EMAIL PROTECTED]" ],
  "qball" => [ "Qball Cow", "[EMAIL PROTECTED]" ],
  "remiss" => [ "Roger Bystrøm", "[EMAIL PROTECTED]" ],
  "sbh" => [ "Avuton Olrich", "[EMAIL PROTECTED]" ],
  "shank" => [ "Warren Dukes", "[EMAIL PROTECTED]" ],
}.each { |k,v| v.each { |x| x.freeze }; v.freeze }.freeze


SVN_UUID_EMAIL = /^(\w+)@#{SVN_UUID}$/.freeze
GIT_SVN_ID = /^git-svn-id:[EMAIL PROTECTED]/.freeze

# We've used Author: to attribute users in commit messages in
# sometimes because From: would cause that information to be lost
# when using git-format-patch + git-am + git-svn
#
# We've also intentionally left out the ":" in "From:" to prevent
# git-am from parsing it, too.
AUTHOR_INFO =
      /^(Submitted-by|Patch-by|Author|From):?\s*(.*)\s*<([EMAIL 
PROTECTED]@[EMAIL PROTECTED])>/.freeze

# Map the ugly [EMAIL PROTECTED] format that git-svn produces into a format
# that is more human-readable.  This is used because the original
# git-svn import did not use --authors-file
%w(AUTHOR COMMITTER).each do |ident|
  if SVN_UUID_EMAIL.match(ENV["GIT_#{ident}_EMAIL"])
    name, email = SVN_USERNAME_MAP[ENV["GIT_#{ident}_NAME"]]
    raise "GIT_#{ident}_NAME could not be mapped" unless name && email

    ENV["GIT_#{ident}_NAME"] = name
    ENV["GIT_#{ident}_EMAIL"] = email
  end
end

message = STDIN.read.split(/\r?\n/).map { |l| l.strip }

# parse author information out of the message and mark any lines
# as nil if we don't want them in the new message
message.each_with_index do |line,i|
  next if line.nil?

  # I didn't add his email address to the commit
  # because I failed to check the AUTHORS file:
  #   (https://svn.musicpd.org/mpd/[EMAIL PROTECTED])
  line.gsub!(/Laszlo Ashin \(Kodest\)/, "Laszlo Ashin <[EMAIL PROTECTED]>")

  if m = AUTHOR_INFO.match(line)
    ENV["GIT_AUTHOR_NAME"] = m[2]
    ENV["GIT_AUTHOR_EMAIL"] = m[3]

    # Patch-by was only used once (https://svn.musicpd.org/mpd/[EMAIL 
PROTECTED])
    if m[1] != "Patch-by"
      message[i] = nil # remove the original line

      # remove blank line before this line
      message[i-1] = nil if message[i-1] && message[i-1] == ""
    end
  end

  # remove the sometimes redundant newline before git-svn-id: lines
  # git-svn blindly inserts "\ngit-svn-id:" because it is common
  # for SVN commit messages to not include a trailing newline.  However,
  # many SVN commit messages also include a trailing newline.  Avoid
  # the redundant "\n" while preserving the git-svn-id: line.
  if i > 1 && GIT_SVN_ID.match(line)
    if message[i-2] && message[i-2] == "" &&
       message[i-1] && message[i-1] == ""
      message[i-2] = nil
    end
  end

end

# remove trailing blank lines, if any
eom = -1
while (eom.abs <= message.size) && (message[eom].nil? || message[eom] == "")
  message[eom] = nil
  eom -= 1
end

# remove all the lines we've set to nil
message.compact!

rd, wr = IO.pipe
if fork
  rd.close
  wr.write(message.join("\n"))
  wr.close
  Process.wait
else
  wr.close
  STDIN.reopen(rd)
  exec *( %w(git commit-tree) + ARGV )
end
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to