diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py index 2de6ac4ac17cc917a629e4fa6e4aad9f5e5b4abf_bWVyY3VyaWFsL3N1YnJlcG8ucHk=..95ca6c8b38da95c065d6454dad775c7ba24e91db_bWVyY3VyaWFsL3N1YnJlcG8ucHk= 100644 --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -43,7 +43,7 @@ rev = {} if '.hgsubstate' in ctx: try: - for l in ctx['.hgsubstate'].data().splitlines(): + for i, l in enumerate(ctx['.hgsubstate'].data().splitlines()): l = l.lstrip() if not l: continue @@ -47,7 +47,12 @@ l = l.lstrip() if not l: continue - revision, path = l.split(" ", 1) + try: + revision, path = l.split(" ", 1) + except ValueError: + raise util.Abort(_("invalid subrepository revision " + "specifier in .hgsubstate line %d") + % (i + 1)) rev[path] = revision except IOError, err: if err.errno != errno.ENOENT: diff --git a/tests/test-subrepo-missing.t b/tests/test-subrepo-missing.t index 2de6ac4ac17cc917a629e4fa6e4aad9f5e5b4abf_dGVzdHMvdGVzdC1zdWJyZXBvLW1pc3NpbmcudA==..95ca6c8b38da95c065d6454dad775c7ba24e91db_dGVzdHMvdGVzdC1zdWJyZXBvLW1pc3NpbmcudA== 100644 --- a/tests/test-subrepo-missing.t +++ b/tests/test-subrepo-missing.t @@ -19,6 +19,15 @@ M .hgsubstate $ hg revert -qC .hgsubstate +abort more gracefully on .hgsubstate parsing error + + $ cp .hgsubstate .hgsubstate.old + >>> file('.hgsubstate', 'wb').write('\ninvalid') + $ hg st --subrepos + abort: invalid subrepository revision specifier in .hgsubstate line 2 + [255] + $ mv .hgsubstate.old .hgsubstate + delete .hgsub and revert it $ rm .hgsub