Why wouldt it work i mean if its done in one chunk its undone in one chunk. Just as long as the command that goes into maya undo queue is one item. Ie one call to function or a single script its then undone in exact same chunk one go.
See mayas undo works on mel, so as long as its one call in mel, its one undo in mel. In api the added hardness is that you must implement the reverse operation yourself.
So maya will undo it in one chunk as long as you dont put more stuff into the undo queue.