[PATCH] pull/push: allow to pull and push all shared bookmarks , (issue2800]

Matt Mackall mpm at selenic.com
Sat May 7 13:02:14 CDT 2011


[forwarded back to the list, please don't ever respond privately]

On Sat, 2011-05-07 at 18:53 +0200, Guido Jansen wrote:
> I don't understand why you consider this two patches. 

I may not have understood your commit message. You apparently claimed
to:

a) be implementing the documented (but you claim missing) functionality
b) be adding push/pull all bookmarks

If you're not touching (a) at all, then why bring it up?

> It is one single functionality.
> 
> Do you mean the implementation should be split in two: 
> One for push
> One for pull
> ?
> 
> Should I resend it as such?
> ________________________________________
> Van: Matt Mackall [mpm at selenic.com]
> Verzonden: zaterdag 7 mei 2011 15:59
> Aan: Guido Jansen
> CC: mercurial-devel at selenic.com
> Onderwerp: Re: [PATCH] pull/push: allow to pull and push all shared bookmarks , (issue2800
> 
> On Sat, 2011-05-07 at 14:06 +0200, Guido Jansen wrote:
> > # HG changeset patch
> > # User guido.jansen at lmsintl.com
> > # Date 1304769172 -7200
> > # Node ID 2b46d7cf58aa78a5ccd500850363fd39c22753a6
> > # Parent  13d44e4235f87cba6b7df2e545d2fca099505c39
> 
> First rule of patching: do not send two patches as one.
> 
> > The description of bookmarks says under the heading
> >    "Working With Remote Repositories":
> > "By default bookmarks that are already present on both the client and server
> > are updated on the client on pull and updated on the server on push."
> >
> > This was not implemented.



>  Also, this does not make sense. You do not know in
> > which direction the sync should go, it depends on how you organized.
> >
> > Still, the functionality is useful, hence this patch which adds a new option
> > to the hg push and pull command:
> >
> > hg -h pull:
> >  -a --allcbm                 pull all common bookmarks from the server
> >
> > hg -h push:
> >  -a --allcbm                 push all common bookmarks to the server
> >
> >
> >  These options will take the intersection of the bookmarks in the source and
> >  the destination and will include them in the push or pull operation.
> >
> > diff -r 13d44e4235f8 -r 2b46d7cf58aa mercurial/commands.py
> > --- a/mercurial/commands.py   Mon May 02 12:10:50 2011 -0500
> > +++ b/mercurial/commands.py   Sat May 07 13:52:52 2011 +0200
> > @@ -3115,12 +3115,25 @@
> >      other = hg.repository(hg.remoteui(repo, opts), source)
> >      ui.status(_('pulling from %s\n') % util.hidepassword(source))
> >      revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
> > -
> > +
> > +    # find bookmarks that are available on both sides and include them in the PULL list
> > +    rb = other.listkeys('bookmarks')
> > +    bookmarkstopull = []
> > +    if opts.get('allcbm'):
> > +        lb = repo.listkeys('bookmarks')
> > +        for b in rb:
> > +            if b in lb:
> > +                bookmarkstopull.append(b)
> > +
> >      if opts.get('bookmark'):
> > +        for b in opts['bookmark']:
> > +            if b not in bookmarkstopull:
> > +                bookmarkstopull.append(b)
> > +
> > +    if bookmarkstopull <> []:
> >          if not revs:
> >              revs = []
> > -        rb = other.listkeys('bookmarks')
> > -        for b in opts['bookmark']:
> > +        for b in bookmarkstopull:
> >              if b not in rb:
> >                  raise util.Abort(_('remote bookmark %s not found!') % b)
> >              revs.append(rb[b])
> > @@ -3145,8 +3158,8 @@
> >          del repo._subtoppath
> >
> >      # update specified bookmarks
> > -    if opts.get('bookmark'):
> > -        for b in opts['bookmark']:
> > +    if bookmarkstopull <> []:
> > +        for b in bookmarkstopull:
> >              # explicit pull overrides local bookmark if any
> >              ui.status(_("importing bookmark %s\n") % b)
> >              repo._bookmarks[b] = repo[rb[b]].node()
> > @@ -3184,8 +3197,25 @@
> >      Returns 0 if push was successful, 1 if nothing to push.
> >      """
> >
> > +    # find bookmarks that are available on both sides and include them in the PUSH list
> > +    dest = ui.expandpath(dest or 'default-push', dest or 'default')
> > +    dest, branches = hg.parseurl(dest, opts.get('branch'))
> > +    other = hg.repository(hg.remoteui(repo, opts), dest)
> > +    rb = other.listkeys('bookmarks')
> > +    bookmarkstopush = []
> > +    if opts.get('allcbm'):
> > +        lb = repo.listkeys('bookmarks')
> > +        for b in rb:
> > +            if b in lb:
> > +                bookmarkstopush.append(b)
> > +
> >      if opts.get('bookmark'):
> >          for b in opts['bookmark']:
> > +            if b not in bookmarkstopush:
> > +                bookmarkstopush.append(b)
> > +
> > +    if bookmarkstopush <> []:
> > +        for b in bookmarkstopush:
> >              # translate -B options to -r so changesets get pushed
> >              if b in repo._bookmarks:
> >                  opts.setdefault('rev', []).append(b)
> > @@ -3194,8 +3224,6 @@
> >                  # this lets simultaneous -r, -b options continue working
> >                  opts.setdefault('rev', []).append("null")
> >
> > -    dest = ui.expandpath(dest or 'default-push', dest or 'default')
> > -    dest, branches = hg.parseurl(dest, opts.get('branch'))
> >      ui.status(_('pushing to %s\n') % util.hidepassword(dest))
> >      revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
> >      other = hg.repository(hg.remoteui(repo, opts), dest)
> > @@ -3217,9 +3245,8 @@
> >
> >      result = (result == 0)
> >
> > -    if opts.get('bookmark'):
> > -        rb = other.listkeys('bookmarks')
> > -        for b in opts['bookmark']:
> > +    if bookmarkstopush <> []:
> > +        for b in bookmarkstopush:
> >              # explicit push overrides remote bookmark if any
> >              if b in repo._bookmarks:
> >                  ui.status(_("exporting bookmark %s\n") % b)
> > @@ -4819,6 +4846,7 @@
> >            ('r', 'rev', [],
> >             _('a remote changeset intended to be added'), _('REV')),
> >            ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
> > +          ('a', 'allcbm', None, _('pull all common bookmarks from the server')),
> >            ('b', 'branch', [],
> >             _('a specific branch you would like to pull'), _('BRANCH')),
> >           ] + remoteopts,
> > @@ -4830,6 +4858,7 @@
> >             _('a changeset intended to be included in the destination'),
> >             _('REV')),
> >            ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
> > +          ('a', 'allcbm', None, _('push all common bookmarks to the server')),
> >            ('b', 'branch', [],
> >             _('a specific branch you would like to push'), _('BRANCH')),
> >            ('', 'new-branch', False, _('allow pushing a new branch')),
> >
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel at selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
> 
> 
> --
> Mathematics is the supreme nostalgia of our time.
> 


-- 
Mathematics is the supreme nostalgia of our time.


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list