##// END OF EJS Templates
mq: check patch name is valid before reading imported file
Idan Kamara -
r14395:dc961471 default
parent child Browse files
Show More
@@ -1829,11 +1829,14 b' class queue(object):'
1829 1829 patchname = filename
1830 1830
1831 1831 else:
1832 if filename == '-' and not patchname:
1833 raise util.Abort(_('need --name to import a patch from -'))
1834 elif not patchname:
1835 patchname = normname(os.path.basename(filename))
1836 self.check_reserved_name(patchname)
1837 checkfile(patchname)
1832 1838 try:
1833 1839 if filename == '-':
1834 if not patchname:
1835 raise util.Abort(
1836 _('need --name to import a patch from -'))
1837 1840 text = sys.stdin.read()
1838 1841 else:
1839 1842 fp = url.open(self.ui, filename)
@@ -1841,10 +1844,6 b' class queue(object):'
1841 1844 fp.close()
1842 1845 except (OSError, IOError):
1843 1846 raise util.Abort(_("unable to read file %s") % filename)
1844 if not patchname:
1845 patchname = normname(os.path.basename(filename))
1846 self.check_reserved_name(patchname)
1847 checkfile(patchname)
1848 1847 patchf = self.opener(patchname, "w")
1849 1848 patchf.write(text)
1850 1849 patchf.close()
@@ -202,3 +202,9 b' qimport -e --name with --force'
202 202 $ hg qser
203 203 this-name-is-better
204 204 url.diff
205
206 qimport with bad name, should abort before reading file
207
208 $ hg qimport non-existant-file --name .hg
209 abort: patch name cannot begin with ".hg"
210 [255]
General Comments 0
You need to be logged in to leave comments. Login now