# coding: utf-8 # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Samples patches to test patch.py.""" class RAW(object): PATCH = ( 'Index: chrome/file.cc\n' '===================================================================\n' '--- chrome/file.cc\t(revision 74690)\n' '+++ chrome/file.cc\t(working copy)\n' '@@ -3,6 +3,7 @@ bb\n' ' ccc\n' ' dd\n' ' e\n' '+FOO!\n' ' ff\n' ' ggg\n' ' hh\n') NEW = ( '--- /dev/null\n' '+++ foo\n' '@@ -0,0 +1 @@\n' '+bar\n') NEW_NOT_NULL = ( '--- file_a\n' '+++ file_a\n' '@@ -0,0 +1 @@\n' '+foo\n') MINIMAL_NEW = ( '--- /dev/null\t2\n' '+++ chrome/file.cc\tfoo\n') MINIMAL = ( '--- file_a\n' '+++ file_a\n') MINIMAL_RENAME = ( '--- file_a\n' '+++ file_b\n') DELETE = ( '--- tools/clang_check/README.chromium\n' '+++ /dev/null\n' '@@ -1,1 +0,0 @@\n' '-bar\n') MINIMAL_DELETE = ( '--- chrome/file.cc\tbar\n' '+++ /dev/null\tfoo\n') DELETE2 = ( 'Index: browser/extensions/extension_sidebar_api.cc\n' '===================================================================\n' '--- browser/extensions/extension_sidebar_api.cc\t(revision 116830)\n' '+++ browser/extensions/extension_sidebar_api.cc\t(working copy)\n' '@@ -1,19 +0,0 @@\n' '-// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n' '-// Use of this source code is governed by a BSD-style license that\n' '-// found in the LICENSE file.\n' '-\n' '-#include "base/command_line.h"\n' '-#include "chrome/browser/extensions/extension_apitest.h"\n' '-#include "chrome/common/chrome_switches.h"\n' '-\n' '-class SidebarApiTest : public ExtensionApiTest {\n' '- public:\n' '- void SetUpCommandLine(CommandLine* command_line) {\n' '- ExtensionApiTest::SetUpCommandLine(command_line);\n' '- command_line->AppendSwitch(switches::Bleh);\n' '- }\n' '-};\n' '-\n' '-IN_PROC_BROWSER_TEST_F(SidebarApiTest, Sidebar) {\n' '- ASSERT_TRUE(RunExtensionTest("sidebar")) << message_;\n' '-}\n') # http://codereview.chromium.org/api/7530007/5001 # http://codereview.chromium.org/download/issue7530007_5001_4011.diff CRAP_ONLY = ( 'Index: scripts/master/factory/skia/__init__.py\n' '===================================================================\n') TWO_HUNKS = ( 'Index: chrome/app/generated_resources.grd\n' '===================================================================\n' '--- chrome/app/generated_resources.grd\t(revision 116830)\n' '+++ chrome/app/generated_resources.grd\t(working copy)\n' '@@ -4169,9 +4169,6 @@\n' ' \n' ' Could not load options page \'$1\n' '- \n' '- Could not load sidebar page \'$1\n' ' \n' ' \n') # http://codereview.chromium.org/download/issue6287022_3001_4010.diff RENAME = ( 'Index: tools/run_local_server.sh\n' 'diff --git a/tools/run_local_server.PY b/tools/run_local_server.sh\n' 'similarity index 100%\n' 'rename from tools/run_local_server.PY\n' 'rename to tools/run_local_server.sh\n') COPY = ( 'diff --git a/PRESUBMIT.py b/pp\n' 'similarity index 100%\n' 'copy from PRESUBMIT.py\n' 'copy to pp\n') COPY_PARTIAL = ( 'diff --git a/wtf b/wtf2\n' 'similarity index 98%\n' 'copy from wtf\n' 'copy to wtf2\n' 'index 79fbaf3..3560689 100755\n' '--- a/wtf\n' '+++ b/wtf2\n' '@@ -1,4 +1,4 @@\n' '-#!/usr/bin/env python\n' '+#!/usr/bin/env python1.3\n' ' # Copyright (c) 2010 The Chromium Authors. All rights reserved.\n' ' # blah blah blah as\n' ' # found in the LICENSE file.\n') NEW = ( 'diff --git a/foo b/foo\n' 'new file mode 100644\n' 'index 0000000..5716ca5\n' '--- /dev/null\n' '+++ b/foo\n' '@@ -0,0 +1 @@\n' '+bar\n') NEW_EXE = ( 'diff --git a/natsort_test.py b/natsort_test.py\n' 'new file mode 100755\n' '--- /dev/null\n' '+++ b/natsort_test.py\n' '@@ -0,0 +1,1 @@\n' '+#!/usr/bin/env python\n') # To make sure the subdirectory was created as needed. NEW_SUBDIR = ( 'diff --git a/new_dir/subdir/new_file b/new_dir/subdir/new_file\n' 'new file mode 100644\n' '--- /dev/null\n' '+++ b/new_dir/subdir/new_file\n' '@@ -0,0 +1,2 @@\n' '+A new file\n' '+should exist.\n') NEW_MODE = ( 'diff --git a/natsort_test.py b/natsort_test.py\n' 'new file mode 100644\n' '--- /dev/null\n' '+++ b/natsort_test.py\n' '@@ -0,0 +1,1 @@\n' '+#!/usr/bin/env python\n') MODE_EXE = ( 'diff --git a/git_cl/git-cl b/git_cl/git-cl\n' 'old mode 100644\n' 'new mode 100755\n') MODE_EXE_JUNK = ( 'Index: Junk\n' 'diff --git a/git_cl/git-cl b/git_cl/git-cl\n' 'old mode 100644\n' 'new mode 100755\n') NEW_NOT_EXECUTABLE = ( 'diff --git a/build/android/ant/create.js b/build/android/ant/create.js\n' 'new file mode 100644\n' 'index 0000000000000000000..542a89e978feada38dd\n' '--- /dev/null\n' '+++ b/build/android/ant/create.js\n' '@@ -0,0 +1,1 @@\n' '+// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n' ) FOUR_HUNKS = ( 'Index: presubmit_support.py\n' 'diff --git a/presubmit_support.py b/presubmit_support.py\n' 'index 52416d3f..d56512f2 100755\n' '--- a/presubmit_support.py\n' '+++ b/presubmit_support.py\n' '@@ -558,6 +558,7 @@ class SvnAffectedFile(AffectedFile):\n' ' AffectedFile.__init__(self, *args, **kwargs)\n' ' self._server_path = None\n' ' self._is_text_file = None\n' '+ self._diff = None\n' ' \n' ' def ServerPath(self):\n' ' if self._server_path is None:\n' '@@ -598,8 +599,10 @@ class SvnAffectedFile(AffectedFile):\n' ' return self._is_text_file\n' ' \n' ' def GenerateScmDiff(self):\n' '- return scm.SVN.GenerateDiff(\n' '- [self.LocalPath()], self._local_root, False, None)\n' '+ if self._diff is None:\n' '+ self._diff = scm.SVN.GenerateDiff(\n' '+ [self.LocalPath()], self._local_root, False, None)\n' '+ return self._diff\n' ' \n' ' \n' ' class GitAffectedFile(AffectedFile):\n' '@@ -611,6 +614,7 @@ class GitAffectedFile(AffectedFile):\n' ' AffectedFile.__init__(self, *args, **kwargs)\n' ' self._server_path = None\n' ' self._is_text_file = None\n' '+ self._diff = None\n' ' \n' ' def ServerPath(self):\n' ' if self._server_path is None:\n' '@@ -645,7 +649,10 @@ class GitAffectedFile(AffectedFile):\n' ' return self._is_text_file\n' ' \n' ' def GenerateScmDiff(self):\n' '- return scm.GIT.GenerateDiff(self._local_root, files=[self.Lo...\n' '+ if self._diff is None:\n' '+ self._diff = scm.GIT.GenerateDiff(\n' '+ self._local_root, files=[self.LocalPath(),])\n' '+ return self._diff\n' ' \n' ' \n' ' class Change(object):\n')