##// END OF EJS Templates
tab/space cleanup
Thomas Arendsen Hein -
r6334:7016f7fb default
parent child Browse files
Show More
@@ -19,10 +19,10 b' static PyObject *init(PyObject *self, Py'
19 {
19 {
20 PyObject *ret = NULL;
20 PyObject *ret = NULL;
21 int fd = -1;
21 int fd = -1;
22
22
23 if (!PyArg_ParseTuple(args, ":init"))
23 if (!PyArg_ParseTuple(args, ":init"))
24 goto bail;
24 goto bail;
25
25
26 Py_BEGIN_ALLOW_THREADS
26 Py_BEGIN_ALLOW_THREADS
27 fd = inotify_init();
27 fd = inotify_init();
28 Py_END_ALLOW_THREADS
28 Py_END_ALLOW_THREADS
@@ -31,19 +31,19 b' static PyObject *init(PyObject *self, Py'
31 PyErr_SetFromErrno(PyExc_OSError);
31 PyErr_SetFromErrno(PyExc_OSError);
32 goto bail;
32 goto bail;
33 }
33 }
34
34
35 ret = PyInt_FromLong(fd);
35 ret = PyInt_FromLong(fd);
36 if (ret == NULL)
36 if (ret == NULL)
37 goto bail;
37 goto bail;
38
38
39 goto done;
39 goto done;
40
40
41 bail:
41 bail:
42 if (fd != -1)
42 if (fd != -1)
43 close(fd);
43 close(fd);
44
44
45 Py_CLEAR(ret);
45 Py_CLEAR(ret);
46
46
47 done:
47 done:
48 return ret;
48 return ret;
49 }
49 }
@@ -74,17 +74,17 b' static PyObject *add_watch(PyObject *sel'
74 PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
74 PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
75 goto bail;
75 goto bail;
76 }
76 }
77
77
78 ret = PyInt_FromLong(wd);
78 ret = PyInt_FromLong(wd);
79 if (ret == NULL)
79 if (ret == NULL)
80 goto bail;
80 goto bail;
81
81
82 goto done;
82 goto done;
83
83
84 bail:
84 bail:
85 if (wd != -1)
85 if (wd != -1)
86 inotify_rm_watch(fd, wd);
86 inotify_rm_watch(fd, wd);
87
87
88 Py_CLEAR(ret);
88 Py_CLEAR(ret);
89
89
90 done:
90 done:
@@ -110,7 +110,7 b' static PyObject *remove_watch(PyObject *'
110 uint32_t wd;
110 uint32_t wd;
111 int fd;
111 int fd;
112 int r;
112 int r;
113
113
114 if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd))
114 if (!PyArg_ParseTuple(args, "iI:remove_watch", &fd, &wd))
115 goto bail;
115 goto bail;
116
116
@@ -122,14 +122,14 b' static PyObject *remove_watch(PyObject *'
122 PyErr_SetFromErrno(PyExc_OSError);
122 PyErr_SetFromErrno(PyExc_OSError);
123 goto bail;
123 goto bail;
124 }
124 }
125
125
126 Py_INCREF(Py_None);
126 Py_INCREF(Py_None);
127
127
128 goto done;
128 goto done;
129
129
130 bail:
130 bail:
131 Py_CLEAR(ret);
131 Py_CLEAR(ret);
132
132
133 done:
133 done:
134 return ret;
134 return ret;
135 }
135 }
@@ -184,7 +184,7 b' static PyObject *decode_mask(int mask)'
184
184
185 if (ret == NULL)
185 if (ret == NULL)
186 goto bail;
186 goto bail;
187
187
188 for (i = 0; bit_names[i].bit; i++) {
188 for (i = 0; bit_names[i].bit; i++) {
189 if (mask & bit_names[i].bit) {
189 if (mask & bit_names[i].bit) {
190 if (bit_names[i].pyname == NULL) {
190 if (bit_names[i].pyname == NULL) {
@@ -197,26 +197,26 b' static PyObject *decode_mask(int mask)'
197 goto bail;
197 goto bail;
198 }
198 }
199 }
199 }
200
200
201 goto done;
201 goto done;
202
202
203 bail:
203 bail:
204 Py_CLEAR(ret);
204 Py_CLEAR(ret);
205
205
206 done:
206 done:
207 return ret;
207 return ret;
208 }
208 }
209
209
210 static PyObject *pydecode_mask(PyObject *self, PyObject *args)
210 static PyObject *pydecode_mask(PyObject *self, PyObject *args)
211 {
211 {
212 int mask;
212 int mask;
213
213
214 if (!PyArg_ParseTuple(args, "i:decode_mask", &mask))
214 if (!PyArg_ParseTuple(args, "i:decode_mask", &mask))
215 return NULL;
215 return NULL;
216
216
217 return decode_mask(mask);
217 return decode_mask(mask);
218 }
218 }
219
219
220 PyDoc_STRVAR(
220 PyDoc_STRVAR(
221 decode_mask_doc,
221 decode_mask_doc,
222 "decode_mask(mask) -> list_of_strings\n"
222 "decode_mask(mask) -> list_of_strings\n"
@@ -233,7 +233,7 b' static void define_const(PyObject *dict,'
233
233
234 if (!pyname || !pyval)
234 if (!pyname || !pyval)
235 goto bail;
235 goto bail;
236
236
237 PyDict_SetItem(dict, pyname, pyval);
237 PyDict_SetItem(dict, pyname, pyval);
238
238
239 bail:
239 bail:
@@ -278,28 +278,28 b' struct event {'
278 PyObject *cookie;
278 PyObject *cookie;
279 PyObject *name;
279 PyObject *name;
280 };
280 };
281
281
282 static PyObject *event_wd(PyObject *self, void *x)
282 static PyObject *event_wd(PyObject *self, void *x)
283 {
283 {
284 struct event *evt = (struct event *) self;
284 struct event *evt = (struct event *) self;
285 Py_INCREF(evt->wd);
285 Py_INCREF(evt->wd);
286 return evt->wd;
286 return evt->wd;
287 }
287 }
288
288
289 static PyObject *event_mask(PyObject *self, void *x)
289 static PyObject *event_mask(PyObject *self, void *x)
290 {
290 {
291 struct event *evt = (struct event *) self;
291 struct event *evt = (struct event *) self;
292 Py_INCREF(evt->mask);
292 Py_INCREF(evt->mask);
293 return evt->mask;
293 return evt->mask;
294 }
294 }
295
295
296 static PyObject *event_cookie(PyObject *self, void *x)
296 static PyObject *event_cookie(PyObject *self, void *x)
297 {
297 {
298 struct event *evt = (struct event *) self;
298 struct event *evt = (struct event *) self;
299 Py_INCREF(evt->cookie);
299 Py_INCREF(evt->cookie);
300 return evt->cookie;
300 return evt->cookie;
301 }
301 }
302
302
303 static PyObject *event_name(PyObject *self, void *x)
303 static PyObject *event_name(PyObject *self, void *x)
304 {
304 {
305 struct event *evt = (struct event *) self;
305 struct event *evt = (struct event *) self;
@@ -334,7 +334,7 b' static void event_dealloc(struct event *'
334 Py_XDECREF(evt->mask);
334 Py_XDECREF(evt->mask);
335 Py_XDECREF(evt->cookie);
335 Py_XDECREF(evt->cookie);
336 Py_XDECREF(evt->name);
336 Py_XDECREF(evt->name);
337
337
338 (*evt->ob_type->tp_free)(evt);
338 (*evt->ob_type->tp_free)(evt);
339 }
339 }
340
340
@@ -353,17 +353,17 b' static PyObject *event_repr(struct event'
353 pymasks = decode_mask(PyInt_AsLong(evt->mask));
353 pymasks = decode_mask(PyInt_AsLong(evt->mask));
354 if (pymasks == NULL)
354 if (pymasks == NULL)
355 goto bail;
355 goto bail;
356
356
357 pymask = _PyString_Join(join, pymasks);
357 pymask = _PyString_Join(join, pymasks);
358 if (pymask == NULL)
358 if (pymask == NULL)
359 goto bail;
359 goto bail;
360
360
361 maskstr = PyString_AsString(pymask);
361 maskstr = PyString_AsString(pymask);
362
362
363 if (evt->name != Py_None) {
363 if (evt->name != Py_None) {
364 PyObject *pyname = PyString_Repr(evt->name, 1);
364 PyObject *pyname = PyString_Repr(evt->name, 1);
365 char *name = pyname ? PyString_AsString(pyname) : "???";
365 char *name = pyname ? PyString_AsString(pyname) : "???";
366
366
367 if (cookie == -1)
367 if (cookie == -1)
368 ret = PyString_FromFormat("event(wd=%d, mask=%s, name=%s)",
368 ret = PyString_FromFormat("event(wd=%d, mask=%s, name=%s)",
369 wd, maskstr, name);
369 wd, maskstr, name);
@@ -386,7 +386,7 b' static PyObject *event_repr(struct event'
386 goto done;
386 goto done;
387 bail:
387 bail:
388 Py_CLEAR(ret);
388 Py_CLEAR(ret);
389
389
390 done:
390 done:
391 Py_XDECREF(pymask);
391 Py_XDECREF(pymask);
392 Py_XDECREF(pymasks);
392 Py_XDECREF(pymasks);
@@ -436,7 +436,7 b' static PyTypeObject event_type = {'
436 0, /* tp_alloc */
436 0, /* tp_alloc */
437 event_new, /* tp_new */
437 event_new, /* tp_new */
438 };
438 };
439
439
440 PyObject *read_events(PyObject *self, PyObject *args)
440 PyObject *read_events(PyObject *self, PyObject *args)
441 {
441 {
442 PyObject *ctor_args = NULL;
442 PyObject *ctor_args = NULL;
@@ -448,22 +448,22 b' PyObject *read_events(PyObject *self, Py'
448 int fd;
448 int fd;
449
449
450 if (!PyArg_ParseTuple(args, "i|O:read", &fd, &pybufsize))
450 if (!PyArg_ParseTuple(args, "i|O:read", &fd, &pybufsize))
451 goto bail;
451 goto bail;
452
452
453 if (pybufsize && pybufsize != Py_None)
453 if (pybufsize && pybufsize != Py_None)
454 bufsize = PyInt_AsLong(pybufsize);
454 bufsize = PyInt_AsLong(pybufsize);
455
455
456 ret = PyList_New(0);
456 ret = PyList_New(0);
457 if (ret == NULL)
457 if (ret == NULL)
458 goto bail;
458 goto bail;
459
459
460 if (bufsize <= 0) {
460 if (bufsize <= 0) {
461 int r;
461 int r;
462
462
463 Py_BEGIN_ALLOW_THREADS
463 Py_BEGIN_ALLOW_THREADS
464 r = ioctl(fd, FIONREAD, &bufsize);
464 r = ioctl(fd, FIONREAD, &bufsize);
465 Py_END_ALLOW_THREADS
465 Py_END_ALLOW_THREADS
466
466
467 if (r == -1) {
467 if (r == -1) {
468 PyErr_SetFromErrno(PyExc_OSError);
468 PyErr_SetFromErrno(PyExc_OSError);
469 goto bail;
469 goto bail;
@@ -475,16 +475,16 b' PyObject *read_events(PyObject *self, Py'
475 static long name_max;
475 static long name_max;
476 static long name_fd = -1;
476 static long name_fd = -1;
477 long min;
477 long min;
478
478
479 if (name_fd != fd) {
479 if (name_fd != fd) {
480 name_fd = fd;
480 name_fd = fd;
481 Py_BEGIN_ALLOW_THREADS
481 Py_BEGIN_ALLOW_THREADS
482 name_max = fpathconf(fd, _PC_NAME_MAX);
482 name_max = fpathconf(fd, _PC_NAME_MAX);
483 Py_END_ALLOW_THREADS
483 Py_END_ALLOW_THREADS
484 }
484 }
485
485
486 min = sizeof(struct inotify_event) + name_max + 1;
486 min = sizeof(struct inotify_event) + name_max + 1;
487
487
488 if (bufsize < min) {
488 if (bufsize < min) {
489 PyErr_Format(PyExc_ValueError, "bufsize must be at least %d",
489 PyErr_Format(PyExc_ValueError, "bufsize must be at least %d",
490 (int) min);
490 (int) min);
@@ -493,7 +493,7 b' PyObject *read_events(PyObject *self, Py'
493 }
493 }
494
494
495 buf = alloca(bufsize);
495 buf = alloca(bufsize);
496
496
497 Py_BEGIN_ALLOW_THREADS
497 Py_BEGIN_ALLOW_THREADS
498 nread = read(fd, buf, bufsize);
498 nread = read(fd, buf, bufsize);
499 Py_END_ALLOW_THREADS
499 Py_END_ALLOW_THREADS
@@ -507,9 +507,9 b' PyObject *read_events(PyObject *self, Py'
507
507
508 if (ctor_args == NULL)
508 if (ctor_args == NULL)
509 goto bail;
509 goto bail;
510
510
511 pos = 0;
511 pos = 0;
512
512
513 while (pos < nread) {
513 while (pos < nread) {
514 struct inotify_event *in = (struct inotify_event *) (buf + pos);
514 struct inotify_event *in = (struct inotify_event *) (buf + pos);
515 struct event *evt;
515 struct event *evt;
@@ -555,12 +555,12 b' PyObject *read_events(PyObject *self, Py'
555
555
556 goto bail;
556 goto bail;
557 }
557 }
558
558
559 goto done;
559 goto done;
560
560
561 bail:
561 bail:
562 Py_CLEAR(ret);
562 Py_CLEAR(ret);
563
563
564 done:
564 done:
565 Py_XDECREF(ctor_args);
565 Py_XDECREF(ctor_args);
566
566
@@ -597,12 +597,12 b' void init_inotify(void)'
597 PyObject *mod, *dict;
597 PyObject *mod, *dict;
598
598
599 if (PyType_Ready(&event_type) == -1)
599 if (PyType_Ready(&event_type) == -1)
600 return;
600 return;
601
601
602 mod = Py_InitModule3("_inotify", methods, doc);
602 mod = Py_InitModule3("_inotify", methods, doc);
603
603
604 dict = PyModule_GetDict(mod);
604 dict = PyModule_GetDict(mod);
605
605
606 if (dict)
606 if (dict)
607 define_consts(dict);
607 define_consts(dict);
608 }
608 }
@@ -199,7 +199,7 b' class localrepository(repo.repository):'
199
199
200 names is a list of strings or, when adding a single tag, names may be a
200 names is a list of strings or, when adding a single tag, names may be a
201 string.
201 string.
202
202
203 if local is True, the tags are stored in a per-repository file.
203 if local is True, the tags are stored in a per-repository file.
204 otherwise, they are stored in the .hgtags file, and a new
204 otherwise, they are stored in the .hgtags file, and a new
205 changeset is committed with the change.
205 changeset is committed with the change.
General Comments 0
You need to be logged in to leave comments. Login now