Bug 1356064 - Remove the mach artifact last subcommand. r?nalexander draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 13 Apr 2017 09:47:27 +0900
changeset 561676 bdd8b0fba7edec9ce7c1863b8f96067ee3a6dfe9
parent 560921 f40e24f40b4c4556944c762d4764eace261297f5
child 561677 ea9fb4700963cbda9b4a741eb4da149296dd589b
push id53798
push userbmo:mh+mozilla@glandium.org
push dateThu, 13 Apr 2017 00:51:58 +0000
reviewersnalexander
bugs1356064, 1341205
milestone55.0a1
Bug 1356064 - Remove the mach artifact last subcommand. r?nalexander It has been broken for a while (bug 1341205).
python/mozbuild/mozbuild/artifacts.py
python/mozbuild/mozbuild/mach_commands.py
--- a/python/mozbuild/mozbuild/artifacts.py
+++ b/python/mozbuild/mozbuild/artifacts.py
@@ -576,33 +576,16 @@ class CacheManager(object):
 
     def print_cache(self):
         with self:
             for item in self._cache.items():
                 self.log(logging.INFO, 'artifact',
                     {'item': item},
                     '{item}')
 
-    def print_last_item(self, args, sorted_kwargs, result):
-        # By default, show nothing.
-        pass
-
-    def print_last(self):
-        # We use the persisted LRU caches to our advantage.  The first item is
-        # most recent.
-        with self:
-            item = next(self._cache.items(), None)
-            if item is not None:
-                (name, args, sorted_kwargs), result = item
-                self.print_last_item(args, sorted_kwargs, result)
-            else:
-                self.log(logging.WARN, 'artifact',
-                    {},
-                    'No last cached item found.')
-
     def __enter__(self):
         self.load_cache()
         return self
 
     def __exit__(self, type, value, traceback):
         self.dump_cache()
 
 class PushheadCache(CacheManager):
@@ -682,22 +665,16 @@ class TaskCache(CacheManager):
             # downloaded artifact for this.  We could also use the uploaded
             # public/build/buildprops.json for this purpose.
             url = get_artifact_url(taskId, artifact_name)
             urls.append(url)
         if not urls:
             raise ValueError('Task for {namespace} existed, but no artifacts found!'.format(namespace=namespace))
         return urls
 
-    def print_last_item(self, args, sorted_kwargs, result):
-        tree, job, rev = args
-        self.log(logging.INFO, 'artifact',
-            {'rev': rev},
-            'Last installed binaries from hg parent revision {rev}')
-
 
 class ArtifactCache(CacheManager):
     '''Fetch Task Cluster artifact URLs and purge least recently used artifacts from disk.'''
 
     def __init__(self, cache_dir, log=None, skip_cache=False):
         # TODO: instead of storing N artifact packages, store M megabytes.
         CacheManager.__init__(self, cache_dir, 'fetch', MAX_CACHED_ARTIFACTS, cache_callback=self.delete_file, log=log, skip_cache=skip_cache)
         self._cache_dir = cache_dir
@@ -763,28 +740,16 @@ class ArtifactCache(CacheManager):
             self.log(logging.INFO, 'artifact',
                 {'path': os.path.abspath(mozpath.join(self._cache_dir, fname))},
                 'Downloaded artifact to {path}')
             return os.path.abspath(mozpath.join(self._cache_dir, fname))
         finally:
             # Cancel any background downloads in progress.
             self._download_manager.cancel()
 
-    def print_last_item(self, args, sorted_kwargs, result):
-        url, = args
-        self.log(logging.INFO, 'artifact',
-            {'url': url},
-            'Last installed binaries from url {url}')
-        self.log(logging.INFO, 'artifact',
-            {'filename': result},
-            'Last installed binaries from local file {filename}')
-        self.log(logging.INFO, 'artifact',
-            {'filename': result + PROCESSED_SUFFIX},
-            'Last installed binaries from local processed file {filename}')
-
 
 class Artifacts(object):
     '''Maintain state to efficiently fetch build artifacts from a Firefox tree.'''
 
     def __init__(self, tree, substs, defines, job=None, log=None,
                  cache_dir='.', hg=None, git=None, skip_cache=False,
                  topsrcdir=None):
         if (hg and git) or (not hg and not git):
@@ -1083,24 +1048,16 @@ class Artifacts(object):
                 source = os.environ['MOZ_ARTIFACT_REVISION']
 
             if source:
                 return self.install_from_revset(source, distdir)
 
             return self.install_from_recent(distdir)
 
 
-    def print_last(self):
-        self.log(logging.INFO, 'artifact',
-            {},
-            'Printing last used artifact details.')
-        self._task_cache.print_last()
-        self._artifact_cache.print_last()
-        self._pushhead_cache.print_last()
-
     def clear_cache(self):
         self.log(logging.INFO, 'artifact',
             {},
             'Deleting cached artifacts and caches.')
         self._task_cache.clear_cache()
         self._artifact_cache.clear_cache()
         self._pushhead_cache.clear_cache()
 
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -1526,24 +1526,16 @@ class PackageFrontend(MachCommandBase):
         help='Skip all local caches to force re-fetching remote artifacts.',
         default=False)
     def artifact_install(self, source=None, skip_cache=False, tree=None, job=None, verbose=False):
         self._set_log_level(verbose)
         artifacts = self._make_artifacts(tree=tree, job=job, skip_cache=skip_cache)
 
         return artifacts.install_from(source, self.distdir)
 
-    @ArtifactSubCommand('artifact', 'last',
-        'Print the last pre-built artifact installed.')
-    def artifact_print_last(self, tree=None, job=None, verbose=False):
-        self._set_log_level(verbose)
-        artifacts = self._make_artifacts(tree=tree, job=job)
-        artifacts.print_last()
-        return 0
-
     @ArtifactSubCommand('artifact', 'print-cache',
         'Print local artifact cache for debugging.')
     def artifact_print_cache(self, tree=None, job=None, verbose=False):
         self._set_log_level(verbose)
         artifacts = self._make_artifacts(tree=tree, job=job)
         artifacts.print_cache()
         return 0