mercurial/cmdutil.py
changeset 16429 71dcce391a44
parent 16381 64c8ae09162e
child 16430 6883c2363f44
--- a/mercurial/cmdutil.py	Sat Apr 14 01:39:35 2012 -0500
+++ b/mercurial/cmdutil.py	Wed Mar 28 11:42:17 2012 +0200
@@ -1356,8 +1356,6 @@
             if path in names:
                 return
             if path in repo[node].substate:
-                ui.warn("%s: %s\n" % (m.rel(path),
-                    'reverting subrepos is unsupported'))
                 return
             path_ = path + '/'
             for f in names:
@@ -1371,6 +1369,11 @@
             if abs not in names:
                 names[abs] = m.rel(abs), m.exact(abs)
 
+        targetsubs = [s for s in repo[node].substate if m(s)]
+        if targetsubs and not opts.get('no_backup'):
+            msg = _("cannot revert subrepos without --no-backup")
+            raise util.Abort(msg)
+
         m = scmutil.matchfiles(repo, names)
         changes = repo.status(match=m)[:4]
         modified, added, removed, deleted = map(set, changes)
@@ -1499,6 +1502,10 @@
                 checkout(f)
                 normal(f)
 
+            if targetsubs:
+                # Revert the subrepos on the revert list
+                for sub in targetsubs:
+                    ctx.sub(sub).revert(ui, ctx.substate[sub], *pats, **opts)
     finally:
         wlock.release()