diff options
author | W. Trevor King <wking@drexel.edu> | 2009-07-19 15:24:51 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-07-19 15:24:51 -0400 |
commit | a6d5f2891dc353ebe5d9d8598790a6674c174eec (patch) | |
tree | a7828e4bc0b981540eacd7f3c5199a0c9f2ab6a4 /libbe/darcs.py | |
parent | b3ce47285a66a35904e5e50636ce471ecb4ce29d (diff) | |
download | bugseverywhere-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/darcs.py')
-rw-r--r-- | libbe/darcs.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/libbe/darcs.py b/libbe/darcs.py index 1beb45d..e7132c0 100644 --- a/libbe/darcs.py +++ b/libbe/darcs.py @@ -131,24 +131,25 @@ class Darcs(RCS): RCS._rcs_duplicate_repo(self, directory, revision) else: self._u_invoke_client("put", "--to-patch", revision, directory) - def _rcs_commit(self, commitfile): + def _rcs_commit(self, commitfile, allow_empty=False): id = self.get_user_id() if '@' not in id: id = "%s <%s@invalid.com>" % (id, id) - # Darcs doesn't like commitfiles without trailing endlines. - f = codecs.open(commitfile, 'r', self.encoding) - contents = f.read() - f.close() - if contents[-1] != '\n': - f = codecs.open(commitfile, 'a', self.encoding) - f.write('\n') - f.close() - status,output,error = self._u_invoke_client('record', '--all', - '--author', id, - '--logfile', commitfile) + args = ['record', '--all', '--author', id, '--logfile', commitfile] + status,output,error = self._u_invoke_client(*args) + empty_strings = ["No changes!"] revision = None - - revline = re.compile("Finished recording patch '(.*)'") + if self._u_any_in_string(empty_strings, output) == True: + if allow_empty == False: + raise rcs.EmptyCommit() + else: # we need a extra call to get the current revision + args = ["changes", "--last=1", "--xml"] + status,output,error = self._u_invoke_client(*args) + revline = re.compile("[ \t]*<name>(.*)</name>") + # note that darcs does _not_ make an empty revision. + # this returns the last non-empty revision id... + else: + revline = re.compile("Finished recording patch '(.*)'") match = revline.search(output) assert match != None, output+error assert len(match.groups()) == 1 |