Changeset 45469 in webkit


Ignore:
Timestamp:
Jul 1, 2009 11:54:37 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-07-01 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

bugzilla-tool fails for SVN users
https://bugs.webkit.org/show_bug.cgi?id=26914

To fix this I moved svn from -F - to using -m
In order for -m to work I had to move us off of shell=True
To move off of shell=True all call sites for run_command
which take args, need to pass their args as an list instead of a string.

In order for the final bug update to work correctly, I had to
abstract the way that we parse out revision numbers from the commit text.

  • Scripts/bugzilla-tool:
  • Scripts/modules/scm.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r45464 r45469  
     12009-07-01  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        bugzilla-tool fails for SVN users
     6        https://bugs.webkit.org/show_bug.cgi?id=26914
     7
     8        To fix this I moved svn from -F - to using -m
     9        In order for -m to work I had to move us off of shell=True
     10        To move off of shell=True all call sites for run_command
     11        which take args, need to pass their args as an list instead of a string.
     12
     13        In order for the final bug update to work correctly, I had to
     14        abstract the way that we parse out revision numbers from the commit text.
     15
     16        * Scripts/bugzilla-tool:
     17        * Scripts/modules/scm.py:
     18
    1192009-07-01  Eric Seidel  <eric@webkit.org>
    220
  • trunk/WebKitTools/Scripts/bugzilla-tool

    r45405 r45469  
    206206        self.apply_patches(patches, tool.scm(), options.local_commit)
    207207
    208 def bug_comment_from_commit_text(commit_text):
    209     comment_lines = []
    210     commit_lines = commit_text.splitlines()
    211     for line in commit_lines:
    212         comment_lines.append(line)
    213         match = re.match("^Committed r(\d+)$", line)
    214         if match:
    215             revision = match.group(1)
    216             comment_lines.append("http://trac.webkit.org/changeset/" + revision)
    217             break
    218     return "\n".join(comment_lines)
    219 
     208def bug_comment_from_commit_text(scm, commit_text):
     209    match = re.search(scm.commit_success_regexp(), commit_text, re.MULTILINE)
     210    svn_revision = match.group('svn_revision')
     211    commit_text += ("\nhttp://trac.webkit.org/changeset/%s" % svn_revision)
     212    return commit_text
    220213
    221214class LandAndUpdateBug(Command):
     
    318311        commit_message = commit_message_for_this_commit(scm)
    319312        commit_log = scm.commit_with_message(commit_message)
    320         return bug_comment_from_commit_text(commit_log)
     313        return bug_comment_from_commit_text(scm, commit_log)
    321314
    322315    @classmethod
  • trunk/WebKitTools/Scripts/modules/scm.py

    r45368 r45469  
    6060
    6161    @staticmethod
    62     def run_command(command, cwd=None, input=None, raise_on_failure=True, return_exit_code=False):
     62    def run_command(args, cwd=None, input=None, raise_on_failure=True, return_exit_code=False):
    6363        stdin = subprocess.PIPE if input else None
    64         process = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=stdin, shell=True, cwd=cwd)
     64        process = subprocess.Popen(args, stdout=subprocess.PIPE, stdin=stdin, cwd=cwd)
    6565        output = process.communicate(input)[0].rstrip()
    6666        exit_code = process.wait()
     
    121121        raise NotImplementedError, "subclasses must implement"
    122122
     123    @staticmethod
     124    def commit_success_regexp():
     125        raise NotImplementedError, "subclasses must implement"
     126
    123127    def working_directory_is_clean(self):
    124128        raise NotImplementedError, "subclasses must implement"
     
    147151    # Subclasses must indicate if they support local commits,
    148152    # but the SCM baseclass will only call local_commits methods when this is true.
    149     def supports_local_commits(self):
     153    @staticmethod
     154    def supports_local_commits():
    150155        raise NotImplementedError, "subclasses must implement"
    151156
     
    179184                return None
    180185   
     186    @staticmethod
     187    def commit_success_regexp():
     188        return "^Committed revision (?P<svn_revision>\d+)\.$"
     189   
    181190    def svn_version(self):
    182191        if not self.cached_version:
    183             self.cached_version = self.run_command("svn --version --quiet")
     192            self.cached_version = self.run_command(['svn', '--version', '--quiet'])
    184193       
    185194        return self.cached_version
    186195
    187196    def working_directory_is_clean(self):
    188         return self.run_command("svn diff") == ""
     197        return self.run_command(['svn', 'diff']) == ""
    189198
    190199    def clean_working_directory(self):
    191         self.run_command("svn revert -R .")
     200        self.run_command(['svn', 'revert', '-R', '.'])
    192201
    193202    def update_webkit(self):
     
    195204
    196205    def status_command(self):
    197         return 'svn status'
     206        return ['svn', 'status']
    198207
    199208    def changed_files(self):
     
    204213        return self.run_status_and_extract_filenames(self.status_command(), status_regexp)
    205214
    206     def supports_local_commits(self):
     215    @staticmethod
     216    def supports_local_commits():
    207217        return False
    208218
     
    216226        if self.dryrun:
    217227            return "Dry run, no remote commit."
    218         return self.run_command('svn commit -F -', input=message)
     228        return self.run_command(['svn', 'commit', '-m', message])
    219229
    220230# All git-specific logic should go here.
     
    225235    @classmethod
    226236    def in_working_directory(cls, path):
    227         return cls.run_command("git rev-parse --is-inside-work-tree 2>&1", cwd=path) == "true"
     237        return cls.run_command(['git', 'rev-parse', '--is-inside-work-tree'], cwd=path) == "true"
    228238
    229239    @classmethod
    230240    def find_checkout_root(cls, path):
    231241        # "git rev-parse --show-cdup" would be another way to get to the root
    232         (checkout_root, dot_git) = os.path.split(cls.run_command("git rev-parse --git-dir", cwd=path))
     242        (checkout_root, dot_git) = os.path.split(cls.run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
    233243        # If we were using 2.6 # checkout_root = os.path.relpath(checkout_root, path)
    234244        if not os.path.isabs(checkout_root): # Sometimes git returns relative paths
     
    236246        return checkout_root
    237247   
     248    @staticmethod
     249    def commit_success_regexp():
     250        return "^Committed r(?P<svn_revision>\d+)$"
     251   
    238252    def discard_local_commits(self):
    239         self.run_command("git reset --hard trunk")
     253        self.run_command(['git', 'reset', '--hard', 'trunk'])
    240254   
    241255    def local_commits(self):
    242         return self.run_command("git log --pretty=oneline head...trunk").splitlines()
    243    
     256        return self.run_command('git', 'log', '--pretty=oneline', 'HEAD...trunk').splitlines()
     257
    244258    def working_directory_is_clean(self):
    245         return self.run_command("git diff-index HEAD") == ""
     259        return self.run_command(['git', 'diff-index', 'HEAD']) == ""
    246260   
    247261    def clean_working_directory(self):
    248262        # Could run git clean here too, but that wouldn't match working_directory_is_clean
    249         self.run_command("git reset --hard HEAD")
     263        self.run_command(['git', 'reset', '--hard', 'HEAD'])
    250264   
    251265    def update_webkit(self):
    252266        # FIXME: Should probably call update-webkit, no?
    253267        log("Updating working directory")
    254         self.run_command("git svn rebase")
     268        self.run_command(['git', 'svn', 'rebase'])
    255269
    256270    def status_command(self):
    257         return 'git status'
     271        return ['git', 'status']
    258272
    259273    def changed_files(self):
    260         status_command = 'git diff -r --name-status -C -M HEAD'
     274        status_command = ['git', 'diff', '-r', '--name-status', '-C', '-M', 'HEAD']
    261275        status_regexp = '^(?P<status>[ADM])\t(?P<filename>.+)$'
    262276        return self.run_status_and_extract_filenames(status_command, status_regexp)
    263277   
    264     def supports_local_commits(self):
     278    @staticmethod
     279    def supports_local_commits():
    265280        return True
    266281
     
    269284
    270285    def create_patch(self):
    271         return self.run_command("git diff HEAD")
     286        return self.run_command(['git', 'diff', 'HEAD'])
    272287
    273288    def commit_with_message(self, message):
     
    278293   
    279294    def commit_locally_with_message(self, message):
    280         self.run_command('git commit -a -F -', input=message)
     295        self.run_command(['git', 'commit', '--all', '-F', '-'], input=message)
    281296       
    282297    def push_local_commits_to_server(self):
    283298        if self.dryrun:
    284299            return "Dry run, no remote commit."
    285         return self.run_command('git svn dcommit')
     300        return self.run_command(['git', 'svn', 'dcommit'])
    286301
    287302    def commit_ids_from_range_arguments(self, args, cherry_pick=False):
    288303        # First get the commit-ids for the passed in revisions.
    289         rev_parse_args = ['git', 'rev-parse', '--revs-only'] + args
    290         revisions = self.run_command(" ".join(rev_parse_args)).splitlines()
    291        
     304        revisions = self.run_command(['git', 'rev-parse', '--revs-only'] + args).splitlines()
     305
    292306        if cherry_pick:
    293307            return revisions
    294        
     308
    295309        # If we're not cherry picking and were only passed one revision, assume "^revision head" aka "revision..head".
    296310        if len(revisions) < 2:
    297311            revisions[0] = "^" + revisions[0]
    298312            revisions.append("HEAD")
    299        
    300         rev_list_args = ['git', 'rev-list'] + revisions
    301         return self.run_command(" ".join(rev_list_args)).splitlines()
     313
     314        return self.run_command(['git', 'rev-list'] + revisions).splitlines()
    302315
    303316    def commit_message_for_commit(self, commit_id):
    304         commit_lines = self.run_command("git cat-file commit " + commit_id).splitlines()
     317        commit_lines = self.run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
    305318
    306319        # Skip the git headers.
     
    312325        return "\n".join(commit_lines[first_line_after_headers:])
    313326
    314     def show_diff_command_for_commit(self, commit_id):
    315         return "git diff-tree -p " + commit_id
    316 
    317327    def files_changed_summary_for_commit(self, commit_id):
    318         return self.run_command("git diff-tree --shortstat --no-commit-id " + commit_id)
     328        return self.run_command(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
Note: See TracChangeset for help on using the changeset viewer.