Mercurial > public > mercurial-scm > hg
diff hgext/mq.py @ 14395:dc961471efde
mq: check patch name is valid before reading imported file
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Fri, 20 May 2011 21:19:33 +0300 |
parents | 2d16f15da7bd |
children | 170747a3e139 |
line wrap: on
line diff
--- a/hgext/mq.py Sat May 21 15:01:28 2011 -0500 +++ b/hgext/mq.py Fri May 20 21:19:33 2011 +0300 @@ -1829,11 +1829,14 @@ patchname = filename else: + if filename == '-' and not patchname: + raise util.Abort(_('need --name to import a patch from -')) + elif not patchname: + patchname = normname(os.path.basename(filename)) + self.check_reserved_name(patchname) + checkfile(patchname) try: if filename == '-': - if not patchname: - raise util.Abort( - _('need --name to import a patch from -')) text = sys.stdin.read() else: fp = url.open(self.ui, filename) @@ -1841,10 +1844,6 @@ fp.close() except (OSError, IOError): raise util.Abort(_("unable to read file %s") % filename) - if not patchname: - patchname = normname(os.path.basename(filename)) - self.check_reserved_name(patchname) - checkfile(patchname) patchf = self.opener(patchname, "w") patchf.write(text) patchf.close()