artemis.py
author Dmitriy Morozov <morozov@cs.duke.edu>
Sat, 29 Dec 2007 02:50:00 -0500
changeset 2 9e804a85c82c
parent 1 0bbf290d6f07
child 4 bf71e2069dbd
permissions -rw-r--r--
list works well, basic show, add, and update functionality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     1
# Author: Dmitriy Morozov <hg@foxcub.org>, 2007
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     3
"""A very simple and lightweight issue tracker for Mercurial."""
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     4
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     5
from mercurial import hg, util
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     6
from mercurial.i18n import _
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     7
import os, time, random, mailbox, glob, socket
0
c1b34481e50a Initial commit
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     8
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
     9
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    10
new_state = "new"
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    11
default_state = new_state
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    12
issues_dir = ".issues"
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    13
filter_filename = ".filters"
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    14
date_format = '%a, %d %b %Y %H:%M:%S %Z'
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    15
0
c1b34481e50a Initial commit
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    16
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    17
def list(ui, repo, **opts):
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    18
	"""List issues associated with the project"""
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    19
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    20
	# Process options
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    21
	show_all = False or opts['all']
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    22
	properties = _get_properties(opts['property']) or [['state', new_state]]
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    23
	date_match = lambda x: True
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    24
	if opts['date']: 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    25
		date_match = util.matchdate(opts['date'])
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    26
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    27
	# Find issues
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    28
	issues_path = os.path.join(repo.root, issues_dir)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    29
	if not os.path.exists(issues_path): return
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    30
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    31
	issues = glob.glob(os.path.join(issues_path, '*'))
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    32
	
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    33
	for issue in issues:
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    34
		mbox = mailbox.mbox(issue)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    35
		property_match = True
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    36
		for property,value in properties: 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    37
			property_match = property_match and (mbox[0][property] == value)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    38
		if not show_all and not property_match: continue
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    39
		if not date_match(util.parsedate(mbox[0]['date'], [date_format])[0]): continue
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    40
		print "%s [%s]: %s (%d)" % (issue[len(issues_path)+1:], # +1 for trailing /
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    41
									mbox[0]['State'],
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    42
									mbox[0]['Subject'], 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    43
									len(mbox)-1)				# number of replies (-1 for self)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    44
	
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    45
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    46
def add(ui, repo):
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    47
	"""Adds a new issue"""
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    48
	
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    49
	# First, make sure issues have a directory
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    50
	issues_path = os.path.join(repo.root, issues_dir)
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    51
	if not os.path.exists(issues_path): os.mkdir(issues_path)
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    52
	
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    53
	user = ui.username()
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    54
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    55
	default_issue_text  = 	"From: %s\nDate: %s\n" % (user,
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    56
													  time.strftime(date_format))
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    57
	default_issue_text += 	"State: %s\nSubject: brief description\n\n" % default_state
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    58
	default_issue_text += 	"Detailed description."
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    59
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    60
	issue = ui.edit(default_issue_text, user)
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    61
	if issue.strip() == '':
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    62
		ui.warn('Empty issue, ignoring\n')
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    63
		return
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    64
	if issue.strip() == default_issue_text:
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    65
		ui.warn('Unchanged issue text, ignoring\n')
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    66
		return
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    67
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    68
	# Create the message
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    69
	msg = mailbox.mboxMessage(issue)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    70
	msg.set_from('artemis', True)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    71
	
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    72
	# Pick random filename
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    73
	issue_fn = issues_path
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    74
	while os.path.exists(issue_fn):
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    75
		issue_id = "%x" % random.randint(2**63, 2**64-1)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    76
		issue_fn = os.path.join(issues_path, issue_id)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    77
	msg.add_header('Message-Id', "%s-0-artemis@%s" % (issue_id, socket.gethostname()))
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    78
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    79
	# Add message to the mailbox
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    80
	mbox = mailbox.mbox(issue_fn)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    81
	mbox.add(msg)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    82
	mbox.close()
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    83
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    84
	# Add the new mailbox to the repository
1
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    85
	repo.add([issue_fn[(len(repo.root)+1):]])			# +1 for the trailing /
0bbf290d6f07 Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 0
diff changeset
    86
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    87
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    88
def show(ui, repo, id, comment = None):
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    89
	"""Shows issue ID, or possibly its comment COMMENT"""
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    90
	
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    91
	issue = _find_issue(ui, repo, id)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    92
	if not issue: return
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    93
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    94
	# Read the issue
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    95
	mbox = mailbox.mbox(issue)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    96
	msg = mbox[0]
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    97
	ui.write(msg.as_string())
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    98
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
    99
	# Walk the mailbox, and output comments
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   100
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   101
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   102
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   103
def update(ui, repo, id, **opts):
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   104
	"""Update properties of issue ID, or add a comment to it or its comment COMMENT"""
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   105
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   106
	issue = _find_issue(ui, repo, id)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   107
	if not issue: return
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   108
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   109
	properties = _get_properties(opts['property'])
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   110
	
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   111
	# Read the issue
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   112
	mbox = mailbox.mbox(issue)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   113
	msg = mbox[0]
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   114
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   115
	# Fix the properties
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   116
	for property, value in properties:
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   117
		msg.replace_header(property, value)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   118
	mbox[0] = msg
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   119
	mbox.flush()
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   120
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   121
	# Deal with comments
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   122
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   123
	# Show updated message
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   124
	ui.write(mbox[0].as_string())
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   125
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   126
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   127
def _find_issue(ui, repo, id):
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   128
	issues_path = os.path.join(repo.root, issues_dir)
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   129
	if not os.path.exists(issues_path): return False
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   130
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   131
	issues = glob.glob(os.path.join(issues_path, id + '*'))
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   132
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   133
	if len(issues) == 0:
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   134
		return False
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   135
	elif len(issues) > 1:
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   136
		ui.status("Multiple choices:\n")
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   137
		for i in issues: ui.status('  ', i[len(issues_path)+1:], '\n')
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   138
		return False
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   139
	
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   140
	return issues[0]
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   141
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   142
def _get_properties(property_list):
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   143
	return [p.split('=') for p in property_list]
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   144
	
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   145
0
c1b34481e50a Initial commit
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
   146
c1b34481e50a Initial commit
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
   147
cmdtable = {
2
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   148
	'ilist':	(list, 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   149
				 [('a', 'all', None, 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   150
				   'list all issues (by default only those with state new)'),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   151
				  ('p', 'property', [], 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   152
				   'list issues with specific field values (e.g., -p state=fixed)'),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   153
				  ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   154
				  ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s)' % (issues_dir, filter_filename))], 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   155
				 _('hg ilist [OPTIONS]')),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   156
	'iadd':   	(add,  
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   157
				 [], 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   158
				 _('hg iadd')),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   159
	'ishow':  	(show, 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   160
				 [('v', 'verbose', None, 'list the comments')], 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   161
				 _('hg ishow ID [COMMENT]')),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   162
	'iupdate':	(update,
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   163
				 [('p', 'property', [], 
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   164
				   'update properties (e.g., -p state=fixed)'),
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   165
				  ('c', 'comment', 0,
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   166
				   'add a comment to issue or its comment COMMENT')],
9e804a85c82c list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents: 1
diff changeset
   167
				 _('hg iupdate [OPTIONS] ID [COMMENT]'))
0
c1b34481e50a Initial commit
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
   168
}