~jelmer/subvertpy/unstable

« back to all changes in this revision

Viewing changes to subvertpy/wc.c

  • Committer: Jelmer Vernooij
  • Date: 2011-08-19 00:10:54 UTC
  • mfrom: (1940.9.169 upstream)
  • Revision ID: jelmer@debian.org-20110819001054-j9sz98fae16441he
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#endif
36
36
 
37
37
staticforward PyTypeObject Entry_Type;
 
38
staticforward PyTypeObject Status_Type;
38
39
staticforward PyTypeObject Adm_Type;
39
40
 
40
41
static PyObject *py_entry(const svn_wc_entry_t *entry);
 
42
static PyObject *py_status(const svn_wc_status2_t *status);
41
43
 
42
44
#if ONLY_BEFORE_SVN(1, 5)
43
45
struct svn_wc_committed_queue_t
453
455
 
454
456
typedef struct {
455
457
        PyObject_HEAD
 
458
        apr_pool_t *pool;
 
459
        svn_wc_status2_t status;
 
460
        PyObject *entry;
 
461
} StatusObject;
 
462
 
 
463
static void status_dealloc(PyObject *self)
 
464
{
 
465
        apr_pool_destroy(((StatusObject *)self)->pool);
 
466
        Py_XDECREF(((StatusObject *)self)->entry);
 
467
        PyObject_Del(self);
 
468
}
 
469
 
 
470
static PyMemberDef status_members[] = {
 
471
        { "entry", T_OBJECT, offsetof(StatusObject, entry), READONLY, 
 
472
                "Can be NULL if not under version control." },
 
473
        { "locked", T_BOOL, offsetof(StatusObject, status.locked), READONLY, 
 
474
                "a directory can be 'locked' if a working copy update was interrupted." },
 
475
        { "copied", T_BOOL, offsetof(StatusObject, status.copied), READONLY, 
 
476
                "a file or directory can be 'copied' if it's scheduled for addition-with-history (or part of a subtree that is scheduled as such.)." },
 
477
        { "switched", T_BOOL, offsetof(StatusObject, status.switched), READONLY, 
 
478
                "a file or directory can be 'switched' if the switch command has been used." },
 
479
        { "url", T_STRING, offsetof(StatusObject, status.url), READONLY, 
 
480
                "URL (actual or expected) in repository" },
 
481
        { "revision", T_LONG, offsetof(StatusObject, status.ood_last_cmt_rev), READONLY, 
 
482
                "Set to the youngest committed revision, or SVN_INVALID_REVNUM if not out of date.", },
 
483
        { "kind", T_INT, offsetof(StatusObject, status.ood_kind), READONLY, 
 
484
                "Set to the node kind of the youngest commit, or svn_node_none if not out of date.", },
 
485
        { "status", T_INT, offsetof(StatusObject, status.text_status), READONLY, 
 
486
                "The status of the entry.", },
 
487
        { NULL, }
 
488
};
 
489
 
 
490
static PyTypeObject Status_Type = {
 
491
        PyObject_HEAD_INIT(NULL) 0,
 
492
        "wc.Status", /* const char *tp_name;  For printing, in format "<module>.<name>" */
 
493
        sizeof(StatusObject), 
 
494
        0,/*    Py_ssize_t tp_basicsize, tp_itemsize;  For allocation */
 
495
        
 
496
        /* Methods to implement standard operations */
 
497
        
 
498
        status_dealloc, /*      destructor tp_dealloc;  */
 
499
        NULL, /*        printfunc tp_print;     */
 
500
        NULL, /*        getattrfunc tp_getattr; */
 
501
        NULL, /*        setattrfunc tp_setattr; */
 
502
        NULL, /*        cmpfunc tp_compare;     */
 
503
        NULL, /*        reprfunc tp_repr;       */
 
504
        
 
505
        /* Method suites for standard classes */
 
506
        
 
507
        NULL, /*        PyNumberMethods *tp_as_number;  */
 
508
        NULL, /*        PySequenceMethods *tp_as_sequence;      */
 
509
        NULL, /*        PyMappingMethods *tp_as_mapping;        */
 
510
        
 
511
        /* More standard operations (here for binary compatibility) */
 
512
        
 
513
        NULL, /*        hashfunc tp_hash;       */
 
514
        NULL, /*        ternaryfunc tp_call;    */
 
515
        NULL, /*        reprfunc tp_str;        */
 
516
        NULL, /*        getattrofunc tp_getattro;       */
 
517
        NULL, /*        setattrofunc tp_setattro;       */
 
518
        
 
519
        /* Functions to access object as input/output buffer */
 
520
        NULL, /*        PyBufferProcs *tp_as_buffer;    */
 
521
        
 
522
        /* Flags to define presence of optional/expanded features */
 
523
        0, /*   long tp_flags;  */
 
524
        
 
525
        NULL, /*        const char *tp_doc;  Documentation string */
 
526
        
 
527
        /* Assigned meaning in release 2.0 */
 
528
        /* call function for all accessible objects */
 
529
        NULL, /*        traverseproc tp_traverse;       */
 
530
        
 
531
        /* delete references to contained objects */
 
532
        NULL, /*        inquiry tp_clear;       */
 
533
        
 
534
        /* Assigned meaning in release 2.1 */
 
535
        /* rich comparisons */
 
536
        NULL, /*        richcmpfunc tp_richcompare;     */
 
537
        
 
538
        /* weak reference enabler */
 
539
        0, /*   Py_ssize_t tp_weaklistoffset;   */
 
540
        
 
541
        /* Added in release 2.2 */
 
542
        /* Iterators */
 
543
        NULL, /*        getiterfunc tp_iter;    */
 
544
        NULL, /*        iternextfunc tp_iternext;       */
 
545
        
 
546
        /* Attribute descriptor and subclassing stuff */
 
547
        NULL, /*        struct PyMethodDef *tp_methods; */
 
548
        status_members, /*      struct PyMemberDef *tp_members; */
 
549
 
 
550
};
 
551
 
 
552
static PyObject *py_status(const svn_wc_status2_t *status)
 
553
{
 
554
        StatusObject *ret;
 
555
        svn_wc_status2_t *dup_status;
 
556
 
 
557
        ret = PyObject_New(StatusObject, &Status_Type);
 
558
        if (ret == NULL)
 
559
                return NULL;
 
560
 
 
561
        ret->pool = Pool(NULL);
 
562
        if (ret->pool == NULL)
 
563
                return NULL;
 
564
 
 
565
        dup_status = svn_wc_dup_status2(status, ret->pool);
 
566
        if (dup_status == NULL)
 
567
        {
 
568
                PyErr_NoMemory();
 
569
                return NULL;
 
570
        }
 
571
        ret->status = *dup_status;
 
572
 
 
573
        ret->entry = py_entry(ret->status.entry);
 
574
        return (PyObject *)ret;
 
575
}
 
576
 
 
577
typedef struct {
 
578
        PyObject_HEAD
456
579
        svn_wc_adm_access_t *adm;
457
580
        apr_pool_t *pool;
458
581
} AdmObject;
643
766
        if (temp_pool == NULL)
644
767
                return NULL;
645
768
#if ONLY_SINCE_SVN(1, 5)
646
 
        RUN_SVN_WITH_POOL(temp_pool, svn_wc_walk_entries3(path, admobj->adm, 
 
769
        RUN_SVN_WITH_POOL(temp_pool, svn_wc_walk_entries3(
 
770
                          svn_path_canonicalize(path, temp_pool), admobj->adm, 
647
771
                                &py_wc_entry_callbacks2, (void *)callbacks,
648
772
                                depth, show_hidden, py_cancel_check, NULL,
649
773
                                temp_pool));
654
778
                apr_pool_destroy(temp_pool);
655
779
                return NULL;
656
780
        }
657
 
        RUN_SVN_WITH_POOL(temp_pool, svn_wc_walk_entries2(path, admobj->adm, 
 
781
        RUN_SVN_WITH_POOL(temp_pool, svn_wc_walk_entries2(
 
782
                          svn_path_canonicalize(path, temp_pool), admobj->adm, 
658
783
                                &py_wc_entry_callbacks, (void *)callbacks,
659
784
                                show_hidden, py_cancel_check, NULL,
660
785
                                temp_pool));
1855
1980
        return ret;
1856
1981
}
1857
1982
 
 
1983
/**
 
1984
 * Determine the status of a file in the specified working copy.
 
1985
 *
 
1986
 * :return: A status object.
 
1987
 */
 
1988
static PyObject *ra_status(PyObject *self, PyObject *args)
 
1989
{
 
1990
        char *path;
 
1991
        svn_wc_status2_t *st;
 
1992
        apr_pool_t *temp_pool;
 
1993
        PyObject *ret;
 
1994
        AdmObject *admobj = (AdmObject *)self;
 
1995
 
 
1996
        if (!PyArg_ParseTuple(args, "s", &path))
 
1997
                return NULL;
 
1998
 
 
1999
        ADM_CHECK_CLOSED(admobj);
 
2000
 
 
2001
        temp_pool = Pool(NULL);
 
2002
        if (temp_pool == NULL)
 
2003
                return NULL;
 
2004
 
 
2005
        RUN_SVN_WITH_POOL(temp_pool, 
 
2006
                        svn_wc_status2(
 
2007
                                &st,
 
2008
                                svn_path_canonicalize(svn_path_join(svn_wc_adm_access_path(admobj->adm), path, temp_pool), temp_pool),
 
2009
                                admobj->adm,
 
2010
                                temp_pool));
 
2011
 
 
2012
        ret = py_status(st);
 
2013
 
 
2014
        apr_pool_destroy(temp_pool);
 
2015
 
 
2016
        return (PyObject*)ret;
 
2017
}
 
2018
 
1858
2019
static PyMethodDef adm_methods[] = { 
1859
2020
        { "prop_set", adm_prop_set, METH_VARARGS, "S.prop_set(name, value, path, skip_checks=False)" },
1860
2021
        { "access_path", (PyCFunction)adm_access_path, METH_NOARGS, 
1916
2077
                "S.conflicted(path) -> (text_conflicted, prop_conflicted, tree_conflicted)" },
1917
2078
        { "resolved_conflict", (PyCFunction)resolved_conflict, METH_VARARGS,
1918
2079
                "S.resolved_conflict(path, resolve_text, resolve_props, resolve_tree, depth, conflict_choice, notify_func=None, cancel=None)" },
 
2080
        { "status", (PyCFunction)ra_status, METH_VARARGS, "status(wc_path) -> Status" },
1919
2081
        { NULL, }
1920
2082
};
1921
2083
 
2495
2657
        if (PyType_Ready(&Entry_Type) < 0)
2496
2658
                return;
2497
2659
 
 
2660
        if (PyType_Ready(&Status_Type) < 0)
 
2661
                return;
 
2662
 
2498
2663
        if (PyType_Ready(&Adm_Type) < 0)
2499
2664
                return;
2500
2665