aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bzr.py
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2006-02-03 15:17:59 -0500
committerAaron Bentley <abentley@panoramicfeedback.com>2006-02-03 15:17:59 -0500
commitd4b7a0a07db702a80c279b5c92a999cd91dfc1bc (patch)
tree61a6db543de3db754b99c310685203b3cc5326bb /libbe/bzr.py
parent979fe49abcd905ac9db403e665ea442376a061c3 (diff)
downloadbugseverywhere-d4b7a0a07db702a80c279b5c92a999cd91dfc1bc.tar.gz
Got commit basics working for bzr
Diffstat (limited to 'libbe/bzr.py')
-rw-r--r--libbe/bzr.py49
1 files changed, 34 insertions, 15 deletions
diff --git a/libbe/bzr.py b/libbe/bzr.py
index 80b9e9b..ac1a8c4 100644
--- a/libbe/bzr.py
+++ b/libbe/bzr.py
@@ -14,27 +14,26 @@
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from subprocess import Popen, PIPE
import os
-import config
-
-def invoke(args):
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
- output = q.stdout.read()
- error = q.stderr.read()
- status = q.wait()
- if status >= 0:
- return status, output, error
- raise Exception("Command failed: %s" % error)
+import tempfile
+import config
+from rcs import invoke, CommandError
def invoke_client(*args, **kwargs):
+ directory = kwargs.get('directory')
+ expect = kwargs.get('expect', (0, 1))
cl_args = ["bzr"]
cl_args.extend(args)
- status,output,error = invoke(cl_args)
- if status not in (0,):
- raise Exception("Command failed: %s" % error)
- return output
+ if directory:
+ old_dir = os.getcwd()
+ os.chdir(directory)
+ try:
+ status,output,error = invoke(cl_args, expect)
+ finally:
+ if directory:
+ os.chdir(old_dir)
+ return status, output
def add_id(filename, paranoid=False):
invoke_client("add", filename)
@@ -101,5 +100,25 @@ def detect(path):
old_path = path
path = os.path.dirname(path)
+def precommit(directory):
+ pass
+def commit(directory, summary, body=None):
+ if body is not None:
+ summary += '\n' + body
+ descriptor, filename = tempfile.mkstemp()
+ try:
+ temp_file = os.fdopen(descriptor, 'wb')
+ temp_file.write(summary)
+ temp_file.close()
+ try:
+ invoke_client('commit', '--unchanged', '--file', filename,
+ directory=directory)
+ except:
+ raise invoke_client('status', directory=directory)[1]
+ finally:
+ os.unlink(filename)
+
+def postcommit(directory):
+ pass
name = "bzr"