diff mercurial/subrepo.py @ 13017:d0e21c5fde41 stable

subrepo: handle missing subrepo spec file as removed Otherwise, all commands involving a dirstate walk will abort when trying to readone of them. Deleting .hgsub basically breaks a repository.
author Patrick Mezard <pmezard@gmail.com>
date Thu, 18 Nov 2010 23:05:10 +0100
parents 82ca0c43bc44
children 96956105e92d 2245fcd0e160
line wrap: on
line diff
--- a/mercurial/subrepo.py	Wed Nov 17 21:25:23 2010 +0100
+++ b/mercurial/subrepo.py	Thu Nov 18 23:05:10 2010 +0100
@@ -21,7 +21,15 @@
     p = config.config()
     def read(f, sections=None, remap=None):
         if f in ctx:
-            p.parse(f, ctx[f].data(), sections, remap, read)
+            try:
+                data = ctx[f].data()
+            except IOError, err:
+                if err.errno != errno.ENOENT:
+                    raise
+                # handle missing subrepo spec files as removed
+                ui.warn(_("warning: subrepo spec file %s not found\n") % f)
+                return
+            p.parse(f, data, sections, remap, read)
         else:
             raise util.Abort(_("subrepo spec file %s not found") % f)