RBTools 0.3.4: Work around for Issue 1113: post-review tool cannot handle revisions with deleted files in Subversion
概要
リビジョン間の差分をレビュー依頼しようとすると、svn delete されたファイルがあるときに死ぬのをなんとかする。
patch
*** postreview.org 2011-09-27 13:19:18.000000000 +0900 --- postreview.py 2011-11-15 21:42:34.000000000 +0900 *************** *** 1753,1760 **** # This is where we decide how mangle the previous '--- ' if self.DIFF_NEW_FILE_LINE_RE.match(line): to_file, _ = self.parse_filename_header(line[4:]) ! info = self.svn_info(to_file) ! if info.has_key("Copied From URL"): url = info["Copied From URL"] root = info["Repository Root"] from_file = urllib.unquote(url[len(root):]) --- 1753,1760 ---- # This is where we decide how mangle the previous '--- ' if self.DIFF_NEW_FILE_LINE_RE.match(line): to_file, _ = self.parse_filename_header(line[4:]) ! info = self.svn_info(to_file, True) ! if info is not None and info.has_key("Copied From URL"): url = info["Copied From URL"] root = info["Repository Root"] from_file = urllib.unquote(url[len(root):]) *************** *** 1780,1785 **** --- 1780,1786 ---- for line in diff_content: front = None + orgLine = line if (self.DIFF_NEW_FILE_LINE_RE.match(line) or self.DIFF_ORIG_FILE_LINE_RE.match(line) or line.startswith('Index: ')): *************** *** 1800,1806 **** path = urllib.unquote( "%s/%s" % (repository_info.base_path, file)) else: ! info = self.svn_info(file) url = info["URL"] root = info["Repository Root"] path = urllib.unquote(url[len(root):]) --- 1801,1810 ---- path = urllib.unquote( "%s/%s" % (repository_info.base_path, file)) else: ! info = self.svn_info(file, True) ! if info is None: ! result.append(orgLine) ! continue url = info["URL"] root = info["Repository Root"] path = urllib.unquote(url[len(root):]) *************** *** 1811,1821 **** return result ! def svn_info(self, path): """Return a dict which is the result of 'svn info' at a given path.""" svninfo = {} ! for info in execute(["svn", "info", path], ! split_lines=True): parts = info.strip().split(": ", 1) if len(parts) == 2: key, value = parts --- 1815,1833 ---- return result ! def svn_info(self, path, ignore_errors=False): """Return a dict which is the result of 'svn info' at a given path.""" svninfo = {} ! ! executeResult = execute(["svn", "info", path], ! split_lines=True, ! ignore_errors=ignore_errors, ! none_on_ignored_error=True) ! ! if executeResult is None: ! return None ! ! for info in executeResult: parts = info.strip().split(": ", 1) if len(parts) == 2: key, value = parts *************** *** 3494,3500 **** def execute(command, env=None, split_lines=False, ignore_errors=False, ! extra_ignore_errors=(), translate_newlines=True, with_errors=True): """ Utility function to execute a command and return the output. """ --- 3506,3513 ---- def execute(command, env=None, split_lines=False, ignore_errors=False, ! extra_ignore_errors=(), translate_newlines=True, with_errors=True, ! none_on_ignored_error=False): """ Utility function to execute a command and return the output. """ *************** *** 3540,3545 **** --- 3553,3560 ---- rc = p.wait() if rc and not ignore_errors and rc not in extra_ignore_errors: die('Failed to execute command: %s\n%s' % (command, data)) + if rc and none_on_ignored_error: + return None return data