Commit Graph

3245 Commits

Author SHA1 Message Date
Felix Merk
9df57fe0d2 undo: preview change - just show delta
Change preview to just show the delta and connected commits.  This means we need
to calculate oldworkingcopyparent and bookmarks diffs.  This output will be
cleaner especially for people with a lot of commits in their repo.

Differential Revision: https://phab.mercurial-scm.org/D467
2017-08-22 10:18:03 -07:00
Mark Thomas
7805c8ae35 infinitepush: improve revset for not-backed-up revisions
Summary:
The first version of infinitepush smartlog summary included some false
positives (in particular, not-backed-up but obsolete revs), and took a long
time to compute the set if there were many heads in the repo.

Improve the revset that is used by taking into account the heads that *should*
be backed up.  Ancestors of these heads, that are not ancestors of the actual
backup heads are the ones that should be considered "not backed up".

Test Plan:
Re-run unit tests.
Manual test on devvm.
Perf test against stash's repo which has more heads than mine.

Reviewers: #fbhgext, stash

Differential Revision: https://phab.mercurial-scm.org/D475
2017-08-22 09:03:43 -07:00
Stanislau Hlebik
d90c0a301d infinitepush: always require a pattern for --list-remote
Summary:
--list-remote can return too many nodes if used without a pattern.
Let's require a pattern.

Test Plan: Run unittests

Reviewers: #fbhgext, ryanmce

Reviewed By: #fbhgext, ryanmce

Subscribers: ryanmce

Differential Revision: https://phab.mercurial-scm.org/D221
2017-08-22 01:24:23 -07:00
Stanislau Hlebik
e3d7418df4 fastlog: use ui.log() instead of ui.warn()
Summary:
ui.warn() just prints to the stderr. It has two disadvantages:
1) Distracts a user
2) Doesn't notify us about the problem.

Let's use ui.log() that will send result to our logging system

Test Plan: Run unit-tests

Reviewers: #fbhgext, quark

Reviewed By: #fbhgext, quark

Differential Revision: https://phab.mercurial-scm.org/D443
2017-08-22 01:23:25 -07:00
Felix Merk
66fc95aa46 interactivui: get rid of flashing
Prevent flashing in 'hg undo -i' for smoother ux.  Tested by running hg undo -i
and not seeing flashes when hitting left or right.

Differential Revision: https://phab.mercurial-scm.org/D465
2017-08-21 15:55:16 -07:00
Jun Wu
805ddc8422 codemod: be compatible with upstream change
D319 renamed `peer.pipe[ioe]` to `peer._pipe[ioe]`.
D320 removed `peer.batch`.
D331 renamed `subprocess` to `_subprocess`.
D336 renamed `_capabilities` to `capabilities`.

Let's be compatible with those changes.

Differential Revision: https://phab.mercurial-scm.org/D425
2017-08-21 15:10:41 -07:00
Felix Merk
fcd302bf7b undo: draft obsolete commits
Visible obsolete commits are slightly tricky.  For example, an amend in the
middle of a stack will leave behind a visible obsoleted commit.  This diff
removes visible obsolete commits from 'olddraft()'.  This removes the need for
some special casing and allows for a more powerful preview.

Differential Revision: https://phab.mercurial-scm.org/D463
2017-08-21 13:28:50 -07:00
Felix Merk
cfbbbdf2c6 undo: preview perf improvements
Based on Adam Simpkin's ideas, faster code for the template functions.

Differential Revision: https://phab.mercurial-scm.org/D462
2017-08-21 13:28:50 -07:00
Felix Merk
e45f912211 undo: preview shows command and time output
Makes hg undo -i and hg undo -p output show an "undo to time, before command"
message and adds directions (left, right, return, q).  Also adds pager check as
pager break interactiveui.

Testing: run hg undo -p and hg undo -i and see output

Differential Revision: https://phab.mercurial-scm.org/D448
2017-08-21 11:25:36 -07:00
Mihails Smolins
c4e13682c5 remotefilelog: efficient keepset computation
Summary:
New keepset computation algorithm yields 50% time improvement on a small set of
commits and about 90% time improvement on a large set of commits. Currently it
takes about 1m10s to compute a keepset of 10 commits with treemanifest
usecunionstore flag unset and 3 seconds with cunionstore config set, provided
all trees are prefetched.

Test Plan: * Ensure that unit tests pass, in particular *-gc.t and *-gcrepack.t

Reviewers: ryanmce, simonfar, durham, #fbhgext

Reviewed By: ryanmce, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D442
2017-08-21 09:08:19 -07:00
Felix Merk
721459469f undo: draft obsolete handling
Obsoleted commits may be visible.  To make sure that they are un-obsoleted after
undo when appropriate, we add "draft() & obsolete()" recording.  The most common
case where this matters is undoing a mid stack amend.

Differential Revision: https://phab.mercurial-scm.org/D438
2017-08-18 11:40:18 -07:00
Felix Merk
2d555e35dd undo: informative output
Instead of the _showstats output from hg.py, we now output the args and time of
the mercurial command we are undoing.

Differential Revision: https://phab.mercurial-scm.org/D412
2017-08-18 11:37:45 -07:00
Felix Merk
aa2547d949 undo: unfinished command handling
hg rebase, histedit, unshelve and other commands may stop in an unfinished state
because of merge conflicts or other reasons.  The user then has the ability to
continue or abort.  Undoing in this case is slightly tricky as for example
aborting a rebase will perform real strips and so undo will fail with an error.
This change still records these states, but flags them as unfinished and skips
over them when undoing and redoing.  Hg undo --absolute does not ignore these
states in the really unlikely situation you want to go to one of them.

Differential Revision: https://phab.mercurial-scm.org/D410
2017-08-18 11:37:45 -07:00
Ryan McElroy
efdd3372ea dirsync: update tests for upstream behavior change
Summary:
Since f33f2b5b487453a0387c80a2d736ec450696cefe, a failed `hg commit -A` will no
longer update the dirstate.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Differential Revision: https://phab.mercurial-scm.org/D433
2017-08-18 03:11:29 -07:00
Ryan McElroy
674d828aad undo: allprecursors -> allpredecessors
Summary: Per upstream name changes. Eliminated develwarns.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Differential Revision: https://phab.mercurial-scm.org/D432
2017-08-18 03:11:29 -07:00
Ryan McElroy
28eed8e961 phabstatus: allprecursors -> allpredecessors
Summary: Renamed upstream. Eliminate more develwarns.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Subscribers: simonfar

Differential Revision: https://phab.mercurial-scm.org/D431
2017-08-18 03:11:29 -07:00
Ryan McElroy
42c167e16e fbamend: allprecursors -> allpredecessors
Summary: Renamed upstream. Prevent develwarns.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Differential Revision: https://phab.mercurial-scm.org/D430
2017-08-18 03:11:29 -07:00
Ryan McElroy
6ce9175cd1 fbamend: precursor -> predecessor
Summary: Get in line with upstream name change and eliminate develwarns.

Reviewers: #fbhgext, simonfar, simpkins

Reviewed By: #fbhgext, simonfar, simpkins

Subscribers: quark, simpkins, simonfar

Differential Revision: https://phab.mercurial-scm.org/D429
2017-08-18 03:11:29 -07:00
Ryan McElroy
e2dfc69dc2 fbamend: precnode -> prednode
Summary:
Upstream is changing names to be more consistent. Follow suit to eliminate
devel-warnings.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Subscribers: simonfar

Differential Revision: https://phab.mercurial-scm.org/D428
2017-08-18 03:11:29 -07:00
Ryan McElroy
7770cdf605 undo: precnode -> prednode
Summary: Names be a'changin.

Reviewers: #fbhgext, simonfar

Reviewed By: #fbhgext, simonfar

Differential Revision: https://phab.mercurial-scm.org/D427
2017-08-18 03:11:29 -07:00
Felix Merk
3f41f783a1 undo: performance improvement attempt
Undo -p is really slow on certain large repos.  This caches 'olddraft()' by
using the revlog nodes.  Since revlogs are immutable this should be really safe
and could hopefully dramatically improve not only hg undo -p performance, but
performance of all undo commands.

Differential Revision: https://phab.mercurial-scm.org/D439
2017-08-17 16:45:37 -07:00
Jun Wu
832ec05e60 pager: migrate to modern pager API
The modern pager API is to use `ui.pager()` explicitly just before the time
a command needs a pager. It's now hard-coded in individual commands, and
opt-in by default. Users wanting to disable pagers for certain commands need
to disable them explicitly. Ideally we don't need the pager extensions or
the `pager.attend` setting.

This patch migrates `show`, `smartlog`, `fastannotate`, and `grep` to use
the modern API.

Differential Revision: https://phab.mercurial-scm.org/D437
2017-08-17 13:42:18 -07:00
Mateusz Kwapich
432714c0bf perftweaks: don't crash if the rebase dest is None
Summary: This happens in case of "pull --rebase" if the source is ancestor of destination

Test Plan: see the new test, it's making hg crash without this change

Reviewers: #fbhgext, ryanmce, simonfar

Reviewed By: #fbhgext, ryanmce, simonfar

Subscribers: ryanmce

Differential Revision: https://phab.mercurial-scm.org/D436
2017-08-17 12:15:02 -07:00
Jun Wu
6e9f7aeb68 absorb: preserve phase
When rewriting changesets, preserve their phases.

Fixes https://bitbucket.org/facebook/hg-experimental/issues/10/hg-absorb-doesnt-preserve-commits-phase

Differential Revision: https://phab.mercurial-scm.org/D418
2017-08-16 13:40:00 -07:00
Mihails Smolins
a2bdf68679 remotefilelog: limit number of changesets to be prefetched
Summary:
Added config option 'prefetchdays' which indicates that commits older than
'prefetchdays' days should not be prefetched. This option is necessary to avoid
prefetch of huge amount of data. The default value is set to 14 days.

Test Plan: Ensure that unit tests pass

Reviewers: ryanmce, simonfar, durham, #fbhgext, simpkins

Reviewed By: #fbhgext, simpkins

Subscribers: simpkins

Differential Revision: https://phab.mercurial-scm.org/D420
2017-08-16 13:21:31 -07:00
Mihails Smolins
a46c678ab9 remotefilelog: flaky bgprefetch test fix
Summary:
The test fails due to a race condition. Now the failing part of the test
output is optional.

Test Plan: Ensure that unit tests do not fail

Reviewers: ryanmce, simonfar, #fbhgext

Reviewed By: ryanmce, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D417
2017-08-16 09:16:07 -07:00
Ryan McElroy
73ea227f7d treemanifest: make tests more lenient and fail more descriptively
Summary:
The test-treemanifest-pushrebase test was failing in our continuous integration
environment with a perplexing error:

```
$ pushclients
+ abort: exporting bookmark master failed!
```

(plus some additional failures later)

I thought this should not be possible because of the redirect, but it turns out
that the order of the redirects matters:

`>/dev/null 2>&1` redirects both stderr and stdout to `/dev/null`, but
`2>&1 >/dev/null` redirects stdout to /dev/null and stderr to stdout

(TIL)

However, this was the only clue to the issue that was going on, and so it's
better to actually keep the error around, if one occurs, so I removed the 2>&1
redirect altogether.

Furthermore, the test was failing with various clients failing to push.
To increase the chance of this succeeding, I'm bumping the sleep time. Ideally,
we should wait for the server to be "ready", but I'm not certain what that means
or how to test and would like to discuss to figure it out. This hopefully will
unblock the continuous integration for now.

Test Plan: Test still passes locally; wait to see if it passes in automation.

Reviewers: #fbhgext, mitrandir

Reviewed By: #fbhgext, mitrandir

Differential Revision: https://phab.mercurial-scm.org/D415
2017-08-16 16:12:04 +01:00
Jun Wu
50e07b913e test: do not ignore test-check sanity check
Previously, if the system hg does not work, `helper-testrepo.sh` will skip
the test (usually `test-check-*.t`). This patch makes it stricter so a
non-functional system hg will be an error so it's less likely to be ignored.

Differential Revision: https://phab.mercurial-scm.org/D387
2017-08-15 16:56:54 -07:00
Felix Merk
00870d6060 undo: don't break when undo isn't first argument
Undo commands where undo wasn't first, for example `hg --pager=off undo` break
multiple things, including hg redo.  This change fixes this.

Differential Revision: https://phab.mercurial-scm.org/D396
2017-08-15 16:56:25 -07:00
Felix Merk
8a98220afc undo: invalidate false cache
Mercurial sometimes leaves bad caches.  Easiest example is when updating to a
hidden commit, where hg undo will fail, but can be reproduced with many commands
(such as fold which is used for testing here).

Test Plan:
unit tests

Differential Revision: https://phab.mercurial-scm.org/D395
2017-08-15 16:56:25 -07:00
Felix Merk
1ab935a4dc undo: add Scuba logging
Adds scuba logging to dev command timers so we can see how often some seemingly
unlikely edge (error) cases happen.  Once we are confident that hg undo is
stable we can get rid of these logs.  This is specifically for things that
don't loudly fail (since the user shouldn't care about them) but we still would
like to know about.  Note that
[sampling]
key.undo=perfpipe_dev_command_timers
is needed in an hgrc file for this to work.

Test: deleted gap file, ran undo and confirmed error was noted in dev command
timers

Differential Revision: https://phab.mercurial-scm.org/D357
2017-08-15 16:50:40 -07:00
Adam Simpkins
f2f8ba9c30 remotefilelog: open pack files with O_CLOEXEC
Summary:
If os.name is "posix", add the "e" flag when opening pack files.  On systems
using glibc 2.7+ this causes the underlying operating system open() call to use
the O_CLOEXEC flag.  This ensures that the pack file descriptors will not be
inherited by any children processes.  This can be helpful since the
remotefilelog code can sometimes have thousands of pack files open.  This
causes problems for children processes that expect to be able to use select()
on file descriptors they create, since they can end up with file descriptor
numbers over 1024.

While making sure to always set close_fds=True when calling subprocess.Popen()
can help with this, using O_CLOEXEC to fix the problem from the start seems
like a nicer fix.

The extra "e" flag generally should be ignored by other C library
implementations that do not support this flag.  I explicitly scoped this to the
"posix" OS just to ensure that this cannot collide with other OS-specific flags
on other operating systems.  (Windows also defines several of its own custom
fopen() flags.  Windows does not currently use "e", but it seems best to avoid
it anyway.)

Test Plan:
Ran hg under strace and confirmed that the pack files were opened with
O_CLOEXEC.

Reviewers: quark, durham, #fbhgext

Reviewed By: quark, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D398
2017-08-15 10:49:20 -07:00
Simon Farnsworth
0d8b65f603 tweakdefaults: do not change the date when using amend --to
Summary:
amend --to is a thin wrapper around histedit, and fails if you ask it
to update the date. tweakdefaults can be configured to ask amend to change the
date. When this is the case, don't change the date when using --to, so that it
can work.

Test Plan:
Test case added here fails before the change complaining about other
flags with --to, and fails in the histedit afterwards (I'm not clear on why - I
suspect phases are significant here).

Reviewers: #fbhgext, ryanmce

Reviewed By: #fbhgext, ryanmce

Differential Revision: https://phab.mercurial-scm.org/D349
2017-08-15 07:21:37 -07:00
Mihails Smolins
907162fe78 remotefilelog: gc option for repacker class
Summary:
Repack is also used for repack of local trees, which should not be garbage
collected. Therefore, we want to be able to pass the gc option to the repacker
class so that we could garbage collect the shared cache but not local trees.

Test Plan:
* Run unit tests
* Test manually on www repo

Reviewers: ryanmce, durham, simonfar, #fbhgext

Reviewed By: ryanmce, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D408
2017-08-15 04:34:12 -07:00
Mihails Smolins
7cd5d8e5d5 remotefilelog: fix flaky bgprefetch test
Summary: The test failed due to a race condition. Now the failing part of the test output is optional.

Test Plan: Ensure that unit tests do not fail

Reviewers: #fbhgext, ryanmce

Reviewed By: #fbhgext, ryanmce

Differential Revision: https://phab.mercurial-scm.org/D407
2017-08-15 03:53:34 -07:00
Adam Simpkins
6f1efddaa4 traceprof: report profile data even on error
Summary:
Update the traceprof contextmanager to always print the profile information,
even when exiting due to an exception.

In particular, this fixes the behavior so that we report profiling information
even if a slow command is interrupted with Ctrl-C.  This also matches the
behavior of the upstream statprof profiler.

Test Plan:
Confirmed that a profile was printed when interrupting a long-running
`hg log -f` command in a large repository.

Reviewers: quark, #fbhgext

Reviewed By: quark, #fbhgext

Differential Revision: https://phab.mercurial-scm.org/D386
2017-08-14 18:12:29 -07:00
Felix Merk
db3ca9f593 undo: improved --branch handling
Adds --branch handling to the no argument redo.  Also adds better branch testing
and takes a more sensible approach to an undo after an undo --branch.

Redo now restores undoredo.i's --branch field.  Undo after a undo --branch is
now an absolute undo.  See test cases.

Test Plan:
unit

Differential Revision: https://phab.mercurial-scm.org/D324
2017-08-11 18:05:03 -07:00
Felix Merk
5cd0a8ae43 undo: better docs
Strips docs of unnescerary info and sticks complex things behind --verbose flag.
In most cases hg undo and redo or hg undo --preview should be enough for the
user.  Also changes --index to --step, which seems clearer.

Differential Revision: https://phab.mercurial-scm.org/D287
2017-08-11 18:05:03 -07:00
Felix Merk
1041cbca21 undo: no argument redo
Changes redo to straight up undo the previous undo.  This is a bit trickier than
it may seem.  The previous redo capabilities are still covered in hg undo as
--index accepts negative numbers allowing you to step both forward and
backwards one step at a time.  The new redo reads the linear undo log to find
out where to undo to while updating the undo/redo index allowing you to continue
from where you left off.

Differential Revision: https://phab.mercurial-scm.org/D286
2017-08-11 18:05:03 -07:00
Felix Merk
a0591aa926 undo: preview interactive ui
Provide interactive preview.  undo -p now provides support of using arrow keys
and return to select state.  The interactive ui is set up to be generic so
potentially could be used for other commands.

Test Plan:
1. Running a bash script that sets up an interesting repo
2. hitting hg undo -p and trying every key combination
    Specifically: control-C still works, q quits, left goes forward,
    right goes backwards, return brings you to a state
3. running redo after preview and return
4. running undo a few times and then using undo -p to go back forward
5. going out of bounds both up and down
6. hitting other random keys during hg undo -p
7. running hg undo -p with other flags

Differential Revision: https://phab.mercurial-scm.org/D263
2017-08-11 18:05:03 -07:00
Felix Merk
223355effd undo: add --index and redo support to preview
Adds --index handling for --preview.  With the added handling, preview also
works for redo.  In order to bypass template logic, we simply change the
"undoredo.i" file and reset it afterwards.

Differential Revision: https://phab.mercurial-scm.org/D207
2017-08-11 18:05:03 -07:00
Felix Merk
070ee13318 undo: basic --preview
Allows for hg undo --preview to see smartlog like preview of what undo will do.
This will be neccesery before a general roll-out so users can see what undo will
do.  This first iteration only shows what "hg undo" will do, not redo and not
--index.

Differential Revision: https://phab.mercurial-scm.org/D206
2017-08-11 18:05:03 -07:00
Zhihui Huang
587971de01 p4fastimporter: handle blob commits
Summary: Since a blob commit does not associate with a p4 changelist, while a regular commit mirrored a p4 change has a p4 changelist number, p4fastimporter needs to know how to handle a blob commit. The solution here is to get p4basecl number (which tells it which changelist number it's based on when creating this blob commit) from the blob commit node, and import from there.

Test Plan:
$ cd ~/facebook-hg-rpms/fb-hgext/test
$ python ../../hg-crew/tests/run-tests.py test-p4fastimport-blobcommit.t
$ python ../../hg-crew/tests/run-tests.py test-p4*

All tests should pass

Reviewers: #idi, davidsp

Reviewed By: davidsp

Subscribers: medson, mjpieters

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

Tasks: 20141624

Signature: t1:5544046:1502405269:9f449550d60b9d29d8be464ab1cc98500bc60cad
2017-08-10 17:54:18 -07:00
Zhihui Huang
bf31927f4c p4fastimporter: blob commits - support lfs
Differential Revision: https://phabricator.intern.facebook.com/D5560829
2017-08-10 17:54:18 -07:00
Zhihui Huang
06ebaed0bb p4fastimporter: blob commits - support bookmark
Differential Revision: https://phabricator.intern.facebook.com/D5550722
2017-08-10 17:54:18 -07:00
Zhihui Huang
49930828ea p4fastimporter: blob commits
Differential Revision: https://phabricator.intern.facebook.com/D5542123
2017-08-10 17:54:18 -07:00
David Soria Parra
dde1b0d2d2 p4fastimport: decode special perforce characters in filenames
Summary:
Perforce encodes certain characters in filenames (see
https://www.perforce.com/perforce/doc.current/manuals/cmdref/filespecs.html)
We must decode this before we add it to Mercurial.

Test Plan:
  python ../../hg-crew/test/run-tests.py test-check* test-p4fastimport*

Reviewers: #idi, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, steaphan, medson, mjpieters

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

Tasks: 20133877

Signature: t1:5570533:1502010300:0ef3ce0c228c61e23396b5a8ac887ac8c65812ff
2017-08-10 15:49:15 -07:00
David Soria Parra
2917133886 p4fastimport: remove stale comment
Summary: remove stale comment

Test Plan: none

Reviewers: #mercurial, #idi, steaphan

Reviewed By: steaphan

Subscribers: steaphan, medson, mjpieters

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

Signature: t1:5570523:1501916483:e16b5dcd0445759d753fd47656e2bad2389b5825
2017-08-10 15:49:15 -07:00
Mihails Smolins
cf3cd8e4cb remotefilelog: change revset computation
Summary:
repo.revs cannot resolve aliased revisions such as 'top' or 'bottom', therefore
it is substituted by scmutil.revrange for any user provided inputs.

Test Plan:
* Test on www repo by running hg pull with remotefilelog.pullprefetch='bottom'(or any other aliased rev)
* Ensure that unit tests pass

Reviewers: simonfar, rmcelroy, durham

Reviewed By: durham

Subscribers: medson, mjpieters, #mercurial

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

Signature: t1:5602536:1502386617:b632f778da4ddef54d7283b60c7c1a24c6b38028
2017-08-10 10:39:08 -07:00
Mihails Smolins
029860b212 remotefilelog: change GC on repack keepset computation
Summary:
Now a set of changesets is computed using scmutil.revrange rather than
repo.revs because repo.revs cannot resolve aliased revisions such as 'bottom'
or 'top'.

Test Plan:
* Test on www repo by running hg repack with remotefilelog.gcrepack flag set and with bgprefetchrevs='bottom'(or any other aliased rev)
* Ensure that unit tests pass

Reviewers: simonfar, durham

Reviewed By: durham

Subscribers: medson, mjpieters, #mercurial

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

Signature: t1:5602139:1502379501:731fff866e16af7f3cbc1b9d80f84fe322e47d70
2017-08-10 08:39:34 -07:00