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

Pierre-Yves David pierre-yves.david at logilab.fr
Wed Sep 26 04:26:29 CDT 2012


On Tue, Sep 25, 2012 at 11:41:51PM +0900, FUJIWARA Katsunori wrote:
> 
> 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.

My point is that "getting diff of bookmark sets" and "exchanging bookmarks
between repository" are very similar operation.


getting diff of bookmark sets:

    1) get remote bookmarks data
    2) get local bookmarks data
    3) compute which bookmarks would move on push
    4) print data about them
    5) compute which bookmarks would move on pull
    6) print data about them

Pushing bookmark

    1) get remote bookmarks data
    2) get local bookmarks data
    3) compute which bookmarks would move on push
    7) move them remotly

Pulling bookmark

    1) get remote bookmarks data
    2) get local bookmarks data
    3) compute which bookmarks would move on pull
    7) move them locally


So I think that the computation of bookmark movement could be factored between
diff, push and pull code.  This mean gathering the movement decision in a
single place and calling the function in all appropriate place.


SPEUDOCODE:

    def diffbookmark():
        bkmovement = bookmark.movement(local, remote)
        for m in bkmovement:
            print m

    def pushbookmark():
        bkmovement = bookmark.movement(local, remote)
        for m in bkmovement:
            if m.move == "push":
                remote.setbk(m)

    def pullbookmark():
        bkmovement = bookmark.movement(local, remote)
        for m in bkmovement:
            if m.move == "pull":
                local.setbk(m)


Note: I had not close look to this matter and I may be wrong. But this sound a
sensible and "easy" refactoring.



> 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 ?

You got it right. (but note that REPLACEMENT are called "successors")

-- 
Pierre-Yves David

http://www.logilab.fr/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120926/0902c503/attachment.pgp>


More information about the Mercurial-devel mailing list