[Request] [+ ] D8585: scmutil: speed up relativization of paths when it's a no-op
valentin.gatienbaron (Valentin Gatien-Baron)
phabricator at mercurial-scm.org
Tue May 26 11:19:24 UTC 2020
valentin.gatienbaron created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Running commands from the root is commmon, in particular for
automation. Running `hg files > /tmp/a` from the root of
mozilla-central on linux:
before:
real 0m1,510s
user 0m1,387s
sys 0m0,090s
after:
real 0m1,266s
user 0m1,165s
sys 0m0,073s
(there are 280k paths, so this was costing ~1us per path somehow)
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8585
AFFECTED FILES
mercurial/scmutil.py
CHANGE DETAILS
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -803,9 +803,12 @@
if relative:
cwd = repo.getcwd()
- pathto = repo.pathto
- return lambda f: pathto(f, cwd)
- elif repo.ui.configbool(b'ui', b'slash'):
+ if cwd != b'':
+ # this branch is correct when cwd == b'', ie cwd = repo root,
+ # but it's slower
+ pathto = repo.pathto
+ return lambda f: pathto(f, cwd)
+ if repo.ui.configbool(b'ui', b'slash'):
return lambda f: f
else:
return util.localpath
To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200526/66a23dfc/attachment.html>
More information about the Mercurial-patches
mailing list