# HG changeset patch # User Nicolas Dumazet # Date 1279680789 -32400 # Node ID da0b9109186d542e2cca60f3a044d73545abadd7 # Parent 9df481f8036d0c5bbc3050ee4e457e13465c881e 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 diff -r 9df481f8036d -r da0b9109186d hgext/mq.py --- 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 == '-': diff -r 9df481f8036d -r da0b9109186d tests/test-mq-qimport --- 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 diff -r 9df481f8036d -r da0b9109186d tests/test-mq-qimport.out --- 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