Make post-review work on machine configured in non english locale
Updated 6 months, 1 week ago
| Xavier Duret | Reviewers | ||
| reviewboard | |||
| None | Review Board SVN | ||
The client side "post-review" script does not work when used on a machine configured as a non English locale. This is due to the fact that the tool parses the output of the subversion commands which is not necessarily written in English. This patch makes sure the subversion command is called with the proper locale. This patch affect only subversion but it is possible that other revision control tools also need it.
Tested on a machine with locale "en_US.UTF-8" and a machine with locale "es_ES.UTF-8".
| trunk/reviewboard/contrib/tools/post-review | |||
|---|---|---|---|
| Revision 1389 | New Change | ||
| ... | 563 lines hidden [Expand] | ||
| 564 | """ |
564 | """ |
| 565 | def get_repository_info(self): |
565 | def get_repository_info(self): |
| 566 | if not check_install('svn help'): |
566 | if not check_install('svn help'): |
| 567 | return None |
567 | return None |
| 568 | 568 | ||
| 569 | data = execute('svn info', ignore_errors=True) |
569 | data = execute('env LANG=en_US.UTF-8 svn info', ignore_errors=True) |
| 570 | 570 | ||
| 571 | m = re.search(r'^Repository Root: (.+)$', data, re.M) |
571 | m = re.search(r'^Repository Root: (.+)$', data, re.M) |
| 572 | if not m: |
572 | if not m: |
| 573 | return None |
573 | return None |
| 574 | 574 | ||
| ... | 22 lines hidden [Expand] | ||
| 597 | 597 | ||
| 598 | return self.scan_for_server_property(repository_info) |
598 | return self.scan_for_server_property(repository_info) |
| 599 | 599 | ||
| 600 | def scan_for_server_property(self, repository_info): |
600 | def scan_for_server_property(self, repository_info): |
| 601 | def get_url_prop(path): |
601 | def get_url_prop(path): |
| 602 | url = execute("svn propget reviewboard:url %s" % path).strip() |
602 | url = execute("env LANG=en_US.UTF-8 svn propget reviewboard:url %s" % path).strip() |
| 603 | return url or None |
603 | return url or None |
| 604 | 604 | ||
| 605 | for path in walk_parents(os.getcwd()): |
605 | for path in walk_parents(os.getcwd()): |
| 606 | if not os.path.exists(os.path.join(path, ".svn")): |
606 | if not os.path.exists(os.path.join(path, ".svn")): |
| 607 | break |
607 | break |
| ... | 10 lines hidden [Expand] | ||
| 618 | 618 | ||
| 619 | SVN repositories do not support branches of branches in a way that |
619 | SVN repositories do not support branches of branches in a way that |
| 620 | makes parent diffs possible, so we never return a parent diff |
620 | makes parent diffs possible, so we never return a parent diff |
| 621 | (the second value in the tuple). |
621 | (the second value in the tuple). |
| 622 | """ |
622 | """ |
| 623 | return (self.do_diff('svn diff --diff-cmd=diff %s' % ' '.join(files)), |
623 | return (self.do_diff('env LANG=en_US.UTF-8 svn diff --diff-cmd=diff %s' % ' '.join(files)), |
| 624 | None) |
624 | None) |
| 625 | 625 | ||
| 626 | def diff_between_revisions(self, revision_range): |
626 | def diff_between_revisions(self, revision_range): |
| 627 | """ |
627 | """ |
| 628 | Performs a diff between 2 revisions of a Subversion repository. |
628 | Performs a diff between 2 revisions of a Subversion repository. |
| 629 | """ |
629 | """ |
| 630 | return self.do_diff('svn diff --diff-cmd=diff -r %s' % revision_range) |
630 | return self.do_diff('env LANG=en_US.UTF-8 svn diff --diff-cmd=diff -r %s' % revision_range) |
| 631 | 631 | ||
| 632 | def do_diff(self, cmd): |
632 | def do_diff(self, cmd): |
| 633 | """ |
633 | """ |
| 634 | Performs the actual diff operation, handling renames and converting |
634 | Performs the actual diff operation, handling renames and converting |
| 635 | paths to absolute. |
635 | paths to absolute. |
| ... | 73 lines hidden [Expand] | ||
| 709 | return result |
709 | return result |
| 710 | 710 | ||
| 711 | def svn_info(self, path): |
711 | def svn_info(self, path): |
| 712 | """Return a dict which is the result of 'svn info' at a given path.""" |
712 | """Return a dict which is the result of 'svn info' at a given path.""" |
| 713 | svninfo = {} |
713 | svninfo = {} |
| 714 | for info in execute("svn info " + path).splitlines(): |
714 | for info in execute("env LANG=en_US.UTF-8 svn info " + path).splitlines(): |
| 715 | parts = info.split(": ", 1) |
715 | parts = info.split(": ", 1) |
| 716 | if len(parts) == 2: |
716 | if len(parts) == 2: |
| 717 | key, value = parts |
717 | key, value = parts |
| 718 | svninfo[key] = value |
718 | svninfo[key] = value |
| 719 | 719 | ||
| ... | 841 lines hidden [Expand] | ||
Other reviews