comparison mercurial/subrepo.py @ 8812:859f841937d0

subrepo: introduce basic state parsing
author Matt Mackall <mpm@selenic.com>
date Mon, 15 Jun 2009 02:45:38 -0500
parents
children db3c1ab0e632
comparison
equal deleted inserted replaced
8811:8b35b08724eb 8812:859f841937d0
1 # subrepo.py - sub-repository handling for Mercurial
2 #
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2, incorporated herein by reference.
7
8 import config, util, errno
9
10 def state(ctx):
11 p = config.config()
12 def read(f, sections=None, remap=None):
13 if f in ctx:
14 try:
15 p.parse(f, ctx[f].data(), sections, remap)
16 except IOError, err:
17 if err.errno != errno.ENOENT:
18 raise
19 read('.hgsub')
20
21 rev = {}
22 if '.hgsubstate' in ctx:
23 try:
24 for l in ctx['.hgsubstate'].data().splitlines():
25 revision, path = l.split()
26 rev[path] = revision
27 except IOError, err:
28 if err.errno != errno.ENOENT:
29 raise
30
31 state = {}
32 for path, src in p[''].items():
33 state[path] = (src, rev.get(path, ''))
34
35 return state