Skip to content

Commit

Permalink
Merge commit 'jwiegley/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Aug 7, 2008
2 parents ccd521d + 3a0ed4b commit 41b8409
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 97 deletions.
94 changes: 43 additions & 51 deletions git-issues
Expand Up @@ -994,8 +994,8 @@ if __name__ == '__main__':

######################################################################

# jww (2008-05-12): Pick the appropriate IssueSet to used based on what we
# find in our environment.
# jww (2008-05-12): Pick the appropriate IssueSet to use based on the
# environment.

issueSet = GitIssueSet().load_state()

Expand Down Expand Up @@ -1060,55 +1060,47 @@ if __name__ == '__main__':
issueSet.get_comment(comment[0:7]).comment)
for comment in issue.comments])
if command == "show":
sys.stdout.write("""
Title: %s
Summary: %s
Description: %s
Author: %s
Reporter: %s
Owner: %s
Assigned: %s
Cc: %s
Type: %s
Status: %s
Resolution: %s
Components: %s
Version: %s
Milestone: %s
Severity: %s
Priority: %s
Tags: %s
Created: %s
Modified: %s
%s
""" % (issue.title,
format_long_text(issue.summary),

format_long_text(issue.description),

issue.author,
format_people_list(issue.reporters),
format_people_list(issue.owners),
format_people_list(issue.assigned),
format_people_list(issue.carbons),

issue.issue_type,
issue.status,
issue.resolution or "",
issue.components or "",
issue.version or "",
issue.milestone or "",
issue.severity,
issue.priority,
issue.tags or "",

issue.created,
issue.modified,
comments))
if issue.title:
print " Title:", issue.title
if issue.summary:
print " Summary:", format_long_text(issue.summary)
print
if issue.description:
print " Description:", format_long_text(issue.description)
print
if issue.author:
print " Author:", issue.author
if issue.reporters:
print " Reporter(s):", format_people_list(issue.reporters)
if issue.owners:
print " Owner(s):", format_people_list(issue.owners)
if issue.assigned:
print " Assigned:", format_people_list(issue.assigned)
if issue.carbons:
print " Cc:", format_people_list(issue.carbons)

if issue.issue_type:
print " Type:", issue.issue_type
if issue.status:
print " Status:", issue.status
if issue.resolution:
print " Resolution:", issue.resolution
if issue.components:
print " Components:", issue.components
if issue.version:
print " Version:", issue.version
if issue.milestone:
print " Milestone:", issue.milestone
if issue.severity:
print " Severity:", issue.severity
if issue.priority:
print " Priority:", issue.priority
if issue.tags:
print " Tags:", issue.tags

print " Created:", issue.created
if issue.modified:
print " Modified:", issue.modified
else:
write_object(issue)

Expand Down
90 changes: 63 additions & 27 deletions gitshelve.py
Expand Up @@ -66,10 +66,10 @@ def __init__(self, cmd, args, kwargs, stderr = None):

def __str__(self):
if self.stderr:
return "Git command failed: git-%s %s: %s" % \
return "Git command failed: git %s %s: %s" % \
(self.cmd, self.args, self.stderr)
else:
return "Git command failed: git-%s %s" % (self.cmd, self.args)
return "Git command failed: git %s %s" % (self.cmd, self.args)

def git(cmd, *args, **kwargs):
restart = True
Expand All @@ -79,7 +79,7 @@ def git(cmd, *args, **kwargs):
stdin_mode = PIPE

if verbose:
print "Command: git-%s %s" % (cmd, join(args, ' '))
print "Command: git %s %s" % (cmd, join(args, ' '))
if kwargs.has_key('input'):
print "Input: <<EOF"
print kwargs['input'],
Expand All @@ -92,12 +92,12 @@ def git(cmd, *args, **kwargs):

git_dir = environ['GIT_DIR']
if not os.path.isdir(git_dir):
proc = Popen('git-init', env = environ,
proc = Popen(('git', 'init'), env = environ,
stdout = PIPE, stderr = PIPE)
if proc.wait() != 0:
raise GitError('init', [], {}, proc.stderr.read())

proc = Popen(('git-' + cmd,) + args, env = environ,
proc = Popen(('git', cmd) + args, env = environ,
stdin = stdin_mode,
stdout = PIPE,
stderr = PIPE)
Expand Down Expand Up @@ -171,17 +171,18 @@ class gitshelve(dict):
This implementation uses a dictionary of gitbook objects, since we don't
really want to use Pickling within a Git repository (it's not friendly to
other Git users, nor does it support merging)."""
ls_tree_pat = re.compile('(040000 tree|100644 blob) ([0-9a-f]{40})\t(start|(.+))$')
ls_tree_pat = re.compile('((\d{6}) (tree|blob)) ([0-9a-f]{40})\t(start|(.+))$')

head = None
dirty = False
objects = None

def __init__(self, branch = 'master', repository = None,
book_type = gitbook):
self.branch = branch
self.repository = repository
self.book_type = book_type
keep_history = True, book_type = gitbook):
self.branch = branch
self.repository = repository
self.keep_history = keep_history
self.book_type = book_type
self.init_data()
dict.__init__(self)

Expand Down Expand Up @@ -225,8 +226,9 @@ def read_repository(self):
assert match

treep = match.group(1) == "040000 tree"
name = match.group(2)
path = match.group(3)
perm = match.group(2)
name = match.group(4)
path = match.group(5)

parts = split(path, os.sep)
d = self.objects
Expand All @@ -236,13 +238,21 @@ def read_repository(self):
d = d[part]

if treep:
d['__root__'] = name
if perm == '040000' :
d['__root__'] = name
else :
raise GitError('read_repository', [], {},
'Invalid mode for %s : 040000 required, %s found' %(path, perm))
else:
d['__book__'] = self.book_type(self, path, name)
if perm == '100644' :
d['__book__'] = self.book_type(self, path, name)
else :
raise GitError('read_repository', [], {},
'Invalid mode for %s : 100644 required, %s found' %(path, perm))

def open(cls, branch = 'master', repository = None,
book_type = gitbook):
shelf = gitshelve(branch, repository, book_type)
keep_history = True, book_type = gitbook):
shelf = gitshelve(branch, repository, keep_history, book_type)
shelf.read_repository()
return shelf

Expand Down Expand Up @@ -304,9 +314,9 @@ def make_tree(self, objects, comment_accumulator = None):

def make_commit(self, tree_name, comment):
if not comment: comment = ""
if self.head:
if self.head and self.keep_history:
name = self.git('commit-tree', tree_name, '-p', self.head,
input = comment)
input = comment)
else:
name = self.git('commit-tree', tree_name, input = comment)

Expand Down Expand Up @@ -379,22 +389,47 @@ def get_tree(self, path, make_dirs = False):
d = d[part]
return d

def get(self, key):
path = '%s/%s' % (key[:2], key[2:])
d = None
try:
d = self.get_tree(path)
except KeyError:
raise KeyError(key)
if not d or not d.has_key('__book__'):
raise KeyError(key)
return d['__book__'].get_data()

def put(self, data):
book = self.book_type(self, '__unknown__')
book.data = data
book.name = self.make_blob(book.serialize_data(book.data))
book.dirty = False # the blob was just written!
book.path = '%s/%s' % (book.name[:2], book.name[2:])

d = self.get_tree(book.path, make_dirs = True)
d.clear()
d['__book__'] = book
self.dirty = True

return book.name

def __getitem__(self, path):
d = None
try:
d = self.get_tree(path)
except KeyError:
raise KeyError(path)

if len(d.keys()) == 1:
if d and d.has_key('__book__'):
return d['__book__'].get_data()
raise KeyError(path)
else:
raise KeyError(path)

def __setitem__(self, path, data):
try:
d = self.get_tree(path, make_dirs = True)
except KeyError:
raise KeyError(path)
if len(d.keys()) == 0:
d = self.get_tree(path, make_dirs = True)
if not d.has_key('__book__'):
d.clear()
d['__book__'] = self.book_type(self, path)
d['__book__'].set_data(data)
self.dirty = True
Expand Down Expand Up @@ -473,7 +508,8 @@ def __setstate__(self, ndict):
self.read_repository()


def open(branch = 'master', repository = None, book_type = gitbook):
return gitshelve.open(branch, repository, book_type)
def open(branch = 'master', repository = None, keep_history = True,
book_type = gitbook):
return gitshelve.open(branch, repository, keep_history, book_type)

# gitshelve.py ends here

0 comments on commit 41b8409

Please sign in to comment.