diff mercurial/subrepo.py @ 16429:71dcce391a44

revert: add support for reverting subrepos Reverting a subrepo is done by updating it to the revision that is selected on the parent repo .hgsubstate file. * ISSUES/TODO: - reverting added and removed subrepos is not supported yet. - reverting subrepos is only supported if the --no-backup flag is used (this limitation will be removed on another patch). - The behavior of the --all flag has been changed. It now reverts subrepos as well. Note that this may lead to data loss if the user has a dirty subrepo.
author Angel Ezquerra <angel.ezquerra@gmail.com>
date Wed, 28 Mar 2012 11:42:17 +0200
parents 0196c437ca9f
children 6883c2363f44
line wrap: on
line diff
--- a/mercurial/subrepo.py	Sat Apr 14 01:39:35 2012 -0500
+++ b/mercurial/subrepo.py	Wed Mar 28 11:42:17 2012 +0200
@@ -368,6 +368,9 @@
     def forget(self, ui, match, prefix):
         return []
 
+    def revert(self, ui, substate, *pats, **opts):
+        return []
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -573,6 +576,14 @@
         return cmdutil.forget(ui, self._repo, match,
                               os.path.join(prefix, self._path), True)
 
+    def revert(self, ui, substate, *pats, **opts):
+        # reverting a subrepo is done by updating it to the revision
+        # specified in the corresponding substate dictionary
+        ui.status(_('reverting subrepo %s\n') % substate[0])
+
+        # Update the repo to the revision specified in the given substate
+        self.get(substate, overwrite=True)
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path