aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bzr.py
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 /libbe/bzr.py
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 'libbe/bzr.py')
-rw-r--r--libbe/bzr.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/libbe/bzr.py b/libbe/bzr.py
index fcbd6ac..b33292c 100644
--- a/libbe/bzr.py
+++ b/libbe/bzr.py
@@ -71,9 +71,21 @@ class Bzr(RCS):
else:
self._u_invoke_client("branch", "--revision", revision,
".", directory)
- def _rcs_commit(self, commitfile):
- status,output,error = self._u_invoke_client("commit", "--unchanged",
- "--file", commitfile)
+ def _rcs_commit(self, commitfile, allow_empty=False):
+ args = ["commit", "--file", commitfile]
+ if allow_empty == True:
+ args.append("--unchanged")
+ status,output,error = self._u_invoke_client(*args)
+ else:
+ kwargs = {"expect":(0,3)}
+ status,output,error = self._u_invoke_client(*args, **kwargs)
+ if status != 0:
+ strings = ["ERROR: no changes to commit.", # bzr 1.3.1
+ "ERROR: No changes to commit."] # bzr 1.15.1
+ if self._u_any_in_string(strings, error) == True:
+ raise rcs.EmptyCommit()
+ else:
+ raise rcs.CommandError(args, status, error)
revision = None
revline = re.compile("Committed revision (.*)[.]")
match = revline.search(error)