From 401411e519f1b4e6206e9020902536a54ca8750b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 20 Nov 2009 09:41:44 -0500 Subject: Removed superfluous 'import time' from becommands/commit.py doctest. --- becommands/commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'becommands/commit.py') diff --git a/becommands/commit.py b/becommands/commit.py index dc70e7e..b530fdc 100644 --- a/becommands/commit.py +++ b/becommands/commit.py @@ -20,7 +20,7 @@ __desc__ = __doc__ def execute(args, manipulate_encodings=True): """ - >>> import os, time + >>> import os >>> from libbe import bug >>> bd = bugdir.SimpleBugDir() >>> os.chdir(bd.root) -- cgit From 614d4e40e148520ac511cbe0606bcbdcf24c8a08 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 21 Nov 2009 15:18:02 -0500 Subject: Added restrict_file_access to becommands' execute() args. + associated adjustments in other files. See cmdutil.restrict_file_access.__doc__ for an explanation of the security hole this closes. --- becommands/commit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'becommands/commit.py') diff --git a/becommands/commit.py b/becommands/commit.py index b530fdc..39d1e2e 100644 --- a/becommands/commit.py +++ b/becommands/commit.py @@ -18,7 +18,7 @@ from libbe import cmdutil, bugdir, editor, vcs import sys __desc__ = __doc__ -def execute(args, manipulate_encodings=True): +def execute(args, manipulate_encodings=True, restrict_file_access=False): """ >>> import os >>> from libbe import bug @@ -49,6 +49,8 @@ def execute(args, manipulate_encodings=True): elif options.body == "EDITOR": body = editor.editor_string("Please enter your commit message above") else: + if restrict_file_access == True: + cmdutil.restrict_file_access(bd, options.body) body = bd.vcs.get_file_contents(options.body, allow_no_vcs=True) try: revision = bd.vcs.commit(summary, body=body, -- cgit From fdf9925ffaada614544d1b2d3ccecb42f1549acb Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 7 Dec 2009 07:18:48 -0500 Subject: be --dir DIR COMMAND now roots the bugdir in DIR without changing directories. Previously, for the directory structure A |-- X `-- Y You could do something like A$ be --dir X diff --dir ../Y Now it's A$ be --dir X diff --dir Y The --root option to `be init` has been removed as redundant. Replace calls like be init --root DIR with be --dir DIR init --- becommands/commit.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'becommands/commit.py') diff --git a/becommands/commit.py b/becommands/commit.py index 39d1e2e..cade355 100644 --- a/becommands/commit.py +++ b/becommands/commit.py @@ -18,7 +18,8 @@ from libbe import cmdutil, bugdir, editor, vcs import sys __desc__ = __doc__ -def execute(args, manipulate_encodings=True, restrict_file_access=False): +def execute(args, manipulate_encodings=True, restrict_file_access=False, + dir="."): """ >>> import os >>> from libbe import bug @@ -37,7 +38,8 @@ def execute(args, manipulate_encodings=True, restrict_file_access=False): if len(args) != 1: raise cmdutil.UsageError("Please supply a commit message") bd = bugdir.BugDir(from_disk=True, - manipulate_encodings=manipulate_encodings) + manipulate_encodings=manipulate_encodings, + root=dir) if args[0] == '-': # read summary from stdin assert options.body != "EDITOR", \ "Cannot spawn and editor when the summary is using stdin." -- cgit From 49a7771336ce09f6d42c7699ef32aecea0e83182 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 7 Dec 2009 20:07:55 -0500 Subject: Initial directory restructuring to clarify dependencies --- becommands/commit.py | 82 ---------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 becommands/commit.py (limited to 'becommands/commit.py') diff --git a/becommands/commit.py b/becommands/commit.py deleted file mode 100644 index cade355..0000000 --- a/becommands/commit.py +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (C) 2009 W. Trevor King -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -"""Commit the currently pending changes to the repository""" -from libbe import cmdutil, bugdir, editor, vcs -import sys -__desc__ = __doc__ - -def execute(args, manipulate_encodings=True, restrict_file_access=False, - dir="."): - """ - >>> import os - >>> from libbe import bug - >>> bd = bugdir.SimpleBugDir() - >>> os.chdir(bd.root) - >>> full_path = "testfile" - >>> test_contents = "A test file" - >>> bd.vcs.set_file_contents(full_path, test_contents) - >>> execute(["Added %s." % (full_path)], manipulate_encodings=False) # doctest: +ELLIPSIS - Committed ... - >>> bd.cleanup() - """ - parser = get_parser() - options, args = parser.parse_args(args) - cmdutil.default_complete(options, args, parser) - if len(args) != 1: - raise cmdutil.UsageError("Please supply a commit message") - bd = bugdir.BugDir(from_disk=True, - manipulate_encodings=manipulate_encodings, - root=dir) - if args[0] == '-': # read summary from stdin - assert options.body != "EDITOR", \ - "Cannot spawn and editor when the summary is using stdin." - summary = sys.stdin.readline() - else: - summary = args[0] - if options.body == None: - body = None - elif options.body == "EDITOR": - body = editor.editor_string("Please enter your commit message above") - else: - if restrict_file_access == True: - cmdutil.restrict_file_access(bd, options.body) - body = bd.vcs.get_file_contents(options.body, allow_no_vcs=True) - try: - revision = bd.vcs.commit(summary, body=body, - allow_empty=options.allow_empty) - except vcs.EmptyCommit, e: - print e - return 1 - else: - print "Committed %s" % revision - -def get_parser(): - parser = cmdutil.CmdOptionParser("be commit COMMENT") - parser.add_option("-b", "--body", metavar="FILE", dest="body", - help='Provide a detailed body for the commit message. In the special case that FILE == "EDITOR", spawn an editor to enter the body text (in which case you cannot use stdin for the summary)', default=None) - parser.add_option("-a", "--allow-empty", dest="allow_empty", - help="Allow empty commits", - default=False, action="store_true") - return parser - -longhelp=""" -Commit the current repository status. The summary specified on the -commandline is a string (only one line) that describes the commit -briefly or "-", in which case the string will be read from stdin. -""" - -def help(): - return get_parser().help_str() + longhelp -- cgit