Mercurial > hg-stable
changeset 11699:da0b9109186d
mq: support "qimport --existing --name renametothis thatexistingpatch"
Before this change, the command would abort with a not too clear "patch
renametothis does not exist" error.
This change makes:
qimport --existing --name renametothis thatexistingpatch
equivalent to:
qimport --existing thatexistingpatch; qrename thatexistingpatch renametothis
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Wed, 21 Jul 2010 11:53:09 +0900 |
parents | 9df481f8036d |
children | 52c863295754 |
files | hgext/mq.py tests/test-mq-qimport tests/test-mq-qimport.out |
diffstat | 3 files changed, 34 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Sat Jul 24 00:28:20 2010 +0900 +++ b/hgext/mq.py Wed Jul 21 11:53:09 2010 +0900 @@ -1687,11 +1687,22 @@ if existing: if filename == '-': raise util.Abort(_('-e is incompatible with import from -')) - if not patchname: - patchname = normname(filename) - self.check_reserved_name(patchname) - if not os.path.isfile(self.join(patchname)): - raise util.Abort(_("patch %s does not exist") % patchname) + filename = normname(filename) + self.check_reserved_name(filename) + originpath = self.join(filename) + if not os.path.isfile(originpath): + raise util.Abort(_("patch %s does not exist") % filename) + + if patchname: + self.check_reserved_name(patchname) + checkfile(patchname) + + self.ui.write(_('renaming %s to %s\n') + % (filename, patchname)) + os.rename(originpath, self.join(patchname)) + else: + patchname = filename + else: try: if filename == '-':
--- a/tests/test-mq-qimport Sat Jul 24 00:28:20 2010 +0900 +++ b/tests/test-mq-qimport Wed Jul 21 11:53:09 2010 +0900 @@ -109,3 +109,12 @@ hg qimport --push another.diff hg qfin -a hg qimport -rtip -P + +hg qpop -a +hg qdel -k 2.diff +echo % qimport -e +hg qimport -e 2.diff +hg qdel -k 2.diff +echo % qimport -e --name newname oldexisitingpatch +hg qimport -e --name this-name-is-better 2.diff +hg qser
--- a/tests/test-mq-qimport.out Sat Jul 24 00:28:20 2010 +0900 +++ b/tests/test-mq-qimport.out Wed Jul 21 11:53:09 2010 +0900 @@ -52,3 +52,12 @@ now at: another.diff patch b.diff finalized without changeset message patch another.diff finalized without changeset message +popping 2.diff +patch queue now empty +% qimport -e +adding 2.diff to series file +% qimport -e --name newname oldexisitingpatch +renaming 2.diff to this-name-is-better +adding this-name-is-better to series file +this-name-is-better +url.diff