Adding unversioned files before commit

This commit is contained in:
2014-11-06 15:40:13 +01:00
parent 7cb1e806af
commit 2bc2020ddc

View File

@@ -31,6 +31,7 @@ import os
import json import json
import svn.local import svn.local
import werkzeug import werkzeug
import xml.etree.ElementTree
from flask import Flask, jsonify, abort, request, make_response, url_for, Response from flask import Flask, jsonify, abort, request, make_response, url_for, Response
from flask.views import MethodView from flask.views import MethodView
@@ -242,23 +243,30 @@ class FileAPI(Resource):
for src_file_path, dst_file_path in path_remap.items(): for src_file_path, dst_file_path in path_remap.items():
shutil.move(os.path.join(extract_tmp_dir, src_file_path), dst_file_path) shutil.move(os.path.join(extract_tmp_dir, src_file_path), dst_file_path)
# TODO (fsiddi), make adding smarter. Right now we just add any untracked file
# result = local_client.run_command('add',
# [local_client.info()['entry_path'], '*'],
# combine=True)
# TODO, dry run commit (using commit message) # TODO, dry run commit (using commit message)
# Seems not easily possible with SVN # Seems not easily possible with SVN, so we might just smartly use svn status
result = local_client.run_command('status', result = local_client.run_command('status',
[local_client.info()['entry_path'], '--xml'], [local_client.info()['entry_path'], '--xml'],
combine=True) combine=True)
# We parse the svn status xml output
root = xml.etree.ElementTree.fromstring(result)
# Loop throught every entry reported by the svn status command
for e in root.iter('entry'):
file_path = e.attrib['path']
item_status = e.find('wc-status').attrib['item']
# We add each unversioned file to SVN
if item_status == 'unversioned':
result = local_client.run_command('add',
[file_path,])
# Commit command # Commit command
result = local_client.run_command('commit', result = local_client.run_command('commit',
[local_client.info()['entry_path'], '--message', arguments['message']], [local_client.info()['entry_path'], '--message', arguments['message']],
combine=True) combine=True)
print(result)
return jsonify(message=result) return jsonify(message=result)
else: else: