|
6 | 6 | from datetime import date |
7 | 7 |
|
8 | 8 | from mercurial import ( |
9 | | - cmdutil, |
10 | | - commands, |
11 | 9 | mdiff, |
12 | 10 | patch, |
13 | 11 | ) |
|
75 | 73 |
|
76 | 74 |
|
77 | 75 | def get_mercurial_default_options_dict(command): |
78 | | - """Borrowed from repoman - get default parameters for a mercurial command.""" |
79 | | - possible = cmdutil.findpossible(command, commands.table) |
80 | | - # Mercurial >= 3.4 returns a tuple whose first element is the old return dict |
81 | | - if type(possible) is tuple: |
82 | | - possible = possible[0] |
83 | | - if len(possible) != 1: |
84 | | - raise Exception(f'unable to find mercurial command "{command}"') |
85 | | - return {r[1].replace(b"-", b"_"): r[2] for r in next(iter(possible.values()))[1][1]} |
| 76 | + """Get default parameters for a mercurial command.""" |
| 77 | + # Use mdiff.diffopts defaults directly instead of introspecting command table |
| 78 | + # (the old cmdutil.findpossible API was removed in Mercurial 7.2) |
| 79 | + if command == b"diff": |
| 80 | + # Convert byte keys to strings but preserve value types (int, bool) |
| 81 | + # as mdiff.diffopts expects properly typed values |
| 82 | + return {(k.decode("utf-8") if isinstance(k, bytes) else k): v for k, v in mdiff.diffopts.defaults.items()} |
| 83 | + raise Exception(f'unable to find mercurial command "{command}"') |
86 | 84 |
|
87 | 85 |
|
88 | 86 | class RepositoryController(BaseUIController, ratings_util.ItemRatings): |
@@ -2366,10 +2364,8 @@ def view_changeset(self, trans, id, ctx_str, **kwd): |
2366 | 2364 | else: |
2367 | 2365 | ctx_child = None |
2368 | 2366 | diffs = [] |
| 2367 | + # Get default diff options with string keys and properly typed values |
2369 | 2368 | options_dict = get_mercurial_default_options_dict(b"diff") |
2370 | | - # Not quite sure if the following settings make any difference, but with a combination of them and the size check on each |
2371 | | - # diff, we don't run out of memory when viewing the changelog of the cisortho2 repository on the test tool shed. |
2372 | | - options_dict = {util.unicodify(k): util.unicodify(v) for k, v in options_dict.items()} |
2373 | 2369 | options_dict["maxfile"] = basic_util.MAXDIFFSIZE |
2374 | 2370 | options_dict["maxtotal"] = basic_util.MAXDIFFSIZE |
2375 | 2371 | diffopts = mdiff.diffopts(**options_dict) |
|
0 commit comments