Mercurial > hg
annotate mercurial/strutil.py @ 28113:d2e0d57824c2
verify: include "manifest" prefix in a few more places
We include the "manifest" prefix on most other errors, so it seems
consistent to add them to the remaining messages too. Also, having the
"manifest" prefix will be more consistent with having the directory
prefix there when we add support for treemanifests. With the
"manifest" at the beginning, let's remove the now-redundant
"manifest" in the message itself.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 02 Feb 2016 10:42:28 -0800 |
parents | b723f05ec49b |
children |
rev | line source |
---|---|
2953 | 1 # strutil.py - string utilities for Mercurial |
2 # | |
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> | |
4 # | |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8155
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
2953 | 7 |
25979
b723f05ec49b
strutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
10263
diff
changeset
|
8 from __future__ import absolute_import |
b723f05ec49b
strutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
10263
diff
changeset
|
9 |
2953 | 10 def findall(haystack, needle, start=0, end=None): |
11 if end is None: | |
12 end = len(haystack) | |
13 if end < 0: | |
14 end += len(haystack) | |
15 if start < 0: | |
16 start += len(haystack) | |
17 while start < end: | |
18 c = haystack.find(needle, start, end) | |
19 if c == -1: | |
20 break | |
21 yield c | |
22 start = c + 1 | |
23 | |
24 def rfindall(haystack, needle, start=0, end=None): | |
25 if end is None: | |
26 end = len(haystack) | |
27 if end < 0: | |
28 end += len(haystack) | |
29 if start < 0: | |
30 start += len(haystack) | |
31 while end >= 0: | |
32 c = haystack.rfind(needle, start, end) | |
33 if c == -1: | |
34 break | |
35 yield c | |
36 end = c - 1 |