You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Thomas Mueller <mu...@adobe.com> on 2014/10/16 07:54:13 UTC

DocumentStore: StableRevisionComparator ignored the branch flag

Hi,

I wonder if there is a bug in the StableRevisionComparator. It uses
Revision.compareRevisionTimeThenClusterId, which doesn't take the "branch"
flag into account. I would probably use the following instead:

/**
 * Compare all components of two revisions.
 * 
 * @param other the other revision
 * @return -1, 0, or 1
 */
    int compareTo(Revision other) {
    int comp = compareRevisionTimeThenClusterId(other);
    if (comp == 0) {
        if (branch != other.branch) {
            return branch ? -1 : 1;
        }
    }
    return comp;
    }



Regards,
Thomas


Re: DocumentStore: StableRevisionComparator ignored the branch flag

Posted by Marcel Reutegger <mr...@adobe.com>.
Hi Thomas,

yes, makes sense to change it. so far, this class was only used
to sort revisions in the document maps where none of the revisions
has a branch flag.

but it's perfectly reasonable to also compare revisions from
a branch and this should work as well.

Regards
 Marcel

On 16/10/14 07:54, "Thomas Mueller" <mu...@adobe.com> wrote:

>Hi,
>
>I wonder if there is a bug in the StableRevisionComparator. It uses
>Revision.compareRevisionTimeThenClusterId, which doesn't take the "branch"
>flag into account. I would probably use the following instead:
>
>/**
> * Compare all components of two revisions.
> * 
> * @param other the other revision
> * @return -1, 0, or 1
> */
>    int compareTo(Revision other) {
>    int comp = compareRevisionTimeThenClusterId(other);
>    if (comp == 0) {
>        if (branch != other.branch) {
>            return branch ? -1 : 1;
>        }
>    }
>    return comp;
>    }
>
>
>
>Regards,
>Thomas
>