comparison push_cmd.py @ 65:b33940d54fe2

push: Fix missing directory creation for the case of a new dir inside a new dir.
author Augie Fackler <durin42@gmail.com>
date Sun, 09 Nov 2008 17:02:07 -0600
parents cc5ebdb1e8d4
children 49b7cbe4c8e3
comparison
equal deleted inserted replaced
64:08be8ee73551 65:b33940d54fe2
67 svn_commit_hashes) 67 svn_commit_hashes)
68 merc_util._encoding = oldencoding 68 merc_util._encoding = oldencoding
69 return 0 69 return 0
70 70
71 71
72 def _findmissing(dirname, svn, branch_path):
73 """Find missing directories in svn. dirname *must* end in a /
74 """
75 assert dirname[-1] == '/'
76 missing = []
77 keep_checking = True
78 # check and see if the dir exists svn-side.
79 path = dirname
80 while keep_checking:
81 try:
82 assert svn.list_dir('%s/%s' % (branch_path, path))
83 keep_checking = False
84 except core.SubversionException, e:
85 # dir must not exist
86 missing.append(path[:-1])
87 path = '/'.join(path.split('/')[:-2] + [''])
88 return missing
89
72 def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision): 90 def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision):
73 """Build and send a commit from Mercurial to Subversion. 91 """Build and send a commit from Mercurial to Subversion.
74 """ 92 """
75 file_data = {} 93 file_data = {}
76 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser()) 94 svn = svnwrap.SubversionRepo(svn_url, username=merc_util.getuser())
97 if file not in parent: 115 if file not in parent:
98 action = 'add' 116 action = 'add'
99 dirname = '/'.join(file.split('/')[:-1] + ['']) 117 dirname = '/'.join(file.split('/')[:-1] + [''])
100 # check for new directories 118 # check for new directories
101 if not list(parent.walk(util.PrefixMatch(dirname))): 119 if not list(parent.walk(util.PrefixMatch(dirname))):
102 # check and see if the dir exists svn-side. 120 added_dirs += _findmissing(dirname, svn, branch_path)
103 try:
104 assert svn.list_dir('%s/%s' % (branch_path, dirname))
105 except core.SubversionException, e:
106 # dir must not exist
107 added_dirs.append(dirname[:-1])
108 else: 121 else:
109 base_data = parent.filectx(file).data() 122 base_data = parent.filectx(file).data()
110 if ('x' in parent.filectx(file).flags() 123 if ('x' in parent.filectx(file).flags()
111 and 'x' not in rev_ctx.filectx(file).flags()): 124 and 'x' not in rev_ctx.filectx(file).flags()):
112 props.setdefault(file, {})['svn:executable'] = None 125 props.setdefault(file, {})['svn:executable'] = None