Code mistakenly removed from the core classes

This commit is contained in:
Thomas Nagy 2012-09-26 18:41:58 +02:00
parent ab385ea63c
commit c14f00f4c1
4 changed files with 21 additions and 0 deletions

View File

@ -1,3 +1,7 @@
NEW IN WAF 1.7.4
----------------
* Fixed a regression in the Node,Task and Context classes
NEW IN WAF 1.7.3
-----------------
* Fixed the LD_LIBRARY_PATH race condition in waf_unit_test #1200

View File

@ -182,6 +182,15 @@ class Context(ctx):
self.exec_dict = {'ctx':self, 'conf':self, 'bld':self, 'opt':self}
self.logger = None
def __hash__(self):
"""
Return a hash value for storing context objects in dicts or sets. The value is not persistent.
:return: hash value
:rtype: int
"""
return id(self)
def load(self, tool_list, *k, **kw):
"""
Load a Waf tool as a module, and try calling the function named :py:const:`waflib.Context.Context.fun` from it.

View File

@ -130,6 +130,10 @@ class Node(object):
"String representation (abspath), for debugging purposes"
return self.abspath()
def __hash__(self):
"Node hash, used for storage in dicts. This hash is not persistent."
return id(self)
def __eq__(self, node):
"Node comparison, based on the IDs"
return id(self) == id(node)

View File

@ -190,6 +190,10 @@ class TaskBase(evil):
return 'executing: %s\n' % self.fun.__name__
return self.__class__.__name__ + '\n'
def __hash__(self):
"Very fast hashing scheme but not persistent (replace/implement in subclasses and see :py:meth:`waflib.Task.Task.uid`)"
return id(self)
def exec_command(self, cmd, **kw):
"""
Wrapper for :py:meth:`waflib.Context.Context.exec_command` which sets a current working directory to ``build.variant_dir``