Skip to content
Snippets Groups Projects
  1. Feb 01, 2019
  2. Jan 08, 2019
    • Yuya Nishihara's avatar
      subrepo: reject potentially unsafe subrepo paths (BC) (SEC) · 83377b4b
      Yuya Nishihara authored
      In addition to the previous patch, this prohibits '~', '$nonexistent', etc.
      for any subrepo types. I think this is safer, and real-world subrepos wouldn't
      use such (local) paths.
    • Yuya Nishihara's avatar
      subrepo: prohibit variable expansion on creation of hg subrepo (SEC) · 6c10eba6
      Yuya Nishihara authored
      It's probably wrong to expand path at localrepo.*repository() layer, but
      fixing the layering issue would require careful inspection of call paths.
      So, this patch adds add a validation to the subrepo constructor.
      
      os.path.realpath(util.expandpath(root)) is what vfsmod.vfs() would do.
      6c10eba6
    • Yuya Nishihara's avatar
      subrepo: extend path auditing test to include more weird patterns (SEC) · 31286c92
      Yuya Nishihara authored
      While reviewing patches for the issue 5739, "$foo in repository path
      expanded", I realized that subrepo paths can also be cheated. This patch
      includes various subrepo paths which are potentially unsafe.
      
      Since an expanded subrepo path isn't audited, this bug allows symlink check
      bypass. As a result, a malicious subrepository could be checked out to a
      sub tree of e.g. $HOME directory. The good news is that the destination
      directory must be empty or nonexistent, so the existing ~/.bashrc wouldn't
      be overwritten. See the last part of the tests for details.
      31286c92
  3. Jan 31, 2019
  4. Jan 24, 2019
    • Boris Feld's avatar
      revlog: make sure we never use sparserevlog without general delta (issue6056) · 189e06b2
      Boris Feld authored
      We are getting user report where the delta code tries to use `sparse-revlog`
      logic on repository where `generaldelta` is disabled. This can't work so we
      ensure the two booleans have a consistent value.
      
      Creating this kind of repository is not expected to be possible the current bug
      report point at a clonebundle related bug that is still to be properly isolated
      (Yuya Nishihara seems to a have done it).
      
      Corrupting a repository to reproduce the issue is possible. A test using this
      method is included in this fix.
      189e06b2
  5. Jan 30, 2019
  6. Jan 23, 2019
  7. Jan 24, 2019
  8. Nov 28, 2018
    • Yuya Nishihara's avatar
      ui: optimize buffered write with no label · ff927ecb
      Yuya Nishihara authored
      This was spotted while making fastannotate faster again after ditching its
      own formatter. Since I'm going to inline _write() into ui.write(), I decided
      to include this patch in this series.
      
      Here, the cost of '(self.label(a, label) for a in args)' was significant
      in hot loops.
      ff927ecb
  9. Jan 23, 2019
    • Boris Feld's avatar
      partialdiscovery: avoid `undecided` related computation sooner than necessary · 76873548
      Boris Feld authored
      Changeset 1d30be90c9dc move the update of the `undecided` set within the
      `partialdiscovery` object in order to clarify the API.
      
      The update to the `undecided` set was unconditional in 1d30be90c9dc and the first
      access to the `self.undecided` property triggered the initial computation of
      the set of undecided revisions. As a result, the set was computed much
      earlier, at a time where less information is available, immediately followed
      by an update of this set to remove common revisions.
      
      To fix this regression, we ignore the `undecided` related logic in
      `addcommons` when that `undecided` set has not been computed yet. Code that
      actually needs to know the `undecided` set will trigger its computation later.
      The change has no effects on semantic because the initial computation
      `undecided` set takes all knowns `common` into account.
      
      Example performance running `hg debugdiscovery` from a pypy repo missing 10
      changesets:
      
      870a89c6909d: 52.3ms (regression parent)
      1d30be90c9dc: 72.0ms (regression)
      5a5f504a7175: 64.8ms (this fix parent)
      this fix:     52.6ms
      76873548
  10. Jan 21, 2019
    • Yuya Nishihara's avatar
      revlog: fix resolution of revlog version 0 · c953c2a9
      Yuya Nishihara authored
      This partially backs out cecf3f8bccd3, "revlog: always process opener options."
      
      My understanding is that if there's no "revlog1" nor "revlog2" in .hg/requires,
      the repository should stick to the v0 format. The reasoning is briefly
      described in 31a5973fcf96, "revlog: get rid of defversion."
      
      Maybe we can drop support for missing opener options, but I didn't do that
      in this patch.
      c953c2a9
  11. Jan 20, 2019
  12. Jan 19, 2019
    • Martin von Zweigbergk's avatar
      narrow: fix crash when restoring backup in legacy repo · 88a7c211
      Martin von Zweigbergk authored
      Using --addremove when committing in an old repo (before we started
      keeping .hg/narrowspec.dirstate) results in a crash. The test
      case modified in this patch would crash like this:
      
        abort: $ENOENT$
      
      The issue is that when the dirstateguard is aborted, it tries to
      restore the backup of .hg/narrowspec.dirstate. However, since we were
      in an old repo, that file did not get created when the dirstateguard
      was created. Note that the dirstateguard is not used unless
      --addremove is passed.
      
      This patch fixes the bug by making restorewcbackup() not fail if the
      backup doesn't exist. I also made clearwcbackup() safe, just in case.
      
      Differential Revision: https://phab.mercurial-scm.org/D5634
      88a7c211
  13. Jan 18, 2019
  14. Jan 19, 2019
  15. Jan 18, 2019
  16. Jan 10, 2019
    • Boris Feld's avatar
      update: fix edge-case with update.atomic-file and read-only files · 593f6359
      Boris Feld authored
      We used to create the tempfile with the original file mode. That means
      creating a read-only tempfile when the original file is read-only, which crash
      if we need to write on the tempfile.
      
      The file in the working directory ends up being writable with and without the
      atomic update config, so the behavior is the same.
      593f6359
  17. Jan 17, 2019
  18. Jan 13, 2019
  19. Sep 26, 2018
  20. Jan 10, 2019
  21. Jan 04, 2019
    • Valentin Gatien-Baron's avatar
      match: support rooted globs in hgignore · 4fab8a7d
      Valentin Gatien-Baron authored
      In a .hgignore, "glob:foo" always means "**/foo". This cannot be
      avoided because there is no syntax like "^" in regexes to say you
      don't want the implied "**/" (of course one can use regexes, but glob
      syntax is nice).
      
      When you have a long list of fairly specific globs like
      path/to/some/thing, this has two consequences:
      1. unintended files may be ignored (not too common though)
      2. matching performance can suffer significantly
        Here is vanilla hg status timing on a private repository:
      
        Using syntax:glob everywhere
        real	0m2.199s
        user	0m1.545s
        sys	0m0.619s
      
        When rooting the appropriate globs
        real	0m1.434s
        user	0m0.847s
        sys	0m0.565s
      
        (tangentially, none of this shows up in --profile's output. It
         seems that C code doesn't play well with profiling)
      
      The code already supports this but there is no syntax to make use of
      it, so it seems reasonable to create such syntax. I create a new
      hgignore syntax "rootglob".
      
      Differential Revision: https://phab.mercurial-scm.org/D5493
      4fab8a7d
  22. Nov 07, 2018
  23. Jan 04, 2019
    • Boris Feld's avatar
      discovery: compute newly discovered missing in a more efficient way · f4277a35
      Boris Feld authored
      Calling "descendants" is expensive, instead, we bound the walk inside the know set
      of undecided revision.
      
      This help with discovery performance:
      
      # without the revset '%ld' improvement
      $ hg perfdiscovery -R pypy-left pypy-right
      before: wall 0.675631 comb 0.680000 user 0.670000 sys 0.010000 (median of 15)
      after:  wall 0.520145 comb 0.530000 user 0.510000 sys 0.020000 (median of 19)
      
      There is another series in flight that greatly improves performances of "%ld"
      substitution in `repo.revs` call. If this changeset is applied above it, we
      see a similar performance boost.
      
      # with the revset '%ld' improvement
      $ hg perfdiscovery -R pypy-left pypy-right
      before: wall 0.477848 comb 0.480000 user 0.480000 sys 0.000000 (median of 22)
      after:  wall 0.404163 comb 0.400000 user 0.400000 sys 0.000000 (median of 24)
      f4277a35
  24. Jan 17, 2019
  25. Jan 14, 2019
    • Boris Feld's avatar
      revsetbenchmark: add more example for roots usages · 41f14e8f
      Boris Feld authored
      We test the `roots` revset in setting similar to our test for `heads`.
      
      Note that the algorithm used for roots can give result without consuming the
      full input set. This provides a significant speedup when testing or accessing
      a single value. We can't just replace it with simple, full algorithm like we
      did for `heads`. See performance number below:
      
      0) roots((tip~100::) - (tip~100::tip))
      1) roots((0::) - (0::tip))
      2) roots(tip~100:)
      3) roots(:42)
      4) roots(not public())
      5) roots((0:tip)::)
      6) roots(0::tip)
      7) 42:68 and roots(42:tip)
      8) roots(0:tip)
      9) roots((:42) + (tip~42:))
      10) roots(all())
      11) roots(-10000:-1)
      12) (-5000:-1000) and roots(-10000:-1)
      13) roots(matching(tip, "author"))
      14) roots(matching(tip, "author")) and -10000:-1
      15) (-10000:-1) and roots(matching(tip, "author"))
      
          plain    min      max      first    last     reverse  rev..rst rev..ast sort     sor..rst sor..ast
      00) 0.000789 0.000801 0.000801 0.000819 0.000784 0.000774 0.000793 0.000816 0.000815 0.000831 0.000799
      01) 0.097610 0.002717 0.096706 0.002615 0.059189 0.089033 0.059862 0.002644 0.098058 0.002640 0.058992
      02) 0.000709 0.000117 0.000382 0.000136 0.000384 0.000724 0.000412 0.000133 0.000733 0.000159 0.000416
      03) 0.000075 0.000064 0.000093 0.000080 0.000097 0.000089 0.000123 0.000079 0.000105 0.000102 0.000126
      04) 0.000055 0.000071 0.000070 0.000087 0.000075 0.000066 0.000100 0.000085 0.000082 0.000110 0.000102
      05) 0.088043 0.001084 0.087816 0.001097 0.048049 0.072454 0.047673 0.001089 0.088491 0.001163 0.047824
      06) 0.058761 0.001727 0.059324 0.001850 0.058562 0.059198 0.058998 0.001743 0.058556 0.001874 0.059420
      07) 0.000131 0.000121 0.000145 0.000138 0.000150 0.000142 0.000178 0.000135 0.000160 0.000163 0.000179
      08) 0.058003 0.000077 0.032327 0.000093 0.031966 0.056812 0.031753 0.000092 0.057113 0.000116 0.031933
      09) 0.000503 0.000145 0.000469 0.000161 0.000476 0.000564 0.000502 0.000160 0.000537 0.000187 0.000500
      10) 0.056654 0.000058 0.033104 0.000073 0.032157 0.056598 0.031877 0.000071 0.056433 0.000094 0.031819
      11) 0.005842 0.000081 0.001907 0.000101 0.001883 0.005868 0.001915 0.000099 0.005836 0.000122 0.001896
      12) 0.003237 0.000634 0.001784 0.000655 0.001803 0.003245 0.001837 0.000649 0.003231 0.000680 0.001858
      41f14e8f
Loading