comparison hgext/bookmarks.py @ 11472:5b89c20e0c0b stable

Merge with stable
author Wagner Bruna <wbruna@softwareexpress.com.br>
date Tue, 22 Jun 2010 20:48:48 -0300
parents cac256790aa4
children 86eea1f97eac
comparison
equal deleted inserted replaced
11471:4da206812ce7 11472:5b89c20e0c0b
28 branching. 28 branching.
29 ''' 29 '''
30 30
31 from mercurial.i18n import _ 31 from mercurial.i18n import _
32 from mercurial.node import nullid, nullrev, hex, short 32 from mercurial.node import nullid, nullrev, hex, short
33 from mercurial import util, commands, repair, extensions, pushkey, hg 33 from mercurial import util, commands, repair, extensions, pushkey, hg, url
34 import os 34 import os
35 35
36 def write(repo): 36 def write(repo):
37 '''Write bookmarks 37 '''Write bookmarks
38 38
443 if not result: 443 if not result:
444 result = 2 444 result = 2
445 445
446 return result 446 return result
447 447
448 def diffbookmarks(ui, repo, remote):
449 ui.status(_("searching for changes\n"))
450
451 lmarks = repo.listkeys('bookmarks')
452 rmarks = remote.listkeys('bookmarks')
453
454 diff = set(rmarks) - set(lmarks)
455 for k in diff:
456 ui.write(" %-25s %s\n" % (k, rmarks[k][:12]))
457
458 if len(diff) <= 0:
459 ui.status(_("no changes found\n"))
460
461 def incoming(oldincoming, ui, repo, source="default", **opts):
462 if opts.get('bookmarks'):
463 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
464 other = hg.repository(hg.remoteui(repo, opts), source)
465 ui.status(_('comparing with %s\n') % url.hidepassword(source))
466 diffbookmarks(ui, repo, other)
467 else:
468 oldincoming(ui, repo, source, **opts)
469
470 def outgoing(oldoutgoing, ui, repo, source="default", **opts):
471 if opts.get('bookmarks'):
472 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
473 other = hg.repository(hg.remoteui(repo, opts), source)
474 ui.status(_('comparing with %s\n') % url.hidepassword(source))
475 diffbookmarks(ui, other, repo)
476 else:
477 oldoutgoing(ui, repo, source, **opts)
478
448 def uisetup(ui): 479 def uisetup(ui):
449 extensions.wrapfunction(repair, "strip", strip) 480 extensions.wrapfunction(repair, "strip", strip)
450 if ui.configbool('bookmarks', 'track.current'): 481 if ui.configbool('bookmarks', 'track.current'):
451 extensions.wrapcommand(commands.table, 'update', updatecurbookmark) 482 extensions.wrapcommand(commands.table, 'update', updatecurbookmark)
452 483
454 entry[1].append(('B', 'bookmark', [], 485 entry[1].append(('B', 'bookmark', [],
455 _("bookmark to import"))) 486 _("bookmark to import")))
456 entry = extensions.wrapcommand(commands.table, 'push', push) 487 entry = extensions.wrapcommand(commands.table, 'push', push)
457 entry[1].append(('B', 'bookmark', [], 488 entry[1].append(('B', 'bookmark', [],
458 _("bookmark to export"))) 489 _("bookmark to export")))
490 entry = extensions.wrapcommand(commands.table, 'incoming', incoming)
491 entry[1].append(('B', 'bookmarks', False,
492 _("compare bookmark")))
493 entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
494 entry[1].append(('B', 'bookmarks', False,
495 _("compare bookmark")))
459 496
460 pushkey.register('bookmarks', pushbookmark, listbookmarks) 497 pushkey.register('bookmarks', pushbookmark, listbookmarks)
461 498
462 def updatecurbookmark(orig, ui, repo, *args, **opts): 499 def updatecurbookmark(orig, ui, repo, *args, **opts):
463 '''Set the current bookmark 500 '''Set the current bookmark