diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -1658,10 +1658,14 @@ class gitsubrepo(abstractsubrepo): def revert(self, substate, *pats, **opts): self.ui.status(_('reverting subrepo %s\n') % substate[0]) if not opts.get('no_backup'): - self.ui.warn('%s: reverting %s subrepos without ' - '--no-backup is unsupported\n' - % (substate[0], substate[2])) - return [] + status = self.status(None) + names = status.modified + for name in names: + bakname = "%s.orig" % name + self.ui.note(_('saving current version of %s as %s\n') % + (name, bakname)) + util.rename(os.path.join(self._abspath, name), + os.path.join(self._abspath, bakname)) self.get(substate, overwrite=True) return [] diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t --- a/tests/test-subrepo-git.t +++ b/tests/test-subrepo-git.t @@ -787,14 +787,13 @@ ensure adding include/exclude ignores th revert the subrepository $ hg revert --all reverting subrepo ../gitroot (glob) - ../gitroot: reverting git subrepos without --no-backup is unsupported (glob) $ hg status --subrepos - M s/foobar - A s/barfoo + ? s/barfoo + ? s/foobar.orig - $ hg revert --no-backup --all - reverting subrepo ../gitroot (glob) + $ mv s/foobar.orig s/foobar + $ hg revert --no-backup s reverting subrepo ../gitroot (glob)