[PATCH 2 of 2] bookmarks: show details of difference between local and remote bookmarks

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue Sep 25 09:41:51 CDT 2012


At Mon, 24 Sep 2012 11:15:07 +0200,
Pierre-Yves David wrote:
> 
> [1  <text/plain; us-ascii (quoted-printable)>]
> On Sat, Sep 22, 2012 at 02:56:42PM +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > # Date 1348293230 -32400
> > # Node ID fb900c89f96b209486068ef2cdb4b9af43db1de6
> > # Parent  750be2c38db4e86c3f09d0cae83e9af9d49795e7
> > bookmarks: show details of difference between local and remote bookmarks
> > 
> > Before this patch, "hg incoming"/"hg outgoing" with -B show only
> > bookmarks newly added on the source repository.
> 
> I think that adding a sample output in the description will helps

Thanks, I'll do so.

> > So, users can't know whether "hg push"/"hg pull" cause divergence or
> > overwriting of specific bookmark or not, before execution of them.
> > 
> > This patch shows not only newly added bookmarks, but also details of
> > difference between local and remote bookmarks.
> > 
> > For local bookmarks which are different from ones on remote, details
> > of them are decided as below: each of "b at local" and "b at remote" are
> > assumed to mean revisions referred by bookmarks on each sides.
> > 
> >   - if "b at remote" is contained in the local:
> >     - if "b at local" and "b at remote" are diverged, show as "(diverged)"
> >     - if "b at local" < "b at remote", show as "(advanced on the remote)"
> >     - otherwise("b at remoet" < "b at local"), show as "(advanced on the local)"
> >   - otherwise:
> >     - show as "(different from the remote)", because "b at local" is
> >       different from "b at remote", but divergence of them can't be
> >       examined with low cost
> 
> I feel like this logic could be factored between diff code and actual
> pull//push code?

For my poor English, please let me confirm what you mean by "be
factored between diff code and actual pull//push code".

Would you mean that "getting diff of bookmark sets" and "checking
change of bookmarks" should be separated clearly ?

"actual pull//push code" doesn't mean bookmark exchanging between
repositories, does it ? : "bookmarks.diff()" is invoked only from
incoming/outgoing, so it must not exchange bookmarks between
repositories.

[snip]
> > +            if scid in local and dcid in local:
> > +                sctx = local[scid]
> > +                dctx = local[dcid]
> > +                if sctx.rev() < dctx.rev():
> > +                    if sctx.descendant(dctx):
> > +                        msg = advmsgs[0]
> > +                    else:
> > +                        msg = _("(diverged)")
> > +                else:
> > +                    if dctx.descendant(sctx):
> > +                        msg = advmsgs[1]
> > +                    else:
> > +                        msg = _("(diverged)")
> > +            else:
> > +                msg = _("(different from the remote)")
> > +        else:
> > +            msg = addmsg
> > +        ui.write("   %-25s %s %s\n" % (k, mark, msg))
> 
> You are using "descendant" here insteads of
> bookmarks.validdest. This means that the difference code won't
> reflect reality where obsolescence relation will be taken in account
> too.

At first, I also though about using "bookmarks.validdest()" to examine
whether old/new revisions are linear or not.

But at that time, I misunderstood that if new revision refers
obsoleted revision, "bookmarks.validdest()" returns False, even if
old/new revisions are linear.

So, I implemented patch with "changectx.descendant()".

Now, I confirm that if old/new versions are linear,
"bookmarks.validdest()" returns True also, even if new revision refers
obsoleted one.

So, I'll use "bookmarks.validdest()" to examine whether old/new is
linear in topological or obsolescence views.

P.S.

I understand that "bookmarks.validdest()" returns True in cases below:

  - "old" is NULL
  - "new" is REPLACEMENT of "old" or its descendants
  - "new" is descendant of "old" (linear in topological view)

Would you teach me if I misunderstand again ?

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list