summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutil/maint/create_patches.sh32
-rwxr-xr-xutil/maint/git-patch-to-hg-patch137
2 files changed, 2 insertions, 167 deletions
diff --git a/util/maint/create_patches.sh b/util/maint/create_patches.sh
index 7c1655f78..339136ac0 100755
--- a/util/maint/create_patches.sh
+++ b/util/maint/create_patches.sh
@@ -44,11 +44,9 @@ REL_SCRIPT_DIR=`dirname "$0"`
SCRIPT_NAME=`basename "$0"`
SCRIPT_DIR=$(cd "$REL_SCRIPT_DIR" && echo "$(pwd -P)")
MSG_FILTER="$SCRIPT_DIR"/upstream_msg_filter.sed
-CONV_HG="$SCRIPT_DIR"/git-patch-to-hg-patch
PATCH_DIR="./patches/"
UPSTREAM="upstream/master"
-PATCH_FORMAT=
usage()
{
@@ -59,7 +57,6 @@ Format a patch series suitable for upstream consumption.
Options:
-u BRANCH Upstream branch
-d DIR Patch directory
- -f FMT Patch format (hg or git)
-h Show this help string.
This script creates a series of patches suitable from upstream
@@ -70,7 +67,7 @@ the following operations in order:
1. Rebase the patches in the current branch onto the upstream
branch.
2. Filter commit messages.
- 3. Generate a set of patches in git format or Mercurial format.
+ 3. Generate a set of patches in git format.
EOF
}
@@ -79,7 +76,7 @@ branch_exists()
git rev-parse --verify -q "$1" > /dev/null
}
-while getopts ":u:d:f:h" OPT; do
+while getopts ":u:d:h" OPT; do
case $OPT in
d)
PATCH_DIR="$OPTARG"
@@ -87,9 +84,6 @@ while getopts ":u:d:f:h" OPT; do
u)
UPSTREAM="$OPTARG"
;;
- f)
- PATCH_FORMAT="$OPTARG"
- ;;
h)
usage
exit 0
@@ -117,21 +111,6 @@ shift $((OPTIND - 1))
BRANCH="${1:-HEAD}"
-case "$PATCH_FORMAT" in
- git|hg)
- ;;
-
- "")
- echo "Error: No patch format specified" >&2
- exit 1
- ;;
-
- *)
- echo "Error: Illegal patch format specified: '$PATCH_FORMAT'" >&2
- exit 1
-esac
-
-
if ! branch_exists "$BRANCH"; then
echo "Error: Patch branch '$BRANCH' doesn't exist" 1>&2
exit 2
@@ -168,10 +147,3 @@ git filter-branch -f \
echo "Creating patches..."
git format-patch -p -o "$PATCH_DIR" "$UPSTREAM"
-
-if [ "$PATCH_FORMAT" == "hg" ]; then
- echo "Converting patches..."
- for P in "$PATCH_DIR"/*.patch; do
- "$CONV_HG" $P
- done
-fi
diff --git a/util/maint/git-patch-to-hg-patch b/util/maint/git-patch-to-hg-patch
deleted file mode 100755
index 1b9e05d09..000000000
--- a/util/maint/git-patch-to-hg-patch
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/env python2
-#
-# This file originated from the moz-git-tools repo on GitHub
-# (https://github.com/mozilla/moz-git-tools), which contains the
-# following LICENSE notice:
-#
-# <quote>
-# Except for git-new-workdir, which is covered under GPLv2, the code
-# in this repository is placed into the public domain via CC0.
-#
-# http://creativecommons.org/publicdomain/zero/1.0/legalcode
-# </quote>
-
-r"""Git format-patch to hg importable patch.
-
-(Who knew this was so complicated?)
-
->>> process(StringIO('From 3ce1ccc06 Mon Sep 17 00:00:00 2001\nFrom: fromuser\nSubject: subject\n\nRest of patch.\nMore patch.\n'))
-'# HG changeset patch\n# User fromuser\n\nsubject\n\nRest of patch.\nMore patch.\n'
-
->>> process(StringIO('From: fromuser\nSubject: A very long subject line. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi faucibus, arcu sit amet\n\nRest of patch.\nMore patch.\n'))
-'# HG changeset patch\n# User fromuser\n\nA very long subject line. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi faucibus, arcu sit amet\n\nRest of patch.\nMore patch.\n'
-
->>> process(StringIO('From: f\nSubject: =?UTF-8?q?Bug=20655877=20-=20Dont=20treat=20SVG=20text=20frames=20?= =?UTF-8?q?as=20being=20positioned.=20r=3D=3F?=\n\nPatch.'))
-'# HG changeset patch\n# User f\n\nBug 655877 - Dont treat SVG text frames as being positioned. r=?\n\nPatch.'
-"""
-
-# Original author: bholley
-
-import sys
-import re
-import fileinput
-import email, email.parser, email.header, email.utils
-import math
-from cStringIO import StringIO
-from itertools import takewhile
-
-def decode_header(hdr_string):
- r"""Clean up weird encoding crap.
-
- >>> clean_header('[PATCH] =?UTF-8?q?Bug=20655877=20r=3D=3F?=')
- '[PATCH] Bug 655877 r=?'
- """
- rv = []
- hdr = email.header.Header(hdr_string, maxlinelen=float('inf'))
- for (part, encoding) in email.header.decode_header(hdr):
- if encoding is None:
- rv.append(part)
- else:
- rv.append(part.decode(encoding).encode('utf-8'))
- return ' '.join(rv)
-
-def clean_header(hdr_string):
- r"""Transform a header split over many lines into a header split only where
- linebreaks are intended. This is important because hg cares about the first
- line of the commit message.
-
- Also clean up weird encoding crap.
-
- >>> clean_header('Foo\n bar\n baz')
- 'Foo bar baz'
- >>> clean_header('Foo\n bar\nSpam\nEggs')
- 'Foo bar\nSpam\nEggs'
- """
-
- lines = []
- curline = ''
- for line in decode_header(hdr_string).split('\n'):
- if not line.startswith(' '):
- lines.append(curline)
- curline = ''
- curline += line
- lines.append(curline)
- return '\n'.join(lines[1:])
-
-def process(git_patch_file):
- parser = email.parser.Parser()
- msg = parser.parse(git_patch_file)
- from_hdr = clean_header(msg['From'])
- commit_title = clean_header(msg['subject'])
- if not len(commit_title) or not len(from_hdr):
- sys.stderr.write("%s does not look like a valid git patch file, skipping\n"
- % git_patch_file.name)
- return
-
- parsed_from = email.utils.parseaddr(from_hdr)
- nuke_prefix = r"\[PATCH( \d+/\d+)?\] "
- match = re.match(nuke_prefix, commit_title)
- if match:
- commit_title = commit_title[match.end():]
-
- patch_body = msg.get_payload()
-
- # git format-patch wraps the diff (including trailing whitespace):
- # ---
- # <diff>
- # --
- # 2.0.3
- # This doesn't hurt parsing the diff at all, but the version number is
- # nonsense once the git specific items have been stripped
- patch_body = re.sub(r'--\s?\n[0-9\.]+\n$', '', patch_body)
-
- return '\n'.join(['# HG changeset patch',
- '# User %s <%s>' % parsed_from,
- '',
- commit_title,
- '',
- patch_body])
-
-if __name__ == "__main__":
- if len(sys.argv) > 1 and sys.argv[1] == '--test':
- import doctest
- doctest.testmod()
- sys.exit(0)
-
- # If there were no arguments, do stdin->stdout.
- filelist = sys.argv[1:]
- if not filelist:
- lines = process(sys.stdin)
- sys.stdout.writelines(lines)
- sys.exit(0)
-
- # Otherwise, we take a list of files.
- for filename in filelist:
-
- # Read the lines.
- f = open(filename, 'r')
- lines = process(f)
- f.close()
-
- # Process.
-
- if lines:
- # Write them back to the same file.
- f = open(filename, 'w')
- f.writelines(lines)
- f.close()