46 def safehasattr(thing, attr): |
47 def safehasattr(thing, attr): |
47 return getattr(thing, attr, _undefined) is not _undefined |
48 return getattr(thing, attr, _undefined) is not _undefined |
48 setattr(util, 'safehasattr', safehasattr) |
49 setattr(util, 'safehasattr', safehasattr) |
49 |
50 |
50 formatteropts = commands.formatteropts |
51 formatteropts = commands.formatteropts |
51 revlogopts = commands.debugrevlogopts |
52 |
|
53 # for "historical portability": |
|
54 # use locally defined option list, if debugrevlogopts isn't available, |
|
55 # because commands.debugrevlogopts has been available since 3.7 (or |
|
56 # 5606f7d0d063), even though cmdutil.openrevlog() has been available |
|
57 # since 1.9 (or a79fea6b3e77). |
|
58 revlogopts = getattr(commands, "debugrevlogopts", [ |
|
59 ('c', 'changelog', False, ('open changelog')), |
|
60 ('m', 'manifest', False, ('open manifest')), |
|
61 ('', 'dir', False, ('open directory manifest')), |
|
62 ]) |
52 |
63 |
53 cmdtable = {} |
64 cmdtable = {} |
54 command = cmdutil.command(cmdtable) |
65 command = cmdutil.command(cmdtable) |
55 |
66 |
56 def getlen(ui): |
67 def getlen(ui): |
819 |
830 |
820 for fn, title in benches: |
831 for fn, title in benches: |
821 timer, fm = gettimer(ui, opts) |
832 timer, fm = gettimer(ui, opts) |
822 timer(fn, title=title) |
833 timer(fn, title=title) |
823 fm.end() |
834 fm.end() |
|
835 |
|
836 def uisetup(ui): |
|
837 if (util.safehasattr(cmdutil, 'openrevlog') and |
|
838 not util.safehasattr(commands, 'debugrevlogopts')): |
|
839 # for "historical portability": |
|
840 # In this case, Mercurial should be 1.9 (or a79fea6b3e77) - |
|
841 # 3.7 (or 5606f7d0d063). Therefore, '--dir' option for |
|
842 # openrevlog() should cause failure, because it has been |
|
843 # available since 3.5 (or 49c583ca48c4). |
|
844 def openrevlog(orig, repo, cmd, file_, opts): |
|
845 if opts.get('dir') and not util.safehasattr(repo, 'dirlog'): |
|
846 raise error.Abort("This version doesn't support --dir option", |
|
847 hint="use 3.5 or later") |
|
848 return orig(repo, cmd, file_, opts) |
|
849 extensions.wrapfunction(cmdutil, 'openrevlog', openrevlog) |