comparison push_cmd.py @ 56:0be16f306a42

push_cmd: remove redundant variable in commit_from_rev()
author Patrick Mezard <pmezard@gmail.com>
date Mon, 03 Nov 2008 08:44:31 -0600
parents 85fcac4e2291
children c3c5546eefb1
comparison
equal deleted inserted replaced
55:987e44afa71e 56:0be16f306a42
70 70
71 71
72 def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision): 72 def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision):
73 """Build and send a commit from Mercurial to Subversion. 73 """Build and send a commit from Mercurial to Subversion.
74 """ 74 """
75 target_files = []
76 file_data = {} 75 file_data = {}
77 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser()) 76 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
78 parent = rev_ctx.parents()[0] 77 parent = rev_ctx.parents()[0]
79 parent_branch = rev_ctx.parents()[0].branch() 78 parent_branch = rev_ctx.parents()[0].branch()
80 branch_path = 'trunk' 79 branch_path = 'trunk'
94 props.setdefault(file, {})['svn:executable'] = '*' 93 props.setdefault(file, {})['svn:executable'] = '*'
95 if 'l' in rev_ctx.filectx(file).flags(): 94 if 'l' in rev_ctx.filectx(file).flags():
96 props.setdefault(file, {})['svn:special'] = '*' 95 props.setdefault(file, {})['svn:special'] = '*'
97 96
98 if file not in parent: 97 if file not in parent:
99 target_files.append(file)
100 action = 'add' 98 action = 'add'
101 dirname = '/'.join(file.split('/')[:-1] + ['']) 99 dirname = '/'.join(file.split('/')[:-1] + [''])
102 # check for new directories 100 # check for new directories
103 if not list(parent.walk(util.PrefixMatch(dirname))): 101 if not list(parent.walk(util.PrefixMatch(dirname))):
104 # check and see if the dir exists svn-side. 102 # check and see if the dir exists svn-side.
106 assert svn.list_dir('%s/%s' % (branch_path, dirname)) 104 assert svn.list_dir('%s/%s' % (branch_path, dirname))
107 except core.SubversionException, e: 105 except core.SubversionException, e:
108 # dir must not exist 106 # dir must not exist
109 added_dirs.append(dirname[:-1]) 107 added_dirs.append(dirname[:-1])
110 else: 108 else:
111 target_files.append(file)
112 base_data = parent.filectx(file).data() 109 base_data = parent.filectx(file).data()
113 if 'x' in parent.filectx(file).flags(): 110 if 'x' in parent.filectx(file).flags():
114 if 'svn:executable' in props.setdefault(file, {}): 111 if 'svn:executable' in props.setdefault(file, {}):
115 del props[file]['svn:executable'] 112 del props[file]['svn:executable']
116 else: 113 else:
120 del props[file]['svn:special'] 117 del props[file]['svn:special']
121 else: 118 else:
122 props.setdefault(file, {})['svn:special'] = None 119 props.setdefault(file, {})['svn:special'] = None
123 action = 'modify' 120 action = 'modify'
124 else: 121 else:
125 target_files.append(file)
126 base_data = parent.filectx(file).data() 122 base_data = parent.filectx(file).data()
127 action = 'delete' 123 action = 'delete'
128 file_data[file] = base_data, new_data, action 124 file_data[file] = base_data, new_data, action
129 125
130 # TODO check for directory deletes here 126 # TODO check for directory deletes here
131 new_target_files = ['%s/%s' % (branch_path, f) for f in target_files] 127 new_target_files = ['%s/%s' % (branch_path, f) for f in rev_ctx.files()]
132 for tf, ntf in zip(target_files, new_target_files): 128 for tf, ntf in zip(rev_ctx.files(), new_target_files):
133 if tf in file_data: 129 if tf in file_data:
134 file_data[ntf] = file_data[tf] 130 file_data[ntf] = file_data[tf]
135 if tf in props: 131 if tf in props:
136 props[ntf] = props[tf] 132 props[ntf] = props[tf]
137 del props[tf] 133 del props[tf]