Mercurial repository identification

后端 未结 2 1601
天命终不由人
天命终不由人 2021-01-13 03:24

I need to be able to uniquely identify a Mercurial repository and have that identifier placed in a file that is included when cloned. If I can put the identifier in a file i

2条回答
  •  失恋的感觉
    2021-01-13 03:53

    error: repository is unrelated message come from mercurial/treediscovery.py:

    base = list(base)
    if base == [nullid]:
        if force:
            repo.ui.warn(_("warning: repository is unrelated\n"))
        else:
            raise util.Abort(_("repository is unrelated"))
    

    base variable store last common parts of two repositories. By giving this idea of push/pull checks we may assume that repositories are related if they have common roots, so check hashes from command:

    $ hg log -r "roots(all())"
    

    For unknown to me reason hg log -r 0 always shown same root, but you may have situation that FIRST_REPO hold SECOND_REPO history, but obviously 0 revs of SECOND_REPO different from FIRST_REPO but Mercurial check is passed.

    You may not trick roots checking by carefully crafting repositories because building two repositories looks like these (with common parts but different roots):

    0 <--- SHA-256-XXX <--- SHA-256-YYY <--- SHA-256-ZZZ
    0 <--- SHA-256-YYY <--- SHA-256-ZZZ
    

    impossible because that mean you reverse SHA-256 as each subsequent hash depends on previous values.

提交回复
热议问题