changeset 22967:a42d67c16fb9

dicthelpers: delete now that they are no longer used
author Martin von Zweigbergk <martinvonz@gmail.com>
date Tue, 14 Oct 2014 23:53:35 -0700
parents ff93aa006e6a
children 01e98eba3bc1
files mercurial/dicthelpers.py tests/test-dicthelpers.py
diffstat 2 files changed, 0 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dicthelpers.py	Tue Oct 14 23:18:07 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-# dicthelpers.py - helper routines for Python dicts
-#
-# Copyright 2013 Facebook
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-def diff(d1, d2, default=None):
-    '''Return all key-value pairs that are different between d1 and d2.
-
-    This includes keys that are present in one dict but not the other, and
-    keys whose values are different. The return value is a dict with values
-    being pairs of values from d1 and d2 respectively, and missing values
-    treated as default, so if a value is missing from one dict and the same as
-    default in the other, it will not be returned.'''
-    res = {}
-    if d1 is d2:
-        # same dict, so diff is empty
-        return res
-
-    for k1, v1 in d1.iteritems():
-        v2 = d2.get(k1, default)
-        if v1 != v2:
-            res[k1] = (v1, v2)
-
-    for k2 in d2:
-        if k2 not in d1:
-            v2 = d2[k2]
-            if v2 != default:
-                res[k2] = (default, v2)
-
-    return res
-
-def join(d1, d2, default=None):
-    '''Return all key-value pairs from both d1 and d2.
-
-    This is akin to an outer join in relational algebra. The return value is a
-    dict with values being pairs of values from d1 and d2 respectively, and
-    missing values represented as default.'''
-    res = {}
-
-    for k1, v1 in d1.iteritems():
-        if k1 in d2:
-            res[k1] = (v1, d2[k1])
-        else:
-            res[k1] = (v1, default)
-
-    if d1 is d2:
-        return res
-
-    for k2 in d2:
-        if k2 not in d1:
-            res[k2] = (default, d2[k2])
-
-    return res
--- a/tests/test-dicthelpers.py	Tue Oct 14 23:18:07 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-from mercurial.dicthelpers import diff, join
-import unittest
-import silenttestrunner
-
-class testdicthelpers(unittest.TestCase):
-    def test_dicthelpers(self):
-        # empty dicts
-        self.assertEqual(diff({}, {}), {})
-        self.assertEqual(join({}, {}), {})
-
-        d1 = {}
-        d1['a'] = 'foo'
-        d1['b'] = 'bar'
-        d1['c'] = 'baz'
-
-        # same identity
-        self.assertEqual(diff(d1, d1), {})
-        self.assertEqual(join(d1, d1), {'a': ('foo', 'foo'),
-                                        'b': ('bar', 'bar'),
-                                        'c': ('baz', 'baz')})
-
-        # vs empty
-        self.assertEqual(diff(d1, {}), {'a': ('foo', None),
-                                        'b': ('bar', None),
-                                        'c': ('baz', None)})
-        self.assertEqual(diff(d1, {}), {'a': ('foo', None),
-                                        'b': ('bar', None),
-                                        'c': ('baz', None)})
-
-        d2 = {}
-        d2['a'] = 'foo2'
-        d2['b'] = 'bar'
-        d2['d'] = 'quux'
-
-        self.assertEqual(diff(d1, d2), {'a': ('foo', 'foo2'),
-                                        'c': ('baz', None),
-                                        'd': (None, 'quux')})
-        self.assertEqual(join(d1, d2), {'a': ('foo', 'foo2'),
-                                        'b': ('bar', 'bar'),
-                                        'c': ('baz', None),
-                                        'd': (None, 'quux')})
-
-        # with default argument
-        self.assertEqual(diff(d1, d2, 123), {'a': ('foo', 'foo2'),
-                                             'c': ('baz', 123),
-                                             'd': (123, 'quux')})
-        self.assertEqual(join(d1, d2, 456), {'a': ('foo', 'foo2'),
-                                             'b': ('bar', 'bar'),
-                                             'c': ('baz', 456),
-                                             'd': (456, 'quux')})
-
-        # check that we compare against default
-        self.assertEqual(diff(d1, d2, 'baz'), {'a': ('foo', 'foo2'),
-                                               'd': ('baz', 'quux')})
-        self.assertEqual(diff(d1, d2, 'quux'), {'a': ('foo', 'foo2'),
-                                                'c': ('baz', 'quux')})
-
-if __name__ == '__main__':
-    silenttestrunner.main(__name__)