[PATCH] convert: fix cvsnt mergepoint referring synthetic parent

Greg Ward greg-hg at gerg.ca
Wed Jun 3 07:47:33 CDT 2009


On Tue, Jun 2, 2009 at 1:51 PM, Henrik Stuart <hg at hstuart.dk> wrote:
> # HG changeset patch
> # User Henrik Stuart <hg at hstuart.dk>
> # Date 1243964916 -7200
> # Node ID 686ac3bc40ce29f58ff6c8398ea19f2accdf60d4
> # Parent  68e0a55eee6e97df2bbb4548c6b6dbd2d2b7bb97
> convert: fix cvsnt mergepoint referring synthetic parent
>
> The mergepoint changesets were not resolved like "normal" parent
> relationships in the conversion so the conversion of a cvsnt
> repository could potentially crash unexpectedly as the synthetic
> revision was deleted.

Looks fairly sensible to me, although I don't claim to fully
understand the mergepoint stuff.  (Never used CVSNT myself.)  Can you
add a test case to test-convert-cvs-builtincvsps-cvsnt-mergepoints?

On a related note, test-convert-cvs-builtincvsps-cvsnt-mergepoints is
not executable and its name is a mouthful.  How about a patch to chmod
+x it and rename to test-convert-cvsnt-mergepoints?

Greg


>
> diff -r 68e0a55eee6e -r 686ac3bc40ce hgext/convert/cvsps.py
> --- a/hgext/convert/cvsps.py    Mon Jun 01 17:12:42 2009 +0200
> +++ b/hgext/convert/cvsps.py    Tue Jun 02 19:48:36 2009 +0200
> @@ -462,6 +462,17 @@
>                                      id(self),
>                                      getattr(self, 'id', "(no id)"))
>
> +def _getfirstrealparent(p):
> +    while p.synthetic:
> +        assert len(p.parents) <= 1, \
> +               _('synthetic changeset cannot have multiple parents')
> +        if p.parents:
> +            p = p.parents[0]
> +        else:
> +            p = None
> +            break
> +    return p
> +
>  def createchangeset(ui, log, fuzz=60, mergefrom=None, mergeto=None):
>     '''Convert log into changesets.'''
>
> @@ -618,17 +629,7 @@
>
>         c.parents = []
>         if p is not None:
> -            p = changesets[p]
> -
> -            # Ensure no changeset has a synthetic changeset as a parent.
> -            while p.synthetic:
> -                assert len(p.parents) <= 1, \
> -                       _('synthetic changeset cannot have multiple parents')
> -                if p.parents:
> -                    p = p.parents[0]
> -                else:
> -                    p = None
> -                    break
> +            p = _getfirstrealparent(changesets[p])
>
>             if p is not None:
>                 c.parents.append(p)
> @@ -636,7 +637,10 @@
>         if c.mergepoint:
>             if c.mergepoint == 'HEAD':
>                 c.mergepoint = None
> -            c.parents.append(changesets[branches[c.mergepoint]])
> +            p = _getfirstrealparent(changesets[branches[c.mergepoint]])
> +
> +            if p is not None:
> +                c.parents.append(p)
>
>         if mergefrom:
>             m = mergefrom.search(c.comment)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>



More information about the Mercurial-devel mailing list