Mercurial > hgsubversion
comparison push_cmd.py @ 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 | c5039390332f |
comparison
equal
deleted
inserted
replaced
9:9eb6bf2be1e7 | 10:dfdc078661db |
---|---|
87 | 87 |
88 if parent_branch and parent_branch != 'default': | 88 if parent_branch and parent_branch != 'default': |
89 branch_path = 'branches/%s' % parent_branch | 89 branch_path = 'branches/%s' % parent_branch |
90 | 90 |
91 added_dirs = [] | 91 added_dirs = [] |
92 props = {} | |
92 for file in rev_ctx.files(): | 93 for file in rev_ctx.files(): |
93 new_data = base_data = '' | 94 new_data = base_data = '' |
94 action = '' | 95 action = '' |
95 if file in rev_ctx: | 96 if file in rev_ctx: |
96 new_data = rev_ctx.filectx(file).data() | 97 new_data = rev_ctx.filectx(file).data() |
98 | |
99 if 'x' in rev_ctx.filectx(file).flags(): | |
100 props.setdefault(file, {})['svn:executable'] = '*' | |
101 if 'l' in rev_ctx.filectx(file).flags(): | |
102 props.setdefault(file, {})['svn:special'] = '*' | |
103 | |
97 if file not in parent: | 104 if file not in parent: |
98 target_files.append(file) | 105 target_files.append(file) |
99 action = 'add' | 106 action = 'add' |
100 dirname = '/'.join(file.split('/')[:-1] + ['']) | 107 dirname = '/'.join(file.split('/')[:-1] + ['']) |
101 # check for new directories | 108 # check for new directories |
104 try: | 111 try: |
105 assert svn.list_dir('%s/%s' % (branch_path, dirname)) | 112 assert svn.list_dir('%s/%s' % (branch_path, dirname)) |
106 except core.SubversionException, e: | 113 except core.SubversionException, e: |
107 # dir must not exist | 114 # dir must not exist |
108 added_dirs.append(dirname[:-1]) | 115 added_dirs.append(dirname[:-1]) |
109 # TODO check for mime-type autoprops here | |
110 # TODO check for directory adds here | |
111 else: | 116 else: |
112 target_files.append(file) | 117 target_files.append(file) |
113 base_data = parent.filectx(file).data() | 118 base_data = parent.filectx(file).data() |
119 if 'x' in parent.filectx(file).flags(): | |
120 if 'svn:executable' in props.setdefault(file, {}): | |
121 del props[file]['svn:executable'] | |
122 else: | |
123 props.setdefault(file, {})['svn:executable'] = None | |
124 if 'l' in parent.filectx(file).flags(): | |
125 if props.setdefault(file, {})['svn:special']: | |
126 del props[file]['svn:special'] | |
127 else: | |
128 props.setdefault(file, {})['svn:special'] = None | |
114 action = 'modify' | 129 action = 'modify' |
115 else: | 130 else: |
116 target_files.append(file) | 131 target_files.append(file) |
117 base_data = parent.filectx(file).data() | 132 base_data = parent.filectx(file).data() |
118 action = 'delete' | 133 action = 'delete' |
121 # TODO check for directory deletes here | 136 # TODO check for directory deletes here |
122 new_target_files = ['%s/%s' % (branch_path, f) for f in target_files] | 137 new_target_files = ['%s/%s' % (branch_path, f) for f in target_files] |
123 for tf, ntf in zip(target_files, new_target_files): | 138 for tf, ntf in zip(target_files, new_target_files): |
124 if tf in file_data: | 139 if tf in file_data: |
125 file_data[ntf] = file_data[tf] | 140 file_data[ntf] = file_data[tf] |
141 if tf in props: | |
142 props[ntf] = props[tf] | |
143 del props[tf] | |
144 if merc_util.binary(file_data[ntf][1]): | |
145 props.setdefault(ntf, {}).update(props.get(ntf, {})) | |
146 props.setdefault(ntf, {})['svn:mime-type'] | |
126 del file_data[tf] | 147 del file_data[tf] |
127 added_dirs = ['%s/%s' % (branch_path, f) for f in added_dirs] | 148 added_dirs = ['%s/%s' % (branch_path, f) for f in added_dirs] |
128 new_target_files += added_dirs | 149 new_target_files += added_dirs |
129 try: | 150 try: |
130 svn.commit(new_target_files, rev_ctx.description(), file_data, | 151 svn.commit(new_target_files, rev_ctx.description(), file_data, |
131 base_revision, set(added_dirs)) | 152 base_revision, set(added_dirs), props) |
132 except core.SubversionException, e: | 153 except core.SubversionException, e: |
133 if hasattr(e, 'apr_err') and e.apr_err == 160028: | 154 if hasattr(e, 'apr_err') and e.apr_err == 160028: |
134 raise merc_util.Abort('Base text was out of date, maybe rebase?') | 155 raise merc_util.Abort('Base text was out of date, maybe rebase?') |
135 else: | 156 else: |
136 raise | 157 raise |