diff --git a/python/eups/app.py b/python/eups/app.py index 5185c37b..419ada2b 100644 --- a/python/eups/app.py +++ b/python/eups/app.py @@ -18,7 +18,7 @@ from .utils import cmp_or_key def printProducts(ostrm, productName=None, versionName=None, eupsenv=None, - tags=None, setup=False, tablefile=False, directory=False, + tags=None, setup=False, tablefile=False, difference=False, directory=False, dependencies=False, showVersion=False, showName=False, showTagsGlob="*", depth=None, productDir=None, topological=False, checkCycles=False, raw=False): """ @@ -32,6 +32,8 @@ def printProducts(ostrm, productName=None, versionName=None, eupsenv=None, @param setup restrict the listing to products that are currently setup (or print actually setup versions with dependencies) @param tablefile include the path to each product's table file + @param difference Print the relative complement (set difference) of declared version + products to setup products @param directory include each product's installation directory @param dependencies print the product's dependencies @param showVersion Only print the product{'s,s'} version[s] (e.g. eups list -V -s afw) @@ -97,7 +99,25 @@ def printProducts(ostrm, productName=None, versionName=None, eupsenv=None, raise ProductNotFound(productName, versionName, msg="Unable to find product %s" % msg) + if difference: + if versionName: + raise EupsException("--diff does not make sense with a version") + if dependencies: + raise EupsException("--diff does not make sense with --dependencies") + setupProducts = set(eupsenv.getSetupProducts()) + dependentProductList = eupsenv.getDependentProducts(productList[0]) + dependentProducts = {x[0] for x in dependentProductList} + productList = list(setupProducts - dependentProducts) + if not productList: + return 0 + productList.sort(key=lambda p: (p.name, p.version)) + + if difference: + # Insert the main product name at the front of the list, to be printed first + productNameIndex = [i for i, p in enumerate(productList) if p.name == productName][0] + productList.insert(0, productList.pop(productList.index(productList[productNameIndex]))) + if dependencies: _msgs = {} # maintain list of printed dependencies recursionDepth, indent = 0, "" @@ -249,7 +269,7 @@ def includeProduct(recursionDepth): info += "|" info += name + "|" + version else: - if productName and not utils.isGlob(productName): + if productName and not utils.isGlob(productName) and not difference: info += " " else: info += "%-21s " % (name) diff --git a/python/eups/cmd.py b/python/eups/cmd.py index d26d6e13..c658938f 100644 --- a/python/eups/cmd.py +++ b/python/eups/cmd.py @@ -455,6 +455,8 @@ def addOptions(self): # these are specific to this command self.clo.add_option("-c", "--current", dest="currentTag", action="store_true", default=False, help="same as --postTag=current") + self.clo.add_option("-C", "--diff", dest="difference", action="store_true", default=False, + help="Print the relative complement (set difference) of declared version products with respect to currently setup products") self.clo.add_option("-D", "--dependencies", dest="depends", action="store_true", default=False, help="Print product's dependencies (must specify version if ambiguous). With --setup print the versions of dependent products that are actually setup.") self.clo.add_option("--depth", dest="depth", action="store", @@ -506,8 +508,9 @@ def execute(self): n = eups.printProducts(sys.stdout, product, version, self.createEups(self.opts, versionName=version, quiet=1), tags=self.opts.tag, - setup=self.opts.setup, + setup=self.opts.setup or self.opts.difference, tablefile=self.opts.tablefile, + difference=self.opts.difference, directory=self.opts.printdir, dependencies=self.opts.depends, showVersion=self.opts.version, showName=self.opts.showName,