From 0f645b68a37ea0d494f578d1ff779f4a3ea6423a Mon Sep 17 00:00:00 2001 From: "epoger@google.com" Date: Tue, 22 May 2012 19:14:01 +0000 Subject: [PATCH] download_baselines.py : only set svn properties of files whose content has changed and while I was at it, sort the filenames before acting on them, to make the output easier to read BUG=http://code.google.com/p/skia/issues/detail?id=618 Review URL: https://codereview.appspot.com/6223061 git-svn-id: http://skia.googlecode.com/svn/trunk@4031 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/download_baselines.py | 26 +++++++++++++++----------- tools/svn.py | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/download_baselines.py b/tools/download_baselines.py index 59069e9..4a4f6c9 100644 --- a/tools/download_baselines.py +++ b/tools/download_baselines.py @@ -108,17 +108,21 @@ def DownloadBaselinesForOnePlatform(baseline_subdir): download_repo = None # Add any new files to SVN control (if we are running with add_new_files). - new_files = repo_to_modify.GetNewFiles() - if new_files and options.add_new_files: - repo_to_modify.AddFiles(new_files) - - # Set the mimetype property on *all* image files in baseline_subdir, even - # the ones that were already there (in case that property wasn't properly - # set already). - repo_to_modify.SetPropertyByFilenamePattern( - '*.png', svn.PROPERTY_MIMETYPE, 'image/png') - repo_to_modify.SetPropertyByFilenamePattern( - '*.pdf', svn.PROPERTY_MIMETYPE, 'application/pdf') + if options.add_new_files: + new_files = repo_to_modify.GetNewFiles() + if new_files: + repo_to_modify.AddFiles(sorted(new_files)) + + # Set the mimetype property on any new/modified image files in + # baseline_subdir. (We used to set the mimetype property on *all* image + # files in the directory, even those whose content wasn't changing, + # but that caused confusion. See + # http://code.google.com/p/skia/issues/detail?id=618 .) + modified_files = repo_to_modify.GetNewAndModifiedFiles() + repo_to_modify.SetProperty(sorted(fnmatch.filter(modified_files, '*.png')), + svn.PROPERTY_MIMETYPE, 'image/png') + repo_to_modify.SetProperty(sorted(fnmatch.filter(modified_files, '*.pdf')), + svn.PROPERTY_MIMETYPE, 'application/pdf') def RaiseUsageException(): raise Exception('%s\nRun with --help for more detail.' % ( diff --git a/tools/svn.py b/tools/svn.py index b2f010c..1fd1120 100644 --- a/tools/svn.py +++ b/tools/svn.py @@ -92,5 +92,5 @@ class Svn: @param property_value what to set the property_name to """ all_files = os.listdir(self._directory) - matching_files = fnmatch.filter(all_files, filename_pattern) + matching_files = sorted(fnmatch.filter(all_files, filename_pattern)) self.SetProperty(matching_files, property_name, property_value) -- 2.7.4