import re SVN_REPO_URL_RE = re.compile('http.*/svnroot/chocolate-doom(.*)') SVN_REPO_URL2_RE = re.compile('svn.*/p/chocolate-doom/code(.*)') # URL of the Subversion repository. SVN_REPO = "file:///.../chocolate-doom-repo" GIT_REPO = "chocolate-doom" BRANCHES = { "/trunk/chocolate-doom" : "v1-branch", "/branches/v2-branch" : "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, 2622 ] # 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 2658: "2011-06-29 15:12:00", # Chocolate Strife beta 2 } 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') # Try both URL patterns. match = SVN_REPO_URL_RE.match(parent_url) if not match: match = SVN_REPO_URL2_RE.match(parent_url) if match: parent_path = match.group(1) else: # If neither patteerns match, it may be a "modern" # repository-relative path, but it must begin with / assert parent_url.startswith('/') parent_path = parent_url.strip() return (parent_path, after) MERGE_CALLBACKS = { "branch_helper:last_merged": branch_helper_callback } # vim: set ft=python: