コード例 #1
0
ファイル: arcdiff.py プロジェクト: xmonader/eden
 def changediff(node):
     nodebase = repo[node].p1().node()
     m = scmutil.matchall(repo)
     diff = patch.diffhunks(repo, nodebase, node, m, opts=mdiff.diffopts(context=0))
     filepatches = {}
     for _fctx1, _fctx2, headerlines, hunks in diff:
         difflines = []
         for hunkrange, hunklines in hunks:
             difflines += list(hunklines)
         header = patch.header(headerlines)
         filepatches[header.files()[0]] = "".join(difflines)
     return (set(filepatches.keys()), filepatches, node)
コード例 #2
0
def show(ui, repo, csid=None, **opts):
    if csid is None:
        raise error.CommandError("snapshot show", _("missing snapshot id"))
    try:
        snapshot = repo.edenapi.fetchsnapshot({
            "cs_id": bytes.fromhex(csid),
        }, )
    except Exception:
        raise error.Abort(_("snapshot doesn't exist"))
    else:
        ctx = _snapshot2ctx(repo, snapshot)
        match = scmutil.matchall(repo)
        printeropt = {"patch": not opts["stat"], "stat": opts["stat"]}
        buffered = False
        if opts["json"] is True:
            displayer = jsonchangeset(ui, repo, match, printeropt, buffered)
        else:
            ui.status(_("snapshot: {}\n").format(csid))
            displayer = changeset_printer(ui, repo, match, printeropt,
                                          buffered)
        displayer.show(ctx)
        displayer.close()
コード例 #3
0
ファイル: infinitepushcommands.py プロジェクト: leszfb/eden
def debugfillinfinitepushmetadata(ui, repo, **opts):
    """Special command that fills infinitepush metadata for a node"""

    nodes = opts["node"]
    if not nodes:
        raise error.Abort(_("nodes are not specified"))

    filelimit = ui.configint("infinitepush", "metadatafilelimit", 100)
    nodesmetadata = {}
    for node in nodes:
        index = repo.bundlestore.index
        if not bool(index.getbundle(node)):
            raise error.Abort(_("node %s is not found") % node)

        if node not in repo:
            newbundlefile = server.downloadbundle(repo, bin(node))
            bundlepath = "bundle:%s+%s" % (repo.root, newbundlefile)
            bundlerepo = hg.repository(ui, bundlepath)
            repo = bundlerepo

        p1 = repo[node].p1().node()
        diffopts = patch.diffallopts(ui, {})
        match = scmutil.matchall(repo)
        chunks = patch.diff(repo, p1, node, match, None, diffopts, relroot="")
        difflines = util.iterlines(chunks)

        states = "modified added removed deleted unknown ignored clean".split()
        status = repo.status(p1, node)
        status = zip(states, status)

        filestatus = {}
        for state, files in status:
            for f in files:
                filestatus[f] = state

        diffstat = patch.diffstatdata(difflines)
        changed_files = {}
        copies = copiesmod.pathcopies(repo[p1], repo[node])
        for filename, adds, removes, isbinary in diffstat[:filelimit]:
            # use special encoding that allows non-utf8 filenames
            filename = pycompat.decodeutf8(
                encoding.jsonescape(pycompat.encodeutf8(filename), paranoid=True)
            )
            changed_files[filename] = {
                "adds": adds,
                "removes": removes,
                "isbinary": isbinary,
                "status": filestatus.get(filename, "unknown"),
            }
            if filename in copies:
                changed_files[filename]["copies"] = copies[filename]

        output = {}
        output["changed_files"] = changed_files
        if len(diffstat) > filelimit:
            output["changed_files_truncated"] = True
        nodesmetadata[node] = output

    with index:
        for node, metadata in pycompat.iteritems(nodesmetadata):
            dumped = json.dumps(metadata, sort_keys=True)
            index.saveoptionaljsonmetadata(node, pycompat.encodeutf8(dumped))