[PATCH [RFC][V2]] revert: add support for reverting subrepos

Matt Mackall mpm at selenic.com
Sat Jan 14 16:28:10 CST 2012


On Fri, 2012-01-13 at 00:40 +0100, Angel Ezquerra wrote:
> On Thu, Jan 12, 2012 at 9:48 PM, Angel Ezquerra
> <angel.ezquerra at gmail.com> wrote:
> > # HG changeset patch
> > # User Angel Ezquerra <angel.ezquerra at gmail.com>
> > # Date 1326364670 -3600
> > # Node ID 747979cca1c541b84d2a15b3e037c63388db1c59
> > # Parent  c47d69ce5208d5b5cfd2fb2f0f1d7a2b4795fbf5
> > 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).
> >
> > - This patch only allows reverting subrepos if the --no-backup flag is used,
> > since no backups are performed on the contents of the subrepo. It could be
> > possible to add support for backing up the subrepo contents by first performing
> > a "revert --all" on the subrepo, and then updating the subrepo to the proper
> > revision.
> >
> > - The behavior of the --all flag has changed. It now reverts subrepos as well.
> > Note that this may lead to data loss if the user has a dirty subrepo. Since this
> > only works with the --no-backup flag it seems reasonable.
> >
> > diff --git a/mercurial/commands.py b/mercurial/commands.py
> > --- a/mercurial/commands.py
> > +++ b/mercurial/commands.py
> > @@ -4791,8 +4791,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:
> > @@ -4806,6 +4804,13 @@
> >             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 unless the no-backup flag is set")
> > +            hint = _("there are subrepos on the revert list, "
> > +                     "use --no-backup to revert them")
> > +            raise util.Abort(msg, hint=hint)
> > +
> >         m = scmutil.matchfiles(repo, names)
> >         changes = repo.status(match=m)[:4]
> >         modified, added, removed, deleted = map(set, changes)
> > @@ -4934,6 +4939,13 @@
> >                 checkout(f)
> >                 normal(f)
> >
> > +            if targetsubs:
> > +                # Revert the subrepos on the revert list
> > +                # reverting a subrepo is done by updating it to the revision
> > +                # specified in the corresponding substate dictionary
> > +                for sname in targetsubs:
> > +                    ui.status(_('reverting subrepo %s\n') % sname)
> > +                    ctx.sub(sname).get(ctx.substate[sname], overwrite=True)
> >     finally:
> >         wlock.release()
> >
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel at selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
> 
> This is a patch that I sent before the mercurial 2.0 code freeze,
> rebased to the tip of the default branch.

On Oct 15, I wrote:

"There's a bit too much uncertainty here still. Let's revisit this after
Nov 1st."

http://markmail.org/message/3jxty7xlucqmnscw

Ok, it is indeed after Nov 1st, but I think you missed the point. It is
Jan 14th, and the code freeze is AGAIN just days away. Given that this
patch is definitely still not ready to go in without more discussion and
tweaking and I have lots of other stuff to address in the next few days,
I have to drop this patch again, for the same reason.

Please resend your patch for discussion on Feb 2. Don't wait until
April.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list