comparison hg_delta_editor.py @ 72:9ec2a12c12ae

hg_delta_editor: make branches_in_paths() return the branch svn path too
author Patrick Mezard <pmezard@gmail.com>
date Wed, 05 Nov 2008 13:37:08 +0100
parents 63ece4ea25c9
children 9c1b53abefcb
comparison
equal deleted inserted replaced
71:bf1e8b8ed452 72:9ec2a12c12ae
139 ''' 139 '''
140 pickle_atomic(self.branches, self.branch_info_file, self.meta_data_dir) 140 pickle_atomic(self.branches, self.branch_info_file, self.meta_data_dir)
141 pickle_atomic(self.tags, self.tag_info_file, self.meta_data_dir) 141 pickle_atomic(self.tags, self.tag_info_file, self.meta_data_dir)
142 142
143 def branches_in_paths(self, paths): 143 def branches_in_paths(self, paths):
144 '''Given a list of paths, return the set of branches that are touched. 144 '''Given a list of paths, return mapping of all branches touched
145 ''' 145 to their branch path.
146 branches = set([]) 146 '''
147 branches = {}
147 for p in paths: 148 for p in paths:
148 if self._is_path_valid(p): 149 if self._is_path_valid(p):
149 junk, branch = self._path_and_branch_for_path(p) 150 junk, branch, branchpath = self._split_branch_path(p)
150 branches.add(branch) 151 branches[branch] = branchpath
151 return branches 152 return branches
152 153
153 def _path_and_branch_for_path(self, path): 154 def _path_and_branch_for_path(self, path):
155 return self._split_branch_path(path)[:2]
156
157 def _split_branch_path(self, path):
154 '''Figure out which branch inside our repo this path represents, and 158 '''Figure out which branch inside our repo this path represents, and
155 also figure out which path inside that branch it is. 159 also figure out which path inside that branch it is.
156 160
157 Raises an exception if it can't perform its job. 161 Raises an exception if it can't perform its job.
158 ''' 162 '''
159 path = self._normalize_path(path) 163 path = self._normalize_path(path)
160 if path.startswith('trunk'): 164 if path.startswith('trunk'):
161 p = path[len('trunk'):] 165 p = path[len('trunk'):]
162 if p and p[0] == '/': 166 if p and p[0] == '/':
163 p = p[1:] 167 p = p[1:]
164 return p, None 168 return p, None, 'trunk'
165 elif path.startswith('branches/'): 169 elif path.startswith('branches/'):
166 p = path[len('branches/'):] 170 p = path[len('branches/'):]
167 br = p.split('/')[0] 171 br = p.split('/')[0]
168 p = p[len(br)+1:] 172 p = p[len(br)+1:]
169 if p and p[0] == '/': 173 if p and p[0] == '/':
170 p = p[1:] 174 p = p[1:]
171 return p, br 175 return p, br, 'branches/' + br
172 return None, None 176 return None, None, None
173 raise Exception,'Things went boom: ' + path 177 raise Exception,'Things went boom: ' + path
174 178
175 def set_current_rev(self, rev): 179 def set_current_rev(self, rev):
176 '''Set the revision we're currently converting. 180 '''Set the revision we're currently converting.
177 ''' 181 '''