hgext/convert/bzr.py
author Gregory Szorc <gregory.szorc@gmail.com>
Thu, 05 May 2016 00:35:45 -0700
changeset 29111 843df550b465
parent 28479 d62b00318c19
child 29205 a0939666b836
permissions -rw-r--r--
sslutil: check for ui.insecureconnections in sslkwargs The end result of this function is the same. We now have a more explicit return branch. We still keep the old code looking at web.cacerts=! a few lines below because we're still setting web.cacerts=! and need to react to the variable. This will be removed in an upcoming patch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8250
1b60efdb8bc5 convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents: 8166
diff changeset
     1
# bzr.py - bzr support for the convert extension
1b60efdb8bc5 convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents: 8166
diff changeset
     2
#
1b60efdb8bc5 convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents: 8166
diff changeset
     3
#  Copyright 2008, 2009 Marek Kubica <marek@xivilization.net> and others
1b60efdb8bc5 convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents: 8166
diff changeset
     4
#
1b60efdb8bc5 convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents: 8166
diff changeset
     5
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 8784
diff changeset
     6
# GNU General Public License version 2 or any later version.
8250
1b60efdb8bc5 convert: add copyright and license headers to back-ends
Martin Geisler <mg@lazybytes.net>
parents: 8166
diff changeset
     7
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
     8
# This module is for handling 'bzr', that was formerly known as Bazaar-NG;
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
     9
# it cannot access 'bar' repositories, but they were never used very much
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    10
from __future__ import absolute_import
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    11
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    12
import os
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    13
from mercurial import (
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    14
    demandimport,
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    15
    error
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    16
)
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    17
from mercurial.i18n import _
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    18
from . import common
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    19
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    20
# these do not work with demandimport, blacklist
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    21
demandimport.ignore.extend([
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    22
        'bzrlib.transactions',
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    23
        'bzrlib.urlutils',
10560
9134725caf1d Add ElementPath to the list of package ignored by demand import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 10394
diff changeset
    24
        'ElementPath',
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    25
    ])
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    26
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    27
try:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    28
    # bazaar imports
28479
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    29
    import bzrlib.bzrdir
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    30
    import bzrlib.errors
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    31
    import bzrlib.revision
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    32
    import bzrlib.revisionspec.RevisionSpec
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    33
    bzrdir = bzrlib.bzrdir
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    34
    errors = bzrlib.errors
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    35
    revision = bzrlib.revision
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
    36
    revisionspec = bzrlib.revisionspec
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    37
except ImportError:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    38
    pass
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    39
8045
e09a2f2ef85d convert/bzr: fix file rename replaced by a dir case (issue1583)
Patrick Mezard <pmezard@gmail.com>
parents: 8035
diff changeset
    40
supportedkinds = ('file', 'symlink')
e09a2f2ef85d convert/bzr: fix file rename replaced by a dir case (issue1583)
Patrick Mezard <pmezard@gmail.com>
parents: 8035
diff changeset
    41
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    42
class bzr_source(common.converter_source):
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    43
    """Reads Bazaar repositories by using the Bazaar Python libraries"""
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    44
25748
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
    45
    def __init__(self, ui, path, revs=None):
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
    46
        super(bzr_source, self).__init__(ui, path, revs=revs)
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    47
7973
db3a68fd9387 convert: attempt to check repo type before checking for tool
Matt Mackall <mpm@selenic.com>
parents: 7060
diff changeset
    48
        if not os.path.exists(os.path.join(path, '.bzr')):
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    49
            raise common.NoRepo(_('%s does not look like a Bazaar repository')
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    50
                              % path)
7973
db3a68fd9387 convert: attempt to check repo type before checking for tool
Matt Mackall <mpm@selenic.com>
parents: 7060
diff changeset
    51
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    52
        try:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    53
            # access bzrlib stuff
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
    54
            bzrdir
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    55
        except NameError:
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    56
            raise common.NoRepo(_('Bazaar modules could not be loaded'))
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    57
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    58
        path = os.path.abspath(path)
8470
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    59
        self._checkrepotype(path)
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
    60
        try:
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
    61
            self.sourcerepo = bzrdir.BzrDir.open(path).open_repository()
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
    62
        except errors.NoRepositoryPresent:
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    63
            raise common.NoRepo(_('%s does not look like a Bazaar repository')
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
    64
                              % path)
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    65
        self._parentids = {}
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    66
8470
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    67
    def _checkrepotype(self, path):
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    68
        # Lightweight checkouts detection is informational but probably
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    69
        # fragile at API level. It should not terminate the conversion.
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    70
        try:
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    71
            dir = bzrdir.BzrDir.open_containing(path)[0]
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    72
            try:
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    73
                tree = dir.open_workingtree(recommend_upgrade=False)
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    74
                branch = tree.branch
12063
516b000fbb7e cleanup: remove unused variables
Brodie Rao <brodie@bitheap.org>
parents: 11134
diff changeset
    75
            except (errors.NoWorkingTree, errors.NotLocalUrl):
8470
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    76
                tree = None
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    77
                branch = dir.open_branch()
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    78
            if (tree is not None and tree.bzrdir.root_transport.base !=
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    79
                branch.bzrdir.root_transport.base):
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    80
                self.ui.warn(_('warning: lightweight checkouts may cause '
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    81
                               'conversion failures, try with a regular '
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    82
                               'branch instead.\n'))
16689
f366d4c2ff34 cleanup: replace naked excepts with except Exception: ...
Brodie Rao <brodie@sf.io>
parents: 16099
diff changeset
    83
        except Exception:
8470
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    84
            self.ui.note(_('bzr source type could not be determined\n'))
dd24488cba2d convert/bzr: warn when source is a lightweight checkout (issue1647)
Patrick Mezard <pmezard@gmail.com>
parents: 8434
diff changeset
    85
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    86
    def before(self):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    87
        """Before the conversion begins, acquire a read lock
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    88
        for all the operations that might need it. Fortunately
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    89
        read locks don't block other reads or writes to the
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    90
        repository, so this shouldn't have any impact on the usage of
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    91
        the source repository.
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    92
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    93
        The alternative would be locking on every operation that
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    94
        needs locks (there are currently two: getting the file and
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    95
        getting the parent map) and releasing immediately after,
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    96
        but this approach can take even 40% longer."""
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    97
        self.sourcerepo.lock_read()
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    98
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
    99
    def after(self):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   100
        self.sourcerepo.unlock()
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   101
16099
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   102
    def _bzrbranches(self):
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   103
        return self.sourcerepo.find_branches(using=True)
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   104
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   105
    def getheads(self):
25748
baea47cafe75 convert: add support for specifying multiple revs
Durham Goode <durham@fb.com>
parents: 24395
diff changeset
   106
        if not self.revs:
16099
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   107
            # Set using=True to avoid nested repositories (see issue3254)
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   108
            heads = sorted([b.last_revision() for b in self._bzrbranches()])
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   109
        else:
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   110
            revid = None
16099
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   111
            for branch in self._bzrbranches():
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   112
                try:
28479
d62b00318c19 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 28411
diff changeset
   113
                    r = revisionspec.RevisionSpec.from_string(self.revs[0])
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   114
                    info = r.in_history(branch)
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   115
                except errors.BzrError:
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   116
                    pass
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   117
                revid = info.rev_id
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   118
            if revid is None:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   119
                raise error.Abort(_('%s is not a valid revision')
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   120
                                  % self.revs[0])
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   121
            heads = [revid]
16061
915e06faa8f3 convert/bzr: handle empty bzr repositories (issue3233)
Patrick Mezard <pmezard@gmail.com>
parents: 16060
diff changeset
   122
        # Empty repositories return 'null:', which cannot be retrieved
915e06faa8f3 convert/bzr: handle empty bzr repositories (issue3233)
Patrick Mezard <pmezard@gmail.com>
parents: 16060
diff changeset
   123
        heads = [h for h in heads if h != 'null:']
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   124
        return heads
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   125
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   126
    def getfile(self, name, rev):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   127
        revtree = self.sourcerepo.revision_tree(rev)
8783
6556d4145122 bzr convert: restore paths to source encoding. Closes issue1692.
Brendan Cully <brendan@kublai.com>
parents: 8423
diff changeset
   128
        fileid = revtree.path2id(name.decode(self.encoding or 'utf-8'))
8423
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   129
        kind = None
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   130
        if fileid is not None:
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   131
            kind = revtree.kind(fileid)
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   132
        if kind not in supportedkinds:
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   133
            # the file is not available anymore - was deleted
22296
650b5b6e75ed convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents: 17424
diff changeset
   134
            return None, None
11134
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10939
diff changeset
   135
        mode = self._modecache[(name, rev)]
8423
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   136
        if kind == 'symlink':
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   137
            target = revtree.get_symlink_target(fileid)
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   138
            if target is None:
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25748
diff changeset
   139
                raise error.Abort(_('%s.%s symlink has no target')
8423
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   140
                                 % (name, rev))
11134
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10939
diff changeset
   141
            return target, mode
8423
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   142
        else:
eb7be0e752d9 convert/bzr: fix symlinks target (issue1626/2)
Patrick Mezard <pmezard@gmail.com>
parents: 8165
diff changeset
   143
            sio = revtree.get_file(fileid)
11134
33010ff1fd6f convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents: 10939
diff changeset
   144
            return sio.read(), mode
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   145
22300
35ab037de989 convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents: 22296
diff changeset
   146
    def getchanges(self, version, full):
35ab037de989 convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents: 22296
diff changeset
   147
        if full:
26779
aaa33ec3c951 grammar: use does instead of do where appropriate
timeless@mozdev.org
parents: 26587
diff changeset
   148
            raise error.Abort(_("convert from cvs does not support --full"))
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   149
        self._modecache = {}
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   150
        self._revtree = self.sourcerepo.revision_tree(version)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   151
        # get the parentids from the cache
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   152
        parentids = self._parentids.pop(version)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   153
        # only diff against first parent id
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   154
        prevtree = self.sourcerepo.revision_tree(parentids[0])
24395
216fa1ba9993 convert: optimize convert of files that are unmodified from p2 in merges
Mads Kiilerich <madski@unity3d.com>
parents: 22300
diff changeset
   155
        files, changes = self._gettreechanges(self._revtree, prevtree)
216fa1ba9993 convert: optimize convert of files that are unmodified from p2 in merges
Mads Kiilerich <madski@unity3d.com>
parents: 22300
diff changeset
   156
        return files, changes, set()
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   157
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   158
    def getcommit(self, version):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   159
        rev = self.sourcerepo.get_revision(version)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   160
        # populate parent id cache
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   161
        if not rev.parent_ids:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   162
            parents = []
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   163
            self._parentids[version] = (revision.NULL_REVISION,)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   164
        else:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   165
            parents = self._filterghosts(rev.parent_ids)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   166
            self._parentids[version] = parents
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   167
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   168
        branch = self.recode(rev.properties.get('branch-nick', u'default'))
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   169
        if branch == 'trunk':
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   170
            branch = 'default'
28411
098bb5660580 convert: bzr use absolute_import
timeless <timeless@mozdev.org>
parents: 26779
diff changeset
   171
        return common.commit(parents=parents,
8305
7a0fcdd3828f convert/bzr: handle Bazaar timestamps correctly (issue1652).
Greg Ward <greg-hg@gerg.ca>
parents: 8250
diff changeset
   172
                date='%d %d' % (rev.timestamp, -rev.timezone),
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   173
                author=self.recode(rev.committer),
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   174
                desc=self.recode(rev.message),
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   175
                branch=branch,
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   176
                rev=version)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   177
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   178
    def gettags(self):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   179
        bytetags = {}
16099
4e4c416a0b1f convert/bzr: ignore nested repos when listing branches (issue3254)
Patrick Mezard <patrick@mezard.eu>
parents: 16061
diff changeset
   180
        for branch in self._bzrbranches():
16060
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   181
            if not branch.supports_tags():
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   182
                return {}
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   183
            tagdict = branch.tags.get_tag_dict()
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   184
            for name, rev in tagdict.iteritems():
f84dda152a55 convert/bzr: convert all branches (issue3229) (BC)
Patrick Mezard <pmezard@gmail.com>
parents: 16059
diff changeset
   185
                bytetags[self.recode(name)] = rev
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   186
        return bytetags
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   187
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   188
    def getchangedfiles(self, rev, i):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   189
        self._modecache = {}
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   190
        curtree = self.sourcerepo.revision_tree(rev)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   191
        if i is not None:
8165
78658990c725 convert/bzr: make it work with filemaps (issue1631)
Patrick Mezard <pmezard@gmail.com>
parents: 8148
diff changeset
   192
            parentid = self._parentids[rev][i]
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   193
        else:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   194
            # no parent id, get the empty revision
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   195
            parentid = revision.NULL_REVISION
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   196
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   197
        prevtree = self.sourcerepo.revision_tree(parentid)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   198
        changes = [e[0] for e in self._gettreechanges(curtree, prevtree)[0]]
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   199
        return changes
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   200
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   201
    def _gettreechanges(self, current, origin):
10394
4612cded5176 fix coding style (reported by pylint)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 10282
diff changeset
   202
        revid = current._revision_id
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   203
        changes = []
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   204
        renames = {}
15461
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   205
        seen = set()
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   206
        # Process the entries by reverse lexicographic name order to
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   207
        # handle nested renames correctly, most specific first.
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   208
        curchanges = sorted(current.iter_changes(origin),
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   209
                            key=lambda c: c[1][0] or c[1][1],
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   210
                            reverse=True)
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   211
        for (fileid, paths, changed_content, versioned, parent, name,
15461
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   212
            kind, executable) in curchanges:
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   213
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   214
            if paths[0] == u'' or paths[1] == u'':
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   215
                # ignore changes to tree root
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   216
                continue
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   217
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   218
            # bazaar tracks directories, mercurial does not, so
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   219
            # we have to rename the directory contents
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   220
            if kind[1] == 'directory':
8126
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents: 8045
diff changeset
   221
                if kind[0] not in (None, 'directory'):
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents: 8045
diff changeset
   222
                    # Replacing 'something' with a directory, record it
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents: 8045
diff changeset
   223
                    # so it can be removed.
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents: 8045
diff changeset
   224
                    changes.append((self.recode(paths[0]), revid))
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents: 8045
diff changeset
   225
15461
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   226
                if kind[0] == 'directory' and None not in paths:
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   227
                    renaming = paths[0] != paths[1]
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   228
                    # neither an add nor an delete - a move
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   229
                    # rename all directory contents manually
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   230
                    subdir = origin.inventory.path2id(paths[0])
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   231
                    # get all child-entries of the directory
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   232
                    for name, entry in origin.inventory.iter_entries(subdir):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   233
                        # hg does not track directory renames
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   234
                        if entry.kind == 'directory':
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   235
                            continue
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   236
                        frompath = self.recode(paths[0] + '/' + name)
15461
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   237
                        if frompath in seen:
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   238
                            # Already handled by a more specific change entry
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   239
                            # This is important when you have:
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   240
                            # a => b
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   241
                            # a/c => a/c
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   242
                            # Here a/c must not be renamed into b/c
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   243
                            continue
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   244
                        seen.add(frompath)
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   245
                        if not renaming:
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   246
                            continue
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   247
                        topath = self.recode(paths[1] + '/' + name)
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   248
                        # register the files as changed
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   249
                        changes.append((frompath, revid))
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   250
                        changes.append((topath, revid))
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   251
                        # add to mode cache
10282
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
   252
                        mode = ((entry.executable and 'x')
08a0f04b56bd many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents: 10263
diff changeset
   253
                                or (entry.kind == 'symlink' and 's')
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   254
                                or '')
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   255
                        self._modecache[(topath, revid)] = mode
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   256
                        # register the change as move
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   257
                        renames[topath] = frompath
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   258
17424
e7cfe3587ea4 fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents: 16689
diff changeset
   259
                # no further changes, go to the next change
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   260
                continue
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   261
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   262
            # we got unicode paths, need to convert them
16059
f5b6046f6ce8 convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)
Patrick Mezard <pmezard@gmail.com>
parents: 15461
diff changeset
   263
            path, topath = paths
f5b6046f6ce8 convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)
Patrick Mezard <pmezard@gmail.com>
parents: 15461
diff changeset
   264
            if path is not None:
f5b6046f6ce8 convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)
Patrick Mezard <pmezard@gmail.com>
parents: 15461
diff changeset
   265
                path = self.recode(path)
f5b6046f6ce8 convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)
Patrick Mezard <pmezard@gmail.com>
parents: 15461
diff changeset
   266
            if topath is not None:
f5b6046f6ce8 convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)
Patrick Mezard <pmezard@gmail.com>
parents: 15461
diff changeset
   267
                topath = self.recode(topath)
15461
6ba2fc0a87ab convert/bzr: correctly handle divergent nested renames (issue3089)
Patrick Mezard <pmezard@gmail.com>
parents: 12063
diff changeset
   268
            seen.add(path or topath)
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   269
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   270
            if topath is None:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   271
                # file deleted
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   272
                changes.append((path, revid))
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   273
                continue
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   274
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   275
            # renamed
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   276
            if path and path != topath:
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   277
                renames[topath] = path
8035
cb77c0fbec39 convert: remove renamed source files (issue1505)
Xavier ALT <dex@phoenix-ind.net>
parents: 7060
diff changeset
   278
                changes.append((path, revid))
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   279
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   280
            # populate the mode cache
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   281
            kind, executable = [e[1] for e in (kind, executable)]
8148
adce97d28389 convert/bzr: fix symlink handling (issue1626)
Patrick Mezard <pmezard@gmail.com>
parents: 8126
diff changeset
   282
            mode = ((executable and 'x') or (kind == 'symlink' and 'l')
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   283
                    or '')
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   284
            self._modecache[(topath, revid)] = mode
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   285
            changes.append((topath, revid))
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   286
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   287
        return changes, renames
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   288
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   289
    def _filterghosts(self, ids):
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   290
        """Filters out ghost revisions which hg does not support, see
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   291
        <http://bazaar-vcs.org/GhostRevision>
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   292
        """
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   293
        parentmap = self.sourcerepo.get_parent_map(ids)
7060
972cce34f345 convert: fixed python2.3 incompatibility in bzr source (generator expression)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7053
diff changeset
   294
        parents = tuple([parent for parent in ids if parent in parentmap])
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
diff changeset
   295
        return parents