Changeset 52739 in webkit


Ignore:
Timestamp:
Jan 4, 2010 8:12:27 AM (14 years ago)
Author:
vestbo@webkit.org
Message:

Add support for Git's "diff.mnemonicprefix" config option to WebKitTools

Reviewed by David Kilzer.

https://bugs.webkit.org/show_bug.cgi?id=32820

  • Scripts/VCSUtils.pm:
  • Scripts/svn-apply:
  • Scripts/svn-unapply:
  • Scripts/test-webkitperl: Run gitdiff2svndiff test
  • Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl: Added.
  • Scripts/webkitpy/diff_parser.py:
  • Scripts/webkitpy/diff_parser_unittest.py:
Location:
trunk/WebKitTools
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r52732 r52739  
     12010-01-04  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        Add support for Git's "diff.mnemonicprefix" config option to WebKitTools
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=32820
     8
     9        * Scripts/VCSUtils.pm:
     10        * Scripts/svn-apply:
     11        * Scripts/svn-unapply:
     12        * Scripts/test-webkitperl: Run gitdiff2svndiff test
     13        * Scripts/webkitperl/VCSUtils_unittest/gitdiff2svndiff.pl: Added.
     14        * Scripts/webkitpy/diff_parser.py:
     15        * Scripts/webkitpy/diff_parser_unittest.py:
     16
    1172010-01-04  Chris Jerdonek  <chris.jerdonek@gmail.com>
    218
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r52732 r52739  
    363363{
    364364    $_ = shift @_;
    365     if (m#^diff --git a/(.+) b/(.+)#) {
     365    if (m#^diff --git \w/(.+) \w/(.+)#) {
    366366        return "Index: $1";
    367367    } elsif (m#^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}#) {
    368368        return "===================================================================";
    369     } elsif (m#^--- a/(.+)#) {
     369    } elsif (m#^--- \w/(.+)#) {
    370370        return "--- $1";
    371     } elsif (m#^\+\+\+ b/(.+)#) {
     371    } elsif (m#^\+\+\+ \w/(.+)#) {
    372372        return "+++ $1";
    373373    }
  • trunk/WebKitTools/Scripts/svn-apply

    r52692 r52739  
    134134    s/([\n\r]+)$//mg;
    135135    my $eol = $1;
    136     if (!defined($indexPath) && m#^diff --git a/#) {
     136    if (!defined($indexPath) && m#^diff --git \w/#) {
    137137        $filter = \&gitdiff2svndiff;
    138138    }
  • trunk/WebKitTools/Scripts/svn-unapply

    r52692 r52739  
    105105    s/([\n\r]+)$//mg;
    106106    my $eol = $1;
    107     if (!defined($indexPath) && m#^diff --git a/#) {
     107    if (!defined($indexPath) && m#^diff --git \w/#) {
    108108        $filter = \&gitdiff2svndiff;
    109109    }
  • trunk/WebKitTools/Scripts/test-webkitperl

    r52732 r52739  
    4444    "fixChangeLogPatch.pl",
    4545    "generatePatchCommand.pl",
     46    "gitdiff2svndiff.pl",
    4647    "runPatchCommand.pl",
    4748);
  • trunk/WebKitTools/Scripts/webkitpy/diff_parser.py

    r46164 r52739  
    4949      line: A string representing a line of the diff.
    5050    """
    51     conversion_patterns = (("^diff --git a/(.+) b/(?P<FilePath>.+)", lambda matched: "Index: " + matched.group('FilePath') + "\n"),
     51    conversion_patterns = (("^diff --git \w/(.+) \w/(?P<FilePath>.+)", lambda matched: "Index: " + matched.group('FilePath') + "\n"),
    5252                           ("^new file.*", lambda matched: "\n"),
    5353                           ("^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}", lambda matched: "===================================================================\n"),
    54                            ("^--- a/(?P<FilePath>.+)", lambda matched: "--- " + matched.group('FilePath') + "\n"),
    55                            ("^\+\+\+ b/(?P<FilePath>.+)", lambda matched: "+++ " + matched.group('FilePath') + "\n"))
     54                           ("^--- \w/(?P<FilePath>.+)", lambda matched: "--- " + matched.group('FilePath') + "\n"),
     55                           ("^\+\+\+ \w/(?P<FilePath>.+)", lambda matched: "+++ " + matched.group('FilePath') + "\n"))
    5656
    5757    for pattern, conversion in conversion_patterns:
     
    7070                       converter from git to SVN.
    7171    """
    72     if match(r"^diff --git a/", first_diff_line):
     72    if match(r"^diff --git \w/", first_diff_line):
    7373        return git_diff_to_svn_diff
    7474    return lambda input: input
  • trunk/WebKitTools/Scripts/webkitpy/diff_parser_unittest.py

    r46164 r52739  
    2929import unittest
    3030import diff_parser
     31import re
    3132
    3233
     
    8384+61a373ee739673a9dcd7bac62b9f182e
    8485\ No newline at end of file
    85 '''.splitlines()
     86'''
    8687
    87 
    88     def test_diff_parser(self):
    89         parser = diff_parser.DiffParser(self._PATCH)
     88    def test_diff_parser(self, parser = None):
     89        if not parser:
     90            parser = diff_parser.DiffParser(self._PATCH.splitlines())
    9091        self.assertEquals(3, len(parser.files))
    9192
     
    127128        self.assertEquals((0, 1), diff.lines[0][0:2])
    128129
     130    def test_git_mnemonicprefix(self):
     131        p = re.compile(r' ([a|b])/')
     132
     133        prefixes = [
     134            { 'a' : 'i', 'b' : 'w' }, # git-diff (compares the (i)ndex and the (w)ork tree)
     135            { 'a' : 'c', 'b' : 'w' }, # git-diff HEAD (compares a (c)ommit and the (w)ork tree)
     136            { 'a' : 'c', 'b' : 'i' }, # git diff --cached (compares a (c)ommit and the (i)ndex)
     137            { 'a' : 'o', 'b' : 'w' }, # git-diff HEAD:file1 file2 (compares an (o)bject and a (w)ork tree entity)
     138            { 'a' : '1', 'b' : '2' }, # git diff --no-index a b (compares two non-git things (1) and (2))
     139        ]
     140
     141        for prefix in prefixes:
     142            patch = p.sub(lambda x: " %s/" % prefix[x.group(1)], self._PATCH)
     143            self.test_diff_parser(diff_parser.DiffParser(patch.splitlines()))
    129144
    130145if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.