Previously there is a race condition:
origpinned = loadpinnednodes(repo) newpinned = .... with repo.lock(): # the lock might be taken by process X # get the lock after some time. at this time, the state file might # be updated by process X but we are not aware of it. savepinnednodes(...) # process X's change gets discarded
This patch solves that by making the write function takes a delta instead of
full content, and apply that delta inside a lock. Using repo lock is
expensive so we use a single-file lightweight flock instead.