Mercurial > repos > other > linux
annotate prompt.py @ 140:f5dd593cc018
Only show "u=" for hg when we're in a VCS'd directory
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 18 Jan 2020 20:54:13 +0000 |
parents | c09729100dd2 |
children | 13435b80c672 |
rev | line source |
---|---|
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 '''get repository information for use in a shell prompt |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 Take a string, parse any special variables inside, and output the result. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 Useful mostly for putting information about the current repository into |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 a shell prompt. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 ''' |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 from __future__ import with_statement |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 import re |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 import os |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
15 import platform |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 import subprocess |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 from datetime import datetime, timedelta |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 from os import path |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 from mercurial import extensions, commands, cmdutil, help |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 from mercurial.i18n import _ |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 from mercurial.node import hex, short |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
23 # command registration moved into `registrar` module in v3.7. |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 cmdtable = {} |
135
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
25 try: |
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
26 from mercurial import registrar |
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
27 command = registrar.command(cmdtable) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
28 except ImportError: |
135
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
29 command = cmdutil.command(cmdtable) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 # `revrange' has been moved into module `scmutil' since v1.9. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 try : |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 from mercurial import scmutil |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 revrange = scmutil.revrange |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 except : |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 revrange = cmdutil.revrange |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
38 CACHE_PATH = b".hg/prompt/cache" |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
39 CACHE_TIMEOUT = timedelta(minutes=15) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
40 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
41 FILTER_ARG = re.compile(rb'\|.+\((.*)\)') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
43 def _cache_remote(repo, kind): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
44 cache = path.join(repo.root, CACHE_PATH, kind) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
45 c_tmp = cache + b'.temp' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
46 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
47 # This is kind of a hack and I feel a little bit dirty for doing it. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
48 IGNORE = open('NUL:','w') if platform.system() == 'Windows' else open('/dev/null','w') |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
49 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
50 subprocess.call(['hg', kind, '--quiet'], stdout=open(c_tmp, 'w'), stderr=IGNORE) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
51 os.rename(c_tmp, cache) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
52 return |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 def _with_groups(groups, out): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 out_groups = [groups[0]] + [groups[-1]] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 if any(out_groups) and not all(out_groups): |
135
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
58 print('Error parsing prompt string. Mismatched braces?') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
60 out = out.replace(b'%', b'%%') |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
61 return (b"%b" + out + b"%b") % (out_groups[0][:-1] if out_groups[0] else b'', |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
62 out_groups[1][1:] if out_groups[1] else b'') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 def _get_filter(name, g): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 '''Return the filter with the given name, or None if it was not used.''' |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
66 matching_filters = list(filter(lambda s: s and s.startswith(b'|%b' % name), g)) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 if not matching_filters: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 return None |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 # Later filters will override earlier ones, for now. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 f = matching_filters[-1] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 return f |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 def _get_filter_arg(f): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 if not f: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 return None |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 args = FILTER_ARG.match(f).groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 if args: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 return args[0] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 else: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 return None |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 |
135
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
85 @command(b'prompt', |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
86 [(b'', b'angle-brackets', None, b'use angle brackets (<>) for keywords'), |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
87 (b'', b'cache-incoming', None, b'used internally by hg-prompt'), |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
88 (b'', b'cache-outgoing', None, b'used internally by hg-prompt')], |
135
298fa524406a
Update to latest HG Prompt and make it Python 3 compliant
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
89 b'hg prompt STRING') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 def prompt(ui, repo, fs='', **opts): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 '''get repository information for use in a shell prompt |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 Take a string and output it for use in a shell prompt. You can use |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 keywords in curly braces:: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 $ hg prompt "currently on {branch}" |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 currently on default |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 You can also use an extended form of any keyword:: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 {optional text here{keyword}more optional text} |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 This will expand the inner {keyword} and output it along with the extra |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 text only if the {keyword} expands successfully. This is useful if you |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 have a keyword that may not always apply to the current state and you |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 have some text that you would like to see only if it is appropriate:: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
107 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 $ hg prompt "currently at {bookmark}" |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 currently at |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 $ hg prompt "{currently at {bookmark}}" |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
111 $ hg bookmark my-bookmark |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 $ hg prompt "{currently at {bookmark}}" |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 currently at my-bookmark |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 See 'hg help prompt-keywords' for a list of available keywords. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 ''' |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 def _basename(m): |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
119 return _with_groups(m.groups(), path.basename(repo.root)) if repo.root else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 def _bookmark(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 try: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
123 book = extensions.find(b'bookmarks').current(repo) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 except AttributeError: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 book = getattr(repo, '_bookmarkcurrent', None) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 except KeyError: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 book = getattr(repo, '_bookmarkcurrent', None) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 if book is None: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 book = getattr(repo, '_activebookmark', None) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 if book: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 cur = repo['.'].node() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 if repo._bookmarks[book] == cur: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 return _with_groups(m.groups(), book) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 else: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
135 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 def _branch(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 branch = repo.dirstate.branch() |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
141 quiet = _get_filter(b'quiet', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
143 out = branch if (not quiet) or (branch != b'default') else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
145 return _with_groups(g, out) if out else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
146 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 def _closed(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
150 quiet = _get_filter(b'quiet', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
151 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
152 p = repo[None].parents()[0] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
153 pn = p.node() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
154 branch = repo.dirstate.branch() |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
155 closed = (p.extra().get(b'close') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
156 and pn in repo.branchheads(branch, closed=True)) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
157 out = b'X' if (not quiet) and closed else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
159 return _with_groups(g, out) if out else b'b' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
160 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 def _count(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 g = m.groups() |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
163 query = [g[1][1:]] if g[1] else [b'all()'] |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 return _with_groups(g, str(len(revrange(repo, query)))) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 def _node(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 parents = repo[None].parents() |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
170 p = 0 if b'|merge' not in g else 1 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 p = p if len(parents) > p else None |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
173 format = short if b'|short' in g else hex |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 node = format(parents[p].node()) if p is not None else None |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
176 return _with_groups(g, str(node)) if node else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 def _patch(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 try: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
182 extensions.find(b'mq') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 except KeyError: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
184 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 q = repo.mq |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
188 if _get_filter(b'quiet', g) and not len(q.series): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
189 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
191 if _get_filter(b'topindex', g): |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 if len(q.applied): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 out = str(len(q.applied) - 1) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 else: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
195 out = b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
196 elif _get_filter(b'applied', g): |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 out = str(len(q.applied)) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
198 elif _get_filter(b'unapplied', g): |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 out = str(len(q.unapplied(repo))) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
200 elif _get_filter(b'count', g): |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 out = str(len(q.series)) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 else: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
203 out = q.applied[-1].name if q.applied else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
205 return _with_groups(g, out) if out else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 def _patches(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 try: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
211 extensions.find(b'mq') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
212 except KeyError: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
213 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
214 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
215 join_filter = _get_filter(b'join', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 join_filter_arg = _get_filter_arg(join_filter) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
217 sep = join_filter_arg if join_filter else b' -> ' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
219 patches = repo.mq.series |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
220 applied = [p.name for p in repo.mq.applied] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 unapplied = filter(lambda p: p not in applied, patches) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
223 if _get_filter(b'hide_applied', g): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
224 patches = list(filter(lambda p: p not in applied, patches)) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
225 if _get_filter(b'hide_unapplied', g): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
226 patches = list(filter(lambda p: p not in unapplied, patches)) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
228 if _get_filter(b'reverse', g): |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
229 patches = reversed(patches) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
231 pre_applied_filter = _get_filter(b'pre_applied', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
232 pre_applied_filter_arg = _get_filter_arg(pre_applied_filter) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
233 post_applied_filter = _get_filter(b'post_applied', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 post_applied_filter_arg = _get_filter_arg(post_applied_filter) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
235 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
236 pre_unapplied_filter = _get_filter(b'pre_unapplied', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
237 pre_unapplied_filter_arg = _get_filter_arg(pre_unapplied_filter) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
238 post_unapplied_filter = _get_filter(b'post_unapplied', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 post_unapplied_filter_arg = _get_filter_arg(post_unapplied_filter) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 for n, patch in enumerate(patches): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 if patch in applied: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 if pre_applied_filter: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 patches[n] = pre_applied_filter_arg + patches[n] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 if post_applied_filter: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
246 patches[n] = patches[n] + post_applied_filter_arg |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 elif patch in unapplied: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 if pre_unapplied_filter: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 patches[n] = pre_unapplied_filter_arg + patches[n] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 if post_unapplied_filter: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 patches[n] = patches[n] + post_unapplied_filter_arg |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
252 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
253 return _with_groups(g, sep.join(patches)) if patches else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
254 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
255 def _queue(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
257 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 try: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
259 extensions.find(b'mq') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
260 except KeyError: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
261 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
262 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 q = repo.mq |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 out = os.path.basename(q.path) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
266 if out == b'patches' and not os.path.isdir(q.path): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
267 out = b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
268 elif out.startswith(b'patches-'): |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 out = out[8:] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
270 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
271 return _with_groups(g, out) if out else b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
272 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
273 def _remote(kind): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
274 def _r(m): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
275 g = m.groups() |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
276 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
277 cache_dir = path.join(repo.root, CACHE_PATH) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
278 cache = path.join(cache_dir, kind) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
279 if not path.isdir(cache_dir): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
280 os.makedirs(cache_dir) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
281 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
282 cache_exists = path.isfile(cache) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
283 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
284 cache_time = (datetime.fromtimestamp(os.stat(cache).st_mtime) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
285 if cache_exists else None) |
139
c09729100dd2
Update outgoing cache when we commit
IBBoard <dev@ibboard.co.uk>
parents:
137
diff
changeset
|
286 if not cache_exists or cache_time < datetime.now() - CACHE_TIMEOUT \ |
c09729100dd2
Update outgoing cache when we commit
IBBoard <dev@ibboard.co.uk>
parents:
137
diff
changeset
|
287 or (kind == b'outgoing' and cache_time < datetime.fromtimestamp(os.stat('.hg/last-message.txt').st_mtime)): |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
288 if not cache_exists: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
289 open(cache, 'w').close() |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
290 subprocess.Popen(['hg', 'prompt', '--cache-%s' % kind.decode('ascii')]) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
291 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
292 if cache_exists: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
293 with open(cache) as c: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
294 count = len(c.readlines()) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
295 if g[1]: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
296 return _with_groups(g, str(count).encode()) if count else b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
297 else: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
298 return _with_groups(g, b'') if count else b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
299 else: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
300 return b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
301 return _r |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
302 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
303 def _rev(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
304 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
305 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
306 parents = repo[None].parents() |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
307 parent = 0 if b'|merge' not in g else 1 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
308 parent = parent if len(parents) > parent else None |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
309 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
310 rev = parents[parent].rev() if parent is not None else -1 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
311 return _with_groups(g, str(rev)) if rev >= 0 else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
312 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
313 def _root(m): |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
314 return _with_groups(m.groups(), repo.root) if repo.root else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
315 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
316 def _status(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
317 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
318 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
319 st = repo.status(unknown=True)[:5] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
320 modified = any(st[:4]) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
321 unknown = len(st[-1]) > 0 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
322 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
323 flag = b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
324 if b'|modified' not in g and b'|unknown' not in g: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
325 flag = b'!' if modified else b'?' if unknown else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
326 else: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
327 if b'|modified' in g: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
328 flag += b'!' if modified else b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
329 if b'|unknown' in g: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
330 flag += b'?' if unknown else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
331 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
332 return _with_groups(g, flag) if flag else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
333 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
334 def _tags(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
335 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
336 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
337 sep = g[2][1:] if g[2] else b' ' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
338 tags = repo[None].tags() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
339 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
340 quiet = _get_filter(b'quiet', g) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
341 if quiet: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
342 tags = list(filter(lambda tag: tag != b'tip', tags)) |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
343 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
344 return _with_groups(g, sep.join(tags)) if tags else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
345 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
346 def _task(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
347 try: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
348 task = extensions.find(b'tasks').current(repo) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
349 return _with_groups(m.groups(), task) if task else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
350 except KeyError: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
351 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
352 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
353 def _tip(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
354 g = m.groups() |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
355 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
356 format = short if b'|short' in g else hex |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
357 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
358 tip = repo[len(repo) - 1] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
359 rev = tip.rev() |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
360 tip = format(tip.node()) if b'|node' in g else tip.rev() |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
361 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
362 return _with_groups(g, str(tip)) if rev >= 0 else b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
363 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
364 def _update(m): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
365 current_rev = repo[None].parents()[0] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
366 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
367 # Get the tip of the branch for the current branch |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
368 try: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
369 heads = repo.branchmap()[current_rev.branch()] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
370 tip = heads[-1] |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
371 except (KeyError, IndexError): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
372 # We are in an empty repository. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
373 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
374 return b'' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
375 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
376 for head in reversed(heads): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
377 if not repo[head].closesbranch(): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
378 tip = head |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
379 break |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
380 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
381 return _with_groups(m.groups(), b'^') if current_rev != repo[tip] else b'' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
382 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
383 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
384 if opts.get("angle_brackets"): |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
385 tag_start = rb'\<([^><]*?\<)?' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
386 tag_end = rb'(\>[^><]*?)?>' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
387 brackets = b'<>' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
388 else: |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
389 tag_start = rb'\{([^{}]*?\{)?' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
390 tag_end = rb'(\}[^{}]*?)?\}' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
391 brackets = b'{}' |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
392 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
393 patterns = { |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
394 b'bookmark': _bookmark, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
395 b'branch(\|quiet)?': _branch, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
396 b'closed(\|quiet)?': _closed, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
397 b'count(\|[^%b]*?)?' % brackets[-1:]: _count, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
398 b'node(?:' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
399 b'(\|short)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
400 b'|(\|merge)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
401 b')*': _node, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
402 b'patch(?:' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
403 b'(\|topindex)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
404 b'|(\|applied)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
405 b'|(\|unapplied)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
406 b'|(\|count)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
407 b'|(\|quiet)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
408 b')*': _patch, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
409 b'patches(?:' + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
410 b'(\|join\([^%b]*?\))' % brackets[-1:] + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
411 b'|(\|reverse)' + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
412 b'|(\|hide_applied)' + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
413 b'|(\|hide_unapplied)' + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
414 b'|(\|pre_applied\([^%b]*?\))' % brackets[-1:] + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
415 b'|(\|post_applied\([^%b]*?\))' % brackets[-1:] + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
416 b'|(\|pre_unapplied\([^%b]*?\))' % brackets[-1:] + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
417 b'|(\|post_unapplied\([^%b]*?\))' % brackets[-1:] + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
418 b')*': _patches, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
419 b'queue': _queue, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
420 b'rev(\|merge)?': _rev, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
421 b'root': _root, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
422 b'root\|basename': _basename, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
423 b'status(?:' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
424 b'(\|modified)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
425 b'|(\|unknown)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
426 b')*': _status, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
427 b'tags(?:' + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
428 b'(\|quiet)' + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
429 b'|(\|[^%b]*?)' % brackets[-1:] + |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
430 b')*': _tags, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
431 b'task': _task, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
432 b'tip(?:' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
433 b'(\|node)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
434 b'|(\|short)' |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
435 b')*': _tip, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
436 b'update': _update, |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
437 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
438 b'incoming(\|count)?': _remote(b'incoming'), |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
439 b'outgoing(\|count)?': _remote(b'outgoing'), |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
440 } |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
441 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
442 if opts.get("cache_incoming"): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
443 _cache_remote(repo, b'incoming') |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
444 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
445 if opts.get("cache_outgoing"): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
446 _cache_remote(repo, b'outgoing') |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
447 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
448 for tag, repl in patterns.items(): |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
449 fs = re.sub(tag_start + tag + tag_end, repl, fs) |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
450 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
451 ui.status(fs) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
452 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
453 def _pull_with_cache(orig, ui, repo, *args, **opts): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
454 """Wrap the pull command to delete the incoming cache as well.""" |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
455 res = orig(ui, repo, *args, **opts) |
137
f71524147eb4
Fix some more binary vs str handling that I missed
IBBoard <dev@ibboard.co.uk>
parents:
136
diff
changeset
|
456 cache = path.join(repo.root, CACHE_PATH, b'incoming') |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
457 if path.isfile(cache): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
458 os.remove(cache) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
459 return res |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
460 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
461 def _push_with_cache(orig, ui, repo, *args, **opts): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
462 """Wrap the push command to delete the outgoing cache as well.""" |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
463 res = orig(ui, repo, *args, **opts) |
137
f71524147eb4
Fix some more binary vs str handling that I missed
IBBoard <dev@ibboard.co.uk>
parents:
136
diff
changeset
|
464 cache = path.join(repo.root, CACHE_PATH, b'outgoing') |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
465 if path.isfile(cache): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
466 os.remove(cache) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
467 return res |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
468 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
469 def uisetup(ui): |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
470 extensions.wrapcommand(commands.table, b'pull', _pull_with_cache) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
471 extensions.wrapcommand(commands.table, b'push', _push_with_cache) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
472 try: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
473 extensions.wrapcommand(extensions.find(b"fetch").cmdtable, b'fetch', _pull_with_cache) |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
474 except KeyError: |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
475 pass |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
476 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
477 help.helptable += ( |
137
f71524147eb4
Fix some more binary vs str handling that I missed
IBBoard <dev@ibboard.co.uk>
parents:
136
diff
changeset
|
478 ([b'prompt-keywords'], _(b'Keywords supported by hg-prompt'), |
f71524147eb4
Fix some more binary vs str handling that I missed
IBBoard <dev@ibboard.co.uk>
parents:
136
diff
changeset
|
479 lambda _: rb'''hg-prompt currently supports a number of keywords. |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
480 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
481 Some keywords support filters. Filters can be chained when it makes |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
482 sense to do so. When in doubt, try it! |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
483 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
484 bookmark |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
485 Display the current bookmark (requires the bookmarks extension). |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
486 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
487 branch |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
488 Display the current branch. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
489 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
490 |quiet |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
491 Display the current branch only if it is not the default branch. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
492 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
493 closed |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
494 Display `X` if working on a closed branch (i.e. committing now would reopen |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
495 the branch). |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
496 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
497 count |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
498 Display the number of revisions in the given revset (the revset `all()` |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
499 will be used if none is given). |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
500 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
501 See `hg help revsets` for more information. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
502 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
503 |REVSET |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
504 The revset to count. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
505 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
506 incoming |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
507 Display nothing, but if the default path contains incoming changesets the |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
508 extra text will be expanded. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
509 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
510 For example: `{incoming changes{incoming}}` will expand to |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
511 `incoming changes` if there are changes, otherwise nothing. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
512 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
513 Checking for incoming changesets is an expensive operation, so `hg-prompt` |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
514 will cache the results in `.hg/prompt/cache/` and refresh them every 15 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
515 minutes. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
516 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
517 |count |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
518 Display the number of incoming changesets (if greater than 0). |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
519 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
520 node |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
521 Display the (full) changeset hash of the current parent. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
522 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
523 |short |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
524 Display the hash as the short, 12-character form. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
525 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
526 |merge |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
527 Display the hash of the changeset you're merging with. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
528 |
136
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
529 outgoing |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
530 Display nothing, but if the current repository contains outgoing |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
531 changesets (to default) the extra text will be expanded. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
532 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
533 For example: `{outgoing changes{outgoing}}` will expand to |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
534 `outgoing changes` if there are changes, otherwise nothing. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
535 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
536 Checking for outgoing changesets is an expensive operation, so `hg-prompt` |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
537 will cache the results in `.hg/prompt/cache/` and refresh them every 15 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
538 minutes. |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
539 |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
540 |count |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
541 Display the number of outgoing changesets (if greater than 0). |
fcd34011b0f0
Fix hg prompt functionality for Python 3.8
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
542 |
64
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
543 patch |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
544 Display the topmost currently-applied patch (requires the mq |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
545 extension). |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
546 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
547 |count |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
548 Display the number of patches in the queue. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
549 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
550 |topindex |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
551 Display (zero-based) index of the topmost applied patch in the series |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
552 list (as displayed by :hg:`qtop -v`), or the empty string if no patch |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
553 is applied. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
554 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
555 |applied |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
556 Display the number of currently applied patches in the queue. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
557 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
558 |unapplied |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
559 Display the number of currently unapplied patches in the queue. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
560 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
561 |quiet |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
562 Display a number only if there are any patches in the queue. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
563 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
564 patches |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
565 Display a list of the current patches in the queue. It will look like |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
566 this: |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
567 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
568 :::console |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
569 $ hg prompt '{patches}' |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
570 bottom-patch -> middle-patch -> top-patch |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
571 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
572 |reverse |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
573 Display the patches in reverse order (i.e. topmost first). |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
574 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
575 |hide_applied |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
576 Do not display applied patches. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
577 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
578 |hide_unapplied |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
579 Do not display unapplied patches. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
580 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
581 |join(SEP) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
582 Display SEP between each patch, instead of the default ` -> `. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
583 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
584 |pre_applied(STRING) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
585 Display STRING immediately before each applied patch. Useful for |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
586 adding color codes. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
587 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
588 |post_applied(STRING) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
589 Display STRING immediately after each applied patch. Useful for |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
590 resetting color codes. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
591 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
592 |pre_unapplied(STRING) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
593 Display STRING immediately before each unapplied patch. Useful for |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
594 adding color codes. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
595 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
596 |post_unapplied(STRING) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
597 Display STRING immediately after each unapplied patch. Useful for |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
598 resetting color codes. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
599 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
600 queue |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
601 Display the name of the current MQ queue. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
602 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
603 rev |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
604 Display the repository-local changeset number of the current parent. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
605 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
606 |merge |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
607 Display the repository-local changeset number of the changeset you're |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
608 merging with. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
609 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
610 root |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
611 Display the full path to the root of the current repository, without a |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
612 trailing slash. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
613 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
614 |basename |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
615 Display the directory name of the root of the current repository. For |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
616 example, if the repository is in `/home/u/myrepo` then this keyword |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
617 would expand to `myrepo`. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
618 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
619 status |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
620 Display `!` if the repository has any changed/added/removed files, |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
621 otherwise `?` if it has any untracked (but not ignored) files, otherwise |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
622 nothing. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
623 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
624 |modified |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
625 Display `!` if the current repository contains files that have been |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
626 modified, added, removed, or deleted, otherwise nothing. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
627 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
628 |unknown |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
629 Display `?` if the current repository contains untracked files, |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
630 otherwise nothing. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
631 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
632 tags |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
633 Display the tags of the current parent, separated by a space. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
634 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
635 |quiet |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
636 Display the tags of the current parent, excluding the tag "tip". |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
637 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
638 |SEP |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
639 Display the tags of the current parent, separated by `SEP`. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
640 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
641 task |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
642 Display the current task (requires the tasks extension). |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
643 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
644 tip |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
645 Display the repository-local changeset number of the current tip. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
646 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
647 |node |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
648 Display the (full) changeset hash of the current tip. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
649 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
650 |short |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
651 Display a short form of the changeset hash of the current tip (must be |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
652 used with the **|node** filter) |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
653 |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
654 update |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
655 Display `^` if the current parent is not the tip of the current branch, |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
656 otherwise nothing. In effect, this lets you see if running `hg update` |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
657 would do something. |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
658 '''), |
39b07c5f8785
Add Git and Mercurial support to command prompt
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
659 ) |