Changeset 47540 in webkit


Ignore:
Timestamp:
Aug 19, 2009 6:58:19 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-19 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

commit-queue/bugzilla-tool can get wedged if git is mid-rebase
https://bugs.webkit.org/show_bug.cgi?id=28436

Make clean_working_directory cancel rebases too (even though that's a bit of a hack).
This code will only ever be run when --force-clean is passed.

I also added a new unit test to make sure this code actually works. :)

  • Scripts/modules/scm.py:
  • Scripts/modules/scm_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r47532 r47540  
     12009-08-19  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        commit-queue/bugzilla-tool can get wedged if git is mid-rebase
     6        https://bugs.webkit.org/show_bug.cgi?id=28436
     7
     8        Make clean_working_directory cancel rebases too (even though that's a bit of a hack).
     9        This code will only ever be run when --force-clean is passed.
     10
     11        I also added a new unit test to make sure this code actually works. :)
     12
     13        * Scripts/modules/scm.py:
     14        * Scripts/modules/scm_unittest.py:
     15
    1162009-08-19  Eric Seidel  <eric@webkit.org>
    217
  • trunk/WebKitTools/Scripts/modules/scm.py

    r47345 r47540  
    287287    def __init__(self, cwd, dryrun=False):
    288288        SCM.__init__(self, cwd, dryrun)
    289    
     289
    290290    @classmethod
    291291    def in_working_directory(cls, path):
     
    311311        return self.run_command(['git', 'log', '--pretty=oneline', 'HEAD...trunk']).splitlines()
    312312
     313    def rebase_in_progress(self):
     314        return os.path.exists(os.path.join(self.checkout_root, '.git/rebase-apply'))
     315
    313316    def working_directory_is_clean(self):
    314317        return self.run_command(['git', 'diff-index', 'HEAD']) == ""
    315    
     318
    316319    def clean_working_directory(self):
    317320        # Could run git clean here too, but that wouldn't match working_directory_is_clean
    318321        self.run_command(['git', 'reset', '--hard', 'HEAD'])
    319    
     322        # Aborting rebase even though this does not match working_directory_is_clean
     323        if self.rebase_in_progress():
     324            self.run_command(['git', 'rebase', '--abort'])
     325
    320326    def update_webkit(self):
    321         # FIXME: Should probably call update-webkit, no?
     327        # FIXME: Call update-webkit once https://bugs.webkit.org/show_bug.cgi?id=27162 is fixed.
    322328        log("Updating working directory")
    323329        self.run_command(['git', 'svn', 'rebase'])
  • trunk/WebKitTools/Scripts/modules/scm_unittest.py

    r46772 r47540  
    3737# Perhaps through some SCMTest base-class which both SVNTest and GitTest inherit from.
    3838
    39 def run(args):
    40     SCM.run_command(args)
     39def run(args, cwd=None):
     40    SCM.run_command(args, cwd=cwd)
     41
     42def run_silent(args, cwd=None):
     43    process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
     44    process.communicate() # ignore output
     45    exit_code = process.wait()
     46    if exit_code:
     47        raise ScriptError('Failed to run "%s"  exit_code: %d  cwd: %s' % (args, exit_code, cwd))
     48
     49def write_into_file_at_path(file_path, contents):
     50    file = open(file_path, 'w')
     51    file.write(contents)
     52    file.close()
    4153
    4254# Exists to share svn repository creation code between the git and svn tests
     
    102114    def _setup_git_clone_of_svn_repository(self):
    103115        self.git_checkout_path = tempfile.mkdtemp(suffix="git_test_checkout")
    104         # --quiet doesn't make git svn silent, so we redirect output
    105         args = ['git', 'svn', '--quiet', 'clone', self.svn_repo_url, self.git_checkout_path]
    106         git_svn_clone = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    107         git_svn_clone.communicate() # ignore output
    108         git_svn_clone.wait()
     116        # --quiet doesn't make git svn silent, so we use run_silent to redirect output
     117        run_silent(['git', 'svn', '--quiet', 'clone', self.svn_repo_url, self.git_checkout_path])
    109118
    110119    def _tear_down_git_clone_of_svn_repository(self):
     
    125134        self.assertEqual(scm.supports_local_commits(), True)
    126135
     136    def test_rebase_in_progress(self):
     137        svn_test_file = os.path.join(self.svn_checkout_path, 'test_file')
     138        write_into_file_at_path(svn_test_file, "svn_checkout")
     139        run(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
     140
     141        git_test_file = os.path.join(self.git_checkout_path, 'test_file')
     142        write_into_file_at_path(git_test_file, "git_checkout")
     143        run(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
     144
     145        # --quiet doesn't make git svn silent, so use run_silent to redirect output
     146        self.assertRaises(ScriptError, run_silent, ['git', 'svn', '--quiet', 'rebase']) # Will fail due to a conflict leaving us mid-rebase.
     147
     148        scm = detect_scm_system(self.git_checkout_path)
     149        self.assertTrue(scm.rebase_in_progress())
     150
     151        # Make sure our cleanup works.
     152        scm.clean_working_directory()
     153        self.assertFalse(scm.rebase_in_progress())
     154
     155        # Make sure cleanup doesn't throw when no rebase is in progress.
     156        scm.clean_working_directory()
     157
    127158    def test_commitish_parsing(self):
    128159        scm = detect_scm_system(self.git_checkout_path)
    129 
     160   
    130161        # Multiple revisions are cherry-picked.
    131162        self.assertEqual(len(scm.commit_ids_from_commitish_arguments(['HEAD~2'])), 1)
    132163        self.assertEqual(len(scm.commit_ids_from_commitish_arguments(['HEAD', 'HEAD~2'])), 2)
    133 
     164   
    134165        # ... is an invalid range specifier
    135166        self.assertRaises(ScriptError, scm.commit_ids_from_commitish_arguments, ['trunk...HEAD'])
Note: See TracChangeset for help on using the changeset viewer.