Commit 89eba833 authored by Julien Muchembled's avatar Julien Muchembled

Fix BT export when svn working copy already contains files/dirs marked for deletion

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40396 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a8611444
...@@ -945,11 +945,12 @@ class SubversionTool(BaseTool): ...@@ -945,11 +945,12 @@ class SubversionTool(BaseTool):
Current directory must be the destination working copy Current directory must be the destination working copy
""" """
# Sets to track svn status in case it is not consistent with existing client = self._getClient()
# Dicts to track svn status in case it is not consistent with existing
# files and directories # files and directories
versioned_set = set(x.getPath() for x in self._getClient().status('.') versioned_dict = dict((x.getPath(), x) for x in client.status('.')
if x.getIsVersioned()) if x.getIsVersioned())
versioned_set.remove('.') del versioned_dict['.']
added_set = set() added_set = set()
# Walk current tree # Walk current tree
...@@ -975,20 +976,23 @@ class SubversionTool(BaseTool): ...@@ -975,20 +976,23 @@ class SubversionTool(BaseTool):
dirpath = dirpath[prefix_length:] dirpath = dirpath[prefix_length:]
for d in dirnames: for d in dirnames:
d = os.path.join(dirpath, d) d = os.path.join(dirpath, d)
if d in versioned_set: status = versioned_dict.pop(d, None)
versioned_set.remove(d) if status is None:
else:
added_set.add(d) added_set.add(d)
elif str(status.getTextStatus()) == 'deleted':
client.revert(d)
if d in svn_dir_set: if d in svn_dir_set:
svn_dir_set.remove(d) svn_dir_set.remove(d)
else: else:
os.mkdir(d) os.mkdir(d)
for f in filenames: for f in filenames:
f = os.path.join(dirpath, f) f = os.path.join(dirpath, f)
if f in versioned_set: status = versioned_dict.pop(f, None)
versioned_set.remove(f) if status is None:
else:
added_set.add(f) added_set.add(f)
elif str(status.getTextStatus()) == 'deleted':
client.revert(f)
svn_file_set.add(f)
# copy file unless unchanged # copy file unless unchanged
file = open(os.path.join(path, f), 'rb') file = open(os.path.join(path, f), 'rb')
try: try:
...@@ -1011,8 +1015,8 @@ class SubversionTool(BaseTool): ...@@ -1011,8 +1015,8 @@ class SubversionTool(BaseTool):
file.close() file.close()
# Remove dangling files/dirs # Remove dangling files/dirs
svn_file_set -= versioned_set # what is in versioned_set svn_file_set.difference_update(versioned_dict) # what is in versioned_dict
svn_dir_set -= versioned_set # is removed after svn_dir_set.difference_update(versioned_dict) # is removed after
for x in svn_file_set: for x in svn_file_set:
if os.path.dirname(x) not in svn_dir_set: if os.path.dirname(x) not in svn_dir_set:
os.remove(x) os.remove(x)
...@@ -1021,10 +1025,10 @@ class SubversionTool(BaseTool): ...@@ -1021,10 +1025,10 @@ class SubversionTool(BaseTool):
shutil.rmtree(x) shutil.rmtree(x)
# Remove deleted files/dirs # Remove deleted files/dirs
self.remove([x for x in versioned_set client.remove([x for x in versioned_dict
if os.path.dirname(x) not in versioned_set]) if os.path.dirname(x) not in versioned_dict])
# Add new files/dirs # Add new files/dirs
self.add([x for x in added_set client.add([x for x in added_set
if os.path.dirname(x) not in added_set]) if os.path.dirname(x) not in added_set])
def treeToXML(self, item, business_template) : def treeToXML(self, item, business_template) :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment