mercurial/branchmap.py
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 20 Dec 2012 13:37:37 +0100
changeset 18117 526e7ec5c96e
parent 18116 bcee63733aad
child 18118 e70ff1e599f4
permissions -rw-r--r--
branchmap: extract write logic from localrepo

# branchmap.py - logic to computes, maintain and stores branchmap for local repo
#
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

from node import hex
import encoding

def write(repo, branches, tip, tiprev):
    try:
        f = repo.opener("cache/branchheads", "w", atomictemp=True)
        f.write("%s %s\n" % (hex(tip), tiprev))
        for label, nodes in branches.iteritems():
            for node in nodes:
                f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
        f.close()
    except (IOError, OSError):
        pass