changeset 10:dfdc078661db

Auto-set executable, symlink, and auto-props.
author Augie Fackler <durin42@gmail.com>
date Mon, 06 Oct 2008 13:52:10 -0500
parents 9eb6bf2be1e7
children 83ed086ddf72
files push_cmd.py svnwrap/svn_swig_wrapper.py
diffstat 2 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/push_cmd.py
+++ b/push_cmd.py
@@ -89,11 +89,18 @@ def commit_from_rev(ui, repo, rev_ctx, h
         branch_path = 'branches/%s' % parent_branch
 
     added_dirs = []
+    props = {}
     for file in rev_ctx.files():
         new_data = base_data = ''
         action = ''
         if file in rev_ctx:
             new_data = rev_ctx.filectx(file).data()
+
+            if 'x' in rev_ctx.filectx(file).flags():
+                props.setdefault(file, {})['svn:executable'] = '*'
+            if 'l' in rev_ctx.filectx(file).flags():
+                props.setdefault(file, {})['svn:special'] = '*'
+
             if file not in parent:
                 target_files.append(file)
                 action = 'add'
@@ -106,11 +113,19 @@ def commit_from_rev(ui, repo, rev_ctx, h
                     except core.SubversionException, e:
                         # dir must not exist
                         added_dirs.append(dirname[:-1])
-                # TODO check for mime-type autoprops here
-                # TODO check for directory adds here
             else:
                 target_files.append(file)
                 base_data = parent.filectx(file).data()
+                if 'x' in parent.filectx(file).flags():
+                    if 'svn:executable' in props.setdefault(file, {}):
+                        del props[file]['svn:executable']
+                    else:
+                        props.setdefault(file, {})['svn:executable'] = None
+                if 'l' in parent.filectx(file).flags():
+                    if props.setdefault(file, {})['svn:special']:
+                        del props[file]['svn:special']
+                    else:
+                        props.setdefault(file, {})['svn:special'] = None
                 action = 'modify'
         else:
             target_files.append(file)
@@ -123,12 +138,18 @@ def commit_from_rev(ui, repo, rev_ctx, h
     for tf, ntf in zip(target_files, new_target_files):
         if tf in file_data:
             file_data[ntf] = file_data[tf]
+            if tf in props:
+                props[ntf] = props[tf]
+                del props[tf]
+            if merc_util.binary(file_data[ntf][1]):
+                props.setdefault(ntf, {}).update(props.get(ntf, {}))
+                props.setdefault(ntf, {})['svn:mime-type']
             del file_data[tf]
     added_dirs = ['%s/%s' % (branch_path, f) for f in added_dirs]
     new_target_files += added_dirs
     try:
         svn.commit(new_target_files, rev_ctx.description(), file_data,
-                   base_revision, set(added_dirs))
+                   base_revision, set(added_dirs), props)
     except core.SubversionException, e:
         if hasattr(e, 'apr_err') and e.apr_err == 160028:
             raise merc_util.Abort('Base text was out of date, maybe rebase?')
--- a/svnwrap/svn_swig_wrapper.py
+++ b/svnwrap/svn_swig_wrapper.py
@@ -241,7 +241,8 @@ class SubversionRepo(object):
                 yield revisions[0]
                 revisions.pop(0)
 
-    def commit(self, paths, message, file_data, base_revision, dirs):
+    def commit(self, paths, message, file_data, base_revision, dirs,
+               properties):
         """Commits the appropriate targets from revision in editor's store.
         """
         self.init_ra_and_client()
@@ -271,6 +272,12 @@ class SubversionRepo(object):
                 baton = editor.delete_entry(path, base_revision, parent, pool)
                 compute_delta = False
 
+            if path in properties:
+                if properties[path].get('svn:special', None):
+                    new_text = 'link %s' % new_text
+                for p, v in properties[path].iteritems():
+                    editor.change_file_prop(baton, p, v)
+
             if compute_delta:
                 handler, wh_baton = editor.apply_textdelta(baton, None,
                                                            self.pool)