[PATCH 4 of 4] dicthelpers: delete now that they are no longer used

Augie Fackler raf at durin42.com
Wed Oct 15 13:23:00 CDT 2014


On Wed, Oct 15, 2014 at 12:02:49AM -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at gmail.com>
> # Date 1413356015 25200
> #      Tue Oct 14 23:53:35 2014 -0700
> # Node ID 486b01711d45611ce9cb35efce667f939919247e
> # Parent  d57d01770688805015bbf991c43b9faf37396d61
> dicthelpers: delete now that they are no longer used

Series LGTM. Does anyone else want eyes on it before I push it?

>
> diff --git a/mercurial/dicthelpers.py b/mercurial/dicthelpers.py
> deleted file mode 100644
> --- a/mercurial/dicthelpers.py
> +++ /dev/null
> @@ -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
> diff --git a/tests/test-dicthelpers.py b/tests/test-dicthelpers.py
> deleted file mode 100644
> --- a/tests/test-dicthelpers.py
> +++ /dev/null
> @@ -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__)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list