[PATCH 2 of 2 RFC] rollback: try to prevent problems with shared clones

Martin Geisler mg at lazybytes.net
Wed Sep 14 02:50:14 CDT 2011


Greg Ward <greg-hg at gerg.ca> writes:

> # HG changeset patch
> # User Greg Ward <greg-hg at gerg.ca>
> # Date 1315790054 14400
> # Node ID 652cef658e59e6922694fc58d59d3858b3590d7b
> # Parent  2d12345fdecc19eff9d0498f9ee98b15669182c9
> rollback: try to prevent problems with shared clones.
>
> Trouble happens with shared clones (multiple working dirs all sharing
> the same repo store) if you commit in one working dir and then
> rollback that transaction in a different working dir: rollback uses
> partial info (.hg/store/undo but no .hg/undo.*) and generally makes a
> mess of things. Try to avoid that by refusing to rollback unless we're
> in the same working dir where the last transaction was created from.

[...]

> -    def _rollback(self, dryrun):
> +    def _rollback(self, dryrun, force):
> +        # check preconditions
> +        try:
> +            wdir = self.sopener.read('undo.wdir').strip()
> +        except IOError:
> +            pass
> +        else:
> +            if not force and wdir != self.root:
> +                raise util.Abort(
> +                    _('attempt to rollback from a different working dir '
> +                      'than where this transaction was created (%s) '
> +                      '(use -f to force: this will make a mess)')

We have a hint keyword argument for the hints, so this should be:

                raise util.Abort(
                    _('attempt to rollback from a different working dir '
                      'than where this transaction was created (%s)')
                    hint=_('use -f to force: this will make a mess'))

That add a newline before the hint.

I'm afraid I don't like the hint much -- it's vague and doesn't tell the
user anything new. I suggest putting some of the commit message into the
help text for rollback so that a user can learn what "mess" means here.

-- 
Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110914/6ca9682f/attachment.pgp>


More information about the Mercurial-devel mailing list