Locks or unlocks the file

        :param lock: Lock or unlock the file
        :type lock: bool
        :param changelist: Optional changelist to checkout the file into
        :type changelist: :class:`.Changelist`

def lock(self, lock=True, changelist=0):
        """Locks or unlocks the file

        :param lock: Lock or unlock the file
        :type lock: bool
        :param changelist: Optional changelist to checkout the file into
        :type changelist: :class:`.Changelist`
        """

        cmd = 'lock' if lock else 'unlock'
        if changelist:
            self._connection.run([cmd, '-c', changelist, self.depotFile])
        else:
            self._connection.run([cmd, self.depotFile])

        self.query()