Mercurial > hg-stable
changeset 22650:36952c91e6c3
push: prepare the issue of multiple kinds of messages
To gather all the bookmark pushing actions together, we need code performing
those actions to be ready for them. We need to be able to produce different
messages for different actions.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 26 Sep 2014 18:33:11 -0700 |
parents | 1d7a2422b90c |
children | b901645a8784 |
files | mercurial/exchange.py |
diffstat | 1 files changed, 33 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/exchange.py Thu Oct 02 13:19:49 2014 -0500 +++ b/mercurial/exchange.py Fri Sep 26 18:33:11 2014 -0700 @@ -150,6 +150,16 @@ else: return self.fallbackheads +# mapping of message used when pushing bookmark +bookmsgmap = {'update': (_("updating bookmark %s\n"), + _('updating bookmark %s failed!\n')), + 'export': (_("exporting bookmark %s\n"), + _('exporting bookmark %s failed!\n')), + 'delete': (_("deleting remote bookmark %s\n"), + _('deleting remote bookmark %s failed!\n')), + } + + def push(repo, remote, force=False, revs=None, newbranch=False, bookmarks=()): '''Push outgoing changesets (limited by revs) from a local repository to remote. Return an integer: @@ -475,9 +485,17 @@ part.addparam('key', enc(book)) part.addparam('old', enc(old)) part.addparam('new', enc(new)) - part2book.append((part.id, book)) + action = 'update' + if not old: + action = 'export' + elif not new: + action = 'delete' + part2book.append((part.id, book, action)) + + def handlereply(op): - for partid, book in part2book: + ui = pushop.ui + for partid, book, action in part2book: partrep = op.records.getreplies(partid) results = partrep['pushkey'] assert len(results) <= 1 @@ -486,9 +504,9 @@ else: ret = int(results[0]['return']) if ret: - pushop.ui.status(_("updating bookmark %s\n") % book) + ui.status(bookmsgmap[action][0] % book) else: - pushop.ui.warn(_('updating bookmark %s failed!\n') % book) + ui.warn(bookmsgmap[action][1] % book) if pushop.bkresult is not None: pushop.bkresult = 1 return handlereply @@ -710,11 +728,20 @@ pushop.stepsdone.add('bookmarks') ui = pushop.ui remote = pushop.remote + for b, old, new in pushop.outbookmarks: + action = 'update' + if not old: + action = 'export' + elif not new: + action = 'delete' if remote.pushkey('bookmarks', b, old, new): - ui.status(_("updating bookmark %s\n") % b) + ui.status(bookmsgmap[action][0] % b) else: - ui.warn(_('updating bookmark %s failed!\n') % b) + ui.warn(bookmsgmap[action][1] % b) + # discovery can have set the value form invalid entry + if pushop.bkresult is not None: + pushop.bkresult = 1 class pulloperation(object): """A object that represent a single pull operation