comparison hgext/convert/convcmd.py @ 45957:89a2afe31e82

formating: upgrade to black 20.8b1 This required a couple of small tweaks to un-confuse black, but now it works. Big formatting changes come from: * Dramatically improved collection-splitting logic upstream * Black having a strong (correct IMO) opinion that """ is better than ''' Differential Revision: https://phab.mercurial-scm.org/D9430
author Augie Fackler <raf@durin42.com>
date Fri, 27 Nov 2020 17:03:29 -0500
parents fdaa4233dc18
children d4ba4d51f85f
comparison
equal deleted inserted replaced
45956:346af7687c6f 45957:89a2afe31e82
94 pycompat.sysstr(orig_encoding), 'replace' 94 pycompat.sysstr(orig_encoding), 'replace'
95 ) 95 )
96 96
97 97
98 def mapbranch(branch, branchmap): 98 def mapbranch(branch, branchmap):
99 ''' 99 """
100 >>> bmap = {b'default': b'branch1'} 100 >>> bmap = {b'default': b'branch1'}
101 >>> for i in [b'', None]: 101 >>> for i in [b'', None]:
102 ... mapbranch(i, bmap) 102 ... mapbranch(i, bmap)
103 'branch1' 103 'branch1'
104 'branch1' 104 'branch1'
113 'branch3' 113 'branch3'
114 'branch4' 114 'branch4'
115 'branch4' 115 'branch4'
116 'branch4' 116 'branch4'
117 'branch5' 117 'branch5'
118 ''' 118 """
119 # If branch is None or empty, this commit is coming from the source 119 # If branch is None or empty, this commit is coming from the source
120 # repository's default branch and destined for the default branch in the 120 # repository's default branch and destined for the default branch in the
121 # destination repository. For such commits, using a literal "default" 121 # destination repository. For such commits, using a literal "default"
122 # in branchmap below allows the user to map "default" to an alternate 122 # in branchmap below allows the user to map "default" to an alternate
123 # default branch in the destination repository. 123 # default branch in the destination repository.
226 226
227 self.splicemap = self.parsesplicemap(opts.get(b'splicemap')) 227 self.splicemap = self.parsesplicemap(opts.get(b'splicemap'))
228 self.branchmap = mapfile(ui, opts.get(b'branchmap')) 228 self.branchmap = mapfile(ui, opts.get(b'branchmap'))
229 229
230 def parsesplicemap(self, path): 230 def parsesplicemap(self, path):
231 """ check and validate the splicemap format and 231 """check and validate the splicemap format and
232 return a child/parents dictionary. 232 return a child/parents dictionary.
233 Format checking has two parts. 233 Format checking has two parts.
234 1. generic format which is same across all source types 234 1. generic format which is same across all source types
235 2. specific format checking which may be different for 235 2. specific format checking which may be different for
236 different source type. This logic is implemented in 236 different source type. This logic is implemented in
237 checkrevformat function in source files like 237 checkrevformat function in source files like
238 hg.py, subversion.py etc. 238 hg.py, subversion.py etc.
239 """ 239 """
240 240
241 if not path: 241 if not path:
242 return {} 242 return {}
243 m = {} 243 m = {}
273 _(b'splicemap file not found or error reading %s:') % path 273 _(b'splicemap file not found or error reading %s:') % path
274 ) 274 )
275 return m 275 return m
276 276
277 def walktree(self, heads): 277 def walktree(self, heads):
278 '''Return a mapping that identifies the uncommitted parents of every 278 """Return a mapping that identifies the uncommitted parents of every
279 uncommitted changeset.''' 279 uncommitted changeset."""
280 visit = list(heads) 280 visit = list(heads)
281 known = set() 281 known = set()
282 parents = {} 282 parents = {}
283 numcommits = self.source.numcommits() 283 numcommits = self.source.numcommits()
284 progress = self.ui.makeprogress( 284 progress = self.ui.makeprogress(
330 raise error.Abort(_(b'unknown splice map parent: %s') % p) 330 raise error.Abort(_(b'unknown splice map parent: %s') % p)
331 pc.append(p) 331 pc.append(p)
332 parents[c] = pc 332 parents[c] = pc
333 333
334 def toposort(self, parents, sortmode): 334 def toposort(self, parents, sortmode):
335 '''Return an ordering such that every uncommitted changeset is 335 """Return an ordering such that every uncommitted changeset is
336 preceded by all its uncommitted ancestors.''' 336 preceded by all its uncommitted ancestors."""
337 337
338 def mapchildren(parents): 338 def mapchildren(parents):
339 """Return a (children, roots) tuple where 'children' maps parent 339 """Return a (children, roots) tuple where 'children' maps parent
340 revision identifiers to children ones, and 'roots' is the list of 340 revision identifiers to children ones, and 'roots' is the list of
341 revisions without parents. 'parents' must be a mapping of revision 341 revisions without parents. 'parents' must be a mapping of revision