[PATCH 2 of 2] bookmarks: show details of difference between local and remote bookmarks
Pierre-Yves David
pierre-yves.david at logilab.fr
Mon Sep 24 04:15:07 CDT 2012
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
> 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?
>
> Examination divergence between revisions by 'changectx.descendant()'
> costs "O(N)" for the number of revisions between ones referred by
> local and remote bookmarks at most.
>
> diff -r 750be2c38db4 -r fb900c89f96b mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py Sat Sep 22 14:53:50 2012 +0900
> +++ b/mercurial/bookmarks.py Sat Sep 22 14:53:50 2012 +0900
> @@ -237,16 +237,55 @@
> if changed:
> write(repo)
>
> -def diff(ui, dst, src):
> +def diff(ui, dst, src, local):
> ui.status(_("searching for changed bookmarks\n"))
>
> smarks = src.listkeys('bookmarks')
> dmarks = dst.listkeys('bookmarks')
>
> - diff = sorted(set(smarks) - set(dmarks))
> - for k in diff:
> + smarkset = set(smarks)
> + dmarkset = set(dmarks)
> + diff = smarkset - dmarkset
> + for k in smarkset & dmarkset:
> + if smarks[k] != dmarks[k]:
> + diff.add(k)
> + if dst.local() == local:
> + # incoming
> + advmsgs = [
> + _("(advanced on the local)"), # b at src < b at dst(local)
> + _("(advanced on the remote)"), # b at dst(local) < b at src
> + ]
> + addmsg = _("(added on the remote)")
> + else:
> + # outgoing
> + advmsgs = [
> + _("(advanced on the remote)"), # b at src(local) < b at dst
> + _("(advanced on the local)"), # b at dst < b at src(local)
> + ]
> + addmsg = _("(added on the local)")
> + for k in sorted(diff):
> mark = ui.debugflag and smarks[k] or smarks[k][:12]
> - ui.write(" %-25s %s\n" % (k, mark))
> + if k in dmarks:
> + scid = smarks[k]
> + dcid = dmarks[k]
> + 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.
--
Pierre-Yves David
-------------- 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/20120924/3541fe63/attachment.pgp>
More information about the Mercurial-devel
mailing list