Jun Wu <quark@fb.com> [Tue, 05 Sep 2017 15:18:45 -0700] rev 34088
wrapcommand: use functools.partial
Like the previous patch, this helps remove noises in traceback.
Practically, this removes another 6 lines in `rebase -s . -d .` traceback in
my setup:
....
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
-File "hg/mercurial/extensions.py", line 331, in closure
- return func(*(args + a), **kw)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
File "fb-hgext/hgext3rd/fbhistedit.py", line 283, in _rebase
return orig(ui, repo, **opts)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
-File "hg/mercurial/extensions.py", line 331, in closure
- return func(*(args + a), **kw)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
File "remotenames.py", line 633, in exrebasecmd
ret = orig(ui, repo, **opts)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
-File "hg/mercurial/extensions.py", line 331, in closure
- return func(*(args + a), **kw)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
File "fb-hgext/hgext3rd/fbamend/__init__.py", line 453, in wraprebase
return orig(ui, repo, **opts)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
....
Differential Revision: https://phab.mercurial-scm.org/D633
Jun Wu <quark@fb.com> [Tue, 05 Sep 2017 13:37:36 -0700] rev 34087
wrapfunction: use functools.partial if possible
Every `extensions.bind` call inserts a frame in traceback:
... in closure
return func(*(args + a), **kw)
which makes traceback noisy.
The Python stdlib has a `functools.partial` which is backed by C code and
does not pollute traceback. However it does not support instancemethod and
sets `args` attribute which could be problematic for alias handling.
This patch makes `wrapfunction` use `functools.partial` if we are wrapping a
function directly exported by a module (so it's impossible to be a class or
instance method), and special handles `wrapfunction` results so alias
handling code could handle `args` just fine.
As an example, `hg rebase -s . -d . --traceback` got 6 lines removed in my
setup:
File "hg/mercurial/dispatch.py", line 898, in _dispatch
cmdpats, cmdoptions)
-File "hg/mercurial/extensions.py", line 333, in closure
- return func(*(args + a), **kw)
File "hg/hgext/journal.py", line 84, in runcommand
return orig(lui, repo, cmd, fullargs, *args)
-File "hg/mercurial/extensions.py", line 333, in closure
- return func(*(args + a), **kw)
File "fb-hgext/hgext3rd/fbamend/hiddenoverride.py", line 119, in runcommand
result = orig(lui, repo, cmd, fullargs, *args)
File "hg/mercurial/dispatch.py", line 660, in runcommand
ret = _runcommand(ui, options, cmd, d)
-File "hg/mercurial/extensions.py", line 333, in closure
- return func(*(args + a), **kw)
File "hg/hgext/pager.py", line 69, in pagecmd
return orig(ui, options, cmd, cmdfunc)
....
Differential Revision: https://phab.mercurial-scm.org/D632
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 12:34:36 -0700] rev 34086
cmdutil: remove redundant commitfunc parameter in amend (API)
Since the redundant commit during the amend has been been removed, there is no
need for commit callback function in amend now. Therefore, this commit removes
the unused parameter "commmitfunc" which was being used for this purpose.
Test Plan:
Ensured that all the tests pass
Differential Revision: https://phab.mercurial-scm.org/D635
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 12:34:36 -0700] rev 34085
cmdutil: remove the redundant commit during amend
There was an extra commit made during the amend operation to track the
changes to the working copy. However, this logic was written a long time back
and newer API's make this extra commit redundant. Therefore, I am removing the
extra commit. After this change, I noticed that
- Execution time of the cmdutil.amend improved by over 40%.
- Execution time of "hg commit --amend" improved by over 20%.
Test Plan:
I ensured that the all the hg tests passed after the change. I had
to fix a few tests which were aware of the extra commit made during the amend.
Differential Revision: https://phab.mercurial-scm.org/D636
Jun Wu <quark@fb.com> [Wed, 06 Sep 2017 12:56:19 -0700] rev 34084
checknlink: rename file object from 'fd' to 'fp'
Make it clear that `fp` (`file` object) is different from `fd` (low-level
file descriptor number).
Differential Revision: https://phab.mercurial-scm.org/D642
Martin von Zweigbergk <martinvonz@google.com> [Tue, 05 Sep 2017 15:06:45 -0700] rev 34083
cleanup: rename "matchfn" to "match" where obviously a matcher
We usually call matchers either "match" or "m" and reserve "matchfn"
for functions.
Differential Revision: https://phab.mercurial-scm.org/D641
Martin von Zweigbergk <martinvonz@google.com> [Wed, 06 Sep 2017 08:22:54 -0700] rev 34082
check-code: fix incorrect capitalization in camelcase regex
This was found internally at Google as part of a monorepo-wide
cleanup.
Differential Revision: https://phab.mercurial-scm.org/D637
Martin von Zweigbergk <martinvonz@google.com> [Wed, 06 Sep 2017 10:41:13 -0700] rev 34081
amend: use context manager for config override
Differential Revision: https://phab.mercurial-scm.org/D639