예제 #1
0
    def _get_changesets(self, org_repo, org_ref, other_repo, other_ref,
                        discovery_data):
        """
        Returns a list of changesets that are incoming from org_repo@org_ref
        to other_repo@other_ref

        :param org_repo:
        :type org_repo:
        :param org_ref:
        :type org_ref:
        :param other_repo:
        :type other_repo:
        :param other_ref:
        :type other_ref:
        :param tmp:
        :type tmp:
        """
        changesets = []
        #case two independent repos
        common, incoming, rheads = discovery_data
        if org_repo != other_repo and incoming:
            obj = findcommonoutgoing(org_repo._repo,
                        localrepo.locallegacypeer(other_repo._repo.local()),
                        force=True)
            revs = obj.missing

            for cs in reversed(map(binascii.hexlify, revs)):
                changesets.append(org_repo.get_changeset(cs))
        else:
            _revset_predicates = {
                    'branch': 'branch',
                    'book': 'bookmark',
                    'tag': 'tag',
                    'rev': 'id',
                }

            revs = [
                "ancestors(%s('%s')) and not ancestors(%s('%s'))" % (
                    _revset_predicates[org_ref[0]], org_ref[1],
                    _revset_predicates[other_ref[0]], other_ref[1]
               )
            ]

            out = scmutil.revrange(org_repo._repo, revs)
            for cs in reversed(out):
                changesets.append(org_repo.get_changeset(cs))

        return changesets
예제 #2
0
    def _get_changesets(self, alias, org_repo, org_ref, other_repo, other_ref,
                        discovery_data):
        """
        Returns a list of changesets that are incoming from org_repo@org_ref
        to other_repo@other_ref

        :param org_repo:
        :param org_ref:
        :param other_repo:
        :param other_ref:
        :param tmp:
        """

        changesets = []
        #case two independent repos
        common, incoming, rheads = discovery_data
        if org_repo != other_repo:
            revs = [
                org_repo._repo.lookup(org_ref[1]),
                org_repo._repo.lookup(other_ref[1]),
            ]

            obj = findcommonoutgoing(org_repo._repo,
                        localrepo.locallegacypeer(other_repo._repo.local()),
                        revs,
                        force=True)
            revs = obj.missing

            for cs in map(binascii.hexlify, revs):
                _cs = org_repo.get_changeset(cs)
                changesets.append(_cs)
            # in case we have revisions filter out the ones not in given range
            if org_ref[0] == 'rev' and other_ref[0] == 'rev':
                revs = [x.raw_id for x in changesets]
                start = org_ref[1]
                stop = other_ref[1]
                changesets = changesets[revs.index(start):revs.index(stop) + 1]
        else:
            #no remote compare do it on the same repository
            if alias == 'hg':
                _revset_predicates = {
                        'branch': 'branch',
                        'book': 'bookmark',
                        'tag': 'tag',
                        'rev': 'id',
                    }

                revs = [
                    "ancestors(%s('%s')) and not ancestors(%s('%s'))" % (
                        _revset_predicates[other_ref[0]], other_ref[1],
                        _revset_predicates[org_ref[0]], org_ref[1],
                   )
                ]

                out = scmutil.revrange(org_repo._repo, revs)
                for cs in (out):
                    changesets.append(org_repo.get_changeset(cs))
            elif alias == 'git':
                so, se = org_repo.run_git_command(
                    'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1],
                                                                     other_ref[1])
                )
                ids = re.findall(r'[0-9a-fA-F]{40}', so)
                for cs in (ids):
                    changesets.append(org_repo.get_changeset(cs))

        return changesets