From abcd43a3e0103667a8058042ec1c76de92571989 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 4 Nov 2012 23:13:30 +0000 Subject: [PATCH] Add Git conversion configuration files. Subversion-branch: /git Subversion-revision: 2539 --- .gitignore | 17 +++++ README | 6 ++ chocolate-doom-misc.cfg | 128 ++++++++++++++++++++++++++++++++ chocolate-doom.cfg | 161 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 312 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100644 chocolate-doom-misc.cfg create mode 100644 chocolate-doom.cfg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bbee65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ + +# These are the default patterns globally ignored by Subversion: +*.o +*.lo +*.la +*.al +.libs +*.so +*.so.[0-9]* +*.a +*.pyc +*.pyo +*.rej +*~ +.#* +.*.swp +.DS_store diff --git a/README b/README new file mode 100644 index 0000000..5953c5a --- /dev/null +++ b/README @@ -0,0 +1,6 @@ + +Configuration files for Subversion-Git conversion. These are for the +Agito conversion tool: + + http://github.com/fragglet/agito + diff --git a/chocolate-doom-misc.cfg b/chocolate-doom-misc.cfg new file mode 100644 index 0000000..c0c68f0 --- /dev/null +++ b/chocolate-doom-misc.cfg @@ -0,0 +1,128 @@ + +# URL of the Subversion repository. + +SVN_REPO = "file:///.../chocolate-doom-repo" + +# Path to directory where the Git repository containing the converted +# history should be stored. + +GIT_REPO = "chocolate-doom-misc" + +# Subversion paths to convert to Git branches. +# If the paths contain the '%' character, this is a wildcard to map +# from Subversion path to Git branch name. For example: +# "/releases/foobar-%" : "v%" +# Will result in this mapping: +# /releases/foobar-0.0.1 -> v0.0.1 + +BRANCHES = { + "/buildscripts" : "buildscripts", + "/debian" : "debian", + "/git" : "git", + "/icon" : "icon", + "/launcher" : "launcher", + "/master" : "master", + "/research" : "research", + "/tools" : "tools", +} + +# Subversion paths to convert to Git tags. + +TAGS = { +} + +# Subversion username to Git author mapping. + +AUTHORS = { + "fraggle" : ("Simon Howard", "fraggle@gmail.com"), + + # Fall back to me. + None : ("Simon Howard", "fraggle@gmail.com"), +} + +# Default author, when not found in the AUTHORS map above. The '%' +# is replaced with the Subversion username. + +DEFAULT_AUTHOR = ("%", "%@users.sourceforge.net") + +# --------------------------------------------------------------------------- + +# If true, tags are created as annotated tag objects, rather than just +# refs to the head of the history of the tag. This is done by taking the +# change at the head of the history, discarding it, and creating a tag +# object in its place, reusing the commit message from the discarded +# commit. This behavior works for most Subversion tags, where the tag +# was created by a 'svn cp' from one path to another. As a sanity check, +# the tree of the head commit is checked to ensure that it matches the +# tree of the parent commit. If it does not, a normal "ref tag" is +# created. + +CREATE_TAG_OBJECTS = True + +# Functions to apply to commit messages to convert from Subversion +# commit messages to Git ones. + +COMMIT_MESSAGE_FILTERS = [ + agito.reflow_text, # Reflow text to 72 columns + agito.append_branch_info, # Append SVN branch/rev info. +] + +# List of revision numbers of Subversion revisions that should be +# "filtered" from the converted history: any changes made in a filtered +# revision will be included in the following revision instead. If you +# filter a commit that is the head of a branch, you're going to have a +# bad time. + +FILTER_REVISIONS = [] + +# Callback function to invoke before creating each commit. This is +# similar to Git's 'filter-branch' command. Invoked with the branch +# path, log entry metadata dictionary, and Directory object representing +# the tree. +# +# The metadata dictionary contains the data used in constructing the Git +# commit - the keys are the same names as the environment variables set +# by 'git filter-branch'. + +#def my_filter_callback(path, entry, metadata, treedir): +# pass +# +#FILTER_BRANCH_CALLBACK = my_filter_callback + +# These lines are included in the root .gitignore file. + +SVN_DEFAULT_IGNORES = """ +# These are the default patterns globally ignored by Subversion: +*.o +*.lo +*.la +*.al +.libs +*.so +*.so.[0-9]* +*.a +*.pyc +*.pyo +*.rej +*~ +.#* +.*.swp +.DS_store +""" + +# Subversion properties used for tracking merges. This maps from a +# property name to a callback function to invoke when the property with +# that value is changed on the root of a branch. The function returns a +# tuple containing the Subversion path of the branch that was merged, +# and the revision number of the point on the branch that was merged. + +#def my_merge_callback(path, entry, changed): +# old_value, new_value = changed +# ... +# return ("/branches/foo-branch", 1234) + +MERGE_CALLBACKS = { + +} + +# vim: set ft=python: diff --git a/chocolate-doom.cfg b/chocolate-doom.cfg new file mode 100644 index 0000000..7c527f6 --- /dev/null +++ b/chocolate-doom.cfg @@ -0,0 +1,161 @@ +import re + +SVN_REPO_URL_RE = re.compile('http.*/svnroot/chocolate-doom(.*)') + +# URL of the Subversion repository. + +SVN_REPO = "file:///.../chocolate-doom-repo" +GIT_REPO = "chocolate-doom" + +BRANCHES = { + "/trunk/chocolate-doom" : "master", + "/branches/%" : "%", +} + +TAGS = { + "/tags/%" : "%", +} + +# Subversion username to Git author mapping. + +AUTHORS = { + "fraggle" : ("Simon Howard", "fraggle@gmail.com"), + "quasar_te" : ("James Haley", "haleyjd@hotmail.com"), + "svkaiser" : ("Samuel Villareal", "svkaiser@gmail.com"), + "rtc_marine" : ("Russell Rice", "rtc_marine@hotmail.com"), + "zbuzanic" : ("Zvonimir Buzanic", "zvonimir.buzanic@gmail.com"), + "jond" : ("Jon Dowland", "jon@dowland.me"), + + # Fall back to me. + None : ("Simon Howard", "fraggle@gmail.com"), +} + +# Default author, when not found in the AUTHORS map above. The '%' +# is replaced with the Subversion username. + +DEFAULT_AUTHOR = ("%", "%@users.sourceforge.net") + +FILTER_REVISIONS = [ 5, 391, 392, 1027, 2528 ] + +# Callback function to invoke before creating each commit. This is similar +# to git's 'filter-branch' command. Invoked with the branch path, log entry +# and Directory object representing the tree. + +def fix_file(treedir, path, old_sha, new_sha): + if path in treedir: + perms, blob_id = treedir[path] + if blob_id == old_sha: + treedir[path] = (perms, new_sha) + +# Original timestamps for tags that were deleted and recreated: +TAG_TIMESTAMPS = { + 2525: "2006-01-20 19:46:14", # v0.1.3 + 2526: "2006-02-13 20:10:03", # v0.1.4 + 2527: "2008-04-20 02:01:14", # v1.1.1 +} + +def filter_callback(path, entry, metadata, treedir): + fix_file(treedir, "data/chocolate-doom.png", + "f4b1dfde689943a08344fff687963a89d0115ee1", + "6d58b87482d0fa39e86b15b715c172688c8f9164") + fix_file(treedir, "data/chocolate-doom.ico", + "36e98b716f1a7ba8602d2e3f2eaef1982fa774d9", + "602d32d4bc2e134400913c27f3a921d1105b3286") + + # Fix tag timestamps: + revnum = entry.revision.number + if revnum in TAG_TIMESTAMPS: + metadata["GIT_AUTHOR_DATE"] = TAG_TIMESTAMPS[revnum] + metadata["GIT_COMMITTER_DATE"] = TAG_TIMESTAMPS[revnum] + +FILTER_BRANCH_CALLBACK = filter_callback + +# These lines are included in the root .gitignore file. + +SVN_DEFAULT_IGNORES = """ +# These are the default patterns globally ignored by Subversion: +*.o +*.lo +*.la +*.al +.libs +*.so +*.so.[0-9]* +*.a +*.pyc +*.pyo +*.rej +*~ +.#* +.*.swp +.DS_store +""" + +# If true, tags are created as annotated tag objects, rather than just +# refs to the head of the history of the tag. This is done by taking +# the change at the head of the history, removing it, and creating a +# tag object in its place, reusing its commit message. +# This behavior works for most Subversion tags, where the tag was +# created by a 'svn cp' from one path to another. +# As a sanity check, the tree of the head commit is checked to ensure +# that it matches the tree of the parent commit. If it does not, a +# normal "ref tag" is created. + +CREATE_TAG_OBJECTS = True + +def conditional_reflow(path, entry, message): + # "Conditionally" reflow a Subversion commit message. + # Chocolate Doom's commit messages are mostly in long line style, + # but some are in multiple-line style with a maximum of 80 + # columns. Therefore, be flexible on reflowing: if all lines + # in a message fit within 80 columns, consider that good enough + # and don't reflow it. However, if anything exceeds 80 columns, + # reflow the whole thing. + # After ~r700, everything is long lines, so become strict. + + if entry.revision.number < 700: + for line in message.split("\n"): + if len(line) > 80: + break + else: + return message + + return agito.reflow_text(path, entry, message) + +def no_double_space(path, entry, message): + return message.replace(". ", ". ") + +# Functions to apply to commit messages to convert from Subversion +# commit messages to git ones. + +COMMIT_MESSAGE_FILTERS = [ + #agito.reflow_text, + no_double_space, + conditional_reflow, + agito.append_branch_info, +] + +def branch_helper_callback(path, entry, changed): + before = int((changed[0] or "0").strip()) + after = int((changed[1] or "0").strip()) + + if after < before: + return None + + # At this point we have detected a legitimate merge. + # Use the 'old' value of parent_url as there are merges where + # the property was changed by mistake. + + print "branch_helper:merged: %i -> %i" % (before, after) + parent_url = agito.propget(path, entry.revision.number - 1, + 'branch_helper:parent_url') + + match = SVN_REPO_URL_RE.match(parent_url) + assert match + return (match.group(1), after) + +MERGE_CALLBACKS = { + "branch_helper:last_merged": branch_helper_callback +} + +# vim: set ft=python: