Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 51762:ca7bde5dbafb
black: format the codebase with 23.3.0
The CI has moved to 23.3.0, which is the last version that supports 3.7
at runtime, so we should honor this change.
# skip-blame mass-reformating only
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 18 Jul 2024 12:36:12 +0200 |
parents | b0a4de6c14f8 |
children | ed28085827ec |
comparison
equal
deleted
inserted
replaced
51761:b0a4de6c14f8 | 51762:ca7bde5dbafb |
---|---|
1326 self[k] = v | 1326 self[k] = v |
1327 for k in f: | 1327 for k in f: |
1328 self[k] = f[k] | 1328 self[k] = f[k] |
1329 | 1329 |
1330 def insert(self, position, key, value): | 1330 def insert(self, position, key, value): |
1331 for (i, (k, v)) in enumerate(list(self.items())): | 1331 for i, (k, v) in enumerate(list(self.items())): |
1332 if i == position: | 1332 if i == position: |
1333 self[key] = value | 1333 self[key] = value |
1334 if i >= position: | 1334 if i >= position: |
1335 del self[k] | 1335 del self[k] |
1336 self[k] = v | 1336 self[k] = v |
2722 def __init__(self, in_iter): | 2722 def __init__(self, in_iter): |
2723 """in_iter is the iterator that's iterating over the input chunks.""" | 2723 """in_iter is the iterator that's iterating over the input chunks.""" |
2724 | 2724 |
2725 def splitbig(chunks): | 2725 def splitbig(chunks): |
2726 for chunk in chunks: | 2726 for chunk in chunks: |
2727 if len(chunk) > 2 ** 20: | 2727 if len(chunk) > 2**20: |
2728 pos = 0 | 2728 pos = 0 |
2729 while pos < len(chunk): | 2729 while pos < len(chunk): |
2730 end = pos + 2 ** 18 | 2730 end = pos + 2**18 |
2731 yield chunk[pos:end] | 2731 yield chunk[pos:end] |
2732 pos = end | 2732 pos = end |
2733 else: | 2733 else: |
2734 yield chunk | 2734 yield chunk |
2735 | 2735 |
2749 buf = [] | 2749 buf = [] |
2750 queue = self._queue | 2750 queue = self._queue |
2751 while left > 0: | 2751 while left > 0: |
2752 # refill the queue | 2752 # refill the queue |
2753 if not queue: | 2753 if not queue: |
2754 target = 2 ** 18 | 2754 target = 2**18 |
2755 for chunk in self.iter: | 2755 for chunk in self.iter: |
2756 queue.append(chunk) | 2756 queue.append(chunk) |
2757 target -= len(chunk) | 2757 target -= len(chunk) |
2758 if target <= 0: | 2758 if target <= 0: |
2759 break | 2759 break |
3079 | 3079 |
3080 return wrapper | 3080 return wrapper |
3081 | 3081 |
3082 | 3082 |
3083 _sizeunits = ( | 3083 _sizeunits = ( |
3084 (b'm', 2 ** 20), | 3084 (b'm', 2**20), |
3085 (b'k', 2 ** 10), | 3085 (b'k', 2**10), |
3086 (b'g', 2 ** 30), | 3086 (b'g', 2**30), |
3087 (b'kb', 2 ** 10), | 3087 (b'kb', 2**10), |
3088 (b'mb', 2 ** 20), | 3088 (b'mb', 2**20), |
3089 (b'gb', 2 ** 30), | 3089 (b'gb', 2**30), |
3090 (b'b', 1), | 3090 (b'b', 1), |
3091 ) | 3091 ) |
3092 | 3092 |
3093 | 3093 |
3094 def sizetoint(s: bytes) -> int: | 3094 def sizetoint(s: bytes) -> int: |