checking for a non-existent node (change and file contexts)

Tay Ray Chuan rctay89 at gmail.com
Thu Mar 11 16:35:13 CST 2010


Hi,

On Fri, Mar 12, 2010 at 12:39 AM, Benoit Boissinot
<benoit.boissinot at ens-lyon.org> wrote:
> On Fri, Mar 12, 2010 at 12:33:25AM +0800, Tay Ray Chuan wrote:
>> I am hacking a mercurial transport (hg-git to be exact) and I wish to
>> know if there's an API method to check for the existence of an
>> arbitrary SHA-1 node.
>
> No, and it's quite expensive.
>
> There are two ways:
> Loop changelogs, record manifest hash, loop manifestdelta() (the truc
> is to use *delta*, it's much less expensive), record files hash, done.
>
> or
>
> Loop store.datafiles(), load revlog index, record hashes (you /might/
> find extra hashes though if there are orphaned revlogs)

Ah, seems like it's more expensive than I figured.

> But it would be probably easier if you explained your high level goal,
> we could see what's the best way to do it.

In hg-git, mappings of hg to git objects via their SHA-1 are recorded.
However, I find myself rewriting history pretty frequently (eg.
through mq's strip), and some of these mappings get stale (ie. a
mapping entry with a SHA-1 pointing to a non-existent hg object).

What I want is to detect which mappings have gone stale.

I've thought about two ways to this:

1. Hook on to mq's strip, so that each time the command is invoked, we
detect which revs get removed/bundled and remove those mappings from
the map file.

  However, I don't see any extensible callback to this easily.

2. Invoke some mercurial API method to detect which SHA-1 points to
non-existent hg objects.

-- 
Cheers,
Ray Chuan


More information about the Mercurial-devel mailing list