Show More
@@ -323,8 +323,7 b' def pushbookmark(repo, key, old, new):' | |||||
323 | finally: |
|
323 | finally: | |
324 | lockmod.release(tr, l, w) |
|
324 | lockmod.release(tr, l, w) | |
325 |
|
325 | |||
326 | def comparebookmarks(repo, srcmarks, dstmarks, |
|
326 | def comparebookmarks(repo, srcmarks, dstmarks, targets=None): | |
327 | srchex=None, dsthex=None, targets=None): |
|
|||
328 | '''Compare bookmarks between srcmarks and dstmarks |
|
327 | '''Compare bookmarks between srcmarks and dstmarks | |
329 |
|
328 | |||
330 | This returns tuple "(addsrc, adddst, advsrc, advdst, diverge, |
|
329 | This returns tuple "(addsrc, adddst, advsrc, advdst, diverge, | |
@@ -347,19 +346,9 b' def comparebookmarks(repo, srcmarks, dst' | |||||
347 | Changeset IDs of tuples in "addsrc", "adddst", "differ" or |
|
346 | Changeset IDs of tuples in "addsrc", "adddst", "differ" or | |
348 | "invalid" list may be unknown for repo. |
|
347 | "invalid" list may be unknown for repo. | |
349 |
|
348 | |||
350 | This function expects that "srcmarks" and "dstmarks" return |
|
|||
351 | changeset ID in 40 hexadecimal digit string for specified |
|
|||
352 | bookmark. If not so (e.g. bmstore "repo._bookmarks" returning |
|
|||
353 | binary value), "srchex" or "dsthex" should be specified to convert |
|
|||
354 | into such form. |
|
|||
355 |
|
||||
356 | If "targets" is specified, only bookmarks listed in it are |
|
349 | If "targets" is specified, only bookmarks listed in it are | |
357 | examined. |
|
350 | examined. | |
358 | ''' |
|
351 | ''' | |
359 | if not srchex: |
|
|||
360 | srchex = lambda x: x |
|
|||
361 | if not dsthex: |
|
|||
362 | dsthex = lambda x: x |
|
|||
363 |
|
352 | |||
364 | if targets: |
|
353 | if targets: | |
365 | bset = set(targets) |
|
354 | bset = set(targets) | |
@@ -381,14 +370,14 b' def comparebookmarks(repo, srcmarks, dst' | |||||
381 | for b in sorted(bset): |
|
370 | for b in sorted(bset): | |
382 | if b not in srcmarks: |
|
371 | if b not in srcmarks: | |
383 | if b in dstmarks: |
|
372 | if b in dstmarks: | |
384 |
adddst((b, None, |
|
373 | adddst((b, None, dstmarks[b])) | |
385 | else: |
|
374 | else: | |
386 | invalid((b, None, None)) |
|
375 | invalid((b, None, None)) | |
387 | elif b not in dstmarks: |
|
376 | elif b not in dstmarks: | |
388 |
addsrc((b, |
|
377 | addsrc((b, srcmarks[b], None)) | |
389 | else: |
|
378 | else: | |
390 |
scid = |
|
379 | scid = srcmarks[b] | |
391 |
dcid = |
|
380 | dcid = dstmarks[b] | |
392 | if scid == dcid: |
|
381 | if scid == dcid: | |
393 | same((b, scid, dcid)) |
|
382 | same((b, scid, dcid)) | |
394 | elif scid in repo and dcid in repo: |
|
383 | elif scid in repo and dcid in repo: | |
@@ -439,11 +428,17 b' def _diverge(ui, b, path, localmarks, re' | |||||
439 |
|
428 | |||
440 | return None |
|
429 | return None | |
441 |
|
430 | |||
|
431 | def unhexlifybookmarks(marks): | |||
|
432 | binremotemarks = {} | |||
|
433 | for name, node in marks.items(): | |||
|
434 | binremotemarks[name] = bin(node) | |||
|
435 | return binremotemarks | |||
|
436 | ||||
442 | def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()): |
|
437 | def updatefromremote(ui, repo, remotemarks, path, trfunc, explicit=()): | |
443 | ui.debug("checking for updated bookmarks\n") |
|
438 | ui.debug("checking for updated bookmarks\n") | |
444 | localmarks = repo._bookmarks |
|
439 | localmarks = repo._bookmarks | |
445 | (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same |
|
440 | (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same | |
446 |
|
|
441 | ) = comparebookmarks(repo, remotemarks, localmarks) | |
447 |
|
442 | |||
448 | status = ui.status |
|
443 | status = ui.status | |
449 | warn = ui.warn |
|
444 | warn = ui.warn | |
@@ -454,15 +449,15 b' def updatefromremote(ui, repo, remotemar' | |||||
454 | changed = [] |
|
449 | changed = [] | |
455 | for b, scid, dcid in addsrc: |
|
450 | for b, scid, dcid in addsrc: | |
456 | if scid in repo: # add remote bookmarks for changes we already have |
|
451 | if scid in repo: # add remote bookmarks for changes we already have | |
457 |
changed.append((b, |
|
452 | changed.append((b, scid, status, | |
458 | _("adding remote bookmark %s\n") % (b))) |
|
453 | _("adding remote bookmark %s\n") % (b))) | |
459 | elif b in explicit: |
|
454 | elif b in explicit: | |
460 | explicit.remove(b) |
|
455 | explicit.remove(b) | |
461 | ui.warn(_("remote bookmark %s points to locally missing %s\n") |
|
456 | ui.warn(_("remote bookmark %s points to locally missing %s\n") | |
462 | % (b, scid[:12])) |
|
457 | % (b, hex(scid)[:12])) | |
463 |
|
458 | |||
464 | for b, scid, dcid in advsrc: |
|
459 | for b, scid, dcid in advsrc: | |
465 |
changed.append((b, |
|
460 | changed.append((b, scid, status, | |
466 | _("updating bookmark %s\n") % (b))) |
|
461 | _("updating bookmark %s\n") % (b))) | |
467 | # remove normal movement from explicit set |
|
462 | # remove normal movement from explicit set | |
468 | explicit.difference_update(d[0] for d in changed) |
|
463 | explicit.difference_update(d[0] for d in changed) | |
@@ -470,13 +465,12 b' def updatefromremote(ui, repo, remotemar' | |||||
470 | for b, scid, dcid in diverge: |
|
465 | for b, scid, dcid in diverge: | |
471 | if b in explicit: |
|
466 | if b in explicit: | |
472 | explicit.discard(b) |
|
467 | explicit.discard(b) | |
473 |
changed.append((b, |
|
468 | changed.append((b, scid, status, | |
474 | _("importing bookmark %s\n") % (b))) |
|
469 | _("importing bookmark %s\n") % (b))) | |
475 | else: |
|
470 | else: | |
476 | snode = bin(scid) |
|
471 | db = _diverge(ui, b, path, localmarks, scid) | |
477 | db = _diverge(ui, b, path, localmarks, snode) |
|
|||
478 | if db: |
|
472 | if db: | |
479 |
changed.append((db, s |
|
473 | changed.append((db, scid, warn, | |
480 | _("divergent bookmark %s stored as %s\n") % |
|
474 | _("divergent bookmark %s stored as %s\n") % | |
481 | (b, db))) |
|
475 | (b, db))) | |
482 | else: |
|
476 | else: | |
@@ -485,13 +479,13 b' def updatefromremote(ui, repo, remotemar' | |||||
485 | for b, scid, dcid in adddst + advdst: |
|
479 | for b, scid, dcid in adddst + advdst: | |
486 | if b in explicit: |
|
480 | if b in explicit: | |
487 | explicit.discard(b) |
|
481 | explicit.discard(b) | |
488 |
changed.append((b, |
|
482 | changed.append((b, scid, status, | |
489 | _("importing bookmark %s\n") % (b))) |
|
483 | _("importing bookmark %s\n") % (b))) | |
490 | for b, scid, dcid in differ: |
|
484 | for b, scid, dcid in differ: | |
491 | if b in explicit: |
|
485 | if b in explicit: | |
492 | explicit.remove(b) |
|
486 | explicit.remove(b) | |
493 | ui.warn(_("remote bookmark %s points to locally missing %s\n") |
|
487 | ui.warn(_("remote bookmark %s points to locally missing %s\n") | |
494 | % (b, scid[:12])) |
|
488 | % (b, hex(scid)[:12])) | |
495 |
|
489 | |||
496 | if changed: |
|
490 | if changed: | |
497 | tr = trfunc() |
|
491 | tr = trfunc() | |
@@ -505,8 +499,8 b' def incoming(ui, repo, other):' | |||||
505 | ''' |
|
499 | ''' | |
506 | ui.status(_("searching for changed bookmarks\n")) |
|
500 | ui.status(_("searching for changed bookmarks\n")) | |
507 |
|
501 | |||
508 |
r = |
|
502 | remotemarks = unhexlifybookmarks(other.listkeys('bookmarks')) | |
509 | dsthex=hex) |
|
503 | r = comparebookmarks(repo, remotemarks, repo._bookmarks) | |
510 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r |
|
504 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r | |
511 |
|
505 | |||
512 | incomings = [] |
|
506 | incomings = [] | |
@@ -522,16 +516,16 b' def incoming(ui, repo, other):' | |||||
522 | incomings.append(" %-25s %s\n" % (b, getid(id))) |
|
516 | incomings.append(" %-25s %s\n" % (b, getid(id))) | |
523 | for b, scid, dcid in addsrc: |
|
517 | for b, scid, dcid in addsrc: | |
524 | # i18n: "added" refers to a bookmark |
|
518 | # i18n: "added" refers to a bookmark | |
525 | add(b, scid, _('added')) |
|
519 | add(b, hex(scid), _('added')) | |
526 | for b, scid, dcid in advsrc: |
|
520 | for b, scid, dcid in advsrc: | |
527 | # i18n: "advanced" refers to a bookmark |
|
521 | # i18n: "advanced" refers to a bookmark | |
528 | add(b, scid, _('advanced')) |
|
522 | add(b, hex(scid), _('advanced')) | |
529 | for b, scid, dcid in diverge: |
|
523 | for b, scid, dcid in diverge: | |
530 | # i18n: "diverged" refers to a bookmark |
|
524 | # i18n: "diverged" refers to a bookmark | |
531 | add(b, scid, _('diverged')) |
|
525 | add(b, hex(scid), _('diverged')) | |
532 | for b, scid, dcid in differ: |
|
526 | for b, scid, dcid in differ: | |
533 | # i18n: "changed" refers to a bookmark |
|
527 | # i18n: "changed" refers to a bookmark | |
534 | add(b, scid, _('changed')) |
|
528 | add(b, hex(scid), _('changed')) | |
535 |
|
529 | |||
536 | if not incomings: |
|
530 | if not incomings: | |
537 | ui.status(_("no changed bookmarks found\n")) |
|
531 | ui.status(_("no changed bookmarks found\n")) | |
@@ -547,8 +541,8 b' def outgoing(ui, repo, other):' | |||||
547 | ''' |
|
541 | ''' | |
548 | ui.status(_("searching for changed bookmarks\n")) |
|
542 | ui.status(_("searching for changed bookmarks\n")) | |
549 |
|
543 | |||
550 |
r = |
|
544 | remotemarks = unhexlifybookmarks(other.listkeys('bookmarks')) | |
551 | srchex=hex) |
|
545 | r = comparebookmarks(repo, repo._bookmarks, remotemarks) | |
552 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r |
|
546 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r | |
553 |
|
547 | |||
554 | outgoings = [] |
|
548 | outgoings = [] | |
@@ -564,19 +558,19 b' def outgoing(ui, repo, other):' | |||||
564 | outgoings.append(" %-25s %s\n" % (b, getid(id))) |
|
558 | outgoings.append(" %-25s %s\n" % (b, getid(id))) | |
565 | for b, scid, dcid in addsrc: |
|
559 | for b, scid, dcid in addsrc: | |
566 | # i18n: "added refers to a bookmark |
|
560 | # i18n: "added refers to a bookmark | |
567 | add(b, scid, _('added')) |
|
561 | add(b, hex(scid), _('added')) | |
568 | for b, scid, dcid in adddst: |
|
562 | for b, scid, dcid in adddst: | |
569 | # i18n: "deleted" refers to a bookmark |
|
563 | # i18n: "deleted" refers to a bookmark | |
570 | add(b, ' ' * 40, _('deleted')) |
|
564 | add(b, ' ' * 40, _('deleted')) | |
571 | for b, scid, dcid in advsrc: |
|
565 | for b, scid, dcid in advsrc: | |
572 | # i18n: "advanced" refers to a bookmark |
|
566 | # i18n: "advanced" refers to a bookmark | |
573 | add(b, scid, _('advanced')) |
|
567 | add(b, hex(scid), _('advanced')) | |
574 | for b, scid, dcid in diverge: |
|
568 | for b, scid, dcid in diverge: | |
575 | # i18n: "diverged" refers to a bookmark |
|
569 | # i18n: "diverged" refers to a bookmark | |
576 | add(b, scid, _('diverged')) |
|
570 | add(b, hex(scid), _('diverged')) | |
577 | for b, scid, dcid in differ: |
|
571 | for b, scid, dcid in differ: | |
578 | # i18n: "changed" refers to a bookmark |
|
572 | # i18n: "changed" refers to a bookmark | |
579 | add(b, scid, _('changed')) |
|
573 | add(b, hex(scid), _('changed')) | |
580 |
|
574 | |||
581 | if not outgoings: |
|
575 | if not outgoings: | |
582 | ui.status(_("no changed bookmarks found\n")) |
|
576 | ui.status(_("no changed bookmarks found\n")) | |
@@ -592,8 +586,8 b' def summary(repo, other):' | |||||
592 |
|
586 | |||
593 | This returns "(# of incoming, # of outgoing)" tuple. |
|
587 | This returns "(# of incoming, # of outgoing)" tuple. | |
594 | ''' |
|
588 | ''' | |
595 |
r = |
|
589 | remotemarks = unhexlifybookmarks(other.listkeys('bookmarks')) | |
596 | dsthex=hex) |
|
590 | r = comparebookmarks(repo, remotemarks, repo._bookmarks) | |
597 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r |
|
591 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r | |
598 | return (len(addsrc), len(adddst)) |
|
592 | return (len(addsrc), len(adddst)) | |
599 |
|
593 |
@@ -603,9 +603,21 b' def _pushdiscoverybookmarks(pushop):' | |||||
603 | explicit = set([repo._bookmarks.expandname(bookmark) |
|
603 | explicit = set([repo._bookmarks.expandname(bookmark) | |
604 | for bookmark in pushop.bookmarks]) |
|
604 | for bookmark in pushop.bookmarks]) | |
605 |
|
605 | |||
606 |
|
|
606 | remotebookmark = bookmod.unhexlifybookmarks(remotebookmark) | |
607 | remotebookmark, srchex=hex) |
|
607 | comp = bookmod.comparebookmarks(repo, repo._bookmarks, remotebookmark) | |
|
608 | ||||
|
609 | def safehex(x): | |||
|
610 | if x is None: | |||
|
611 | return x | |||
|
612 | return hex(x) | |||
|
613 | ||||
|
614 | def hexifycompbookmarks(bookmarks): | |||
|
615 | for b, scid, dcid in bookmarks: | |||
|
616 | yield b, safehex(scid), safehex(dcid) | |||
|
617 | ||||
|
618 | comp = [hexifycompbookmarks(marks) for marks in comp] | |||
608 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp |
|
619 | addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp | |
|
620 | ||||
609 | for b, scid, dcid in advsrc: |
|
621 | for b, scid, dcid in advsrc: | |
610 | if b in explicit: |
|
622 | if b in explicit: | |
611 | explicit.remove(b) |
|
623 | explicit.remove(b) | |
@@ -617,7 +629,7 b' def _pushdiscoverybookmarks(pushop):' | |||||
617 | explicit.remove(b) |
|
629 | explicit.remove(b) | |
618 | pushop.outbookmarks.append((b, '', scid)) |
|
630 | pushop.outbookmarks.append((b, '', scid)) | |
619 | # search for overwritten bookmark |
|
631 | # search for overwritten bookmark | |
620 | for b, scid, dcid in advdst + diverge + differ: |
|
632 | for b, scid, dcid in list(advdst) + list(diverge) + list(differ): | |
621 | if b in explicit: |
|
633 | if b in explicit: | |
622 | explicit.remove(b) |
|
634 | explicit.remove(b) | |
623 | pushop.outbookmarks.append((b, dcid, scid)) |
|
635 | pushop.outbookmarks.append((b, dcid, scid)) | |
@@ -1456,6 +1468,7 b' def _pullbookmarks(pullop):' | |||||
1456 | pullop.stepsdone.add('bookmarks') |
|
1468 | pullop.stepsdone.add('bookmarks') | |
1457 | repo = pullop.repo |
|
1469 | repo = pullop.repo | |
1458 | remotebookmarks = pullop.remotebookmarks |
|
1470 | remotebookmarks = pullop.remotebookmarks | |
|
1471 | remotebookmarks = bookmod.unhexlifybookmarks(remotebookmarks) | |||
1459 | bookmod.updatefromremote(repo.ui, repo, remotebookmarks, |
|
1472 | bookmod.updatefromremote(repo.ui, repo, remotebookmarks, | |
1460 | pullop.remote.url(), |
|
1473 | pullop.remote.url(), | |
1461 | pullop.gettransaction, |
|
1474 | pullop.gettransaction, |
General Comments 0
You need to be logged in to leave comments.
Login now