def SetReferenceControls(controls, refControls):
    """Set the reference controls for the controls passed in

    This does some minor checking as following:
     * test that there are the same number of reference controls as
       controls - fails with an exception if there are not
     * test if all the ID's are the same or not
    """
    if len(controls) != len(refControls):
        raise RuntimeError(
            'Numbers of controls on ref. dialog does not match Loc. dialog')
    for i, ctrl in enumerate(controls):
        ctrl.ref = refControls[i]
    toRet = 1
    allIDsSameFlag = 2
    allClassesSameFlag = 4
    if [ctrl.control_id() for ctrl in controls] == [ctrl.control_id() for
        ctrl in refControls]:
        toRet += allIDsSameFlag
    if [ctrl.class_name() for ctrl in controls] == [ctrl.class_name() for
        ctrl in refControls]:
        toRet += allClassesSameFlag
    return toRet
