[PATCH 2 of 2 V2] push: move handling of explicitly pushed bookmarks into localrepo.push()
Pierre-Yves David
pierre-yves.david at logilab.fr
Mon Dec 10 04:49:23 CST 2012
On Fri, Dec 07, 2012 at 01:43:16PM -0600, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock at ringworld.org>
> # Date 1354905590 21600
> # Node ID 64d29f52afb979d79992cc9eaafc56690db372a3
> # Parent 106b515749cf338617d24c2fae3850987bf46734
> push: move handling of explicitly pushed bookmarks into localrepo.push()
>
> This puts the handling of bookmarks pushed with -B/--bookmark in the
> same place as already-shared bookmarks. It also avoids calling listkeys
> on the remote repo twice (hence the change to test-hook.t).
>
> diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
> --- a/hgext/largefiles/reposetup.py
> +++ b/hgext/largefiles/reposetup.py
> @@ -434,7 +434,7 @@ def reposetup(ui, repo):
> finally:
> wlock.release()
>
> - def push(self, remote, force=False, revs=None, newbranch=False):
> + def push(self, remote, force=False, revs=None, newbranch=False, marks=[]):
> o = lfutil.findoutgoing(self, remote, force)
> if o:
> toupload = set()
> @@ -465,7 +465,7 @@ def reposetup(ui, repo):
> if lfutil.isstandin(f) and f in ctx]))
> lfcommands.uploadlfiles(ui, self, remote, toupload)
> return super(lfilesrepo, self).push(remote, force, revs,
> - newbranch)
> + newbranch, marks)
>
> repo.__class__ = lfilesrepo
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4766,31 +4766,9 @@ def push(ui, repo, dest=None, **opts):
> return False
> finally:
> del repo._subtoppath
> - result = repo.push(other, opts.get('force'), revs=revs,
> - newbranch=opts.get('new_branch'))
> -
> - result = not result
> -
> - if opts.get('bookmark'):
> - rb = other.listkeys('bookmarks')
> - for b in opts['bookmark']:
> - # explicit push overrides remote bookmark if any
> - if b in repo._bookmarks:
> - ui.status(_("exporting bookmark %s\n") % b)
> - new = repo[b].hex()
> - elif b in rb:
> - ui.status(_("deleting remote bookmark %s\n") % b)
> - new = '' # delete
> - else:
> - ui.warn(_('bookmark %s does not exist on the local '
> - 'or remote repository!\n') % b)
> - break
> - old = rb.get(b, '')
> - r = other.pushkey('bookmarks', b, old, new)
> - if not r:
> - ui.warn(_('updating bookmark %s failed!\n') % b)
> -
> - return result
> + return not repo.push(other, opts.get('force'), revs=revs,
> + newbranch=opts.get('new_branch'),
> + marks=opts.get('bookmark'))
>
> @command('recover', [])
> def recover(ui, repo):
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1866,7 +1866,7 @@ class localrepository(object):
> """
> pass
>
> - def push(self, remote, force=False, revs=None, newbranch=False):
> + def push(self, remote, force=False, revs=None, newbranch=False, marks=[]):
> '''Push outgoing changesets (limited by revs) from the current
> repository to remote. Return an integer:
> - None means nothing to push
> @@ -2049,6 +2049,22 @@ class localrepository(object):
> else:
> self.ui.warn(_('updating bookmark %s'
> ' failed!\n') % k)
> + for b in marks:
> + # explicit push overrides remote bookmark if any
> + if b in unfi._bookmarks:
> + unfi.ui.status(_("exporting bookmark %s\n") % b)
> + new = unfi[b].hex()
> + elif b in rb:
> + unfi.ui.status(_("deleting remote bookmark %s\n") % b)
> + new = '' # delete
> + else:
> + unfi.ui.warn(_('bookmark %s does not exist on the local '
> + 'or remote repository!\n') % b)
> + break
> + old = rb.get(b, '')
> + r = remote.pushkey('bookmarks', b, old, new)
> + if not r:
> + unfi.ui.warn(_('updating bookmark %s failed!\n') % b)
can't this be factored with the sync of common bookmark?
(and break still want to be a continue)
--
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/20121210/7131480a/attachment.pgp>
More information about the Mercurial-devel
mailing list