diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -2011,10 +2011,14 @@ def rename(ui, repo, patch, name=None, * if r: wlock = r.wlock() try: - if r.dirstate[name] == 'r': - r.undelete([name]) - r.copy(patch, name) - r.remove([patch], False) + if r.dirstate[patch] == 'a': + r.dirstate.forget(patch) + r.dirstate.add(name) + else: + if r.dirstate[name] == 'r': + r.undelete([name]) + r.copy(patch, name) + r.remove([patch], False) finally: del wlock