Skip to content

Commit a63030c

Browse files
committed
make the script use an "accept" command, which is more like what Alex wants
1 parent 6a89ea0 commit a63030c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

setversion.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def init_rewriter(line, ctxt):
7777

7878
def rewrite_file(infilename, rewritefunc, ctxt):
7979
outfilename = infilename + ".new"
80-
if not ctxt["renameonly"]:
80+
if not ctxt["accept"]:
8181
infile = open(infilename, "r")
8282
outfile = open(outfilename, "w")
8383
try:
@@ -110,27 +110,27 @@ def main():
110110
"the version numbers in the source.",
111111
epilog="After running, edit docs/changelog.rst and add the new changelog "
112112
"information under the new heading.")
113-
parser.add_argument("version", help="New version number to add")
113+
parser.add_argument("version", help="New version number to add, or \"accept\" to accept changes to .new files")
114114
parser.add_argument("-n", "--nodelete", action="store_true",
115115
help="Do not delete existing files, leave new files with .new extension")
116116
parser.add_argument("-b", "--backup", action="store_true",
117117
help="Keep old versions of files around with a .bak extension")
118-
parser.add_argument("-r", "--renameonly", action="store_true",
119-
help="Do rename of .new files only; don't rewrite")
120118

121119
args = parser.parse_args()
122120

123-
if args.renameonly and args.nodelete:
124-
print("cannot specify --renameonly and --nodelete together")
125-
return 1
126-
127-
if not args.renameonly:
121+
is_accept = False
122+
if args.version == "accept":
123+
if args.nodelete:
124+
print("cannot specify --nodelete with accept command")
125+
return 1
126+
is_accept = True
127+
else:
128128
vnexpr = re.compile(r"^[1-9]\d*\.\d+\.\d+$")
129129
if not vnexpr.match(args.version):
130130
print("Invalid version number {0}: must be three numeric values separated by dots\n".format(args.version))
131131
return 1
132132

133-
ctxt = {"version": args.version, "nodelete": args.nodelete, "backup": args.backup, "renameonly": args.renameonly}
133+
ctxt = {"version": args.version, "nodelete": args.nodelete, "backup": args.backup, "accept": is_accept}
134134
rewrite_file("README.md", readme_rewriter, ctxt)
135135
rewrite_file("docs/changelog.rst", changelog_rewriter, ctxt)
136136
rewrite_file("docs/conf.py", doc_conf_rewriter, ctxt)

0 commit comments

Comments
 (0)