| author | Dmitriy Morozov <morozov@cs.duke.edu> |
| Sun, 06 Jan 2008 01:18:02 -0500 | |
| changeset 14 | e78a97664dba |
| parent 13 | e155f2129514 |
| child 15 | e5b03298394e |
| permissions | -rw-r--r-- |
|
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 _ |
|
7
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
7 |
import os, time, random, mailbox, glob, socket, ConfigParser |
| 0 | 8 |
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
9 |
|
|
5
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
10 |
state = {'new': 'new', 'fixed': 'fixed'}
|
|
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
11 |
state['default'] = state['new'] |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
12 |
issues_dir = ".issues" |
|
7
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
13 |
filter_prefix = ".filter" |
|
2
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 | 16 |
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
17 |
def ilist(ui, repo, **opts): |
|
1
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 |
|
5
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
21 |
show_all = opts['all'] |
|
7
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
22 |
properties = [] |
|
11
8bf7b97035f1
Added date parsing bug (c56), and a pseudo-fix
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
8
diff
changeset
|
23 |
match_date, date_match = False, lambda x: True |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
24 |
if opts['date']: |
|
11
8bf7b97035f1
Added date parsing bug (c56), and a pseudo-fix
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
8
diff
changeset
|
25 |
match_date, date_match = True, util.matchdate(opts['date']) |
|
2
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 |
|
|
7
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
33 |
# Process filter |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
34 |
if opts['filter']: |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
35 |
filters = glob.glob(os.path.join(issues_path, filter_prefix + '*')) |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
36 |
config = ConfigParser.SafeConfigParser() |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
37 |
config.read(filters) |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
38 |
if not config.has_section(opts['filter']): |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
39 |
ui.warning('No filter %s defined\n', opts['filter'])
|
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
40 |
else: |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
41 |
properties += config.items(opts['filter']) |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
42 |
|
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
43 |
_get_properties(opts['property']) |
|
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
44 |
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
45 |
for issue in issues: |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
46 |
mbox = mailbox.mbox(issue) |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
47 |
property_match = True |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
48 |
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
|
49 |
property_match = property_match and (mbox[0][property] == value) |
|
5
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
50 |
if not show_all and (not properties or not property_match) and (properties or mbox[0]['State'].upper() == state['fixed'].upper()): continue |
|
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
51 |
|
|
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
52 |
|
|
11
8bf7b97035f1
Added date parsing bug (c56), and a pseudo-fix
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
8
diff
changeset
|
53 |
if match_date and not date_match(util.parsedate(mbox[0]['date'], [date_format])[0]): continue |
|
5
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
54 |
ui.write("%s (%d) [%s]: %s\n" % (issue[len(issues_path)+1:], # +1 for trailing /
|
|
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
55 |
len(mbox)-1, # number of replies (-1 for self) |
|
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
56 |
mbox[0]['State'], |
|
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
57 |
mbox[0]['Subject'])) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
58 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
59 |
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
60 |
def iadd(ui, repo, id = None, comment = 0): |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
61 |
"""Adds a new issue, or comment to an existing issue ID or its comment COMMENT""" |
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
62 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
63 |
comment = int(comment) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
64 |
|
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
65 |
# 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
|
66 |
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
|
67 |
if not os.path.exists(issues_path): os.mkdir(issues_path) |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
68 |
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
69 |
if id: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
70 |
issue_fn, issue_id = _find_issue(ui, repo, id) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
71 |
if not issue_fn: |
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
72 |
ui.warn('No such issue\n')
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
73 |
return |
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
74 |
|
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
75 |
user = ui.username() |
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
76 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
77 |
default_issue_text = "From: %s\nDate: %s\n" % (user, time.strftime(date_format)) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
78 |
if not id: |
|
5
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
79 |
default_issue_text += "State: %s\n" % state['default'] |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
80 |
default_issue_text += "Subject: brief description\n\n" |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
81 |
default_issue_text += "Detailed description." |
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
82 |
|
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
83 |
issue = ui.edit(default_issue_text, user) |
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
84 |
if issue.strip() == '': |
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
85 |
ui.warn('Empty issue, ignoring\n')
|
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
86 |
return |
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
87 |
if issue.strip() == default_issue_text: |
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
88 |
ui.warn('Unchanged issue text, ignoring\n')
|
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
89 |
return |
|
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
90 |
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
91 |
# Create the message |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
92 |
msg = mailbox.mboxMessage(issue) |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
93 |
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
|
94 |
|
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
95 |
# Pick random filename |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
96 |
if not id: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
97 |
issue_fn = issues_path |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
98 |
while os.path.exists(issue_fn): |
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
99 |
issue_id = _random_id() |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
100 |
issue_fn = os.path.join(issues_path, issue_id) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
101 |
# else: issue_fn already set |
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
102 |
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
103 |
# 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
|
104 |
mbox = mailbox.mbox(issue_fn) |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
105 |
if id and comment not in mbox: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
106 |
ui.warn('No such comment number in mailbox, commenting on the issue itself\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
107 |
if not id: |
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
108 |
msg.add_header('Message-Id', "<%s-0-artemis@%s>" % (issue_id, socket.gethostname()))
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
109 |
else: |
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
110 |
msg.add_header('Message-Id', "<%s-%s-artemis@%s>" % (issue_id, _random_id(), socket.gethostname()))
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
111 |
msg.add_header('References', mbox[(comment < len(mbox) and comment) or 0]['Message-Id'])
|
|
13
e155f2129514
Fixed In-Reply-To bug (b7c)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
11
diff
changeset
|
112 |
msg.add_header('In-Reply-To', mbox[(comment < len(mbox) and comment) or 0]['Message-Id'])
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
113 |
mbox.add(msg) |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
114 |
mbox.close() |
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
115 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
116 |
# If adding issue, add the new mailbox to the repository |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
117 |
if not id: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
118 |
repo.add([issue_fn[(len(repo.root)+1):]]) # +1 for the trailing / |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
119 |
ui.status('Added new issue %s\n' % issue_id)
|
|
1
0bbf290d6f07
Commit artemis before cleaning repository
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
0
diff
changeset
|
120 |
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
121 |
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
122 |
def ishow(ui, repo, id, comment = 0, **opts): |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
123 |
"""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
|
124 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
125 |
comment = int(comment) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
126 |
issue, id = _find_issue(ui, repo, id) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
127 |
if not issue: return |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
128 |
mbox = mailbox.mbox(issue) |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
129 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
130 |
if opts['all']: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
131 |
ui.write('='*70 + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
132 |
for i in xrange(len(mbox)): |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
133 |
_write_message(ui, mbox[i], i) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
134 |
ui.write('-'*70 + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
135 |
return |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
136 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
137 |
_show_mbox(ui, mbox, comment) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
138 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
139 |
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
140 |
def iupdate(ui, repo, id, **opts): |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
141 |
"""Update properties of issue ID""" |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
142 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
143 |
issue, id = _find_issue(ui, repo, id) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
144 |
if not issue: return |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
145 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
146 |
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
|
147 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
148 |
# Read the issue |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
149 |
mbox = mailbox.mbox(issue) |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
150 |
msg = mbox[0] |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
151 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
152 |
# Fix the properties |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
153 |
properties_text = '' |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
154 |
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
|
155 |
msg.replace_header(property, value) |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
156 |
properties_text += '%s=%s\n' % (property, value) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
157 |
mbox[0] = msg |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
158 |
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
159 |
# Write down a comment about updated properties |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
160 |
if properties and not opts['no_property_comment']: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
161 |
user = ui.username() |
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
162 |
properties_text = "From: %s\nDate: %s\nSubject: properties changes (%s)\n\n%s" % \ |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
163 |
(user, time.strftime(date_format), |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
164 |
_pretty_list(list(set([property for property, value in properties]))), |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
165 |
properties_text) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
166 |
msg = mailbox.mboxMessage(properties_text) |
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
167 |
msg.add_header('Message-Id', "<%s-%s-artemis@%s>" % (id, _random_id(), socket.gethostname()))
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
168 |
msg.add_header('References', mbox[0]['Message-Id'])
|
|
13
e155f2129514
Fixed In-Reply-To bug (b7c)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
11
diff
changeset
|
169 |
msg.add_header('In-Reply-To', mbox[0]['Message-Id'])
|
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
170 |
msg.set_from('artemis', True)
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
171 |
mbox.add(msg) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
172 |
mbox.flush() |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
173 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
174 |
# Show updated message |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
175 |
_show_mbox(ui, mbox, 0) |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
176 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
177 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
182 |
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
|
183 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
184 |
if len(issues) == 0: |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
185 |
return False, 0 |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
186 |
elif len(issues) > 1: |
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
187 |
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
|
188 |
for i in issues: ui.status(' ', i[len(issues_path)+1:], '\n')
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
189 |
return False, 0 |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
190 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
191 |
return issues[0], issues[0][len(issues_path)+1:] |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
192 |
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
193 |
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
|
194 |
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
|
195 |
|
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
196 |
def _write_message(ui, message, index = 0): |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
197 |
if index: ui.write("Comment: %d\n" % index)
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
198 |
if ui.verbose: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
199 |
ui.write(message.as_string().strip() + '\n') |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
200 |
else: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
201 |
if 'From' in message: ui.write('From: %s\n' % message['From'])
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
202 |
if 'Date' in message: ui.write('Date: %s\n' % message['Date'])
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
203 |
if 'Subject' in message: ui.write('Subject: %s\n' % message['Subject'])
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
204 |
if 'State' in message: ui.write('State: %s\n' % message['State'])
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
205 |
ui.write('\n' + message.get_payload().strip() + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
206 |
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
207 |
def _show_mbox(ui, mbox, comment): |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
208 |
# Output the issue (or comment) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
209 |
if comment >= len(mbox): |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
210 |
comment = 0 |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
211 |
ui.warn('Comment out of range, showing the issue itself\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
212 |
msg = mbox[comment] |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
213 |
ui.write('='*70 + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
214 |
if comment: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
215 |
ui.write('Subject: %s\n' % mbox[0]['Subject'])
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
216 |
ui.write('State: %s\n' % mbox[0]['State'])
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
217 |
ui.write('-'*70 + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
218 |
_write_message(ui, msg, comment) |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
219 |
ui.write('-'*70 + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
220 |
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
221 |
# Read the mailbox into the messages and children dictionaries |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
222 |
messages = {}
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
223 |
children = {}
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
224 |
for i in xrange(len(mbox)): |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
225 |
m = mbox[i] |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
226 |
messages[m['Message-Id']] = (i,m) |
|
13
e155f2129514
Fixed In-Reply-To bug (b7c)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
11
diff
changeset
|
227 |
children.setdefault(m['In-Reply-To'], []).append(m['Message-Id']) |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
228 |
children[None] = [] # Safeguard against infinte loop on empty Message-Id |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
229 |
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
230 |
# Iterate over children |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
231 |
id = msg['Message-Id'] |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
232 |
id_stack = (id in children and map(lambda x: (x, 1), reversed(children[id]))) or [] |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
233 |
if not id_stack: return |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
234 |
ui.write('Comments:\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
235 |
while id_stack: |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
236 |
id,offset = id_stack.pop() |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
237 |
id_stack += (id in children and map(lambda x: (x, offset+1), reversed(children[id]))) or [] |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
238 |
index, msg = messages[id] |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
239 |
ui.write(' '*offset + ('%d: ' % index) + msg['Subject'] + '\n')
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
240 |
ui.write('-'*70 + '\n')
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
241 |
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
242 |
def _pretty_list(lst): |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
243 |
s = '' |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
244 |
for i in lst: |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
245 |
s += i + ', ' |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
246 |
return s[:-2] |
|
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
247 |
|
|
8
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
248 |
def _random_id(): |
|
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
249 |
return "%x" % random.randint(2**63, 2**64-1) |
|
b1f268a9e4ed
Message-Ids in <...> + randomized comment ids
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
7
diff
changeset
|
250 |
|
| 0 | 251 |
|
252 |
cmdtable = {
|
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
253 |
'ilist': (ilist, |
|
5
cef66aa31468
ilist doesn't show fixed issues by default (instead of showing only new ones)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
4
diff
changeset
|
254 |
[('a', 'all', False,
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
255 |
'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
|
256 |
('p', 'property', [],
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
257 |
'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
|
258 |
('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'),
|
|
7
74cbd53bf7d8
Implemented basic filters functionality in ilist (fixing 8e4)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
6
diff
changeset
|
259 |
('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s*)' % (issues_dir, filter_prefix))],
|
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
260 |
_('hg ilist [OPTIONS]')),
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
261 |
'iadd': (iadd, |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
262 |
[], |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
263 |
_('hg iadd [ID] [COMMENT]')),
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
264 |
'ishow': (ishow, |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
265 |
[('a', 'all', None, 'list all comments')],
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
266 |
_('hg ishow [OPTIONS] ID [COMMENT]')),
|
|
6
11cab5930258
Function rename + pretty list
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
5
diff
changeset
|
267 |
'iupdate': (iupdate, |
|
2
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
268 |
[('p', 'property', [],
|
|
9e804a85c82c
list works well, basic show, add, and update functionality
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
1
diff
changeset
|
269 |
'update properties (e.g., -p state=fixed)'), |
|
4
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
270 |
('n', 'no-property-comment', None,
|
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
271 |
'do not add a comment about changed properties')], |
|
bf71e2069dbd
Basic functionality in place; added feature request for integration with commit (ef1)
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
2
diff
changeset
|
272 |
_('hg iupdate [OPTIONS] ID'))
|
| 0 | 273 |
} |