public
Description: A distributed issue tracking system based on Git repositories, written in Python
Homepage: http://www.newartisans.com/software.html
Clone URL: git://github.com/jwiegley/git-issues.git
Search Repo:
Click here to lend your support to: git-issues and make a donation at www.pledgie.com !
Fixed complaints from pylint.
jwiegley (author)
Wed May 14 20:30:03 -0700 2008
commit  9f6565fc677f44f26c78a8be488a303cc0e30a77
tree    6f73bdcf7c6447067bdaf2856e6a06ab62151189
parent  2f5e79ca9f929e6a4b4086a3c0e67c1813d78db4
...
695
696
697
698
 
699
700
701
...
695
696
697
 
698
699
700
701
0
@@ -695,7 +695,7 @@
0
 
0
 ######################################################################
0
 
0
-class GitIssue(gitshelve.gitbook):
0
+class GitIssue(Issue, gitshelve.gitbook):
0
     def serialize_data(self):
0
         return object_to_string(self.data)
0
 
...
29
30
31
32
33
34
35
...
38
39
40
 
41
42
43
44
45
...
60
61
62
 
63
64
65
66
 
 
67
68
 
69
70
71
...
75
76
77
78
 
79
80
81
82
83
84
...
107
108
109
110
 
111
112
113
 
114
115
116
117
118
119
120
 
 
121
122
123
124
125
 
126
127
128
...
140
141
142
143
144
 
 
145
146
147
148
...
155
156
157
 
 
 
 
158
159
160
161
 
162
163
164
165
166
167
168
169
...
185
186
187
188
 
189
190
191
192
193
194
195
 
196
197
198
199
 
 
200
201
202
203
 
 
 
204
205
206
 
207
208
 
209
210
211
212
...
214
215
216
217
218
 
 
219
220
221
222
223
224
 
225
226
227
228
229
230
231
232
233
234
235
236
237
238
...
230
231
232
233
234
 
 
235
236
237
 
 
238
239
240
241
242
243
244
 
245
246
247
248
 
249
250
251
252
253
 
 
254
255
256
 
 
257
258
259
 
260
261
262
263
264
 
 
 
265
266
267
268
 
269
270
271
 
272
273
274
 
275
276
277
 
 
278
279
280
281
...
289
290
291
292
 
293
294
295
 
296
297
298
...
318
319
320
321
322
 
 
323
324
325
326
327
328
329
330
...
334
335
336
337
338
 
 
339
340
341
342
343
 
 
 
 
344
345
346
347
 
348
349
350
351
352
 
 
353
354
355
356
357
 
358
359
360
361
362
 
 
 
363
364
365
366
...
369
370
371
372
 
373
374
375
376
377
378
 
 
379
380
381
...
383
384
385
386
 
387
388
389
...
397
398
399
400
401
 
 
402
403
404
...
426
427
428
429
430
 
 
431
432
433
...
29
30
31
 
32
33
34
...
37
38
39
40
41
42
43
44
45
...
60
61
62
63
64
65
66
 
67
68
69
 
70
71
72
73
...
77
78
79
 
80
81
82
83
84
85
86
...
109
110
111
 
112
113
114
 
115
116
117
118
119
120
 
 
121
122
123
124
125
126
 
127
128
129
130
...
142
143
144
 
 
145
146
147
148
149
150
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
192
193
194
 
195
196
197
198
199
200
201
 
202
203
204
 
 
205
206
207
 
 
 
208
209
210
211
212
 
213
214
 
215
216
217
218
219
...
221
222
223
 
 
224
225
226
227
228
229
230
 
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
237
238
239
 
 
240
241
242
 
 
243
244
245
246
247
248
249
250
 
251
252
253
254
 
255
256
257
258
 
 
259
260
261
 
 
262
263
264
265
 
266
267
268
 
 
 
269
270
271
272
273
274
 
275
276
277
 
278
279
280
 
281
282
 
 
283
284
285
286
287
288
...
296
297
298
 
299
300
301
 
302
303
304
305
...
325
326
327
 
 
328
329
330
331
332
333
334
335
336
337
...
341
342
343
 
 
344
345
346
 
 
 
 
347
348
349
350
351
352
353
 
354
355
356
357
 
 
358
359
360
361
362
363
 
364
365
366
 
 
 
367
368
369
370
371
372
373
...
376
377
378
 
379
380
381
382
383
 
 
384
385
386
387
388
...
390
391
392
 
393
394
395
396
...
404
405
406
 
 
407
408
409
410
411
...
433
434
435
 
 
436
437
438
439
440
0
@@ -29,7 +29,6 @@
0
 # directory 'foo/bar'. Running 'git log' will show the change you made.
0
 
0
 import re
0
-import string
0
 import os.path
0
 
0
 try:
0
@@ -38,6 +37,7 @@
0
     from StringIO import StringIO
0
 
0
 from subprocess import Popen, PIPE
0
+from string import split, join
0
 
0
 ######################################################################
0
 
0
0
0
@@ -60,12 +60,14 @@
0
         self.args = args
0
         self.kwargs = kwargs
0
         self.stderr = stderr
0
+ Exception.__init__(self)
0
 
0
     def __str__(self):
0
         if self.stderr:
0
- return "Git command failed: git-%s %s: %s" % (self.cmd, self.args, self.stderr)
0
+ return "Git command failed: git-%s %s: %s" % \
0
+ (self.cmd, self.args, self.stderr)
0
         else:
0
- return "Git command failed: git-%s %s" % (self.cmd, self.args)
0
+ return "Git command failed: git-%s %s" % (self.cmd, self.args)
0
 
0
 def git(cmd, *args, **kwargs):
0
     restart = True
0
@@ -75,7 +77,7 @@
0
             stdin_mode = PIPE
0
 
0
         if verbose:
0
- print "Command: git-%s %s" % (cmd, string.join(args, ' '))
0
+ print "Command: git-%s %s" % (cmd, join(args, ' '))
0
             if kwargs.has_key('input'):
0
                 print "Input: <<EOF"
0
                 print kwargs['input'],
0
0
0
0
@@ -107,22 +109,22 @@
0
 class gitbook:
0
     """Abstracts a reference to a data file within a Git repository. It also
0
     maintains knowledge of whether the object has been modified or not."""
0
- def __init__(self, shelf, path, hash = None):
0
+ def __init__(self, shelf, path, name = None):
0
         self.shelf = shelf
0
         self.path = path
0
- self.hash = hash
0
+ self.name = name
0
         self.data = None
0
         self.dirty = False
0
 
0
     def get_data(self):
0
         if self.data is None:
0
- assert self.hash is not None
0
- self.data = self.deserialize_data(self.shelf.get_blob(self.hash))
0
+ assert self.name is not None
0
+ self.data = self.deserialize_data(self.shelf.get_blob(self.name))
0
         return self.data
0
         
0
     def set_data(self, data):
0
         if data != self.data:
0
- self.hash = None
0
+ self.name = None
0
             self.data = data
0
             self.dirty = True
0
 
0
@@ -140,8 +142,8 @@
0
         del odict['dirty'] # remove dirty flag
0
         return odict
0
 
0
- def __setstate__(self,dict):
0
- self.__dict__.update(dict) # update attributes
0
+ def __setstate__(self, ndict):
0
+ self.__dict__.update(ndict) # update attributes
0
         self.dirty = False
0
 
0
 
0
0
@@ -155,10 +157,15 @@
0
     other Git users, nor does it support merging)."""
0
     ls_tree_pat = re.compile('(040000 tree|100644 blob) ([0-9a-f]{40})\t(start|(.+))$')
0
 
0
+ head = None
0
+ dirty = False
0
+ objects = {}
0
+
0
     def __init__(self, branch, book_type = gitbook):
0
         self.branch = branch
0
         self.book_type = book_type
0
         self.init_data()
0
+ dict.__init__(self)
0
 
0
     def init_data(self):
0
         self.head = None
0
0
0
0
0
0
@@ -185,27 +192,27 @@
0
         if not self.head:
0
             return
0
 
0
- ls_tree = string.split(git('ls-tree', '-r', '-t', '-z', self.head),
0
+ ls_tree = ssplit(git('ls-tree', '-r', '-t', '-z', self.head),
0
                                '\0')
0
         for line in ls_tree:
0
             match = self.ls_tree_pat.match(line)
0
             assert match
0
 
0
             treep = match.group(1) == "040000 tree"
0
- hash = match.group(2)
0
+ name = match.group(2)
0
             path = match.group(3)
0
 
0
- parts = string.split(path, os.sep)
0
- dict = self.objects
0
+ parts = split(path, os.sep)
0
+ d = self.objects
0
             for part in parts:
0
- if not dict.has_key(part):
0
- dict[part] = {}
0
- dict = dict[part]
0
+ if not d.has_key(part):
0
+ d[part] = {}
0
+ d = d[part]
0
 
0
             if treep:
0
- dict['__root__'] = hash
0
+ d['__root__'] = name
0
             else:
0
- dict['__book__'] = self.book_type(self, path, hash)
0
+ d['__book__'] = self.book_type(self, path, name)
0
 
0
     def open(cls, branch, book_type = gitbook):
0
         shelf = gitshelve(branch, book_type)
0
0
@@ -214,14 +221,14 @@
0
 
0
     open = classmethod(open)
0
 
0
- def get_blob(self, hash):
0
- return git('cat-file', 'blob', hash, keep_newline = True)
0
+ def get_blob(self, name):
0
+ return git('cat-file', 'blob', name, keep_newline = True)
0
 
0
     def make_blob(self, data):
0
         return git('hash-object', '-w', '--stdin', input = data)
0
 
0
     def make_tree(self, objects, comment_accumulator = None):
0
- buffer = StringIO()
0
+ buf = StringIO()
0
 
0
         root = None
0
         if objects.has_key('__root__'):
0
0
0
0
0
0
0
0
0
0
0
0
@@ -230,51 +237,51 @@
0
         for path in objects.keys():
0
             if path == '__root__': continue
0
 
0
- object = objects[path]
0
- assert isinstance(object, dict)
0
+ obj = objects[path]
0
+ assert isinstance(obj, dict)
0
 
0
- if len(object.keys()) == 1 and object.has_key('__book__'):
0
- book = object['__book__']
0
+ if len(obj.keys()) == 1 and obj.has_key('__book__'):
0
+ book = obj['__book__']
0
                 if book.dirty:
0
                     if comment_accumulator:
0
                         comment = book.change_comment()
0
                         if comment:
0
                             comment_accumulator.write(comment)
0
 
0
- book.hash = self.make_blob(book.serialize_data())
0
+ book.name = self.make_blob(book.serialize_data())
0
                     book.dirty = False
0
                     root = None
0
 
0
- buffer.write("100644 blob %s\t%s\0" % (book.hash, path))
0
+ buf.write("100644 blob %s\t%s\0" % (book.name, path))
0
 
0
             else:
0
                 tree_root = None
0
- if object.has_key('__root__'):
0
- tree_root = object['__root__']
0
+ if obj.has_key('__root__'):
0
+ tree_root = obj['__root__']
0
 
0
- tree_hash = self.make_tree(object, comment_accumulator)
0
- if tree_hash != tree_root:
0
+ tree_name = self.make_tree(obj, comment_accumulator)
0
+ if tree_name != tree_root:
0
                     root = None
0
 
0
- buffer.write("040000 tree %s\t%s\0" % (tree_hash, path))
0
+ buf.write("040000 tree %s\t%s\0" % (tree_name, path))
0
 
0
         if root is None:
0
- hash = git('mktree', '-z', input = buffer.getvalue())
0
- objects['__root__'] = hash
0
- return hash
0
+ name = git('mktree', '-z', input = buf.getvalue())
0
+ objects['__root__'] = name
0
+ return name
0
         else:
0
             return root
0
 
0
- def make_commit(self, tree_hash, comment):
0
+ def make_commit(self, tree_name, comment):
0
         if not comment: comment = ""
0
         if self.head:
0
- hash = git('commit-tree', tree_hash, '-p', self.head,
0
+ name = git('commit-tree', tree_name, '-p', self.head,
0
                        input = comment)
0
         else:
0
- hash = git('commit-tree', tree_hash, input = comment)
0
+ name = git('commit-tree', tree_name, input = comment)
0
 
0
- self.update_head(hash)
0
- return hash
0
+ self.update_head(name)
0
+ return name
0
 
0
     def commit(self, comment = None):
0
         if not self.dirty:
0
0
@@ -289,10 +296,10 @@
0
         tree = self.make_tree(self.objects, accumulator)
0
         if accumulator:
0
             comment = accumulator.getvalue()
0
- hash = self.make_commit(tree, comment)
0
+ name = self.make_commit(tree, comment)
0
 
0
         self.dirty = False
0
- return hash
0
+ return name
0
 
0
     def sync(self):
0
         self.commit()
0
@@ -318,8 +325,8 @@
0
 
0
             if objects[key].has_key('__book__'):
0
                 book = objects[key]['__book__']
0
- if book.hash:
0
- kind = 'blob ' + book.hash
0
+ if book.name:
0
+ kind = 'blob ' + book.name
0
                 else:
0
                     kind = 'blob'
0
             else:
0
0
0
0
0
0
@@ -334,32 +341,32 @@
0
                 self.dump_objects(fd, indent + 2, objects[key])
0
 
0
     def get_tree(self, path, make_dirs = False):
0
- parts = string.split(path, os.sep)
0
- dict = self.objects
0
+ parts = split(path, os.sep)
0
+ d = self.objects
0
         for part in parts:
0
- if make_dirs and not dict.has_key(part):
0
- dict[part] = {}
0
- dict = dict[part]
0
- return dict
0
+ if make_dirs and not d.has_key(part):
0
+ d[part] = {}
0
+ d = d[part]
0
+ return d
0
 
0
     def __getitem__(self, path):
0
         try:
0
- dict = self.get_tree(path)
0
+ d = self.get_tree(path)
0
         except KeyError:
0
             raise KeyError(path)
0
 
0
- if len(dict.keys()) == 1:
0
- return dict['__book__'].get_data()
0
+ if len(d.keys()) == 1:
0
+ return d['__book__'].get_data()
0
         raise KeyError(path)
0
 
0
     def __setitem__(self, path, data):
0
         try:
0
- dict = self.get_tree(path, make_dirs = True)
0
+ d = self.get_tree(path, make_dirs = True)
0
         except KeyError:
0
             raise KeyError(path)
0
- if len(dict.keys()) == 0:
0
- dict['__book__'] = self.book_type(self, path)
0
- dict['__book__'].set_data(data)
0
+ if len(d.keys()) == 0:
0
+ d['__book__'] = self.book_type(self, path)
0
+ d['__book__'].set_data(data)
0
         self.dirty = True
0
 
0
     def prune_tree(self, objects, paths):
0
0
@@ -369,13 +376,13 @@
0
 
0
     def __delitem__(self, path):
0
         try:
0
- self.prune_tree(self.objects, string.split(path, os.sep))
0
+ self.prune_tree(self.objects, ssplit(path, os.sep))
0
         except KeyError:
0
             raise KeyError(path)
0
 
0
     def __contains__(self, path):
0
- dict = self.get_tree(path)
0
- return len(dict.keys()) == 1 and dict.has_key('__book__')
0
+ d = self.get_tree(path)
0
+ return len(d.keys()) == 1 and d.has_key('__book__')
0
 
0
     def walker(self, kind, objects, path = ''):
0
         for item in objects.items():
0
@@ -383,7 +390,7 @@
0
             assert isinstance(item[1], dict)
0
 
0
             if path:
0
- key = string.join((path, item[0]), os.sep)
0
+ key = join((path, item[0]), os.sep)
0
             else:
0
                 key = item[0]
0
 
0
@@ -397,8 +404,8 @@
0
                     assert kind == 'items'
0
                     yield (key, value)
0
             else:
0
- for object in self.walker(kind, item[1], key):
0
- yield object
0
+ for obj in self.walker(kind, item[1], key):
0
+ yield obj
0
 
0
         raise StopIteration
0
 
0
@@ -426,8 +433,8 @@
0
         del odict['dirty'] # remove dirty flag
0
         return odict
0
 
0
- def __setstate__(self,dict):
0
- self.__dict__.update(dict) # update attributes
0
+ def __setstate__(self, ndict):
0
+ self.__dict__.update(ndict) # update attributes
0
         self.dirty = False
0
 
0
         # If the HEAD reference is out of date, throw away all data and

Comments

    No one has commented yet.