| 1 |
# bzr.py - bzr support for the convert extension |
| 2 |
# |
| 3 |
# Copyright 2008, 2009 Marek Kubica <[email protected]> and others |
| 4 |
# |
| 5 |
# This software may be used and distributed according to the terms of the |
| 6 |
# GNU General Public License version 2 or any later version. |
| 7 |
|
| 8 |
# This module is for handling Breezy imports or `brz`, but it's also compatible |
| 9 |
# with Bazaar or `bzr`, that was formerly known as Bazaar-NG; |
| 10 |
# it cannot access `bar` repositories, but they were never used very much. |
| 11 |
|
| 12 |
from __future__scip-python python python-stdlib 3.11 __future__/__init__: import annotationsscip-python python python-stdlib 3.11 __future__/annotations.annotations. |
| 13 |
|
| 14 |
import osscip-python python python-stdlib 3.11 os/__init__: |
| 15 |
|
| 16 |
from mercurial.i18nscip-python python mercurial 7.2.2 `mercurial.i18n`/__init__: import _scip-python python mercurial 7.2.2 `mercurial.i18n`/_(). |
| 17 |
from mercurialscip-python python mercurial 7.2.2 mercurial/__init__: import ( |
| 18 |
demandimportscip-python python mercurial 7.2.2 mercurial/demandimport., |
| 19 |
errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:, |
| 20 |
utilscip-python python mercurial 7.2.2 `mercurial.util`/__init__:, |
| 21 |
) |
| 22 |
from . import commonscip-python python mercurial 7.2.2 common/__init__: |
| 23 |
|
| 24 |
|
| 25 |
# these do not work with demandimport, blacklist |
| 26 |
demandimportscip-python python mercurial 7.2.2 mercurial/demandimport..IGNORESscip-python python mercurial 7.2.2 hgdemandimport/IGNORES..updatescip-python python python-stdlib 3.11 builtins/set#update().( |
| 27 |
[ |
| 28 |
'breezy.transactions', |
| 29 |
'breezy.urlutils', |
| 30 |
'ElementPath', |
| 31 |
] |
| 32 |
) |
| 33 |
|
| 34 |
try: |
| 35 |
# bazaar imports |
| 36 |
# pytype: disable=import-error |
| 37 |
import breezy.bzr.bzrdir |
| 38 |
import breezy.errors |
| 39 |
import breezy.revision |
| 40 |
import breezy.revisionspec |
| 41 |
|
| 42 |
# pytype: enable=import-error |
| 43 |
|
| 44 |
bzrdirscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzrdir. = breezy.bzr.bzrdir |
| 45 |
errorsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/errors. = breezy.errors |
| 46 |
revisionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/revision. = breezy.revision |
| 47 |
revisionspecscip-python python mercurial 7.2.2 `hgext.convert.bzr`/revisionspec. = breezy.revisionspec |
| 48 |
revisionspecscip-python python mercurial 7.2.2 `hgext.convert.bzr`/revisionspec..RevisionSpec |
| 49 |
|
| 50 |
try: |
| 51 |
# brz 3.3.0 (revno: 7614.2.2) |
| 52 |
from breezy.transportscip-python python mercurial 7.2.2 `breezy.transport`/__init__: import NoSuchFile |
| 53 |
except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 54 |
from breezy.errorsscip-python python mercurial 7.2.2 `breezy.errors`/__init__: import NoSuchFile |
| 55 |
except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 56 |
pass |
| 57 |
|
| 58 |
supportedkindsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/supportedkinds. = ('file', 'symlink') |
| 59 |
|
| 60 |
|
| 61 |
class bzr_sourcescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#(commonscip-python python mercurial 7.2.2 common/__init__:.converter_sourcescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#): |
| 62 |
"""Reads Bazaar repositories by using the Bazaar Python libraries""" |
| 63 |
|
| 64 |
def __init__scip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(self), uiscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(ui), repotypescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(repotype), pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path), revsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(revs)=None): |
| 65 |
superscip-python python python-stdlib 3.11 builtins/super#().__init__scip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#__init__().(uiscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(ui), repotypescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(repotype), pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path), revsscip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#__init__().(revs)=revsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(revs)) |
| 66 |
|
| 67 |
if not osscip-python python python-stdlib 3.11 os/__init__:.pathscip-python python python-stdlib 3.11 os/path..existsscip-python python python-stdlib 3.11 genericpath/exists().(osscip-python python python-stdlib 3.11 os/__init__:.pathscip-python python python-stdlib 3.11 os/path..joinscip-python python python-stdlib 3.11 genericpath/exists().(pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path), b'.bzr')): |
| 68 |
raise commonscip-python python mercurial 7.2.2 common/__init__:.NoReposcip-python python mercurial 7.2.2 `hgext.convert.common`/NoRepo#( |
| 69 |
_(b'%s does not look like a Bazaar repository') % pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path) |
| 70 |
) |
| 71 |
|
| 72 |
try: |
| 73 |
# access breezy stuff |
| 74 |
bzrdirscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzrdir. |
| 75 |
except NameErrorscip-python python python-stdlib 3.11 builtins/NameError#: |
| •76 |
raise commonscip-python python mercurial 7.2.2 common/__init__:.NoReposcip-python python mercurial 7.2.2 `hgext.convert.common`/NoRepo#(_(b'Bazaar modules could not be loaded') + |
| 77 |
_(b' (try installing the %s package)') % b'bzr') |
| 78 |
|
| 79 |
pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path) = utilscip-python python mercurial 7.2.2 `mercurial.util`/__init__:.abspathscip-python python mercurial 7.2.2 `mercurial.util`/abspath.(pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path)) |
| 80 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(self)._checkrepotypescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path)) |
| 81 |
try: |
| 82 |
bzr_dir = bzrdirscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzrdir..BzrDir.open(pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path).decode()) |
| 83 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo. = bzr_dir.open_repository() |
| 84 |
except errorsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/errors..NoRepositoryPresent: |
| 85 |
raise commonscip-python python mercurial 7.2.2 common/__init__:.NoReposcip-python python mercurial 7.2.2 `hgext.convert.common`/NoRepo#( |
| 86 |
_(b'%s does not look like a Bazaar repository') % pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(path) |
| 87 |
) |
| 88 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(self)._parentidsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_parentids. = {} |
| 89 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(self)._saverevscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_saverev. = uiscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#__init__().(ui).configboolscip-python python mercurial 7.2.2 `mercurial.ui`/ui#configbool().(b'convert', b'bzr.saverev') |
| 90 |
|
| 91 |
def _checkrepotypescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(self), pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(path)): |
| 92 |
# Lightweight checkouts detection is informational but probably |
| 93 |
# fragile at API level. It should not terminate the conversion. |
| 94 |
try: |
| 95 |
dir = bzrdirscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzrdir..BzrDir.open_containing(pathscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(path).decode())[0] |
| 96 |
try: |
| 97 |
tree = dir.open_workingtree(recommend_upgrade=False) |
| 98 |
branch = tree.branch |
| 99 |
except (errorsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/errors..NoWorkingTree, errorsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/errors..NotLocalUrl): |
| 100 |
tree = None |
| 101 |
branch = dir.open_branch() |
| 102 |
if ( |
| 103 |
tree is not None |
| 104 |
and tree.controldir.root_transport.base |
| 105 |
!= branch.controldir.root_transport.base |
| 106 |
): |
| 107 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(self).uiscip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#ui..warnscip-python python mercurial 7.2.2 `mercurial.ui`/ui#warn().( |
| 108 |
_( |
| 109 |
b'warning: lightweight checkouts may cause ' |
| 110 |
b'conversion failures, try with a regular ' |
| 111 |
b'branch instead.\n' |
| 112 |
) |
| 113 |
) |
| 114 |
except Exceptionscip-python python python-stdlib 3.11 builtins/Exception#: |
| 115 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_checkrepotype().(self).uiscip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#ui..notescip-python python mercurial 7.2.2 `mercurial.ui`/ui#note().(_(b'bzr source type could not be determined\n')) |
| 116 |
|
| 117 |
def beforescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#before().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#before().(self)): |
| 118 |
"""Before the conversion begins, acquire a read lock |
| 119 |
for all the operations that might need it. Fortunately |
| 120 |
read locks don't block other reads or writes to the |
| 121 |
repository, so this shouldn't have any impact on the usage of |
| 122 |
the source repository. |
| 123 |
|
| 124 |
The alternative would be locking on every operation that |
| 125 |
needs locks (there are currently two: getting the file and |
| 126 |
getting the parent map) and releasing immediately after, |
| 127 |
but this approach can take even 40% longer.""" |
| 128 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#before().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..lock_read() |
| 129 |
|
| 130 |
def afterscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#after().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#after().(self)): |
| 131 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#after().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..unlock() |
| 132 |
|
| 133 |
def _bzrbranchesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_bzrbranches().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_bzrbranches().(self)): |
| 134 |
return selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_bzrbranches().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..find_branches(using=True) |
| 135 |
|
| 136 |
def getheadsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(self)): |
| 137 |
if not selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(self).revsscip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#revs.: |
| 138 |
# Set using=True to avoid nested repositories (see issue3254) |
| 139 |
heads = sortedscip-python python python-stdlib 3.11 builtins/sorted().([b.last_revision() for b in selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(self)._bzrbranchesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_bzrbranches().()]) |
| 140 |
else: |
| 141 |
revid = None |
| 142 |
for branch in selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(self)._bzrbranchesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_bzrbranches().(): |
| 143 |
try: |
| 144 |
revspec = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(self).revsscip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#revs.[0].decode() |
| 145 |
r = revisionspecscip-python python mercurial 7.2.2 `hgext.convert.bzr`/revisionspec..RevisionSpec.from_string(revspec) |
| 146 |
info = r.in_history(branch) |
| 147 |
except errorsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/errors..BzrError: |
| 148 |
pass |
| 149 |
revid = info.rev_id |
| 150 |
if revid is None: |
| 151 |
raise errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:.Abortscip-python python mercurial 7.2.2 `mercurial.error`/Abort#( |
| 152 |
_(b'%s is not a valid revision') % selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getheads().(self).revsscip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#revs.[0] |
| 153 |
) |
| 154 |
heads = [revid] |
| 155 |
# Empty repositories return 'null:', which cannot be retrieved |
| 156 |
heads = [h for h in heads if h != b'null:'] |
| 157 |
return heads |
| 158 |
|
| 159 |
def getfilescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(self), namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name), revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(rev)): |
| 160 |
namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name) = namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name).decode() |
| 161 |
revtree = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..revision_tree(revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(rev)) |
| 162 |
|
| 163 |
try: |
| 164 |
kind = revtree.kind(namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name)) |
| 165 |
except NoSuchFile: |
| 166 |
return None, None |
| 167 |
if kind not in supportedkindsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/supportedkinds.: |
| 168 |
# the file is not available anymore - was deleted |
| 169 |
return None, None |
| 170 |
mode = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(self)._modecachescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_modecache.[(namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name).encode(), revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(rev))] |
| 171 |
if kind == 'symlink': |
| 172 |
target = revtree.get_symlink_target(namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name)) |
| 173 |
if target is None: |
| 174 |
raise errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:.Abortscip-python python mercurial 7.2.2 `mercurial.error`/Abort#( |
| 175 |
_(b'%s.%s symlink has no target') % (namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name), revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(rev)) |
| 176 |
) |
| 177 |
return target.encode(), mode |
| 178 |
else: |
| 179 |
sio = revtree.get_file(namescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getfile().(name)) |
| 180 |
return sio.read(), mode |
| 181 |
|
| 182 |
def getchangesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self), versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(version), fullscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(full)): |
| 183 |
if fullscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(full): |
| 184 |
raise errorscip-python python mercurial 7.2.2 `mercurial.error`/__init__:.Abortscip-python python mercurial 7.2.2 `mercurial.error`/Abort#(_(b"convert from cvs does not support --full")) |
| 185 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self)._modecachescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_modecache. = {} |
| 186 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self)._revtreescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_revtree. = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..revision_tree(versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(version)) |
| 187 |
# get the parentids from the cache |
| 188 |
parentids = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self)._parentidsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_parentids..popscip-python python python-stdlib 3.11 builtins/dict#pop().(versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(version)) |
| 189 |
# only diff against first parent id |
| 190 |
prevtree = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..revision_tree(parentids[0]) |
| 191 |
files, changes = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self)._gettreechangesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchanges().(self)._revtreescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_revtree., prevtree) |
| 192 |
return files, changes, setscip-python python python-stdlib 3.11 builtins/set#() |
| 193 |
|
| 194 |
def getcommitscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self), versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(version)): |
| 195 |
rev = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..get_revision(versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(version)) |
| 196 |
# populate parent id cache |
| 197 |
if not rev.parent_ids: |
| 198 |
parents = [] |
| 199 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self)._parentidsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_parentids.[versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(version)] = (revisionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/revision..NULL_REVISION,) |
| 200 |
else: |
| 201 |
parents = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self)._filterghostsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(rev.parent_ids) |
| 202 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self)._parentidsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_parentids.[versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(version)] = parents |
| 203 |
|
| 204 |
branch = rev.properties.get('branch-nick', 'default') |
| 205 |
if branch == 'trunk': |
| 206 |
branch = 'default' |
| 207 |
return commonscip-python python mercurial 7.2.2 common/__init__:.commitscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#( |
| 208 |
parentsscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(parents)=parents, |
| 209 |
datescip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(date)=b'%d %d' % (rev.timestamp, -rev.timezone), |
| 210 |
authorscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(author)=selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(rev.committer), |
| 211 |
descscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(desc)=selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(rev.message), |
| 212 |
branchscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(branch)=branch.encodescip-python python python-stdlib 3.11 builtins/str#encode().('utf8'), |
| 213 |
revscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(rev)=versionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(version), |
| 214 |
saverevscip-python python mercurial 7.2.2 `hgext.convert.common`/commit#__init__().(saverev)=selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getcommit().(self)._saverevscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_saverev., |
| 215 |
) |
| 216 |
|
| 217 |
def gettagsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#gettags().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#gettags().(self)): |
| 218 |
bytetags = {} |
| 219 |
for branch in selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#gettags().(self)._bzrbranchesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_bzrbranches().(): |
| 220 |
if not branch.supports_tags(): |
| 221 |
return {} |
| 222 |
tagdict = branch.tags.get_tag_dict() |
| 223 |
for name, rev in tagdict.items(): |
| 224 |
bytetags[selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#gettags().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(name)] = rev |
| 225 |
return bytetags |
| 226 |
|
| 227 |
def getchangedfilesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(self), revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(rev), iscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(i)): |
| 228 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(self)._modecachescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_modecache. = {} |
| 229 |
curtree = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..revision_tree(revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(rev)) |
| 230 |
if iscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(i) is not None: |
| 231 |
parentid = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(self)._parentidsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_parentids.[revscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(rev)][iscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(i)] |
| 232 |
else: |
| 233 |
# no parent id, get the empty revision |
| 234 |
parentid = revisionscip-python python mercurial 7.2.2 `hgext.convert.bzr`/revision..NULL_REVISION |
| 235 |
|
| 236 |
prevtree = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..revision_tree(parentid) |
| 237 |
changes = [e[0] for e in selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#getchangedfiles().(self)._gettreechangesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(curtree, prevtree)[0]] |
| 238 |
return changes |
| 239 |
|
| 240 |
def _gettreechangesscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self), currentscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(current), originscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(origin)): |
| 241 |
revid = currentscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(current)._revision_id |
| 242 |
changes = [] |
| 243 |
renames = {} |
| 244 |
seen = setscip-python python python-stdlib 3.11 builtins/set#() |
| 245 |
|
| 246 |
# Fall back to the deprecated attribute for legacy installations. |
| 247 |
try: |
| 248 |
inventory = originscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(origin).root_inventory |
| 249 |
except AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#: |
| 250 |
inventory = originscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(origin).inventory |
| 251 |
|
| 252 |
# Process the entries by reverse lexicographic name order to |
| 253 |
# handle nested renames correctly, most specific first. |
| 254 |
|
| 255 |
def keyscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#key().(cscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#key().(c)): |
| 256 |
return cscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#key().(c).path[0] or cscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#key().(c).path[1] or "" |
| 257 |
|
| 258 |
curchanges = sortedscip-python python python-stdlib 3.11 builtins/sorted().( |
| 259 |
currentscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(current).iter_changes(originscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(origin)), |
| 260 |
keyscip-python python python-stdlib 3.11 builtins/sorted().(key)=keyscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#key()., |
| 261 |
reversescip-python python python-stdlib 3.11 builtins/sorted().(reverse)=True, |
| 262 |
) |
| 263 |
for change in curchanges: |
| 264 |
paths = change.path |
| 265 |
kind = change.kind |
| 266 |
executable = change.executable |
| 267 |
if paths[0] == '' or paths[1] == '': |
| 268 |
# ignore changes to tree root |
| 269 |
continue |
| 270 |
|
| 271 |
# bazaar tracks directories, mercurial does not, so |
| 272 |
# we have to rename the directory contents |
| 273 |
if kind[1] == 'directory': |
| 274 |
if kind[0] not in (None, 'directory'): |
| 275 |
# Replacing 'something' with a directory, record it |
| 276 |
# so it can be removed. |
| 277 |
changes.appendscip-python python python-stdlib 3.11 builtins/list#append().((selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(paths[0]), revid)) |
| 278 |
|
| 279 |
if kind[0] == 'directory' and None not in paths: |
| 280 |
renaming = paths[0] != paths[1] |
| 281 |
# neither an add nor an delete - a move |
| 282 |
# rename all directory contents manually |
| 283 |
subdir = inventory.path2id(paths[0]) |
| 284 |
# get all child-entries of the directory |
| 285 |
for name, entry in inventory.iter_entries(subdir): |
| 286 |
# hg does not track directory renames |
| 287 |
if entry.kind == 'directory': |
| 288 |
continue |
| 289 |
frompath = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(paths[0] + '/' + name) |
| 290 |
if frompath in seen: |
| 291 |
# Already handled by a more specific change entry |
| 292 |
# This is important when you have: |
| 293 |
# a => b |
| 294 |
# a/c => a/c |
| 295 |
# Here a/c must not be renamed into b/c |
| 296 |
continue |
| 297 |
seen.addscip-python python python-stdlib 3.11 builtins/set#add().(frompath) |
| 298 |
if not renaming: |
| 299 |
continue |
| 300 |
topath = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(paths[1] + '/' + name) |
| 301 |
# register the files as changed |
| 302 |
changes.appendscip-python python python-stdlib 3.11 builtins/list#append().((frompath, revid)) |
| 303 |
changes.appendscip-python python python-stdlib 3.11 builtins/list#append().((topath, revid)) |
| 304 |
# add to mode cache |
| 305 |
mode = ( |
| 306 |
(entry.executable and b'x') |
| 307 |
or (entry.kind == 'symlink' and b's') |
| 308 |
or b'' |
| 309 |
) |
| 310 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self)._modecachescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_modecache.[(topath, revid)] = mode |
| 311 |
# register the change as move |
| 312 |
renames[topath] = frompath |
| 313 |
|
| 314 |
# no further changes, go to the next change |
| 315 |
continue |
| 316 |
|
| 317 |
# we got unicode paths, need to convert them |
| 318 |
path, topath = paths |
| 319 |
if path is not None: |
| 320 |
path = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(path) |
| 321 |
if topath is not None: |
| 322 |
topath = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self).recodescip-python python mercurial 7.2.2 `hgext.convert.common`/converter_source#recode().(topath) |
| 323 |
seen.addscip-python python python-stdlib 3.11 builtins/set#add().(path or topath) |
| 324 |
|
| 325 |
if topath is None: |
| 326 |
# file deleted |
| 327 |
changes.appendscip-python python python-stdlib 3.11 builtins/list#append().((path, revid)) |
| 328 |
continue |
| 329 |
|
| 330 |
# renamed |
| 331 |
if path and path != topath: |
| 332 |
renames[topath] = path |
| 333 |
changes.appendscip-python python python-stdlib 3.11 builtins/list#append().((path, revid)) |
| 334 |
|
| 335 |
# populate the mode cache |
| 336 |
kind, executable = (e[1] for e in (kind, executable)) |
| 337 |
mode = (executable and b'x') or (kind == 'symlink' and b'l') or b'' |
| 338 |
selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_gettreechanges().(self)._modecachescip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_modecache.[(topath, revid)] = mode |
| 339 |
changes.appendscip-python python python-stdlib 3.11 builtins/list#append().((topath, revid)) |
| 340 |
|
| 341 |
return changes, renames |
| 342 |
|
| 343 |
def _filterghostsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(self), idsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(ids)): |
| 344 |
"""Filters out ghost revisions which hg does not support, see |
| 345 |
<http://bazaar-vcs.org/GhostRevision> |
| 346 |
""" |
| 347 |
parentmap = selfscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(self).sourcereposcip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#sourcerepo..get_parent_map(idsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(ids)) |
| 348 |
parents = tuplescip-python python python-stdlib 3.11 builtins/tuple#([parent for parent in idsscip-python python mercurial 7.2.2 `hgext.convert.bzr`/bzr_source#_filterghosts().(ids) if parent in parentmap]) |
| 349 |
return parents |