Show More
@@ -600,9 +600,17 b' class queue:' | |||||
600 | raise util.Abort(_("local changes found")) |
|
600 | raise util.Abort(_("local changes found")) | |
601 | return m, a, r, d |
|
601 | return m, a, r, d | |
602 |
|
602 | |||
|
603 | _reserved = ('series', 'status', 'guards') | |||
|
604 | def check_reserved_name(self, name): | |||
|
605 | if (name in self._reserved or name.startswith('.hg') | |||
|
606 | or name.startswith('.mq')): | |||
|
607 | raise util.Abort(_('"%s" cannot be used as the name of a patch') | |||
|
608 | % name) | |||
|
609 | ||||
603 | def new(self, repo, patch, *pats, **opts): |
|
610 | def new(self, repo, patch, *pats, **opts): | |
604 | msg = opts.get('msg') |
|
611 | msg = opts.get('msg') | |
605 | force = opts.get('force') |
|
612 | force = opts.get('force') | |
|
613 | self.check_reserved_name(patch) | |||
606 | if os.path.exists(self.join(patch)): |
|
614 | if os.path.exists(self.join(patch)): | |
607 | raise util.Abort(_('patch "%s" already exists') % patch) |
|
615 | raise util.Abort(_('patch "%s" already exists') % patch) | |
608 | if opts.get('include') or opts.get('exclude') or pats: |
|
616 | if opts.get('include') or opts.get('exclude') or pats: | |
@@ -1372,6 +1380,7 b' class queue:' | |||||
1372 |
|
1380 | |||
1373 | if not patchname: |
|
1381 | if not patchname: | |
1374 | patchname = normname('%d.diff' % r) |
|
1382 | patchname = normname('%d.diff' % r) | |
|
1383 | self.check_reserved_name(patchname) | |||
1375 | checkseries(patchname) |
|
1384 | checkseries(patchname) | |
1376 | checkfile(patchname) |
|
1385 | checkfile(patchname) | |
1377 | self.full_series.insert(0, patchname) |
|
1386 | self.full_series.insert(0, patchname) | |
@@ -1394,6 +1403,7 b' class queue:' | |||||
1394 | raise util.Abort(_('-e is incompatible with import from -')) |
|
1403 | raise util.Abort(_('-e is incompatible with import from -')) | |
1395 | if not patchname: |
|
1404 | if not patchname: | |
1396 | patchname = normname(filename) |
|
1405 | patchname = normname(filename) | |
|
1406 | self.check_reserved_name(patchname) | |||
1397 | if not os.path.isfile(self.join(patchname)): |
|
1407 | if not os.path.isfile(self.join(patchname)): | |
1398 | raise util.Abort(_("patch %s does not exist") % patchname) |
|
1408 | raise util.Abort(_("patch %s does not exist") % patchname) | |
1399 | else: |
|
1409 | else: | |
@@ -1408,6 +1418,7 b' class queue:' | |||||
1408 | raise util.Abort(_("unable to read %s") % patchname) |
|
1418 | raise util.Abort(_("unable to read %s") % patchname) | |
1409 | if not patchname: |
|
1419 | if not patchname: | |
1410 | patchname = normname(os.path.basename(filename)) |
|
1420 | patchname = normname(os.path.basename(filename)) | |
|
1421 | self.check_reserved_name(patchname) | |||
1411 | checkfile(patchname) |
|
1422 | checkfile(patchname) | |
1412 | patchf = self.opener(patchname, "w") |
|
1423 | patchf = self.opener(patchname, "w") | |
1413 | patchf.write(text) |
|
1424 | patchf.write(text) |
@@ -42,6 +42,12 b' echo % qinit -c' | |||||
42 | hg --cwd c qinit -c |
|
42 | hg --cwd c qinit -c | |
43 | hg -R c/.hg/patches st |
|
43 | hg -R c/.hg/patches st | |
44 |
|
44 | |||
|
45 | echo % qnew should refuse bad patch names | |||
|
46 | hg -R c qnew series | |||
|
47 | hg -R c qnew status | |||
|
48 | hg -R c qnew guards | |||
|
49 | hg -R c qnew .hgignore | |||
|
50 | ||||
45 | echo % qnew implies add |
|
51 | echo % qnew implies add | |
46 |
|
52 | |||
47 | hg -R c qnew test.patch |
|
53 | hg -R c qnew test.patch |
@@ -59,6 +59,11 b' adding b/z' | |||||
59 | % qinit -c |
|
59 | % qinit -c | |
60 | A .hgignore |
|
60 | A .hgignore | |
61 | A series |
|
61 | A series | |
|
62 | % qnew should refuse bad patch names | |||
|
63 | abort: "series" cannot be used as the name of a patch | |||
|
64 | abort: "status" cannot be used as the name of a patch | |||
|
65 | abort: "guards" cannot be used as the name of a patch | |||
|
66 | abort: ".hgignore" cannot be used as the name of a patch | |||
62 | % qnew implies add |
|
67 | % qnew implies add | |
63 | A .hgignore |
|
68 | A .hgignore | |
64 | A series |
|
69 | A series |
General Comments 0
You need to be logged in to leave comments.
Login now