Reviewed by Adam Roben.
include svn revisions in git diffs for the code review tool to use
https://bugs.webkit.org/show_bug.cgi?id=53569
* Scripts/webkitpy/common/checkout/scm.py:
* Scripts/webkitpy/common/checkout/scm_unittest.py:
2011-02-01 Ojan Vafai <ojan@chromium.org>
Reviewed by Adam Roben.
include svn revisions in git diffs for the code review tool to use
https://bugs.webkit.org/show_bug.cgi?id=53569
* PrettyPatch/PrettyPatch.rb:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77889
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-01 Ojan Vafai <ojan@chromium.org>
+
+ Reviewed by Adam Roben.
+
+ include svn revisions in git diffs for the code review tool to use
+ https://bugs.webkit.org/show_bug.cgi?id=53569
+
+ * Scripts/webkitpy/common/checkout/scm.py:
+ * Scripts/webkitpy/common/checkout/scm_unittest.py:
+
2011-02-03 MORITA Hajime <morrita@google.com>
Reviewed by Darin Fisher.
def display_name(self):
return "git"
+ def prepend_svn_revision(self, diff):
+ revision = None
+ tries = 0
+ while not revision and tries < 10:
+ # If the git checkout is not tracking an SVN repo, then svn_revision_from_git_commit throws.
+ try:
+ revision = self.svn_revision_from_git_commit('HEAD~' + str(tries))
+ except:
+ return diff
+ tries += 1
+
+ if not revision:
+ return diff
+
+ return "Subversion Revision: " + str(revision) + '\n' + diff
+
def create_patch(self, git_commit=None, changed_files=None):
"""Returns a byte array (str()) representing the patch file.
Patch files are effectively binary since they may contain
command = ['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self.merge_base(git_commit), "--"]
if changed_files:
command += changed_files
- return self.run(command, decode_output=False, cwd=self.checkout_root)
+ return self.prepend_svn_revision(self.run(command, decode_output=False, cwd=self.checkout_root))
def _run_git_svn_find_rev(self, arg):
# git svn find-rev always exits 0, even when the revision or commit is not found.
run_command(['git', 'config', '--add', 'svn-remote.svn.fetch', 'trunk:remote2'])
self.assertEqual(self.tracking_scm.remote_branch_ref(), 'remote1')
+ def test_create_patch(self):
+ write_into_file_at_path('test_file_commit1', 'contents')
+ run_command(['git', 'add', 'test_file_commit1'])
+ scm = detect_scm_system(self.untracking_checkout_path)
+ scm.commit_locally_with_message('message')
+
+ patch = scm.create_patch()
+ self.assertFalse(re.search(r'Subversion Revision:', patch))
+
+
class GitSVNTest(SCMTest):
def _setup_git_checkout(self):
patch = scm.create_patch()
self.assertTrue(re.search(r'test_file_commit2', patch))
self.assertTrue(re.search(r'test_file_commit1', patch))
+ self.assertTrue(re.search(r'Subversion Revision: 5', patch))
def test_create_patch_with_changed_files(self):
self._one_local_commit_plus_working_copy_changes()
+2011-02-01 Ojan Vafai <ojan@chromium.org>
+
+ Reviewed by Adam Roben.
+
+ include svn revisions in git diffs for the code review tool to use
+ https://bugs.webkit.org/show_bug.cgi?id=53569
+
+ * PrettyPatch/PrettyPatch.rb:
+
2011-02-01 Ojan Vafai <ojan@chromium.org>
Reviewed by Adam Barth.
fileDiffs = FileDiff.parse(string)
str = HEADER + "\n"
+
+ # Just look at the first line to see if it is an SVN revision number as added
+ # by webkit-patch for git checkouts.
+ string.each_line do |line|
+ match = /^Subversion\ Revision: (\d*)$/.match(line)
+ unless match.nil?
+ str += "<span class='revision'>" + match[1] + "</span>\n"
+ end
+ break
+ end
+
str += fileDiffs.collect{ |diff| diff.to_html }.join
end