416
416
for (i = 0; i < window->num_ops; i++) {
417
PyList_SetItem(ops, i, Py_BuildValue("(iII)", window->ops[i].action_code,
418
window->ops[i].offset,
419
window->ops[i].length));
417
PyObject *pyval = Py_BuildValue("(iII)",
418
window->ops[i].action_code,
419
window->ops[i].offset,
420
window->ops[i].length);
423
PyList_SetItem(ops, i, pyval);
421
425
if (window->new_data != NULL && window->new_data->data != NULL) {
422
426
py_new_data = PyString_FromStringAndSize(window->new_data->data, window->new_data->len);
424
428
py_new_data = Py_None;
426
py_window = Py_BuildValue("((LIIiOO))", window->sview_offset, window->sview_len, window->tview_len,
427
window->src_ops, ops, py_new_data);
430
py_window = Py_BuildValue("((LIIiOO))",
431
window->sview_offset,
434
window->src_ops, ops, py_new_data);
435
if (py_window == NULL)
429
438
Py_DECREF(py_new_data);
1529
1544
apr_pool_destroy(temp_pool);
1548
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
1549
static PyObject *range_to_tuple(svn_merge_range_t *range)
1551
return Py_BuildValue("(llb)", range->start, range->end, range->inheritable);
1554
static PyObject *merge_rangelist_to_list(apr_array_header_t *rangelist)
1559
ret = PyList_New(rangelist->nelts);
1561
for (i = 0; i < rangelist->nelts; i++) {
1562
PyObject *pyval = range_to_tuple(APR_ARRAY_IDX(rangelist, i, svn_merge_range_t *));
1565
PyList_SetItem(ret, i, pyval);
1570
static PyObject *mergeinfo_to_dict(svn_mergeinfo_t mergeinfo, apr_pool_t *temp_pool)
1572
PyObject *ret = PyDict_New();
1575
apr_hash_index_t *idx;
1576
apr_array_header_t *range;
1578
for (idx = apr_hash_first(temp_pool, mergeinfo); idx != NULL;
1579
idx = apr_hash_next(idx)) {
1581
apr_hash_this(idx, (const void **)&key, &klen, (void **)&range);
1582
pyval = merge_rangelist_to_list(range);
1585
PyDict_SetItemString(ret, key, pyval);
1592
static PyObject *ra_mergeinfo(PyObject *self, PyObject *args)
1594
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
1595
RemoteAccessObject *ra = (RemoteAccessObject *)self;
1596
apr_array_header_t *apr_paths;
1597
apr_pool_t *temp_pool;
1598
svn_mergeinfo_catalog_t catalog;
1600
apr_hash_index_t *idx;
1601
svn_mergeinfo_t val;
1604
svn_revnum_t revision = -1;
1606
svn_mergeinfo_inheritance_t inherit = svn_mergeinfo_explicit;
1607
svn_boolean_t include_descendants;
1609
if (!PyArg_ParseTuple(args, "O|lib", &paths, &revision, &inherit, &include_descendants))
1612
temp_pool = Pool(NULL);
1613
if (temp_pool == NULL)
1616
if (!string_list_to_apr_array(temp_pool, paths, &apr_paths)) {
1617
apr_pool_destroy(temp_pool);
1621
RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_mergeinfo(ra->ra,
1622
&catalog, apr_paths, revision, inherit,
1623
include_descendants,
1628
if (catalog != NULL) {
1629
for (idx = apr_hash_first(temp_pool, catalog); idx != NULL;
1630
idx = apr_hash_next(idx)) {
1632
apr_hash_this(idx, (const void **)&key, &klen, (void **)&val);
1633
pyval = mergeinfo_to_dict(val, temp_pool);
1634
if (pyval == NULL) {
1635
apr_pool_destroy(temp_pool);
1638
PyDict_SetItemString(ret, key, pyval);
1642
apr_pool_destroy(temp_pool);
1646
PyErr_SetString(PyExc_NotImplementedError, "mergeinfo is only supported in Subversion >= 1.5");
1651
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
1652
static svn_error_t *py_location_segment_receiver(svn_location_segment_t *segment, void *baton, apr_pool_t *pool)
1654
PyObject *fn = baton, *ret;
1656
ret = PyObject_CallFunction(fn, "llz", segment->range_start, segment->range_end, segment->path);
1658
return py_svn_error();
1664
static PyObject *ra_get_location_segments(PyObject *self, PyObject *args)
1666
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 5
1667
RemoteAccessObject *ra = (RemoteAccessObject *)self;
1668
svn_revnum_t peg_revision, start_revision, end_revision;
1671
apr_pool_t *temp_pool;
1673
if (!PyArg_ParseTuple(args, "slllO", &path, &peg_revision, &start_revision,
1674
&end_revision, &py_rcvr))
1677
temp_pool = Pool(NULL);
1678
if (temp_pool == NULL)
1681
RUN_RA_WITH_POOL(temp_pool, ra, svn_ra_get_location_segments(ra->ra,
1682
path, peg_revision, start_revision, end_revision,
1683
py_location_segment_receiver,
1684
py_rcvr, temp_pool));
1686
apr_pool_destroy(temp_pool);
1689
PyErr_SetString(PyExc_NotImplementedError, "mergeinfo is only supported in Subversion >= 1.5");
1533
1695
static PyObject *ra_get_file_revs(PyObject *self, PyObject *args)
1592
1754
{ "get_locks", ra_get_locks, METH_VARARGS, NULL },
1593
1755
{ "lock", ra_lock, METH_VARARGS, NULL },
1594
1756
{ "unlock", ra_unlock, METH_VARARGS, NULL },
1757
{ "mergeinfo", ra_mergeinfo, METH_VARARGS, NULL },
1758
{ "get_location_segments", ra_get_location_segments, METH_VARARGS, NULL },
1595
1759
{ "has_capability", ra_has_capability, METH_VARARGS, NULL },
1596
1760
{ "check_path", ra_check_path, METH_VARARGS, NULL },
1597
1761
{ "get_lock", ra_get_lock, METH_VARARGS, NULL },