3
  5   ˆl–Ü4ý(”ÂXÔÊ�jàp,©‹Fÿ�þY)nV¥~BH@‘ ?Ðƒ ×ÏÎÍ ì    # Generated from /usr/share/i18n/charmaps/CP1256.gz
0x0000-0x007F 0x0000
0x0080 0x20AC
0x0081 0x067E
0x0082 0x201A
0x0083 0x0192
0x0084 0x201E
0x0085 0x2026
0x0086-0x0087 0x2020
0x0088 0x02C6
0x0089 0x2030
0x008A 0x0679
0x008B 0x2039
0x008C 0x0152
0x008D 0x0686
0x008E 0x0698
0x008F 0x0688
0x0090 0x06AF
0x0091-0x0092 0x2018
0x0093-0x0094 0x201C
0x0095 0x2022
0x0096-0x0097 0x2013
0x0098 0x06A9
0x0099 0x2122
0x009A 0x0691
0x009B 0x203A
0x009C 0x0153
0x009D-0x009E 0x200C
0x009F 0x06BA
0x00A0 0x00A0
0x00A1 0x060C
0x00A2-0x00A9 0x00A2
0x00AA 0x06BE
0x00AB-0x00B9 0x00AB
0x00BA 0x061B
0x00BB-0x00BE 0x00BB
0x00BF 0x061F
0x00C0 0x06C1
0x00C1-0x00D6 0x0621
0x00D7 0x00D7
0x00D8-0x00DB 0x0637
0x00DC-0x00DF 0x0640
0x00E0 0x00E0
0x00E1 0x0644
0x00E2 0x00E2
0x00E3-0x00E6 0x0645
0x00E7-0x00EB 0x00E7
0x00EC-0x00ED 0x0649
0x00EE-0x00EF 0x00EE
0x00F0-0x00F3 0x064B
0x00F4 0x00F4
0x00F5-0x00F6 0x064F
0x00F7 0x00F7
0x00F8 0x0651
0x00F9 0x00F9
0x00FA 0x0652
0x00FB-0x00FC 0x00FB
0x00FD-0x00FE 0x200E
0x00FF 0x06D2
  A   ˆl–äY>”JeJe@†à¸Û*bÑ¿�þJËË7(\+"	$i ?ÑƒeÆ�Ð_ŠI|¥�+Wé3ž¯ÐÏ 8    # Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.


from mercurial.i18n import _
from mercurial.node import hex

from mercurial import (
    bundle2,
    changegroup,
    error,
    extensions,
    revsetlang,
    util,
)

from . import common

isremotebooksenabled = common.isremotebooksenabled

scratchbranchparttype = b'b2x:infinitepush'


def getscratchbranchparts(repo, peer, outgoing, ui, bookmark):
    if not outgoing.missing:
        raise error.Abort(_(b'no commits to push'))

    if scratchbranchparttype not in bundle2.bundle2caps(peer):
        raise error.Abort(
            _(b'no server support for %r') % scratchbranchparttype
        )

    _validaterevset(
        repo, revsetlang.formatspec(b'%ln', outgoing.missing), bookmark
    )

    supportedversions = changegroup.supportedoutgoingversions(repo)
    # Explicitly avoid using '01' changegroup version in infinitepush to
    # support general delta
    supportedversions.discard(b'01')
    cgversion = min(supportedversions)
    _handlelfs(repo, outgoing.missing)
    cg = changegroup.makestream(repo, outgoing, cgversion, b'push')

    params = {}
    params[b'cgversion'] = cgversion
    if bookmark:
        params[b'bookmark'] = bookmark
        # 'prevbooknode' is necessary for pushkey reply part
        params[b'bookprevnode'] = b''
        bookmarks = repo._bookmarks
        if bookmark in bookmarks:
            params[b'bookprevnode'] = hex(bookmarks[bookmark])

    # Do not send pushback bundle2 part with bookmarks if remotenames extension
    # is enabled. It will be handled manually in `_push()`
    if not isremotebooksenabled(ui):
        params[b'pushbackbookmarks'] = b'1'

    parts = []

    # .upper() marks this as a mandatory part: server will abort if there's no
    #  handler
    parts.append(
        bundle2.bundlepart(
            scratchbranchparttype.upper(),
            advisoryparams=params.items(),
            data=cg,
        )
    )

    return parts


def _validaterevset(repo, revset, bookmark):
    """Abort if the revs to be pushed aren't valid for a scratch branch."""
    if not repo.revs(revset):
        raise error.Abort(_(b'nothing to push'))
    if bookmark:
        # Allow bundle with many heads only if no bookmark is specified
        heads = repo.revs(b'heads(%r)', revset)
        if len(heads) > 1:
            raise error.Abort(
                _(b'cannot push more than one head to a scratch branch')
            )


def _handlelfs(repo, missing):
    """Special case if lfs is enabled

    If lfs is enabled then we need to call prepush hook
    to make sure large files are uploaded to lfs
    """
    try:
        lfsmod = extensions.find(b'lfs')
        lfsmod.wrapper.uploadblobsfromrevs(repo, missing)
    except KeyError:
        # Ignore if lfs extension is not enabled
 