Commit Graph

352 Commits

Author SHA1 Message Date
Phil Cohen
45b775ae72 pushrebase: exchange -> bundle2
Summary: Broken by an upstream refactor

Test Plan: Fixes test

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5149611
2017-05-30 13:13:36 -07:00
Jun Wu
cc95aa58ff test-inhibit: fix the test
Summary: Fix lint errors and make the test pass.

Test Plan: arc unit

Reviewers: #sourcecontrol, sid0

Reviewed By: sid0

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5142477

Signature: t1:5142477:1496173824:bf941d895d3259fc788c09d4fefca7dddd11a33b
2017-05-30 12:56:20 -07:00
Jun Wu
e3e36e37ec inhibit: vendor inhibit and directaccess from mutable-history
Summary:
Vendored using GPL2 license from https://bitbucket.org/marmoute/mutable-history
changeset c9f1118b33d60f8faa4b89988a8155c544f5bb0d without modification.

Test Plan: N/A. The code was imported as is.

Reviewers: #sourcecontrol, sid0

Reviewed By: sid0

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5142063

Signature: t1:5142063:1496173803:d0a9fa50a8423a531432ac3cff378b50952684b1
2017-05-30 12:55:33 -07:00
Jun Wu
78c76613b9 annotate: add skiprevs parameter
Summary:
This adds the `skiprevs` parameter to all `filectx.annotate` methods
to match the upstream change.

For fastannotate, things is a bit more complex since it's a mix of two
algorithms. For now we just fallback to the slow path for correctness.

I'll think about adding back a fast path later.

Test Plan: arc unit

Reviewers: sid0, #mercurial, quark

Subscribers: stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5128392
2017-05-30 09:29:33 -07:00
Stanislau Hlebik
23e41d98e5 copytrace: move to hgext3rd
Summary:
copytracing extension is going to be simpler than I expected in the beginning.
There is no need to separate folder, let's move it to hgext3rd

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5146585

Tasks: 18508761

Signature: t1:5146585:1496147733:ad6ad14f663a8b9bf4b687f0767395321f9840b7
2017-05-30 06:39:31 -07:00
Stanislau Hlebik
bbe014cb96 perftweaks: remove newhiddencache
Summary: Upstream dropped hidden cache in 2f38ac4af04e70af3ffce4700c5a15252391e391, let's drop newhiddencache too

Test Plan: arc unit

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D5146661

Signature: t1:5146661:1496140799:a5a4ddeac577f58a7e1998a5f9fb2eac305cc9d2
2017-05-30 03:42:56 -07:00
Jun Wu
3ed8d7b512 smartlog: add a simple ancestor cache
Summary:
`revlog.ancestor` is expensive on long changelog, but is only called a few
(about 30) times for smartlog usage. Therefore we could simply cache the
result in a key-value database.

This speeds up smartlog by about 200ms.

Test Plan: Added a new test

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5135746

Signature: t1:5135746:1495783503:411260551fd29fda42c9fc809b56f8f77fb2eaf4
2017-05-26 09:03:58 -07:00
Durham Goode
5caecec1ee sparse: switch to using repr for hash computation
Upstream is refactoring the matcher api (952017471f9) and recommends using repr
for hash computation now. This is how fsmonitor in core now does it.
2017-05-24 09:24:19 -07:00
Durham Goode
0d916abbed perftweaks: rename _getdynamicblocks to revealedrevs
Upstream has renamed this function.
2017-05-24 09:18:45 -07:00
Durham Goode
56be761d2e chistedit: fix lint error 2017-05-23 15:38:09 -07:00
Jun Wu
3b9d8cf876 traceprof: store raw Python code object
Summary:
Previously, the tracer extracts file name, function name from Python code
objects and stores them as std::string. And frame the de-duplication logic
hashes those strings, which is actually quite expensive.

`hg id` takes 1.0 seconds without frame de-duplication, and 2.5 seconds with
de-duplication.

This diff assumes Python code object is unique (i.e. Python won't generate two
code objects for a single code segment). That seems reasonable and `lsprof`
seems to make a same assumption.

With that assumption, just store `PyCodeObject` (contains file, method name and
line number) instead of `std::string` (for file, method names) and line numbers
for code identity and use the raw address of `PyCodeObject` to do frame
de-duplication.

That is helpful during profiling and de-duplication:

  - During profiling, no need to copy strings (convert to std::string),
    therefore less overhead
  - During frame de-duplication, no need to read long strings and hash them,
    therefore much faster

Debug flag during compilation is added to make debugging easier as the code
starts to mix of C++ and Python objects, which means mistakes could be made
more easily.

Test Plan:
With this patch, `hg id` with frame de-duplication takes 1.0 seconds.
There is no visible overhead doing de-duplication. Cheers!

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5112636

Signature: t1:5112636:1495562232:dd0724198ebb7f2eb4e9fd3a83517fc9160fa01e
2017-05-23 11:51:10 -07:00
Jun Wu
85be37794d traceprof: implement frame deduplication
Summary:
Previously, traceprof hashes frames using their raw memory addresses, which
causes a same frame (same traceback) being recorded multiple times because
of memory address change. That's for low overhead because hashing all the
way back to the top frame is slow.

This patch implements slow frame hashing and de-duplication so the output
could look tidier in some cases. The slow de-duplication runs after
profiling ends so it won't affect profiling accuracy.

Test Plan:
Trace IPython, before:

```
  6211          \ run                           posix.py:50
  6152            \ call_inputhook (10 times)   inputhook.py:60
                    ....
  6147              \ select_fds (10 times)     select.py:194
     6                \ select                  select.py:85
     6                 | select                 select.py:179
   501                \ select                  select.py:85
*  501                 | select                 select.py:179
  3775                \ select                  select.py:85
* 3775                 | select                 select.py:179
*  627                \ select (2 times)        select.py:85
   736                \ select (3 times)        select.py:85
*  736                 | select (6 times)       select.py:179
   501                \ select                  select.py:85
*  501                 | select (2 times)       select.py:179
```

After:

```
  4397          \ run                           posix.py:50
  4350            \ call_inputhook (4 times)    inputhook.py:60
  4349             | select_fds (4 times)       select.py:194
  4348             | select (4 times)           select.py:85
* 4348             | select (8 times)           select.py:179
```

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5112561

Signature: t1:5112561:1495562165:bf86c3283156d3b67918706dc875e6d3e28eac18
2017-05-23 11:50:33 -07:00
Jun Wu
c41d432bb1 fastannotate: move to hgext3rd
Summary: Extensions should belong there.

Test Plan: Updated existing tests

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5113146

Signature: t1:5113146:1495562344:47bae69e6b22c14b32a8a9511878e88e89759d8f
2017-05-23 11:47:22 -07:00
Jun Wu
a97e026674 remoteid: move to hgext3rd
Summary: This is what extensions should belong to.

Test Plan: Changed existing test.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5113042

Signature: t1:5113042:1495561987:d1af0f7cebfdb8b0c1a6bb71cdc826d817a4e441
2017-05-23 11:47:04 -07:00
Martin von Zweigbergk
050cb5d1db chistedit: fail only when attempting to run if curses is not found
If curses is not available, we can still be nice and not fail until
the user actually tries to run the chistedit command.
2017-05-22 23:00:54 -07:00
Jun Wu
f1be725a71 traceprof: new extension to perform accurate profiling
Summary:
Instead of sampling periodically like the default profiler `statprof`, trace
every function call so the report is accurate. The output is designed to be
similar to `statprof`.

Written in C++ and inline assembly to minimize overhead. Cython is used as a
glue layer.

Comparing to `lsprof`, the overhead is similarly small. The major difference is
this profiler cares about "frame object" and records `frame->f_back` (parent
frame) so it could draw a statprof-like tree of the callgraph. `lsprof` records
"code object" instead and could have difficulty to deal with recursive calls.

The following code could demostrate the difference:

```
def fib(x):
    if x < 2:
        return x
    return fib(x - 1) + fib(x - 2)

# lsprof - recorded 1 code object for fib and no way to figure out callgraph
import _lsprof
p = _lsprof.Profiler()
p.enable(subcalls=True)
fib(5)
p.disable()
for s in p.getstats():
    print(s)

'''output:
_lsprof.profiler_entry(code="<method 'disable' of '_lsprof.Profiler' objects>", callcount=1, reccallcount=0, totaltime=0.0, inlinetime=0.0, calls=None)
_lsprof.profiler_entry(code=<code object fib at 0x7f27ca587530, file "a.py", line 1>, callcount=15, reccallcount=14, totaltime=8e-06, inlinetime=8e-06, calls=[_lsprof.profiler_subentry(code=<code object fib at 0x7f27ca587530, file "a.py", line 1>, callcount=14, reccallcount=12, totaltime=6e-06, inlinetime=6e-06)])
'''

# traceprof (with timethreshold set to 0) - callgraph drawn correctly
import sys
from hgext3rd import traceprof
with traceprof.profile(None, sys.stderr):
    fib(5)

'''output:
    | <module>                                  a.py:1
  0  \ fib                                      a.py:1
  0    \ fib                                    a.py:1
  0      \ fib                                  a.py:1
  0        \ fib                                a.py:1
  0         | fib                               a.py:1
  0        \ fib                                a.py:1
  0      \ fib                                  a.py:1
  0       | fib                                 a.py:1
  0    \ fib                                    a.py:1
  0     | fib                                   a.py:1
     \ __exit__                                 contextlib.py:21
'''
```

There are some performance / correctness tradeoffs. The current implementation
takes `frame` address and several (but not theoretically complete) fields to
hash a frame.  That could in theory lead to inaccurate frame information being
recorded. But hashing all fields recursively incurs significant overhead. The
related logic is the `hashframe` function, which could be tweaked later.

This is an initial version. It probably does not cover all corner cases like
exception handling well. And it may duplicate a same frame multiple times
because of the way it hashes a frame. The duplicated frame issue could be
solved by adding post-profiling filtering though.

Here is a real-world example of `hg log -r .` on `hg-committed`:

```
      | <module>                                hg:10
      | run                                     dispatch.py:81
      | dispatch                                dispatch.py:132
      | _runcatch                               dispatch.py:202
      | _callcatch                              dispatch.py:309
      | callcatch                               scmutil.py:133
      | _runcatchfunc                           dispatch.py:215
      | _dispatch                               dispatch.py:744
    2  \ repository                             hg.py:166
    2   | _peerorrepo                           hg.py:151
    2   | instance                              localrepo.py:2025
    2   | __init__                              localrepo.py:275
  863  \ runcommand                             dispatch.py:656
  863   | _runcommand                           dispatch.py:926
  863   | <lambda>                              dispatch.py:918
  863   | check                                 util.py:1059
  863   | log                                   commands.py:3262
  480    \ getlogrevs                           cmdutil.py:2236
  479     | _logrevs                            cmdutil.py:2190
  479     | revrange                            scmutil.py:429
  479     | anyrevs                             localrepo.py:622
  478     | mfunc                               revset.py:2275
  478     | __init__ (4 times)                  smartset.py:1033
  478     | __init__ (4 times)                  smartset.py:919
  478     | __len__ (4 times)                   localrepo.py:587
  478     | changelog                           repoview.py:309
  477     | filterrevs (11 times)               repoview.py:260
  477     | computehidden                       repoview.py:171
  455      \ hideablerevs                       repoview.py:24
  455       | getrevs                           obsolete.py:1114
  455       | _computeobsoleteset               obsolete.py:1143
    3        \ __get__ (2 times)                localrepo.py:76
    7        \ node (5760 times)                changelog.py:359
    4         | node (8938 times)               revlog.py:482
    9        \ __get__ (5760 times)             localrepo.py:76
  428        \ __get__                          util.py:798
  428         | successors                      obsolete.py:672
  225          \ __get__                        util.py:798
  224           | _all                          obsolete.py:662
    6            \ tryread                      vfs.py:32
    6             | read                        vfs.py:60
  200            \ _readmarkers                 obsolete.py:442
* 199             | _fm1readmarkers             obsolete.py:430
   15            \ _checkinvalidmarkers         obsolete.py:523
* 203          \ _addsuccessors                 obsolete.py:504
    3      \ tryreadcache                       repoview.py:166
    3       | cachehash                         repoview.py:98
    3       | heads                             localrepo.py:1884
   17      \ <genexpr> (5225 times)             repoview.py:191
   15       | __contains__ (5226 times)         ancestor.py:334
    5       | parentrevs (4010 times)           changelog.py:371
    2       | parentrevs (4332 times)           revlog.py:479
    9    \ pager                                ui.py:843
    9     | _runpager                           ui.py:906
    8     | __init__                            subprocess.py:330
    8     | _execute_child                      subprocess.py:880
    5     | _eintr_retry_call                   subprocess.py:118
  374    \ show                                 cmdutil.py:1308
  374     | _show                               cmdutil.py:1316
  365      \ _changesetlabels                   cmdutil.py:1266
  365       | troubled                          context.py:225
   12        \ unstable (2 times)               context.py:207
   12         | getrevs                         obsolete.py:1114
   12         | _computeunstableset             obsolete.py:1154
    3          \ set (322 times)                localrepo.py:610
    3            \ revs (3 times)               localrepo.py:593
    8            \ __getitem__ (963 times)      localrepo.py:566
    4          \ parents (321 times)            context.py:246
    4           | __get__ (321 times)           util.py:798
    4           | _parents (321 times)          context.py:562
    3          \ <genexpr> (642 times)          obsolete.py:1164
    3           | obsolete (321 times)          context.py:199
    2           | getrevs (321 times)           obsolete.py:1114
  319        \ bumped (2 times)                 context.py:211
  319         | getrevs                         obsolete.py:1114
  319         | _computebumpedset               obsolete.py:1181
    4          \ set (322 times)                localrepo.py:610
  312          \ allprecursors (2021 times)     obsolete.py:850
  308           | __get__                       util.py:798
  308           | precursors                    obsolete.py:678
* 308           | _addprecursors                obsolete.py:509
   34        \ divergent (2 times)              context.py:218
   34         | getrevs                         obsolete.py:1114
   33         | _computedivergentset            obsolete.py:1204
    4          \ set (322 times)                localrepo.py:610
   24          \ successorssets (1368 times)    obsolete.py:899
    3            \ __get__ (1368 times)         localrepo.py:76
    4            \ __contains__ (200 times)     localrepo.py:575
    9      \ names (2 times)                    namespaces.py:184
    9       | <lambda>                          namespaces.py:43
    9       | nodetags                          localrepo.py:741
    8       | __get__                           util.py:798
    8       | _tagscache                        localrepo.py:646
    8       | _findtags                         localrepo.py:685
    7       | findglobaltags                    tags.py:170
    7       | _readtagcache                     tags.py:370
    6       | filteredhash                      scmutil.py:307
       \ __exit__                               contextlib.py:21
        | maybeprofile                          profiling.py:199
        | __exit__                              contextlib.py:21
        | profile                               profiling.py:148
        | __exit__                              contextlib.py:21
Total time: 867 ms
```

Some example conclusions from reading the above output include:

  1. `_fm1readmarkers`, `_addsuccessors`, `_addprecursors` are slow
  2. `changelog.node` and `changelog.parentrevs` are called thousands of times,
     but they are just a few milliseconds.
  3. Reading the `obsstore` file (`vfs.read`) takes 5ms exactly

While `statprof` may get 1 right, `lsprof` may get 2 right, neither of them is
helpful for 3. `statprof` is not accurate enough to be confident about 5ms,
`lsprof` will include other `vfs.read` calls so it's impossible to see just the
read for obsstore.


Test Plan:
With the upstream [patch](https://patchwork.mercurial-scm.org/patch/20822/), run:

```
 HGPROF=traceprof hg id --config extensions.traceprof= --profile
```

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters, jiangyuan

Differential Revision: https://phabricator.intern.facebook.com/D5104851

Signature: t1:5104851:1495480386:666847ea08bb6a94658bc10d7f0e91c225d56836
2017-05-22 15:49:45 -07:00
Durham Goode
dcaee39e39 obsmarkers: update obsmarker operation wrapping to work with upstream
Summary:
Upstream has added an optional operation argument to createmarkers, which we
need to also accept. This argument is currently only processed if a config
option is set, so for now we will still put the operation in the metadata dict
manually.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5106511

Signature: t1:5106511:1495485044:23d45d9ba389cf0d49b31705ae36902310c5056c
2017-05-22 13:38:37 -07:00
Durham Goode
0766a3469c dirstate: switch to new parentchange context
Summary: Upstream has deprecated begin/endparentchange in favor of a context object.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5106500

Signature: t1:5106500:1495485058:8377335a0f678de7bb50cb93fff29bcfeb53fe1d
2017-05-22 13:38:37 -07:00
Durham Goode
e34660b057 commands: update to use registrar instead of cmdutil
Summary: Upstream has deprecated cmdutil.commands() in favor of registrar.commands()

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5106486

Signature: t1:5106486:1495485074:0e20f00622cc651e8c9dda837f84dd84cc51099e
2017-05-22 13:38:37 -07:00
Jun Wu
f532dddaa4 lfs: implement byte-level progress bar
Summary:
Previously, the progress bar is file-level - it moves when a file is transferred.

When uploading or downloading a single giant file, progress bar matters. And
this diff adds it to make people more patient.

Test Plan:
Manually upload and download several big files.
Make sure the progress bar appears in both cases.

Also make sure the output is sane with `-v`.

Reviewers: #mercurial, davidsp, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5100014

Signature: t1:5100014:1495316719:c500ccd63d3a495e41575cadd72419a41f5fb259
2017-05-22 11:03:14 -07:00
Durham Goode
f02e3e0686 revlog: rename revlog constants
Upstream has renamed some revlog constants, so we need to update our code
accordingly.
2017-05-21 17:09:08 -07:00
Jun Wu
65b1cff91e dirsync: use _fileset
Upstream has renamed _fileroots to _fileset.
2017-05-19 21:39:47 -07:00
Jun Wu
0fd94f75db fixcorrupt: use REVLOGV1
Upstream has renamed REVLOGNG to REVLOGV1.
2017-05-19 21:32:02 -07:00
Jun Wu
3e43e09a97 lfs: add a lfs_files template
Summary:
This allows automation to know which modified or added files are LFS for
specific changesets.

Test Plan: Added a test

Reviewers: #mercurial, davidsp

Reviewed By: davidsp

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5091591

Signature: t1:5091591:1495163606:138638d8ccc57b8ed6c1e324750ec5dc15c198a0
2017-05-18 22:18:20 -07:00
Jun Wu
546cff40f8 lfs: skip uploading when remotestore is a null store
Summary:
When remotestore is a null store, uploading is a no-op and can be skipped.
This diff makes it so.

Test Plan: arc unit

Reviewers: #mercurial, davidsp

Reviewed By: davidsp

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5090686

Signature: t1:5090686:1495144964:956549307912f4a44201aa305959bf8de26ac028
2017-05-18 15:10:39 -07:00
Misha Shneerson
cbdaa23f88 conduit: added correct Content-Type header for conduit queries
Summary:
conduit HTTP POST request did not have correct content-type header set.
Now they do. Ideally we should use python-request package to do HTTP
but I do not know enough how to import these dependencies so I just went
with the minimal changes.

Test Plan:
ran hg log from dev environment and eventually got it all working.
{P57411895}

Reviewers: simpkins

Reviewed By: simpkins

Subscribers: net-systems-diffs@fb.com, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5080725

Tasks: 18294945

Signature: t1:5080725:1495052201:1bbd6edad4c1c4b3482a7479259460a815947630
2017-05-17 13:50:37 -07:00
Rainer Alves
37fdd68496 morestatus: make conflict paths relative
Summary: morestatus: make conflict paths relative

Test Plan: Output: https://phabricator.intern.facebook.com/P57402806

Reviewers: rmcelroy, mgorven

Differential Revision: https://phabricator.intern.facebook.com/D5062074

Tasks: 10366065
2017-05-17 07:13:41 -07:00
Jun Wu
24d8640017 absorb: do not strip innocent children
Summary:
`repair.strip` removes required revisions and their children unconditionally.
That means innocent children may be removed. This patch fixes it.

We may want to have an in-core function for this feature to not strip innocent
children.

Thanks Zibi Braniecki from Mozilla for reporting [1]!

[1]: https://bitbucket.org/facebook/hg-experimental/issues/6/hg-absorb-merges-diverged-commits

Test Plan: Added a test

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5073342

Signature: t1:5073342:1494972231:ca2a9881415119047771c8f35e059f4bfb1749e5
2017-05-16 16:25:00 -07:00
Jun Wu
a82574317b lfs: upload blobs during 'hg bundle'
Summary:
When a bundle is created, the bundle could be exchanged via copy and possibly
eventually reach to a publishing repo. If we don't upload LFS blobs, hg server
could have revisions that can never be checked out or verified.

So let's just assume bundles generated by `hg bundle` will be public, and
upload LFS blobs automatically, without depending on other code review tooling.

Note: there is a `preoutgoing` hook which will be triggered in this case,
however it's not useful since it does not have the `outgoing` information.

Test Plan: Will add a new test

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5050945

Signature: t1:5050945:1494958648:0c46ab1d85755838ba189bbb1e0673882922bb58
2017-05-16 15:49:32 -07:00
Jun Wu
7098094e7e lfs: cleanup file headers
Summary:
This diff removes `# coding=UTF-8` and adds standard GPL2 headers to lfs
files.

Test Plan: arc unit

Reviewers: davidsp, #mercurial, simonfar, rmcelroy

Reviewed By: simonfar, rmcelroy

Subscribers: simonfar, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5067881

Signature: t1:5067881:1494947941:e669d4d9485c390138f76031608a7f727c57bf55
2017-05-16 15:44:06 -07:00
Jun Wu
f0c7a3cef9 lfs: remove util.py
Summary:
`util.py` only contains 2 small things: `lfsvfs` and `sha256`. Both of them
only have one user (in terms of files). Therefore just move the code to
related files to make it simpler.

Test Plan: arc unit

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5067862

Signature: t1:5067862:1494955824:b99021f1bb44568dc0c738b0e472eb732f2bc91a
2017-05-16 15:43:36 -07:00
Jun Wu
ae8a1ccb8f lfs: update old PointerDeserializationError error handling
Summary:
The error was renamed to `InvalidPointer`. This diff updates error handling
to catch that instead.

Test Plan: arc unit

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5067496

Signature: t1:5067496:1494955510:5f0162a8cc6f1d0d83e3ab6319ec3202028684d8
2017-05-16 15:42:30 -07:00
Jun Wu
acfcc44094 lfs: add a fctx.islfs method
Summary:
This simplifies code a bit, and could be useful for 3rd party code. We already
have `isbinary`, `islink`, `isexec`, `isabsent`. So another `is` method looks
fine.

Test Plan: Run existing tests

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5067369

Signature: t1:5067369:1494955466:ae17e310e743c704cc0d9bb73e0d2e82adcffff8
2017-05-16 15:41:39 -07:00
Jun Wu
2eef188bc0 lfs: add a filectx.cmp fast path
Summary:
The `filectx.cmp` fast path allows us to show "binary file changed" diff output
when two binaries have the same size but different content.

Test Plan: Added a test case

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5067266

Signature: t1:5067266:1494954783:a41e8213782afe24618ef2930c9576f21610fd3e
2017-05-16 15:38:51 -07:00
Jun Wu
9eedb98b61 lfs: downgrade "computing set of blobs to upload" to debug message
Summary:
Calculating what blobs to upload should be fast since we use changelog `files`
information. Users will see `lfs: uploading ...` very soon. So let's downgrade
`lfs: computing set of blobs to upload` to a debug message to make `-v`
cleaner.

Test Plan: Updated existing test.

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5066600

Signature: t1:5066600:1494954115:c00925a1930f9b53e914078d32b6c4e4161099ee
2017-05-16 15:27:25 -07:00
Jun Wu
ae541c9f80 lfs: show status per object when ui.verbose is set
Summary:
Downloading or uploading a single LFS object could take long. Instead of
showing a summary of what objects are downloaded or uploaded, print a message
per object if --verbose is provided.

Test Plan: Added a test

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5066327

Signature: t1:5066327:1494953894:3593436ff53eaff117a2932476dfc4b867fb9f17
2017-05-16 15:24:04 -07:00
Jun Wu
28de141267 lfs: handle "wrong action" error earlier
Summary:
Previously, when an object is not found server-side, we error out during the
basic transfer API. This diffs move the check to the batch metadata API so the
check is preformed earlier.

That also means, when batch fetching many LFS objects, we could report multiple
objects being missing instead of just one.

Test Plan: Modified an existing test

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5065623

Signature: t1:5065623:1494952131:cb1df73e1cea21e07bfd0ec630bacec60e5b385c
2017-05-16 15:19:40 -07:00
David Soria Parra
aca5b8465c p4fastimport: filelog transaction wtih support for concurrent access
Summary:
We are adding a simple transaction that works only with filelogs but
allows for concurrent access from multiple workers. This allows for a proper
rollback in case of a failure in a worker process, which previously would result
in bad data in the repositoriy.

Test Plan: rt test-p4* test-check*

Reviewers: #mercurial, durham, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5070340

Signature: t1:5070340:1494958313:b10b1eac5b42b36d1a587c4ae1c95fc2f8b5ad35
2017-05-16 12:36:23 -07:00
Jun Wu
b78dbc3dad lfs: check object errors from batch API early
Summary:
The batch API allows server to return errors per object, handling them early
seems to be a good idea.

This is an attempt to distinguish "cannot upload - no permission" from
"no need to upload - already exist".

Unfortunately, `lfs-test-server` reference implementation does not provide
the error message so it's not reflected in tests.

Reviewers: #mercurial, davidsp, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057816

Signature: t1:5057816:1494951879:07f2b67408e9d77255104b932baae2e50af9890b
2017-05-16 12:30:23 -07:00
Jun Wu
adb61e1976 lfs: split basic transfer API out from _batch
Summary:
The basic transfer API [1] worths a separate method.

[1]: https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md

Reviewers: #mercurial, davidsp, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057683

Signature: t1:5057683:1494951784:de3d3a28a69366fbbc4546f9e68b4d664ba00dfa
2017-05-16 12:26:30 -07:00
Jun Wu
d5a9c91ff9 lfs: move batch API to a separate method
Summary:
The LFS uploading or downloading process consists of 2 parts: a batch API to
get metadata about objects, followed by `len(objects)` requests.

This diff moves the first metadata API out from a giant `_batch` method to
make the code structure easier to maintain. Later diffs will further split
`_batch` method.

A side effect is `lfs: mapping blobs to #{action} URLs` message is removed.
More user-friendly message will be added back in a later patch.

Reviewers: #mercurial, davidsp, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057541

Signature: t1:5057541:1494949989:d510c3d9369744e7ee776c0d0a26d263dfaf8352
2017-05-16 12:24:20 -07:00
Jun Wu
31882a9791 lfs: remove total parameters from remote store APIs
Summary:
Displaying total bytes to upload is currently inaccurate - the server could
already have some objects so only a subset of selected objects will be
uploaded.

Besides, we pass `pointers` to related upload and download APIs so `total`
could be calculated from them.

This diff removes the inaccurate "need to upload" message and unnecessary
parameters. An accurate message will be added in a later patch.

Reviewers: #mercurial, davidsp, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057470

Signature: t1:5057470:1494949554:07e637a8b58c894598b3f0c2dd53f80a5ade25a8
2017-05-16 11:19:39 -07:00
Don Stewart
bc85e8a4cf hgext: accept a --unified param for lines of diff context
Summary: Added -U/--unified NUM to fbshow.py, and used that to set diff.unified=NUM.

Test Plan: hg show --help; hg show -U 1; hg show -U 2; hg show -U by induction.

Reviewers: mburman, simonfar, ikostia

Differential Revision: https://phabricator.intern.facebook.com/D5052156

Tasks: 10006036

Tags: python
2017-05-15 05:59:55 -07:00
Jun Wu
f484dba4a0 lfs: narrow down try block
Summary:
A try block is only effective for the HTTP error. Let's narrow it down to
just the HTTP request.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057107

Signature: t1:5057107:1494634308:584877babc6a4705fa0740788dcf58affdf51bec
2017-05-12 17:28:45 -07:00
Jun Wu
853b228a8a lfs: handle batch API's HTTP and JSON error
Summary:
There are `1+n` HTTP requests. `n` of them is handled. But the first one
about JSON metadata is not. Let's handle it.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057053

Signature: t1:5057053:1494634184:fa0e562dc7879379106bf37915a2e5ea3cc01a4d
2017-05-12 17:26:06 -07:00
Jun Wu
d5e501b573 lfs: provide more detailed message on network error
Summary:
The server or the HTTP library may provide more detailed error message.
Let's use them. `RequestFailedError` is also renamed to `LfsRemoteError` to
make it clear it's related to LFS and network.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5057014

Signature: t1:5057014:1494634052:00c1cb1b337a0e4cb92828cd49e95b7b0ff7e540
2017-05-12 17:22:02 -07:00
Jun Wu
b808e0f70f lfs: remove UnavailableBatchOperationError
Summary:
It's caught, and re-raise with RequestFailedError. We can just raise
RequestFailedError directly.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5056886

Signature: t1:5056886:1494633307:3fdf2fab13e783224d343266a1278c41ed4394e8
2017-05-12 17:18:05 -07:00
Jun Wu
34ffa6d4ce lfs: use ProgrammingError for invalid action in _batch
Summary:
_batch is called by programmers. If action is not expected, it's a
ProgrammingError.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5056822

Signature: t1:5056822:1494634121:59737eb0d3f42d706ee8b0dc18ec7a4b49ada34f
2017-05-12 17:14:52 -07:00
David Soria Parra
07292913da p4fastimport: move p4fastimport under hgext3rd
Summary:
move p4fastimport under hgext3rd as that's where it belongs.
Also has the benefit that we package it up.

Test Plan: rt test-p4*

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D5056664

Signature: t1:5056664:1494631758:4892f47922d8fbbd2c1f7793f3f29ee73fa8fa42
2017-05-12 17:03:20 -07:00
Jun Wu
d3b28f4b42 lfs: remove StoreID
Summary:
For long I have been wondering - we have `oid` already and an `oid` could
identify an object already, why do we need a `StoreID` which contains both
`oid` and `size`? It does not seem necessary?

I figured out the answer - the batch download or upload API *requires* size
information per object [1].

Since we will have LFS pointers during upload or download, we can just use
pointers. This diff removes `StoreID`, changes remote blob store to take
`pointers` directly, and local blob store to take `oid` directly.

As a side effect, `debuglfsupload` no longer takes `-o`, which seems fine
because `-r` should be more useful.

[1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md

Test Plan: `arc unit`

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D5043694

Signature: t1:5043694:1494496522:ea10f3dd12fc2ae3ab77b8f623eeead84dcc25fa
2017-05-11 17:57:42 -07:00