Esempio n. 1
0
    def revision_id_bzr_to_foreign(cls, revid):
        assert isinstance(revid, str)

        if not revid.startswith(cls.revid_prefix):
            raise errors.InvalidRevisionId(revid, "")

        try:
            (version, uuid, branch_path, srevnum) = revid.split(":")
        except ValueError:
            raise errors.InvalidRevisionId(revid, "")

        branch_path = mapping.unescape_svn_path(branch_path)

        return (uuid, branch_path, int(srevnum)), cls()
Esempio n. 2
0
 def revision_id_bzr_to_foreign(cls, revision_id):
     """See VcsMapping.revision_id_foreign_to_bzr."""
     if revision_id == _mod_revision.NULL_REVISION:
         return mercurial.node.nullid, cls()
     if not revision_id.startswith("%s:" % cls.revid_prefix):
         raise errors.InvalidRevisionId(revision_id, cls)
     return bin(revision_id[len(cls.revid_prefix) + 1:]), cls()
Esempio n. 3
0
    def _parse_revision_id(cls, revid):
        if not isinstance(revid, bytes):
            raise TypeError(revid)

        if not revid.startswith(cls.revid_prefix):
            raise bzr_errors.InvalidRevisionId(revid, "")

        try:
            (version, uuid, branch_path, srevnum) = revid.split(":")
        except ValueError:
            raise bzr_errors.InvalidRevisionId(revid, "")

        scheme = version[len(cls.revid_prefix):]

        branch_path = mapping.unescape_svn_path(branch_path)

        return (uuid, branch_path, int(srevnum), scheme)
Esempio n. 4
0
 def revision_id_bzr_to_foreign(self, bzr_revid):
     if bzr_revid == _mod_revision.NULL_REVISION:
         return mercurial.node.nullid, None
     if not bzr_revid.startswith("hg-"):
         raise errors.InvalidRevisionId(bzr_revid, None)
     (mapping_version, hg_ref) = bzr_revid.split(":", 1)
     mapping = self.get(mapping_version)
     return mapping.revision_id_bzr_to_foreign(bzr_revid)
Esempio n. 5
0
 def get_revision(self, revision_id):
     if not type(revision_id) is str:
         raise errors.InvalidRevisionId(revision_id, self)
     hgrevid, mapping = self.lookup_bzr_revision_id(revision_id)
     assert mapping is not None
     hgchange = self._hgrepo.changelog.read(hgrevid)
     hgparents = self._hgrepo.changelog.parents(hgrevid)
     parent_ids = as_bzr_parents(hgparents, self.lookup_foreign_revision_id)
     return mapping.import_revision(revision_id, parent_ids, hgrevid,
         hgchange[0], hgchange[1].decode("utf-8"), hgchange[2],
         hgchange[4].decode("utf-8"), hgchange[5])[0]
Esempio n. 6
0
 def set_last_revision_info(self, revno, revision_id):
     if not revision_id or not isinstance(revision_id, basestring):
         raise errors.InvalidRevisionId(revision_id=revision_id, branch=self)
     revision_id = _mod_revision.ensure_null(revision_id)
     old_revno, old_revid = self.last_revision_info()
     # TODO: Check append_revisions_only ?
     self._run_pre_change_branch_tip_hooks(revno, revision_id)
     self._write_last_revision_info(revno, revision_id)
     self._clear_cached_state()
     self._last_revision_info_cache = revno, revision_id
     self._run_post_change_branch_tip_hooks(old_revno, old_revid)