join: Refactor clone_only case to simplify code
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 11 Jun 2018 04:33:19 +0000 (16:33 +1200)
committerGary Lockyer <gary@samba.org>
Tue, 3 Jul 2018 03:24:14 +0000 (05:24 +0200)
commit3230c345da33a6ebd444791d04df5e0e408102dd
treeea024b5e4e9ac1483e66b904af3c3a002abd4462
parent3ee38df87d7a75ac72400c8f95d84e0622e074f5
join: Refactor clone_only case to simplify code

Currently for DC clones, we create a regular DCJoinContext, se a
'clone_only' flag, and then make lots of special checks for this flag
throughout the code. Instead, we can use inheritance to create a
DCCloneContext sub-class, and put the specialization there.

This means we can remove all the 'clone_only' checks from the code. The
only 2 methods that really differ are do_join() and join_finalize(), and
these don't share much code at all. (To avoid duplication, I split the
first part of do_join() into a new build_nc_lists() function, but this
is a pretty trivial code move).

We still pass the clone_only flag into the __init__() as there's still
one case where we want to avoid doing work in the case of the clone.
For clarity, I'll refactor this in a subsequent patch.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
python/samba/join.py