# HG changeset patch # User Mathias De Maré # Date 1418553291 -3600 # Node ID 7fa2189c1e87f1c6830c7841dacbc3fb61b3b545 # Parent 609ecde2778fc54bd381333363c0db1c700b8142 subrepo: add revert support without backup for git subrepos Previously, git subrepos did not support reverting. This change adds basic support for reverting when '--no-backup' is specified. A warning is given (and the current state is kept) when a revert is done without the '--no-backup' flag. diff -r 609ecde2778f -r 7fa2189c1e87 mercurial/subrepo.py --- a/mercurial/subrepo.py Sat Nov 01 22:56:49 2014 -0700 +++ b/mercurial/subrepo.py Sun Dec 14 11:34:51 2014 +0100 @@ -1656,6 +1656,17 @@ elif match(gitprefix): #Subrepo is matched ui.write(self._gitcommand(cmd)) + def revert(self, ui, substate, *pats, **opts): + ui.status(_('reverting subrepo %s\n') % substate[0]) + if not opts.get('no_backup'): + ui.warn('%s: reverting %s subrepos without ' + '--no-backup is unsupported\n' + % (substate[0], substate[2])) + return [] + + self.get(substate, overwrite=True) + return [] + def shortid(self, revid): return revid[:7] diff -r 609ecde2778f -r 7fa2189c1e87 tests/test-subrepo-git.t --- a/tests/test-subrepo-git.t Sat Nov 01 22:56:49 2014 -0700 +++ b/tests/test-subrepo-git.t Sun Dec 14 11:34:51 2014 +0100 @@ -784,4 +784,21 @@ $ hg diff --subrepos -I s/foobar $ hg diff --subrepos -X s/foobar +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 + + $ hg revert --no-backup --all + reverting subrepo ../gitroot (glob) + $ hg revert --no-backup s + reverting subrepo ../gitroot (glob) + + $ hg status --subrepos + ? s/barfoo + $ cd ..