From f93a719a100b92f473d1b07a20ed71bb4566e51b Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 15 Aug 2013 20:03:31 +0000 Subject: [PATCH] No longer check for new git-review releases * git-review(latest_is_newer,main,print_exit_message) (update_latest_version): The git-review tool is now being packaged actively by most operating systems/distributions popular amongst the current user base, and has been stable without serious usability bugs for some time. As a result, the expectation is that most users are now installing from places other than PyPI and so the somewhat hackish functions which check for and warn users about the existence of new releases have outlived their usefulness. Removing them to pave the way for continued ease of maintainability improvements, and also to be one less annoying thing packagers and users have to disable downstream. Closes-Bug: 1212829 Change-Id: I9d2ddea794f2b53d4137f0916de4afa029120f59 --- git-review | 68 +++--------------------------------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/git-review b/git-review index 4bd4cec8..e7557f5b 100755 --- a/git-review +++ b/git-review @@ -26,7 +26,6 @@ import shlex import subprocess import sys import textwrap -import time if sys.version < '3': import ConfigParser @@ -43,8 +42,6 @@ else: urlparse = urllib.parse.urlparse do_input = input -from distutils import version as du_version - version = "1.23" VERBOSE = False @@ -148,48 +145,6 @@ def run_command_exc(klazz, *argv, **env): return output -def update_latest_version(version_file_path): - """Cache the latest version of git-review for the upgrade check.""" - - if not os.path.exists(CONFIGDIR): - os.makedirs(CONFIGDIR) - - if os.path.exists(version_file_path) and not UPDATE: - if (time.time() - os.path.getmtime(version_file_path)) < 28800: - return - - latest_version = version - try: - latest_version = json.load(urlopen(PYPI_URL))['info']['version'] - except Exception: - pass - - with open(version_file_path, "w") as version_file: - version_file.write(latest_version) - - -def latest_is_newer(): - """Check if there is a new version of git-review.""" - - # Skip version check if distro package turns it off - if os.path.exists(GLOBAL_CONFIG): - config = dict(check=False) - configParser = ConfigParser.ConfigParser(config) - configParser.read(GLOBAL_CONFIG) - if not configParser.getboolean("updates", "check"): - return False - - version_file_path = os.path.join(CONFIGDIR, "latest-version") - update_latest_version(version_file_path) - - latest_version = None - with open(version_file_path, "r") as version_file: - latest_version = du_version.StrictVersion(version_file.read()) - if latest_version > du_version.StrictVersion(version): - return True - return False - - def git_directories(): """Determine (absolute git work directory path, .git subdirectory path).""" cmd = ("git", "rev-parse", "--show-toplevel", "--git-dir") @@ -953,22 +908,6 @@ def convert_bool(one_or_zero): return one_or_zero in ["1", "true", "True"] -def print_exit_message(status, needs_update): - - if needs_update: - print(""" -*********************************************************** -A new version of git-review is available on PyPI. Please -update your copy with: - - pip install -U git-review - -to ensure proper behavior with gerrit. Thanks! -*********************************************************** -""") - sys.exit(status) - - def main(): usage = "git review [OPTIONS] ... [BRANCH]" @@ -1105,7 +1044,6 @@ def main(): yes = options.yes status = 0 - needs_update = latest_is_newer() check_remote(branch, remote, config['hostname'], config['port'], config['project']) @@ -1145,9 +1083,9 @@ def main(): if options.rebase: if not rebase_changes(branch, remote): - print_exit_message(1, needs_update) + sys.exit(1) if not options.force_rebase and not undo_rebase(): - print_exit_message(1, needs_update) + sys.exit(1) assert_one_change(remote, branch, yes, have_hook) ref = "publish" @@ -1188,7 +1126,7 @@ def main(): if options.custom_script: run_custom_script("post") - print_exit_message(status, needs_update) + sys.exit(status) if __name__ == "__main__":