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