diff -r e11c14f14491 -r f02d7a562a21 mercurial/subrepo.py --- a/mercurial/subrepo.py Thu Dec 16 07:45:22 2010 -0600 +++ b/mercurial/subrepo.py Mon Nov 29 09:37:23 2010 +0100 @@ -13,6 +13,19 @@ nullstate = ('', '', 'empty') + +def substate(ctx): + rev = {} + if '.hgsubstate' in ctx: + try: + for l in ctx['.hgsubstate'].data().splitlines(): + revision, path = l.split(" ", 1) + rev[path] = revision + except IOError as err: + if err.errno != errno.ENOENT: + raise + return rev + def state(ctx, ui): """return a state dict, mapping subrepo paths configured in .hgsub to tuple: (source from .hgsub, revision from .hgsubstate, kind @@ -39,15 +52,7 @@ for path, src in ui.configitems('subpaths'): p.set('subpaths', path, src, ui.configsource('subpaths', path)) - rev = {} - if '.hgsubstate' in ctx: - try: - for l in ctx['.hgsubstate'].data().splitlines(): - revision, path = l.split(" ", 1) - rev[path] = revision - except IOError, err: - if err.errno != errno.ENOENT: - raise + rev = substate(ctx) state = {} for path, src in p[''].items():