Mercurial > hg
changeset 23550:7fa2189c1e87
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.
author | Mathias De Maré <mathias.demare@gmail.com> |
---|---|
date | Sun, 14 Dec 2014 11:34:51 +0100 |
parents | 609ecde2778f |
children | 7651621507cf |
files | mercurial/subrepo.py tests/test-subrepo-git.t |
diffstat | 2 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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]
--- 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 ..