From bb930461cee056de210816e58c36a8d6dfd122be Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 25 Feb 2020 15:18:31 -0500 Subject: subcmds: stop instantiating at import time The current subcmds design has singletons in all_commands. This isn't exactly unusual, but the fact that our main & help subcommand will then attach members to the classes before invoking them is. This makes it hard to keep track of what members a command has access to, and the two code paths (main & help) attach different members depending on what APIs they then invoke. Lets pull this back a step by storing classes in all_commands and leave the instantiation step to when they're used. This doesn't fully clean up the confusion, but gets us closer. Change-Id: I6a768ff97fe541e6f3228358dba04ed66c4b070a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259154 Tested-by: Mike Frysinger Reviewed-by: David Pursehouse --- subcmds/version.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'subcmds/version.py') diff --git a/subcmds/version.py b/subcmds/version.py index 91dbe68f..8721bf49 100644 --- a/subcmds/version.py +++ b/subcmds/version.py @@ -44,9 +44,9 @@ class Version(Command, MirrorSafeCommand): print('repo version %s' % rp_ver) print(' (from %s)' % rem.url) - if Version.wrapper_path is not None: - print('repo launcher version %s' % Version.wrapper_version) - print(' (from %s)' % Version.wrapper_path) + if self.wrapper_path is not None: + print('repo launcher version %s' % self.wrapper_version) + print(' (from %s)' % self.wrapper_path) if src_ver != rp_ver: print(' (currently at %s)' % src_ver) -- cgit v1.2.3-54-g00ecf