hgext/convert/convcmd.py
changeset 45942 89a2afe31e82
parent 44102 fdaa4233dc18
child 46819 d4ba4d51f85f
equal deleted inserted replaced
45941:346af7687c6f 45942: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