swh.loader.mercurial.identify module#
- class swh.loader.mercurial.identify.HgAuthor(fullname: bytes, name: bytes | None, email: bytes | None)[source]#
Bases:
NamedTuple
Represent a Mercurial revision author.
Create new instance of HgAuthor(fullname, name, email)
- class swh.loader.mercurial.identify.HgRevision(node_id: bytes, author: HgAuthor, timestamp: bytes, offset: bytes, parents: List[bytes], extras: Dict[bytes, bytes], description: bytes)[source]#
Bases:
NamedTuple
Represent a Mercurial revision.
Create new instance of HgRevision(node_id, author, timestamp, offset, parents, extras, description)
- static from_bytes(data: bytes, description: bytes) HgRevision [source]#
Convert bytes to an HgRevision named tuple.
Expected data format: ‘’’ node_id:{node} author:{author} timestamp_offset:[{timestamp}, {offset}] p1:{p1} p2:{p2} extras:{key1}={value1} … extras:{keyn}={value} ‘’’
- class swh.loader.mercurial.identify.HgBranch(name: bytes, node_id: bytes)[source]#
Bases:
NamedTuple
Represent a Mercurial branch.
Create new instance of HgBranch(name, node_id)
- class swh.loader.mercurial.identify.HgTag(name: bytes, node_id: bytes)[source]#
Bases:
NamedTuple
Represent a Mercurial tag.
Create new instance of HgTag(name, node_id)
- class swh.loader.mercurial.identify.Hg(repository_root: Path)[source]#
Bases:
object
Provide methods to extract data from a Mercurial repository.
- log(rev: bytes | str | None = None) List[HgRevision] [source]#
Return the specified revisions of the Mercurial repository.
Mercurial revsets are supported. (See hg help revsets)
If no revision range is specified, return all revisions”.
- tip() HgRevision [source]#
Return the tip node-id.
- swh.loader.mercurial.identify.identify_directory(path: Path) CoreSWHID [source]#
Return the SWHID of the given path.
- class swh.loader.mercurial.identify.RevisionIdentity(swhid: CoreSWHID, node_id: bytes, directory_swhid: CoreSWHID)[source]#
Bases:
NamedTuple
Represent a swh revision identity.
Create new instance of RevisionIdentity(swhid, node_id, directory_swhid)
- swh.loader.mercurial.identify.identify_revision(hg: Hg, rev: bytes | None = None, node_id_2_swhid: Dict[bytes, CoreSWHID] | None = None) Iterator[RevisionIdentity] [source]#
Return the repository revision identities.
- Parameters:
hg – A Hg repository instance
rev – An optional revision or Mercurial revsets (See hg help revsets) If not provided all the repository revisions will be computed.
node_id_2_swhid – An optional cache mapping hg node ids to SWHIDs It will be updated in place with new mappings.
- class swh.loader.mercurial.identify.ReleaseIdentity(swhid: CoreSWHID, node_id: bytes, name: bytes)[source]#
Bases:
NamedTuple
Represent a swh release identity.
Create new instance of ReleaseIdentity(swhid, node_id, name)
- swh.loader.mercurial.identify.identify_release(hg: Hg, node_id_2_swhid: Dict[bytes, CoreSWHID] | None = None) Iterator[ReleaseIdentity] [source]#
Return the repository’s release identities.
- Parameters:
hg – A Hg repository instance
node_id_2_swhid – An optional cache mapping hg node ids to SWHIDs If not provided it will be computed using identify_revision.
- swh.loader.mercurial.identify.identify_snapshot(hg: Hg, node_id_2_swhid: Dict[bytes, CoreSWHID] | None = None, releases: List[ReleaseIdentity] | None = None) CoreSWHID [source]#
Return the repository snapshot identity.
- Parameters:
hg – A Hg repository instance
node_id_2_swhid – An optional cache mapping hg node ids to SWHIDs If not provided it will be computed using identify_revision.
release – an optional list of ReleaseIdentity. If not provided it will be computed using identify_release.