Mercurial > hgsubversion
comparison push_cmd.py @ 173:f244eaee5069
push_cmd: make _isdir() a standalone function
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Tue, 30 Dec 2008 20:34:03 -0600 |
parents | b77a4caaf77b |
children | 2412800b1258 |
comparison
equal
deleted
inserted
replaced
172:84fbf1469a31 | 173:f244eaee5069 |
---|---|
89 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) | 89 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, ui_=ui) |
90 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) | 90 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) |
91 merc_util._encoding = oldencoding | 91 merc_util._encoding = oldencoding |
92 return 0 | 92 return 0 |
93 | 93 |
94 def _isdir(svn, branchpath, svndir): | |
95 try: | |
96 svn.list_dir('%s/%s' % (branchpath, svndir)) | |
97 return True | |
98 except core.SubversionException: | |
99 return False | |
100 | |
94 def _getdirchanges(svn, branchpath, parentctx, ctx, changedfiles): | 101 def _getdirchanges(svn, branchpath, parentctx, ctx, changedfiles): |
95 """Compute directories to add or delete when moving from parentctx | 102 """Compute directories to add or delete when moving from parentctx |
96 to ctx, assuming only 'changedfiles' files changed. | 103 to ctx, assuming only 'changedfiles' files changed. |
97 | 104 |
98 Return (added, deleted) where 'added' is the list of all added | 105 Return (added, deleted) where 'added' is the list of all added |
100 Intermediate directories are included: if a/b/c is new and requires | 107 Intermediate directories are included: if a/b/c is new and requires |
101 the addition of a/b and a, those will be listed too. Intermediate | 108 the addition of a/b and a, those will be listed too. Intermediate |
102 deleted directories are also listed, but item order of undefined | 109 deleted directories are also listed, but item order of undefined |
103 in either list. | 110 in either list. |
104 """ | 111 """ |
105 def exists(svndir): | |
106 try: | |
107 svn.list_dir('%s/%s' % (branchpath, svndir)) | |
108 return True | |
109 except core.SubversionException: | |
110 return False | |
111 | |
112 def finddirs(path): | 112 def finddirs(path): |
113 pos = path.rfind('/') | 113 pos = path.rfind('/') |
114 while pos != -1: | 114 while pos != -1: |
115 yield path[:pos] | 115 yield path[:pos] |
116 pos = path.rfind('/', 0, pos) | 116 pos = path.rfind('/', 0, pos) |
138 return added, deleted | 138 return added, deleted |
139 olddirs = getctxdirs(parentctx, changeddirs) | 139 olddirs = getctxdirs(parentctx, changeddirs) |
140 newdirs = getctxdirs(ctx, changeddirs) | 140 newdirs = getctxdirs(ctx, changeddirs) |
141 | 141 |
142 for d in newdirs: | 142 for d in newdirs: |
143 if d not in olddirs and not exists(d): | 143 if d not in olddirs and not _isdir(svn, branchpath, d): |
144 added.append(d) | 144 added.append(d) |
145 | 145 |
146 for d in olddirs: | 146 for d in olddirs: |
147 if d not in newdirs and exists(d): | 147 if d not in newdirs and _isdir(svn, branchpath, d): |
148 deleted.append(d) | 148 deleted.append(d) |
149 | 149 |
150 return added, deleted | 150 return added, deleted |
151 | 151 |
152 | 152 |