aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-19 15:24:51 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-19 15:24:51 -0400
commita6d5f2891dc353ebe5d9d8598790a6674c174eec (patch)
treea7828e4bc0b981540eacd7f3c5199a0c9f2ab6a4 /becommands
parentb3ce47285a66a35904e5e50636ce471ecb4ce29d (diff)
downloadbugseverywhere-a6d5f2891dc353ebe5d9d8598790a6674c174eec.tar.gz
Added --allow-empty to "be commit"
Previously many backends would silently add an empty commit. Not very useful. When the new --allow-empty flag and related allow_empty options are false, every versioning backend is guaranteed to raise the EmptyCommit exception in the case of an attempted empty commit.
Diffstat (limited to 'becommands')
-rw-r--r--becommands/commit.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/becommands/commit.py b/becommands/commit.py
index bda51c4..4f3bdbd 100644
--- a/becommands/commit.py
+++ b/becommands/commit.py
@@ -14,7 +14,7 @@
# 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
+from libbe import cmdutil, bugdir, editor, rcs
import sys
__desc__ = __doc__
@@ -49,13 +49,22 @@ def execute(args, manipulate_encodings=True):
body = editor.editor_string("Please enter your commit message above")
else:
body = bd.rcs.get_file_contents(options.body, allow_no_rcs=True)
- revision = bd.rcs.commit(summary, body=body)
- print "Committed %s" % revision
+ try:
+ revision = bd.rcs.commit(summary, body=body,
+ allow_empty=options.allow_empty)
+ except rcs.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="""