Commit Graph

421 Commits

Author SHA1 Message Date
Jun Wu
44c4a80415 pushrebase: deal with phase move correctly
Summary:
Previously we ignore "draft -> public" phase move, and new nodes returned by
the server may remain "draft" until the next pull. This diff records the
obsmarkers and updates phases of the new nodes correctly so they become
public without an extra hg pull.

Test Plan: Modified an existing testcase

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:4934720:1493076241:9b23da1140b68aece9e838c604e64611b3498794
2017-04-25 14:46:36 -07:00
Phil Cohen
eb2814985f resolve: add internal:dumpjson as an internal merge tool (as an extension, for now)
Summary:
This basically takes the last upstream version of my conflictinfo patch and makes it an extension, so we can get it out to FB/Nuclide users
a bit faster. @asriram has already been developing with this version as a personal extension for a couple of weeks.

I still plan to ship the upstream version through after the freeze ends -- when that happens, we can delete this extension. During the time the two
versions overlap, they shouldn't conflict. (The extension version will still run over the internal version until it's disabled, though.)

Review-wise, this is similar to the last upstream version, except it adds the "command" key that indicates which command generated the conflicts (based on which mutually-exclusive state file exists), and incorporates most of the feedback.

Test Plan: Added a test and ran associated tests.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, asriram, mjpieters

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

Signature: t1:4944709:1493148790:a4e798f5bd17ada767ae6c96fe8c8ab973960383
2017-04-25 12:46:28 -07:00
Stanislau Hlebik
8595e6160c logginghelper: log obsstore size
Summary: That's an interesting piece of information that we'd like to know.

Test Plan: Enable patched logginghelper.py extension and check that new field is logged

Reviewers: #mercurial, simonfar

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 17453793
2017-04-25 01:09:28 -07:00
Rodrigo Damazio Bovendorp
31b8b83011 chistedit: choose default revision just like histedit
This makes the default behavior consistent between "histedit" and "chistedit"
in picking the ancestor revision to use when none is specified.
2017-04-24 10:00:31 -07:00
Rodrigo Damazio Bovendorp
7f02e97a65 nointerrupt: allowing attendance to default to True
This lets us prevent interrupts by default, and only allow them for
the few commands we know are safe.
2017-04-24 10:00:31 -07:00
Rodrigo Damazio Bovendorp
fe81fd7cdc backups: small output improvements for backups extension
This allows us to turn off the obsolescence warning altogether, since we still
use strip together with obsolescence in some situations (e.g. changing the
narrowspec for narrowhg, in which case we "insert" revisions which were
previously not relevant in the middle of the change log and then have to
strip and re-create their children to repoint p1).
2017-04-24 10:00:31 -07:00
Stanislau Hlebik
fceac7d85b phrevset: return baseset instead of list
Summary:
There was a recent change in mercurial and revsets
shouldn't return lists anymore. This diff fixes it.

This diff also fixes git diff handling. It returned not even a list,
but a single rev number. Unfortunately it's not tested because we need to
mock conduit response.

Test Plan: arc unit

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

Subscribers: ikostia, kulshrax, mjpieters, #sourcecontrol

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

Signature: t1:4938930:1493051696:cfb278773e5932d5f38942b0a0ca49f018ec5083
2017-04-24 09:47:52 -07:00
Jun Wu
00a9465989 lfs: be compatible with filelog metadata
Summary:
This diff changes lfs `revision(raw=False)` output to include hg filelog
metadata. The LFS blob does not contain filelog metadata as before.

This hurts performance if there is a rename, or the binary starts with the
magic `\1\n`. But compatibility is greatly improved - it's now possible to swap
a non-lfs revision with mercurial rename to a lfs revision, and easier to be
compatible with remotefilelog (namely, remotefilelog defers filelog.add until
commit hash is known).

Test Plan: Modified existing test.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: rmcelroy, durham, mjpieters

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

Signature: t1:4906074:1492559513:09b25fc1026d4ce8fd784a044d6724f12e8bda45
2017-04-21 19:56:27 -07:00
Jun Wu
6cef30df92 absorb: do not invalidate fsmonitorstate
Summary:
@sid0 noticed absorb invalidating fsmonitorstate, causing `hg status` to be
slow. Unfortunately, `dirstate.rebuild` seems to be the only way to move
working directory parent without changing working copy, which is also used
by `hg reset` and removing state invalidation will cause `test-reset.t` to
fail. Fortunately, in absorb's case, it's fine to not invalidate fsmonitorstate
because no new status will occur outside ctx.files (`hg status` after absorb is
a subset of `hg status` before absorb).

Test Plan: `rt --extra-config-opt=extensions.fsmonitor= test-absorb*.t --chg`

Reviewers: #mercurial, sid0

Reviewed By: sid0

Subscribers: mjpieters, sid0

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

Signature: t1:4925426:1492796143:0d6cd4fd46ce130286d0b6ea5a01eadf350397b8
2017-04-21 19:47:00 -07:00
Durham Goode
cd53821465 warnings: remove deprecated nested usages
Summary:
Upstream Mercurial has enabled python deprecation warning in the tests, so
python 2.6 runs now complain about our use of context.nested(). The current fix
of marking all those functions with suppression decorators breaks the tests in
some environments since the suppression module can't be found unless it's
installed or the environment has been set up correctly.

Let's just get rid of our use of nested() and the nodeprecate module.

Test Plan: Ran the tests on centos7 with python 2.7

Reviewers: wez, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4920337:1492676584:1c26f2673c14e79793a3ee80c3281fd1bc76a313
2017-04-20 10:58:50 -07:00
Arun Kulshreshtha
02e5cc57ba tweakdefaults: allow hg update --merge without --nocheck
Summary: The --merge flag is relatively new; we shouldn't add --check if it is specified.

Test Plan: Unit test

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Tasks: 17490374

Signature: t1:4916396:1492647440:d9955931cb9177719a58325c08a715d4d51d1226
2017-04-19 17:20:23 -07:00
Arun Kulshreshtha
6065ceef3f fbamend: use unfiltered repo when clearing preamend bookmarks
Summary: Sometimes restack attempts to clear preamend bookmarks on hidden commits. This only happens when the user has a configuration error (typically inhibit is disabled) which would mess up other parts of restack. Nonetheless, there is no reason to crash here.

Test Plan: Disable inhibit, perform an amend, and run `hg restack`. Unit test is forthcoming.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Tasks: 16726367

Signature: t1:4856640:1491816803:56beeb11360a7a2f6bc6243069c562b08a015afc
2017-04-19 15:52:45 -07:00
Wez Furlong
04ee6433d4 warnings: squelch contextlib.nested DeprecationWarnings
Summary:
deals with the tests failing like this on my python 2.7 system:

```
+  /data/users/wez/facebook-hg-rpms/fb-hgext/hgext3rd/uncommit.py:144: DeprecationWarning: With-statements now directly support multiple context managers
+    with nested(repo.wlock(), repo.lock()):
```

Test Plan: arc unit

Reviewers: #mercurial, stash, simonfar, wez

Reviewed By: stash, simonfar

Subscribers: mjpieters

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

Signature: t1:4910040:1492593520:ff815c5dbed4a341e0a313cd7160b700d878ee2c
2017-04-19 03:28:23 -07:00
Simon Farnsworth
e31246ce99 rage: include klist output
Summary:
We're seeing a rise in the number of auth issues. As a first step,
let's have rage grab klist, so we can see if the user has a valid Kerberos
ticket for hg.vvv or not.

Test Plan: Run it and see https://phabricator.intern.facebook.com/P57315650

Reviewers: #sourcecontrol, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4907615:1492546856:969cab7b8deacf220c374d4c9e1b6e99f84ca059
2017-04-19 03:18:04 -07:00
Kostia Balytskyi
aeef0ad5cc compatibility: migrate from scmutil.vfs to mercurial.vfs.vfs
Differential Revision: https://phabricator.intern.facebook.com/D4908906
2017-04-18 14:42:33 -07:00
Wez Furlong
934dfaf08b templater: fixup for templater changes upstream
Summary:
The function signature for a number of functions relating to templating changed.

In addition, the templater layer now requires that template functions have been
registered via the decorator, otherwise a require attribute is missing and
things blow up.

Test Plan: arc unit.  rt.

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4908220:1492545033:66f089e03a6064ae96ca36f3abf99ecb6d48d422
2017-04-18 13:04:11 -07:00
Wez Furlong
7170cd6411 tweakdefaults: switch hg grep to use dirstate.walk
Summary:
previously, this was using .match() to find candidate names
and then reaching inside the dirstate._map to check the status of
the file.

This implementation uses the dirstate.walk instead, which returns a
map of filename -> stat information.

This approach works better with custom dirstate implementations, such
as eden, where a local map of the required information is not available
and where it would be suboptimal to request that information on
demand on a per-file basis.

Test Plan:
testing before and after this change:

`time hg grep eden foo` has a runtime of ~1.2 seconds.

If you have sqldirstate enabled, this change makes the runtime 3 seconds
compared to 2 with sqldirstate on and without this change.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, simpkins

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

Signature: t1:4903110:1492473495:ebe375f3e2533f6ae4ca7ea9a494f6feb9704f9e
2017-04-18 10:05:31 -07:00
Arun Kulshreshtha
a72a47d515 absorb: s/chunks/chunk
Summary: Noticed this minor gramatical error when using absorb.

Test Plan: Unit tests.

Reviewers: quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4887040:1492123047:dcae53cabd64f1df13d80a20953c712ce0aaaa09
2017-04-13 16:00:51 -07:00
Adam Simpkins
642dea7e2c fixcorrupt: automatically look back as far as necessary
Summary:
Update the fixcorrupt extension to look back as far as necessary in the revlog
to find a good entry.  Previously the user had to supply a good value using the
--checklen argument.  If --checklen was too small, fixcorrupt could end up
trying to truncate in the middle of a corrupted section of the revlog, which
would cause problems as it was still using corrupted data.

This change ensures that fixcorrupt always looks back far enough to find a good
entry.  We start by looking at the last 10 entries, and double that amount each
time the first item in the list is still bad.

Test Plan:
Used it to fix a corrupted fbsource repository where the corruption was 36
commits back.

Reviewers: #mercurial, quark, stash

Reviewed By: stash

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

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

Signature: t1:4874243:1492007518:7406b03a9967815a496a8c2fae394c5f21f7e60a
2017-04-12 14:09:22 -07:00
Durham Goode
4da0040f03 fastlog: fix ScmQuery request parameter name
Summary:
This was totally wrong and has been forever. I think we got lucky because the
server was serving from memcache mostly, which did not validate this parameter.

Test Plan:
Ran log before and after the change.

hg.real log wdc --config extensions.fastlog=../../facebook-hg-rpms/fb-hgext/hgext3rd/fastlog.py

Reviewers: #mercurial, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters, jeroenv

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

Tasks: 17327887

Signature: t1:4878633:1492030224:cf1b802345c7e00d1134ee81fbe9f271cf1a6752
2017-04-12 13:51:18 -07:00
Stanislau Hlebik
8f8cdc2d49 hgext3rd: cleanobsstore extension
Summary: See comments and docstring

Test Plan: arc unit

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: quark, mjpieters, #sourcecontrol

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

Signature: t1:4851138:1491589247:5ca750e45bcc9fc996c9d7c14e31cb5f24ea983f
2017-04-12 01:16:01 -07:00
Jun Wu
340750c4f4 pushrebase: send obsmarkers to client if client supports it
Summary:
Previously when the client has obsstore enabled, and the server has obsstore
disabled, clients won't get the obsmarkers, which is suboptimal. This diff
makes the server send obsmarkers in that case.

Practically, this means people will no longer need to run `strip` after landing
a diff in this repo.

Note: `test-pushrebase-manifests.t` is somehow flaky about the empty lines. I
guess they are not related to the change. But the test change is not 100%
reproducible.

Test Plan: Added a new test case

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: rmcelroy, ikostia, stash, mjpieters

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

Signature: t1:4865150:1491895844:afbc3079a40a9a9fa9af1eab4eeaca91091e8d2d
2017-04-11 13:21:27 -07:00
Jun Wu
11cd7af681 lfs: add a fast path for filelog.size
Summary:
Previously, `filelog.size` requires loading the lfs blob in memory. This
makes it unnecessary.

Test Plan: Run existing tests.

Reviewers: #mercurial, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

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

Signature: t1:4861358:1491923349:f1d2fe5656158854e1dd50987ea3db64a9793db6
2017-04-11 13:20:58 -07:00
Jun Wu
de5e7c6545 fixcorrupt: new extension to fix corrupted repo
Summary:
We sometimes get reports about corrupted repos. Usually the corrupted part
is just at the end of changelog or manifest.

Truncating them manually works but people need to be very careful. This
extension is like the manual fix but automatized.

Test Plan:
Run `hg debugfixcorrupt --no-dryrun` on a reported corrupted repo and check
it truncates files correctly and the repo passes `hg verify` afterwards.

Reviewers: #mercurial, durham, stash

Reviewed By: stash

Subscribers: stash, rmcelroy, durham, lcharignon, mjpieters

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

Signature: t1:3408396:1491897232:fc17a105124b568963441adfec97e26735df3258
2017-04-11 13:19:42 -07:00
Adam Simpkins
fdc2c3e6f9 extutil: add unit tests for runbgcommand
Summary:
Add some basic unit tests for extutil.runbgcommand().

This also changes the behavior to throw an OSError if we fail to execute the
process, instead of a subprocess.CalledProcessError.  This matches the behavior
of the subprocess module when it fails to execute the command.

Test Plan: Ran the tests.

Reviewers: stash, quark

Reviewed By: quark

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

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

Signature: t1:4864999:1491874918:c03edafe02af217e41c28a770137bfd72bcbba9b
2017-04-11 11:25:40 -07:00
Pallav Shinghal
3ded80a5c7 rage: fix hg sparse entry in hg rage output
Summary: The `hg sparse` entry in `hg rage` output is consistently `(Failed. See footnote [1])` due to the `sparse` function being called with the wrong signature.

Test Plan:
Ran `hg rage` in <reponame>. Output contained:

```
hg sparse:
---------------------------
%include .hgsparse-<reponame>
[include]

[exclude]

```

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: quark, mjpieters, dawidp

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

Tasks: 17269067

Signature: t1:4861832:1491869628:0abc55eb5308a83effe78943dba8d13e9f12d616
2017-04-11 07:19:26 -07:00
Jun Wu
dc051c4791 tweakdefaults: fix common incorrect PAGER config automatically
Summary:
People may mistakenly set PAGER=less, which will lose colors and does not
have the friendly "exit if there is less than one screen" feature.

Detect that and add "-FRQX" automatically.

Test Plan:
Unset all my `pager.pager` configs, and export `PAGER=less`, verify `hg sl` has
the desired pager and colors are fine.

Reviewers: wez, #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4864822:1491870110:246f906d41b5ac72ecfdda487aa8f412a90cf2cb
2017-04-10 17:38:22 -07:00
Adam Simpkins
df34a531e6 extutil: add a new runbgcommand() function
Summary:
Add a new `runbgcommand()` function, which is similar to `runshellcommand()`
but does not require running the command through a subshell.  Running commands
through a shell is a very common place for security vulnerabilities if care is
not taken to correctly escape all arguments.

This changes `runshellcommand()` to be implemented using `runbgcommand()`.
This does change the behavior of `runshellcommand()` slightly:
`runshellcommand()` now throws an exception if it failed to execute the
command.  Previously the Unix implementation silently swallowed most
exceptions.  This also fixes the unix implementation to properly wait on the
intermediate child process.  Previously it would remain as a zombie process.

Test Plan: Ran all unit tests.

Reviewers: #mercurial, stash

Reviewed By: stash

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

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

Signature: t1:4856672:1491813879:367e1f42b9aa7797542f0d02da99f46683b80df8
2017-04-10 11:44:32 -07:00
Jun Wu
2f1756608e lfs: remove manifest walk in prepush hook
Summary:
`ctx.files` should contain changed files from both p1 and p2. There is no
need to walk the manifest, which could also be painfully slow for large
repos. So the manifest walk got removed.

Test Plan: `arc unit`

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4856552:1491639067:8080f9bc7e246a8d36fcc3504716e9c95ee24fcf
2017-04-10 11:22:54 -07:00
Jun Wu
46d44c8b07 lfs: use non-chunking spec format if possible
Summary:
The "chunking" feature is not specified by [the current Git LFS standard](21e1695220/docs/spec.md).

Therefore avoid using it if possible - if there is only one chunk, use the
standard specification (`https://git-lfs.github.com/spec/v1`).

An upload message is slightly changed to be more accurate.

Test Plan: Changed existing tests

Reviewers: davidsp, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4856527:1491638822:1c6f555b706e7bb22dd9090afa156f2161bf9f7f
2017-04-10 11:17:48 -07:00
Jun Wu
38632025a9 lfs: add bundle support
Summary:
This diff adds bundle support for lfs:

  - Let `hg bundle` use changegroup3 instead of changegroup2 to record revlog
    flags.
  - Hook related functions so `hg -R bundle.hg` works with LFS.

Test Plan: Added a test

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4856335:1491638660:d56ba54ea5f59262f009418b9c7e48c8f2a25ed6
2017-04-10 11:11:37 -07:00
Jun Wu
cdc9accca5 lfs: do not store mercurial filelog metadata in lfs blobs
Summary:
Per discussion with @davidsp, it's better for LFS to not store Mercurial
filelog metadata, which is currently used to store rename information. That has
many advantages:

  - Large blobs could be reused across renames
  - No need to special handle files starting with `\1\n`
  - P4 LFS server implementation is much easier
  - remotefilelog LFS support is easier and cleaner

That said, the rename information is stored as lfs metadata using the
non-standard `x-hg-copy`, `x-hg-copyrev` keys. So they still exist and are
functional.

The disadvantage is that rename gets no longer hashed, which is probably fine.


Test Plan: Added a test

Reviewers: davidsp, #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: jsgf, rmcelroy, stash, mjpieters, davidsp

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

Signature: t1:4849764:1491580506:1d80ad476b9cbd6773843cb52aee6745f478a0b0
2017-04-07 18:29:35 -07:00
Stanislau Hlebik
1c6b1b495d fastpartialmatch: catch write exceptions
Summary:
We saw a couple of weird exceptions during clone. Since read path is wrapped
in try/catch, let's wrap write path too. If exception happened then let's
remove index completely since it will be rebuilt on the next pull.

Test Plan:
arc unit

Unit-tests are actually almost useless in this case.
So I added fake exception raises and checked that it behaves as expected.

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 17153898

Signature: t1:4843497:1491536062:8e72a4ad4fffe5625866a90b3b89acda75211ce8
2017-04-07 02:21:54 -07:00
TJ
9b91e50f77 edrecord: allow specifying a different editor for chunk selection
Summary:
a user may want to use a special-purpose 'editor' to do chunk selection, but not
have to use that same 'editor' to write commit messages and resolve merge conflicts

This is hacked together to make it work.  I'm not super familiar with the correct way to do this in python.

Test Plan: added test case

Reviewers: rmcelroy, simonfar, most, quark

Reviewed By: quark

Subscribers: mjpieters

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

Tasks: 15728734

Signature: t1:4832207:1491519433:82a3e62d5ae03f456abe97caf1bd352a02fe35c3
2017-04-06 16:49:27 -07:00
Jeroen Vaelen
8bc1e221b6 hgext: rename show.py to fbshow.py to prevent upstream collision
Summary:
Upstream recently introduced show as an extension. Because the file
name is the same and it lives in core, extensions.show now points to it.

It behaves differently. Rename our extension. In the next diff I'll update
facebook.rc to make extensions.show point to our version.

Test Plan: Ran tests

Reviewers: durham, #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4845959
2017-04-06 13:36:18 -07:00
Jun Wu
de84869150 lfs: cleanup user-facing messages
Summary:
The diff cleans up messages shown to the user. It makes verbose messages
gated by `if ui.verbose`, and simplifies some words.

The resulting user experience is, when there is no large file involved, lfs
shows nothing. When there are largefiles being downloaded or uploaded, show
progress bar if it takes long. The progress bar is the only user visible
output from lfs by default.

Test Plan: `rt test-lfs.t`

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:4813297:1491213089:c9ec363eb65df4c85282c90b230da3321b93b5e0
2017-04-05 15:58:56 -07:00
Jun Wu
b1cdf3f0e6 lfs: remove setup.py
Summary:
The logic in `setup.py` is now simple enough to be moved to `reposetup`.
`setup.py` becomes unused and gets removed.

Test Plan: `rt test-lfs.t`

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4813193:1491212154:0238ea448269b0e5516c927c1fa989d6d9130d4a
2017-04-05 15:49:08 -07:00
Jun Wu
f0b6b81970 lfs: simplify remote blobstore.logic
Summary:
Previously, the remote blobstore could be either `git-lfs` or `dummy`. The
application code does not really care, it only wants a "remote" blobstore.

This diff adds a factory method and makes `git-lfs` and `dummy` stores private.

The `@staticmethod get(vfs)` interface is also removed as it's duplicated and
unnecessary - as long as mercurial calls `reposetup`, the blob store objects
are set, and they cannot be missing.

The error message about an unsupported store is also changed to be consistent
with mercurial style. A test was added to test the error.

Test Plan: `rt test-lfs.t`

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:4813023:1491382755:b9d8ec6518141d0ba8263e16c53f430ce80c39f0
2017-04-05 15:48:10 -07:00
Jun Wu
039e232a0f lfs: fix an error caused by a wrong merge resolution
The change should belong to D4812131. But the change gets lost during a wrong
merge resolution. This patch fixes it.
2017-04-04 16:22:31 -07:00
Jun Wu
00e6156a07 lfs: let blobstore.local and blobstore.remote take an repo argument
Summary:
Previously local takes a path, remote takes a ui. This diff makes it more
consistent.

Test Plan: `rt test-lfs.t`

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4812884:1491211049:6b3709e3b7e054b11d4a3f9a92e7921fe55de9fa
2017-04-04 16:13:16 -07:00
Jun Wu
ead899b26b lfs: cleanup option passing
Summary:
For options passed to revlog, use `repo.svfs.options`. For objects, use
`repo.svfs.objname`.

Unused assignments and unused functions are removed.

Test Plan: `arc unit`

Reviewers: #mercurial, simonfar, rmcelroy

Reviewed By: simonfar, rmcelroy

Subscribers: rmcelroy, simonfar, mjpieters

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

Signature: t1:4812131:1491210581:004297885b8b09d23b58e0a3bee147910615ce62
2017-04-04 16:10:29 -07:00
Jun Wu
6d19f83af9 lfs: add a "bypass" config option
Summary:
The bypass option limits lfs's functionality to only skip hash checks. It is
intended to be used server-side, to make it more predictable - the server
never interacts with the lfs blob service.

Test Plan: Added a test case

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, simonfar, mjpieters

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

Signature: t1:4811828:1491301114:c2e3c4200ce4cc84b9c5872a8b9a040176bb002a
2017-04-04 16:08:36 -07:00
Jun Wu
6c51d725bd errorredirect: log and fallback to old error handler when appropriate
Summary:
Previously errorredirect swallows errors in some cases. This diff makes it
more robust.

  - Always log commandexception. `blackbox.log` will probably catch it.
  - Print the trace if the handler script cannot be executed.
  - Print the trace if the handler script exits with non-zero.
  - Add exception for the Ctrl+C case, to not pollute user's terminal.

Test Plan: Added some test cases

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4824767:1491299807:3fd863cb99ce71a6c2b59643b0c89eece7985d4b
2017-04-04 10:27:30 -07:00
Stanislau Hlebik
ebde6a9a79 gitlookup: fix lookup if not string is passed
Test Plan:
arc unit

Note: making sure that int is passed in repo.lookup(...) is not easy.
For example `hg log -r 1` does not pass an int value to repo.lookup().
But `hg bundle` actually does it so use `hg bundle` to verify that fix works.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters, #sourcecontrol

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

Signature: t1:4825996:1491292671:9bd0897205dff93cb6dee75498827b3826f894da
2017-04-04 01:04:40 -07:00
Jun Wu
08d017f89e absorb: move to a package
Summary:
The ideal interactive mode couldn't be implemented trivially. Move `absorb`
to a directory so we can add related, but decoupled components as separate
files.

Test Plan: `make local`

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4813909:1491211561:e9c40b1242c9b74230c0b8937723a2d4548e22c3
2017-04-03 10:40:31 -07:00
Jun Wu
abb7a83354 lfs: make tests stronger
Summary:
This diff makes the `test-lfs.t` much more stronger. It reveals a lot of core
hg issues in this area. I'll send patches to fix them all.

Regarding on lfs, there are some changes:

  - An existence check in its push hook was added. Otherwise pushing a revision
    with rename will cause crash.
  - The "read" processor is responsible for downloading blobs, and translate
    raw revision to lfs text. It should always return lfs text. But it may
    return raw revision text on error currently. That error handler was
    removed to avoid further damage.


Test Plan: Added new test cases. I also added `hg verify` to sanity check things are good.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4792641:1490868946:8f09c84dc9ebda3889d6a1ea04c49a06acbf38a3
2017-03-30 16:41:46 -07:00
Adam Simpkins
36dcf86559 phabstatus: fail gracefully if necessary arcrc settings are missing
Summary:
If the user does not have necesary credentials defined in their arc
configuration, catch the KeyError and convert it into an ArcConfigError.

The existing call sites in the phabstatus and arcdiff extensions catch and
handle ArcConfigError, but not generic KeyErrors.

This also fixes the phabstatus warning messages to end with a newline.

Test Plan: Added a unit test.

Reviewers: #sourcecontrol, quark, simonfar, wez, rmcelroy

Reviewed By: wez, rmcelroy

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

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

Tasks: 17002914

Signature: t1:4800977:1490847078:e18bba042e3ff57100e0a7b25c610b5cad17fa2e
2017-03-30 11:55:39 -07:00
Stanislau Hlebik
2fc45e80f1 gitlookup: fix gitnode() template and revset
Summary:
Neither gitnode() template nor gitnode() revset worked on the server. They
both called `hg.peer(repo, {}, 'default)` and since 'default' is not a valid
url these calls failed. To fix it let's wrap `localrepo.lookup()` and call
local repo instead of peer repo if we can't find default path.

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 16848812

Signature: t1:4794488:1490795600:24269507f24613883406f0c1838fce302f86df58
2017-03-29 07:13:41 -07:00
Phil Cohen
0e0f112b48 pushrebase: prepopulate the post-lock bundle manifest cache
Summary:
Previously we copied the old bundle dirmancache entries into the new bundle
dirmancache entries, but that missed any manifests that weren't already in the
cache. Since we have a list of bundle revs that are guaranteed to be needed
during the rebase, lets read them before the lock and force them into the cache
after the lock.

Test Plan:
Ran all pushrebase tests with a block like:

```
bundle.manifestlog[mfnode].read()
realmf = newdirmancache[''][mfnode].read()
if realmf.text() != mfdict.text():
     raise Exception("cache invalid")
```

...to verify the manifest we cached is the same as can be read from disk.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4774728:1490736995:6e20d69181b4df76aeb800ea246a0dae0a4b802d
2017-03-28 17:18:59 -07:00
Phil Cohen
5afc9c89dd pushrebase: set the manifest revlog fulltextcache
Summary:
This fetches the old master's full text before the lock is taken, and puts it in
the revlog._cache field so we don't have to read the full delta chain when we go
to read the latest master revision. This minimizes the amount of time we have to
spend processing the manifest during the first write.

Test Plan:
Ran all tests using a block like the following:

```
        for mfnode, mfdict in bundlerepocache.iteritems():
            bundle.manifestlog[mfnode].read()
            existing = newdirmancache[""][mfnode].read().text()
            new = mfdict.text()
            if new != existing:
                raise Exception("Cache failed")
```

...which raises if the data we were about to pull from the cache was different from what we were reading from the manifest before.

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: durham

Subscribers: rmcelroy, quark, mjpieters

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

Signature: t1:4774716:1490735677:85bac79999d607f5554d090978d0ee6787f5e11c
2017-03-28 17:18:59 -07:00
Phil Cohen
948d47064a pushrebase: avoid diff'ing manifests for conflict detection
Summary:
Previously, pushrebase detected if it was ok to rebase a commit by diff'ing the
original common ancestor of the bundle and master with the new master. This
required reading both manifests. To improve performance, let's read the
changelog files list instead, which is much, much faster.

Merge commits don't have a files list that is representative of the actual diff,
so fall back to manifest diff in that case.

Test Plan: ran tests

Reviewers: #mercurial, stash, durham

Reviewed By: stash, durham

Subscribers: stash, mjpieters

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

Signature: t1:4774694:1490601056:18f78ab7c3e35a1beb2a7775160271a3311e38bb
2017-03-28 17:18:59 -07:00
Jun Wu
07d5d0f836 lfs: fix a pyflakes issue 2017-03-28 15:43:52 -07:00
Jun Wu
eeeb0210ae lfs: allow blobstore to be outside the repo
Summary:
Previously `lfs.blobstore` must be a relative path. If an absolute
blobstore path is set, it will traceback because vfs audit fails:

```
  File "hg/mercurial/revlog.py", line 1356, in _processflags
    text, vhash = writetransform(self, text)
  File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore
    blobstore.local.get(self.opener).write(storeid, chunk)
  File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write
    fp = self._opener(self.filename(storeid), 'w+', atomictemp=True)
  File "hg/mercurial/vfs.py", line 344, in __call__
    self.audit(path)
  File "hg/mercurial/pathutil.py", line 64, in __call__
    raise error.Abort(_("path contains illegal component: %s") % path)
  Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18
```

That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs`
to avoid the issue. The `lfsvfs` also did the correct filename check (the
old `re.match` check will not match the whole string), so `blobstore.local`
could be simplified a lot.


Test Plan:
A new test case was added to make sure absolute blobstore path works. I also
did some cleanups for the test file to de-dup hgrc, and avoid writing files
outside `$TESTTMP`.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters, remi

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

Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-28 15:41:59 -07:00
Jun Wu
adfd01303d perftweaks: remove hardlink tweak
Summary:
The core mercurial could now detect filesystem for Linux and OSX, and enable
real hardlink support for their major filesystems. So the hardlink tweak is no
longer needed.

Test Plan: `arc unit`

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4776139:1490601097:0be66e2a0111b71a932b453ef4e1e75fed8276e6
2017-03-27 10:43:01 -07:00
Jun Wu
c3fd525bf8 lfs: fix tests
Summary:
A bunch of modifications to get the test pass with the new lfs code.

- Move `lfs` to `hgext3rd`. The code was supposed for hg-core. For now, we do
  them in fb-hgext to speed up the process
- Remove the windows test, which is not supported by `run-tests.py` and is
  duplicated with `test-lfs.t`.
- Do import `mercurial.i18n._` correctly.
- Change some i18n logic a bit so it's more translator-friendly.
- Change `revlog.RevlogError` to `error.RevlogError`.
- Avoid direct symbol import of `mercurial.util.bytecount`, which will fail the
  upstream importchecker test.
- Fix various lint issues like lines being too long etc.
- Document lfs config options.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4772216:1490401458:1ad3c18ab80e1d31085d0b6b4c630e62a7dc7930
2017-03-24 19:01:42 -07:00
Simon Farnsworth
ccf6655f3a fb-hgext: fix test-check-code.t failures
Summary: test-check-code.t now dislikes our docstrings. Fix them up

Test Plan: Run the test locally on my devserver

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4773908:1490394131:9d9e5f85b4243119a3615044605bcc5abdecbe4f
2017-03-24 15:22:31 -07:00
Kostia Balytskyi
b6a03bd647 pushrebase: get page size form mmap instead of resource
Summary: `resource` is UNIX-only module, we can't use it if we want `pushrebase` to work on Windows. As we only use `getpagesize()`, we can also do `mmap.PAGESIZE` instead.

Test Plan: - apply change on Linux, see that they do not introduce any new failures

Reviewers: #sourcecontrol, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4762553:1490294453:fdcb2e9caa38f5d14eafc6ff36a1bb7d9429b6e9
2017-03-23 11:51:56 -07:00
Jeroen Vaelen
b7e3010b10 perftweaks: enable hardlink backups
Summary:
Hardlink backups are significantly cheaper than file copies. They are
disabled in core because they are problematic on CIFS.

Test Plan: Ran the tests.

Reviewers: #sourcecontrol

Subscribers: mjpieters

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

Tasks: 16406729
2017-03-21 13:05:28 -08:00
Jun Wu
1e30f781e0 dirsync: rename in-repo config file to .hgdirsync
Summary:
It will allow sparse to not ignore the file, and is more consistent with
other special files.

Test Plan: Updated existing tests

Reviewers: rmcelroy, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4738766:1490032493:199f3fef9c74a137b16ae7637b87de625ca5115d
2017-03-20 10:55:43 -07:00
Stanislau Hlebik
7f8418f995 newhiddencache: record obsinhibit
Summary:
We forgot one more store file: obsinhibit.
This diff adds it

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 16558840

Signature: t1:4714522:1489717585:fdabf3c5f0c11310708ba3d78df39cbaa04a3afa
2017-03-20 01:38:06 -07:00
Stanislau Hlebik
f0b136f93b newhiddencache: add knob to enable fasthiddencache
Summary: Add a knob to easily disable/enable fasthiddencache functionality

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 16558840

Signature: t1:4714509:1489717542:d022201fd7c17863ffe664ae4115b8d1d896da3c
2017-03-20 01:38:06 -07:00
Stanislau Hlebik
32199b95b4 newhiddencache: restore back
Summary:
This diff just restores the code that was reverted before. Next diffs will fix
it

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 16558840

Signature: t1:4714397:1489717436:9777d783d1443dea46460450e8f3da862c147483
2017-03-20 01:38:06 -07:00
Jun Wu
5404cd9a3c codemod: get rid of ui.backupconfig
Summary:
The upstream will remove `ui.backupconfig` soon(tm). Let's migrate our code
to `ui.configoverride` to avoid future breakages.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:4734300:1489803960:a4101d6bc95ab62af67f0076b8e21f57cf926e13
2017-03-17 19:42:50 -07:00
Jun Wu
c133169b8b dirsync: read ".dirsync" in the working copy as part of its config
Summary:
It'd be nice to have dirsync config in the repo, since it's better synced, and
easier to be modified.

Test Plan: Added a test case

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:4732054:1489793650:ca6c63ef47a1d9ebd181fbaee5554975801324eb
2017-03-17 16:35:08 -07:00
Jun Wu
ca4723ad22 patchrmdir: new extension to workaround rmdir kernel issues
Summary:
We have encountered a kernel issue where `rmdir` a non-empty directory may race
with other things and hang in kernel for a long time.

This patch changes `os.rmdir` to avoid `rmdir` non-empty directories. It is
written in Cython calling the low-level `readdir` libc friends to make overhead
minimal.

Test Plan: Added a new test

Reviewers: #sourcecontrol, clm, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, simpkins, osandov, mjpieters

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

Tasks: 16647532

Signature: t1:4716711:1489627923:7c7432748c1fd8c070ce257bd172feebd3807f65
2017-03-15 18:55:48 -07:00
Mateusz Kwapich
1bcc10919d fbmetaedit: intoduce the extension
Summary:
It's just copy-paste from my mutable-history patch series that ended up as
persistent hotfix.

The wrapping logic is very simple: it redirects '--fold' calls to original
metaedit and handles all the rest.

Test Plan:
Included a big copy-pase from test-evolve.t preserving only cases that were
executing metaedit and modified for the smaller test repo (the metaedit tests
were at the end of evolve test file).

Reviewers: #sourcecontrol, quark, simonfar

Reviewed By: quark, simonfar

Subscribers: rmcelroy, quark, mjpieters

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

Signature: t1:4708017:1489524494:d682aab857e8422bb1a23adc22dddfb9f505b6b3
2017-03-15 07:40:26 -07:00
Jun Wu
02d79f722e codemod: replace repo.join to repo.vfs.join
Summary: Upstream has deprecated `repo.join`. Let's use `repo.vfs.join` instead.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4704018:1489462391:532b15c24faa33d584f25bb9382c1ff4b2c0c483
2017-03-13 20:51:37 -07:00
Jun Wu
3440ef0a0d chistedit: use an alternative way to disable color
Summary:
The upstream has changed how color works. `chistedit` seems to use a very hacky
way to disable color. Let's use a safer and simpler approach.

Test Plan: Run chistedit with hg-committed.

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4702229:1489446376:f0c7b4d31eb62bb6aea4cfeb13d78be8c219374c
2017-03-13 16:07:21 -07:00
TJ
10a278c273 edrecord: fix binary change comment bug
Summary: The poorly formatted docstring was causing an extra blank line to be inserted both before and after the content

Test Plan: Changed a binary in an hg repo. Committed interactively using the editor. Made sure that there were no blank lines

Reviewers: rmcelroy, quark, simonfar

Reviewed By: simonfar

Subscribers: most, asriram, mjpieters

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

Tasks: 15728734

Signature: t1:4684549:1489269897:faecd381c98e8c2b9884f9bacd18dfc32ee77758
2017-03-13 10:34:38 -07:00
Durham Goode
b0c4b9a793 fbamend: unlink rebasestate after transaction
Summary:
Previously, the rebase logic itself would unlink its state file. Now that the
state file is part of the transaction, it gets serialized at the end of the
transaction, even if it was unlinked midway through the transaction. This
affects fbamend because it wraps various rebases in a higher transaction.

Ideally we would add support to the mercurial transaction framework to allow
marking a file as deleted halfway through the transaction, but this patch will
fix the tests until we get that upstream.

Test Plan: Tests now pass

Reviewers: kulshrax, #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4696578:1489348040:b12104b2519d69dab98d2076f640f9f3157036e2
2017-03-12 13:11:47 -07:00
Durham Goode
932cc0e5b1 grepdiff: fix to match upstream
Summary:
Upstream changed the format from ['diff ...\n', 'file1\nfile2\nchunks...'] to be
['diff ...\nfile1\nfile2\n', 'chunks...'] in 199440c7d1f49752. So grepdiff needs
to be updated.

Test Plan: Tests now pass

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4695911:1489282635:920e88fecc5d6d4660d1d21289d1d07e26c93315
2017-03-12 12:49:18 -07:00
Stanislau Hlebik
4b2050d789 logginghelper: add logging.configoptions
Summary: Let's add option that contains a list of other config options to log.

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

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

Signature: t1:4681336:1489171115:dddd27032e945f37fcc846a511e3aaa9e83d29d3
2017-03-12 12:01:45 -07:00
Durham Goode
33a1d6afdc fix: update manifest.diff usages to handle match arg
Summary:
Upstream has added a new match argument to manifest.diff() and removed the
existing manifest.matches() function, so we need to update our internal usage.

A separate diff will update treemanifest to support the new diff() api.

Test Plan:
Ran the tests, some still fail because of the upstream changes, but
future patches fix those.

Reviewers: #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D4677002
2017-03-12 10:14:35 -08:00
Arun Kulshreshtha
7174632e3c fbamend: add --towards flag to hg next
Summary: This diff adds a `--towards` flag to `hg next`. This flag tells `hg next` to always proceed in a linear fashion towards the specified commit. This is useful in situations where the user has a very branchy stack. For example, if the user has a local stack with several branches, each with a feature bookmark at the top, if the user wants to go up a particular stack they can do so with something like `hg next 3 --towards bookmark`.

Test Plan:
Here is an example of basic usage. Also see test file.

```
$ hg debugbuilddag "+5 *2 +2"
$ hg book -r 4 feature1
$ hg book -r 7 feature2
$ hg up 0
$ hg sl
o  92eaf3  debugbuilddag  feature2
|  r7
|
o  8bbe84  debugbuilddag
|  r6
|
o  914970  debugbuilddag
|  r5
|
| o  bebd16  debugbuilddag  feature1
| |  r4
| |
| o  2dc09a  debugbuilddag
| |  r3
| |
| o  012414  debugbuilddag
|/   r2
|
o  66f7d4  debugbuilddag
|  r1
|
@  1ea734  debugbuilddag
   r0
$ hg next 3 --towards feature1
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
[2dc09a] r3
$ hg sl
o  92eaf3  debugbuilddag  feature2
|  r7
|
o  8bbe84  debugbuilddag
|  r6
|
o  914970  debugbuilddag
|  r5
|
| o  bebd16  debugbuilddag  feature1
| |  r4
| |
| @  2dc09a  debugbuilddag
| |  r3
| |
| o  012414  debugbuilddag
|/   r2
|
o  66f7d4  debugbuilddag
|  r1
|
o  1ea734  debugbuilddag
   r0
```

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:4695861:1489325959:1145a29ba87f99d07ede1e81415804723dc48818
2017-03-12 10:09:12 -07:00
David Soria Parra
83b308aa75 chistedit: make chistedit compatible with current tip 2017-03-10 14:11:11 -08:00
Adam Simpkins
143d13f6e3 perftweaks: revert new computehidden cache functionality
Summary:
The computehidden caching functionality doesn't seem to be correct, and breaks
my repository.  "hg log -r head()" now incorrectly reports some obsolete
commits, which causes various mercurial commands to crash.  (They incorrectly
think that these commits aren't obsolete, but their parents are obsolete, which
breaks things.)

This diff reverts the new functionality until it gets fixed.

Test Plan: Confirmed that "hg-dev pull" no longer crashes in my repository.

Reviewers: #mercurial, stash, durham, quark

Reviewed By: quark

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

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

Tasks: 16558840

Signature: t1:4676573:1489008220:f730da69ec0f8d7220cad16ea6956944cfeb670d
2017-03-08 13:42:01 -08:00
Arun Kulshreshtha
9df08f6f42 fbamend: ensure that restack obsmarkers have correct metadata
Summary: Previously, we were relying on the `allowunstable` extension to wrap various instability-inducing commands and set the appropriate config option to cause the `tweakdefaults` extension to write the correct operation metadata into the obsmarkers produced by each respective command, causing commits to show up as "amended as", "rebased as", etc, in `hg sl`. Since the operation name was based on the command being run, if a user ran `hg amend --fixup` instead of `hg restack`, for example, smartlog would say "amended as" instead of "rebased as". This diff fixes the problem by always setting the operation to "rebase" during a restack.

Test Plan:
1. Create a stack of two commits.
2. Amend the bottom one without `--rebase`.
3. Run `hg amend --fixup` with the `fbamend.userestack` config option enabled.
4. Run `hg sl --hidden` and observe that the rebased commit is marked as "rebased".

See test file for an example.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Tasks: 16529478

Signature: t1:4670066:1488991076:58c139c50a1aab2aa4fc7e28b1efd57a67bdfb08
2017-03-08 11:30:14 -08:00
Jun Wu
84143416ed sigtrace: new extension provides stack traces on signal
Summary:
Sometimes the hg process gets stuck, and we want to get the stack traces to
learn what it's doing. It's not a big issue if gdb can be used with python
debugging support [1]. However, that feature could not be easily set up on
OS X. This extension will make debugging on OS X easier by providing the
Python stack traces on SIGUSR1.

It's similar to OpenStack's "GuruMeditationReport" feature [2].

Unlike `contrib/showsstack.py`, this extension uses SIGUSR1 instead of SIGQUIT,
and writes to a file, instead of stderr, and prints all threads, instead of
just the current one. So it's more practically useful. We may want to
replace `showstack.py` eventually.

[1]: https://wiki.python.org/moin/DebuggingWithGdb
[2]: https://wiki.openstack.org/wiki/GuruMeditationReport

Test Plan: Added a new test

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4660938:1488927878:c751856681816a739160c361ed5cc10bab325000
2017-03-07 17:25:40 -08:00
Durham Goode
6434f61b55 sparse: update hg.updaterepo wrapper to match upstream
Summary:
Upstream changed the api of this function. Let's add args and kwargs to cover
future api changes.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Signature: t1:4667282:1488910879:7db5764704dd345946f7f933e7e2c4a8fd77b699
2017-03-07 10:27:05 -08:00
Durham Goode
1cb65599a2 opener: replace repo.*opener with repo.*vfs
Summary:
Upstream has deprecated repo.*opener properties, so we need to switch to the
equivalent vfs apis to prevent us from being spammed with deprecation warnings.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4667252:1488911019:efc3adf21f723151f1ee3b21b91fe62ea3c7b259
2017-03-07 10:27:05 -08:00
Arun Kulshreshtha
6b191cfb3e rage: fix and update 'hg rage' output
Differential Revision: https://phabricator.intern.facebook.com/D4664999
2017-03-07 01:27:12 -08:00
Simon Farnsworth
21802b82da histedit: set blockedtag when invoking user process
Summary: Improve dev_command_timers by removing some unknown_system sources

Test Plan:
testinprod

But also run-tests.py -j40

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir, mjpieters

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

Signature: t1:4658516:1488812254:474cf4033fc8e59c3eadf41bf9b3218a6ff4c236
2017-03-06 06:58:53 -08:00
Stanislau Hlebik
ba7fe90440 hgext3rd: newhiddencachekey extension
Summary:
Computing cache key can be quite slow (100ms and even more). Instead let's use
a simpler cache key: size + mtime of phaseroots, obsstore and changelod and
whether changelog write was delayed.

Test Plan:
1) arc unit

2) Run test-newhiddencache.t

3) Run upstream unittest with extension enabled.
python run-tests.py --extra-config-opt extensions.newhiddencachekey=/home/stash/facebook-hg-rpms/fb-hgext/hgext3rd/newhiddencachekey.py -j20

Verify that there are no failures except for those that show that new extension were added.
Note: also need to comment out debug output in the extension

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, quark, mjpieters

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

Signature: t1:4604811:1487958882:702ea8fdee16def674db97344832936d53f0cd9d
2017-03-06 01:18:58 -08:00
Stanislau Hlebik
68889ae8f4 fastpartialmatch: add amended commits to the index
Summary:
Upstream mercurial doesn't run hooks for temporary amended commits
(see https://bz.mercurial-scm.org/show_bug.cgi?id=3501 and
c2ca20984e3c9f30d73f0f35c35904b64edbd692). No other hook contains info about
temporary amended commits.

Let's wrap localrepository.commit() function and add missing commits inside
this wrapper.

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

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

Tasks: 16387175

Signature: t1:4634950:1488399457:1d299c6ad3cfd418dda32a7ec20c60290f8d7778
2017-03-02 01:14:09 -08:00
Stanislau Hlebik
0e16b9b84d checkmessagehook: use reposetup to setup a hook
Summary:
It makes it easier to set up a hook - just enabling the extension will enable
the hook.

Test Plan:
Run perl script



  system("echo 1 >> 1");
  system("hg add 1");
  system("hg ci -m"."\x80");
  system("hg ci -m"."\x01");
  system("hg ci -m ok");

make sure only one commit was created

Reviewers: #sourcecontrol, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Tasks: 16212973

Signature: t1:4604980:1487944300:8e4e7f340c746237b47773fc81759025e97b919e
2017-03-02 01:05:19 -08:00
Stanislau Hlebik
f008b056b4 fastpartialmatch: do not use fastpartialmatch in bundlerepos
Summary:
bundlerepo adds new commits that are not present in fastpartialmatch index.
Without this diff any access to the commit from bundle fails if
fastpartialmatch.raiseifinconsistent config option is set.

Let's not use fastpartialmatch in bundlerepos

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 16394593

Signature: t1:4635368:1488393506:15b8f6a9fddabe681de7fd1296bbfafb9512f558
2017-03-02 00:53:09 -08:00
Stanislau Hlebik
098f1ee4b6 fastpartialmatch: remove changectx.__init__() wrapper
Summary:
Turned out that wrapping `changectx.__init__()` doesn't give any performance
benefits but instead it breaks initializing of changectx. For example, if
there is a commit which revision number N is a prefix of another commit A then
`hg log -r N` outputs commit A instead of commit N. Let's get rid of this
wrapping.

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 16394593

Signature: t1:4635311:1488393427:eae091a0d155df336adbb122f2881a28e95ba6b6
2017-03-02 00:37:17 -08:00
Scott Ragan
598c76eb7b creates hg sparse --clear-rules option
Summary:
The sparse profile in .hg/sparse currently only can grow, removing rules from this must either be done manually (by editing the file), or one by one using the the -d/--delete command line switch.

To mirror the hg sparse --import-rules command line, hg sparse --clear-rules removes local includes/excludes rules.

Test Plan: fb-hgext/tests/test-sparse-clear.t

Reviewers: marianomartin, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Tasks: 16073155

Signature: t1:4609102:1488028035:f5f7b7420d911667fb4a07ac770b7e0480a76977
2017-02-27 10:53:50 -08:00
Durham Goode
f1d376b16f debuginhibit: remove warning if inhibit is not enabled
Summary:
We have users who don't use inhibit, so printing this message clutters their UI.
Let's just move this debug.

Test Plan: yolo

Reviewers: kulshrax, #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4614036:1487986024:6945b057aae62fc7a9fded9474d47ba134496e5a
2017-02-25 15:28:15 -08:00
Durham Goode
2bc65bd9db hiddenerror: fix out of bounds error
Summary:
The current code checks if the filter error reports a rev number, and if it does
tries to convert it to a node. If the 'number' is actually just a short form of
a hash that happens to be all digits, then it may be a number greater than the
size of the changelog, so we need to not attempt to access it in the changelog,
otherwise we get an IndexError.

Test Plan: Added a test, it failed before with a weird error

Reviewers: #mercurial, kulshrax

Reviewed By: kulshrax

Subscribers: mjpieters

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

Signature: t1:4613988:1488027938:4f5ffcb07aeecbaf59cad20fb3a592dd92ed2beb
2017-02-25 15:26:19 -08:00
Stanislau Hlebik
fa422ea77d fastpartialmatch: remove useless code
Summary:
`changectx.__init__()` always returns None since it's an `__init__()` func.
Next comparison is useless

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters, #sourcecontrol

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

Signature: t1:4608204:1487928626:7205b9e7d9c931692337c3a1aa33451104b05fcd
2017-02-24 05:34:22 -08:00
Jun Wu
635683876d codemod: fix compatibility with the upstream revset refactoring
Summary:
`mercurial.revset` was recently split into `revset + revsetlang + smartset`.
Update our code accordingly.

D4604848 has fixed the `revsetlang` part. This patch fixes the remaining
`smartset` part.

Also fixes some test failures introduced by D4547080.

Test Plan: `arc unit`

Reviewers: #mercurial

Subscribers: jeroenv, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4595417
2017-02-23 13:09:59 -08:00
TJ
01fdb5bf0d edrecord: introduce interactive commits with an editor interface
Summary: creating a mercurial extension so that `hg record` functionality can be used via a text editor (instead of interactive command prompt or curses menu)

Test Plan: `$ run-tests.py test-edrecord.t`

Reviewers: durham, skreyen, most, #sourcecontrol, asriram, simonfar

Reviewed By: simonfar

Subscribers: quark, rmcelroy, simonfar, mjpieters, #nuclide

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

Tasks: 15728734

Signature: t1:4547080:1487842609:8855e35010cac3b6d2b136a80d7effa369eb1da8
2017-02-23 11:27:52 -08:00
Stanislau Hlebik
31e3ca4aa3 fb-hgext: make compatible to upstream changes
Summary:
c6cf3ac8c9bb811afa5b6eb5b69b29d128a7476a made revset API change.
This diff fixes our extensions

Test Plan: arc unit

Reviewers: #sourcecontrol, mjpieters, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4604848:1487851636:1c7618e9050f607e2d8b47ed495a349b877ed48a
2017-02-23 04:08:18 -08:00
Martijn Pieters
1752a2ba84 Send a single string (normal) to scuba
Summary: The data was being sent to scuba, but then ignored altogether. Turn this into a single string instead.

Test Plan: arc unit

Reviewers: #sourcecontrol, andrasbelo

Reviewed By: andrasbelo

Subscribers: mjpieters, andrasbelo

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

Signature: t1:4598196:1487784582:8952e0e386325d1635029aab2b9d97e9284376ea
2017-02-22 14:36:28 -08:00
Stanislau Hlebik
47e9e5588c hgext3rd: add checkcommitmessage
Summary:
Let's add a script that can be used as a commit hook to prevent bad commit
messages from happenning.

Test Plan:
Run the following perl script:
  system("echo 1 >> 1");
  system("hg add 1");
  system("hg ci -m"."\x80");
  system("hg ci -m"."\x01");
  system("hg ci -m ok");

Output:
  fbcode/1 already tracked!
  transaction abort!
  rollback completed
  abort: decoding near '': 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte!
  non-printable characters in commit message
  transaction abort!
  rollback completed
  abort: pretxncommit hook failed

Make sure that commit is made with "ok" message, but there are no commits with
bad commit messages

Reviewers: #sourcecontrol, tja

Reviewed By: tja

Subscribers: tja, mjpieters

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

Tasks: 16212973

Signature: t1:4597432:1487761552:cf38eabf93374b0ec2feb653dd70033de25e6e0e
2017-02-22 04:50:24 -08:00
Jun Wu
8a407d22ea hiddenerror: fix Python 2.6 compatibility
Python 2.6 does not support `'{}' % x`, so change it to `'{0}' % x`.
2017-02-17 16:34:59 -08:00
Jun Wu
78b2c91c65 profiling: remove the extension
Summary:
The profiling extension is to log interactive time.

The upstream change 459366b580cf breaks the profiling extension as it could
no longer wrap `maybeprofile` in time. And @simonfar's
`ui.timeblockedsection` is going to be a superior solution. So just remove
the profiling extension and its tests.

Test Plan: Checked that the extension is not enabled in our config files.

Reviewers: simonfar, #mercurial

Subscribers: mjpieters, simonfar

Differential Revision: https://phabricator.intern.facebook.com/D4583087
2017-02-17 16:27:19 -08:00
Jeroen Vaelen
0ecf1322c6 fastlog-hg: use smartset to merge multi-path results
Summary:
97d0be4019ac in core broke the fastlog extension for multi-path
queries. We did not have a test to catch it. It was reported as broken by a
user.

Test Plan:
```
$ ../../hg/tests/run-tests.py test-fastlog.t
```

Reviewers: #sourcecontrol

Subscribers: mjpieters

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

Tasks: 16154586
2017-02-17 09:01:50 -08:00
Mateusz Kwapich
7b859c681d whereami: add extension
Summary:
This command will allow us to expose simple api to all automation checking
working copy parent.  It's meant to be overridden by our wrapper to read the
dirsate directly without shelling out to hg (see D4454504 )

Test Plan: see tests

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4454502:1485441135:09902c6437a7af55dfa5c97e3165681de687231f
2017-02-17 16:01:02 +00:00
Stanislau Hlebik
3ba3866802 fastpartialmatch: add generation number
Summary:
fastpartialmatch index may be incorrect if fastpartialmatch extension was
disabled, then new commits were added and then fastpartialmatch was
enabled back. We need to detect this situation and rebuild the index in
this case.

One approach would be to use _handleinconsistentindex() function to mark index
as invalid. There are a couple of drawbacks to this approach:
1) It requires more significant code changes
2) The output may still be incorrect if hash with the same prefix was added while fastpartialmatch was disabled.

Another approach would be to use header version from index files
(see class _header). That's even worse because we'll need to bump index
version in the code whenever we disable fastpartialmatch.

Third approach would be to use changelog mtime + size as a validation key but
then we need to ensure partialmatch index is written after changelog.

Instead I suggest to use generation numbers. It's just a number in the config
and in the special file inside partialmatch index directory. If the
two doesn't match then index is incorrect and needs to be deleted. The biggest
drawback to this approach is that we need to bump generation number each time
the extension is enabled. I think it should be fine because the one who enables
extensions usually understands it and he or she will bump the generation number.

Test Plan: arc unit

Reviewers: #sourcecontrol, durham, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Signature: t1:4571926:1487263035:53419c9ca4e344127f391ac19c1071a826fea3f1
2017-02-16 10:18:22 -08:00
Stanislau Hlebik
bc7415f5e7 fastpartialmatch: use _realopener
Summary:
User reported failures because revlog.opener doesn't have `exists` function.
The reason is that sometimes opener is wrapped inside the function.
Let's use _realopener instead

Test Plan: arc unit

Reviewers: #sourcecontrol, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Signature: t1:4571659:1487267797:a950ab7c88d75573df64ec1964755c054307c7ea
2017-02-16 10:17:54 -08:00
Adam Simpkins
33b2fbc0bc fbconduit: fix error handling in gitnode() revset
Summary:
Don't let errors propagate out of the gitnode() revset.  Always report errors
in gitnode() as a translation failure, rather than letting exceptions propagate
up and crash mercurial.  The code was previously only catching internally
generated ConduitError exceptions, but it can also throw HttpError exceptions,
and the underlying httplib code can throw its own exceptions as well as
socket.error exceptions.

This also fixes the test code to use an ephemeral TCP port rather than assuming
port 8543 will always be available.  Using a fixed TCP port in test code is a
very common way to cause bogus failures if the tests are run in parallel.
(For instance, testing multiple repositories in parallel on the same build
host.)

Test Plan:
Added unit tests that check the behavior when the server returns a 500 error,
and when the server refuses the connection entirely.

Reviewers: quark, durham, rmcelroy

Reviewed By: rmcelroy

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

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

Signature: t1:4556871:1487062142:b58d770d46c975d44933bec08cfce8acb25ff16b
2017-02-15 12:35:06 -08:00
Jun Wu
763e41cee8 smartlog: work better with repos where there is no master
Summary:
Previously, smartlog use `tip` as the fallback master, and prompts:

  warning: there is no master changeset locally, try pulling from server

if master is `tip`.

That makes smartlog less friendly for external users. This patch removes the
prompt and changes the fallback master to the last public revision so it
works out-of-box.

Test Plan: `arc unit`

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:4555346:1487036530:35a5fa65d5419e7324d3203fa52de9a82b8132e3
2017-02-14 17:25:12 -08:00
Arun Kulshreshtha
e71276b303 hiddenerror: make error message configurable
Summary:
This diff makes the following modifications to the (former) `hiddenhash` extension:

- Makes the error messages configurable, allowing us to easily change the error messages in `facebook.rc`.
- Renames the extension to `hiddenerror`, since the primary feature is now the configurable error messages rather than using a hash in the message.
- Changes the method by which the extension wraps the `changectx` constructor. The old method of wrapping would result in errors in code paths that in `context.py` that performed `isinstance()` checks on contexts.

Test Plan: To test arc patch this extension into your `facebook-hg-rpms` and enable it for a test repo. Then, attempt to access a hidden node. You should see the default error message defined in the extension. Setting `hiddenerror.message` and `hiddenerror.hint` should allow you to customize the messages. See test file for examples.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, durham, mjpieters

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

Tasks: 15896355

Signature: t1:4548140:1487063552:06395c1eaaa83b00ead8e80e2cd8f9d13f7d08e2
2017-02-14 11:15:19 -08:00
Kyle Lippincott
13f723e8dd fbconduit: add conduit_protocol global: makes test-check-pyflakes.t happy 2017-02-14 02:11:09 -08:00
Martijn Pieters
3455bf3ae6 Allow sparse profiles to contain comments
Summary: Sometimes you want to be able to justify why a line is in a sparse profile. Support empty lines and comments (starting with a hash).

Test Plan: Run the test runner

Reviewers: #mercurial, rmcelroy, durham

Reviewed By: durham

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

Tasks: 15993301

Signature: t1:4537617:1486687441:18a00b65df244b573bab095809fb1fbb57e21d71
2017-02-13 04:17:51 -08:00
Arun Kulshreshtha
f46e6eb4da debuginhibit: print out inhibited nodes by default
Summary: If `hg debuginhibit` is run with no arguments, print out a list of inhibited nodes. This is similar to how `hg debugobsolete` works and will assist with debugging.

Test Plan: Run `hg debuginhibit` in a repo with inhibited nodes. (This can be tested by either stripping some test commits and then updating back to them, or by manually inhibiting the commits with `hg debuginhibit`.) A list of inhibited nodes should be printed. See test file for an example.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

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

Tasks: 16004717

Signature: t1:4541514:1486722366:10b4232830ed88931bd6ac610972114743797192

Revert Plan:
2017-02-10 11:28:33 -08:00
Stanislau Hlebik
e553fcf9af hiddenhash: fix centos6 build
Summary:
To get rid of this DeprecationWarning:

    --- /data/hgbuild/facebook-hg-rpms/fb-hgext/tests/test-hiddenhash.t
    +++ /data/hgbuild/facebook-hg-rpms/fb-hgext/tests/test-hiddenhash.t.err
    @@ -10,5 +10,7 @@
       $ hg debugbuilddag +1
       $ hg debugobsolete 1ea73414a91b0920940797d8fc6a11e447f8ea1e
       $ hg log -r 0
    +  $TESTTMP/hiddenhash.py:33: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
    +    match = re.match(r"hidden revision '(\d+)'", e.message)
       abort: hidden changeset 1ea73414a91b!
       [255]


let's not access `.message` and use str(e) instead

Test Plan:
arc unit,
Will test on centos6 soon

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:4521398:1486470861:e39e4639346d0f1f2e4a69fc38ccf34fbc432df6
2017-02-07 04:51:20 -08:00
Stanislau Hlebik
c4a1147f39 sampling: fix comment
Summary:
HG_SAMPLING_FILEPATH was renamed to SCM_SAMPLING_FILEPATH long time ago.
Let's update the comment

Test Plan: Not tested

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4507708:1486141731:8a96ac74006cf9d240ad4cbbff928fe49fe71cb3
2017-02-07 00:39:26 -08:00
Arun Kulshreshtha
da74a12dac hiddenhash: make hidden commit errors more user friendly
Summary:
Previously, when a command tried to access a hidden revision without the `--hidden` flag, the user would get the following error:

```
abort: hidden revision '0'!
(use --hidden to access hidden revisions)
```

With this extension, the error is now:

```
abort: hidden commit b8144197c244!
```

This way, novice users aren't tempted to immediately re-run the command with `--hidden`, which may have undesired results. It also makes it much easier to find the commit in question in `hg sl --hidden` since by default smartlog does not show rev numbers.


Test Plan: Attempt to access a hidden commit, observe new error message as seen above. Note that in the test file the word "changeset" is present instead of "commit" due to the lack of the `dialect` extension in the test.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Tasks: 15747879

Signature: t1:4506065:1486122372:d82ebd488a00d1958c235f733a9455111954c116
2017-02-03 12:26:22 -08:00
Stanislau Hlebik
fa28a07404 perftweaks: fix failure
Summary:
turned out that transaction can be None in some cases.
Let's just write to the cache in this case.

Test Plan: arc unit

Reviewers: #sourcecontrol, durham, andrasbelo

Reviewed By: andrasbelo

Subscribers: andrasbelo, mjpieters

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

Tasks: 15862906

Signature: t1:4507653:1486133933:de0997ef1724ba1082c3597ea64aab760f670b47
2017-02-03 07:22:07 -08:00
Arun Kulshreshtha
3c80b1176b fbamend: make inhibit hook fire after rebase
Summary:
Recently @rmcelroy discovered that attempting to rebase a single commit in the middle of a stack results in the rest of the stack being marked as unstable. See https://fb.facebook.com/groups/sourcecontrol/permalink/1207767375939547/ for full example.

It turns out that the inhibit extension's post-transaction hook that would ordinarily inhibit the rebased (and thus obsolete) commit, and thereby hide the instability, was not firing in this case. This was similar to a previous problem with `hg next --rebase` wherein `--continue`'ing a rebase with conflicts would result in visible instability for the same reason. In both cases, the problem appears to be that `rebase` doesn't actually create a transaction, so of course the post-transaction hook doesn't fire.

The solution for `hg next --rebase` was to add a (nearly) empty transaction after the rebase call to trigger the hook. This diff just makes this the default behavior for `hg rebase` so that the hook is always called.

Test Plan:
See new test file. Basically, create a situation like:

```
o  e5d56d  debugbuilddag
|  r3
|
| o  c175ba  debugbuilddag
| |  r2
| |
| o  220949  debugbuilddag
|/   r1
|
o  1ad88b  debugbuilddag
   r0
```

Perform `hg rebase -r 1 -d 3`, which rebases commit "r1" onto "r3", which would ordinarily make "r2" unstable. Instead, the result should be as below, with no visible instability because "r1" is inhibited.

```
o  738e8e  debugbuilddag
|  r1
|
o  e5d56d  debugbuilddag
|  r3
|
| o  c175ba  debugbuilddag
| |  r2
| |
| x  220949 (Rebased as 738e8e)  debugbuilddag
|/   r1
|
o  1ad88b  debugbuilddag
   r0
```

Reviewers: rmcelroy, #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, rmcelroy

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

Tasks: 15697758

Signature: t1:4491870:1486033128:45b8e9a72af1e88ab78484ddef47a788d1aca7b5
2017-02-02 11:49:44 -08:00
Stanislau Hlebik
1632aa627b fastpartialmatch: fix the build
Summary: Sort the output to fix tests on different platforms

Test Plan: arc unit on mac

Reviewers: #sourcecontrol, simonfar, ikostia

Reviewed By: simonfar, ikostia

Subscribers: mjpieters

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

Signature: t1:4501449:1486050577:3041dc3c3691f48e39a0e9e05b1f97954a6d88e2
2017-02-02 08:00:55 -08:00
Stanislau Hlebik
47060cb7d0 fastpartialmatch: trigger rebuilds if there were too many unsorted entries
Summary:
If we have too many unsorted entries then finding matching revisions is
slower. To fix it we will rebuild partial index from time to time.
_findcandidates function marks index as need-to-be-rebuilt if it notices
index file with too many unsorted entries. Then _changegrouphook rebuilds
the index.

Test Plan: arc unit

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4494617
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
470276319f fastpartialmatch: use bisect to quickly find matching revisions
Summary:
Since we have some of the nodes sorted we can now use bisect to quickly find
matching nodes.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4494419
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
01b8e8e509 fastpartialmatch: add header
Summary:
Append header to each fast partial match index file. For now it contains
version number and number of sorted entries in the file.
File is ignored if version number from file is different.

Test Plan: arc unit

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4488417
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
c28363dc2e fastpartialmatch: sort the nodes during rebuilding
Summary:
We'll add bisect algorithm soon.
Let's sort the nodes first during index rebuilding

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4488263
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
79d4a8903d fastpartialmatch: handle strips correctly
Summary:
strip may change revision numbers of many nodes at once.
It's better to rebuild index in case of strip.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474710
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
591b66079d fastpartialmatch: pretxnchangegroup hook
Summary:
This hook builds index if it's not present and it appends new entries
from the changegroup.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474704
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
3c58c2dbc4 fastpartialmatch: wrap revlog._partialmatch and changectx.__init__
Summary: These two functions actually use fastpartial index to resolve revision for a node.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474658
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
e76fcd369f fastpartialmatch: add commit hook
Summary:
Add commit hook to append new entries to the index.
It uses the same transactions as revlogs.
Do not append entries if index is not built (i.e.
if _partialindex does not exist). This is to ensure that we either
have complete index or none at all. Besides next diff will add
hooks to build index after pull if it doesn't exist.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474654
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
144ba285fb fastpartialmatch: initial commit
Summary:
Index to make node partial match fast i. e. speed up matching of partial hashes like f9bbd5.

This is an initial diff and it doesn't add any useful functionality, just debug commands.

Storage format is simple. There are a few files (at most 256).
Each file contains entries:



  <20-byte node hash><4 byte encoded rev>


Each entry represents a commit (node).
Name of the file is the first two letters of the hex node hash. Nodes with the
same first two letters go to the same file. Nodes are NOT sorted inside the file
to make appends of new nodes easier.
Partial index should always be correct i.e. it should contain only nodes that
are present in the repo (regardless of whether they are visible or not) and
rev numbers for nodes should be correct too.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474642
2017-02-02 05:12:10 -08:00
Arun Kulshreshtha
d7c143274c debuginhibit: add debuginhibit extension
Summary: Add a new extension to assist with debugging issues with the inhibit extension. Adds the `hg debuginhibit` and `hg debugdeinhibit` commands to manually inhibit/deinhibit commits as well as config options to print out the nodes being inhibited and truncated stack traces of each call site. I mostly made this into an extension so that it would be easy to debug inhibit issues from any user by just asking them to run their command with the appropriate `--config` flag.

Test Plan: See test file. Enabling the `debuginhibit.printnodes` and `debuginhibit.printstack` functions should result in the relevant nodes and stack traces to be printed whenever nodes are inhibited and deinhibited.

Reviewers: durham, rmcelroy, #mercurial, mitrandir, simonfar

Reviewed By: simonfar

Subscribers: mitrandir, mjpieters

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

Signature: t1:4485659:1485985964:e6920b67450942c706c9523e9df48b4093b26d69
2017-02-01 15:17:04 -08:00
Arun Kulshreshtha
4a81b50bc3 fbamend: return early on split/fold error
Summary: Although the split and fold commands usually abort on error, in some cases they simply write to stderr and return a nonzero exit status. Previously, the wrappers in fbamend would expect failures to result in an abort, and therefore didn't return early. This resulted in restack errors when this was not the case -- notably in the case of folding a commit with itself. This diff fixes the problem by returning early on error.

Test Plan: Attempting to fold a commit with itself (i.e., `hg fold --exact . .`) fails with an error message instead of crashing.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Tasks: 15704338

Signature: t1:4493029:1485986404:17186b47786cf79c735b33adbb19de79ac75a5be
2017-02-01 15:14:17 -08:00
Arun Kulshreshtha
37e275d052 fbamend: move bookmarks after split/fold
Summary: Previously, if a user ran split or fold on commits with bookmarks on them, those bookmarks would remain on the original commit instead of the new split or folded commits. This behavior was unexpected and confusing because it meant the obsolete commit would remain visible and the user would be forced to manually move the bookmark. This change makes split and fold automatically move any bookmarks on the old commits onto the newly created commits.

Test Plan: Run `hg split` or `hg fold` on a commit or set of commits with one or more bookmarks, and observe that the bookmarks are updated to point to the newly created commits. See tests for examples.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Tasks: 15595449

Signature: t1:4490655:1485986009:858f099d3f95c6a45fe8b119d4f8d376b87652b7
2017-02-01 15:14:17 -08:00
Durham Goode
6b981a083a perftweaks: fix noderev cache for non existent nodes
Summary:
In certain situations, like infinitepush, the noderev cache builders would try
to save a node that didn't exist in the repo. This caused an exception. Now we
check each node before we attempt to resolve it to a rev.

Test Plan: Added a test. It failed before, and passes now.

Reviewers: #mercurial, andrasbelo

Reviewed By: andrasbelo

Subscribers: andrasbelo, mjpieters

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

Signature: t1:4494848:1485964835:986d4fe3e29404cac22e4acf7d88c3715fcb51b9
2017-02-01 08:03:49 -08:00
Durham Goode
5d9152387e uncommit: don't lose copy information of remaining files (issue5403)
This is an import of a bugfix in upstream evolve by Martin.

As reported in the issue, "hg uncommit" would lose copy information of
the files that remained in the commit. The problem was simply that the
a dict of copies was iterated as "src, dst in copies.items()" where it
should have been "dst, src ...".
2017-02-01 02:17:40 -08:00
Durham Goode
5da804759f perftweaks: increase noderev cache coverage
Summary:
Previously the noderev cache only covered the branchmap. These days remotenames
and phases are also doing a lot of node->rev look ups, so let's add them to the
noderev cache as well.

Test Plan:
Compared hg book before and after the change. Noticed a significant
perf increase.

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4487962:1485871615:634d95f61e916d81440a0f440010912af5ae6a13
2017-01-31 06:11:25 -08:00
Arun Kulshreshtha
d9d96358f5 allowunstable: allow hg record in the middle of a stack
Summary: This is basically the same as `hg amend -i` but since allowunstable operates at the command function level we need to explicitly whitelist this command. Note that I've set the obsmarker metadata to "amend" so that commits affected will be marked as "Amended as XXX" in smartlog. I don't think any other `hg record` flags other than --amend create obsmarkers so this should be OK.

Test Plan: Run `hg record --amend` in the middle of a stack and observe that it works now.

Reviewers: durham, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, reedriley

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

Tasks: 15705764

Signature: t1:4466338:1485424744:442604ce2089298f0724c27025502a3602113401
2017-01-26 10:24:16 -08:00
Arun Kulshreshtha
63ffce24fb fbamend: abort on hg restack --hidden
Summary: There is no valid reason to run `hg restack --hidden` (and this will cause unexpected behavior) so disable it.

Test Plan: `hg restack --hidden` now aborts. Added check to unit test.

Reviewers: rmcelroy, #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 15615216

Signature: t1:4463934:1485386049:9836ec970d7c3e11c7dfaed21aa0ce8b58013294
2017-01-25 15:48:12 -08:00
Arun Kulshreshtha
d1693cf7c4 rage: annotate hidden nodes in hg sl
Summary: Use `{hsl}` smartlog template to show label hidden nodes in `hg pasterage` output.

Test Plan: Example pasterage output: P56992404

Reviewers: #sourcecontrol, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4452488:1485222832:5adabafd7d0d55bf76b11684c7d1f03d6681f225
2017-01-23 17:56:38 -08:00
Mateusz Kwapich
2d3a634a86 py3: replace pycompat.getenv with encoding.environ.get
Summary: Following the replacement in core.

Test Plan: test-rage.t passes now

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4441823:1484921100:b1c8e1c0aef1196b7a8009a919e6d1fa3e2eb06c
2017-01-20 06:23:56 -08:00
Arun Kulshreshtha
19887fc8fa arcdiff: use absolute paths
Differential Revision: https://phabricator.intern.facebook.com/D4440103
2017-01-20 00:24:45 -08:00
Arun Kulshreshtha
b703374248 smartlog: make split successor labels work correctly
Summary: The template keyword for split was not producing output because obsmarkers with multiple successors were being filtered out.

Test Plan: Correct "Split into XXX, YYY" labels appear in smartlog. Tests have been added for all of the obsolescence-related smartlog template keywords.

Reviewers: #sourcecontrol, rmcelroy, durham

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4396453:1484880307:bfdc60385e42fee169ff2f0ec4f85dd0747b55c9
2017-01-20 00:24:45 -08:00
Arun Kulshreshtha
50c7f6c256 fbamend: add automatic restacking to split and fold
Summary: Automatically rebase unstable commits left behind after a split or fold in the middle of a stack. Previously, users had to run `hg restack` to fix their stacks after the fact. This change also fixes the issue identified in t14560234 whereby the old stack (entirely obsolete) stack would be left visible after splitting or folding a head commit due to the inhibit extension not correctly deinhibiting the old stack.

Test Plan: Create a stack of commits and perform `hg split` or `hg fold` on a commit (or set of commits) that have descendants. After the operation these commits should be rebased, preserving the linearity of the stack. See unit tests for specific test cases.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14560234, 15266009

Signature: t1:4432833:1484880689:1e07e421c8871dfef8bd016454aaed5a88a4a7d1
2017-01-20 00:24:45 -08:00
Adam Simpkins
63b7bb19c5 templates: fix help messages for template keywords
Summary:
Many of the template keywords in our extensions were being registered
incorrectly, causing their help output to be rendered incorrectly in the
"hg help templates" output.  The ones in smartlog.py were particularly bad, as
most of them showed only their description, without displaying the name of the
template.  In smartlog.py only singlepublicsuccessor was being displayed
correctly, because it's docstring explicitly included it's own name at the
start.

This fixes all of our extensions to consistently use the
registrar.templatekeyword() decorator to register the keywords.  This decorator
automatically prefixes the help message with the keyword name.  The
mercurial/extensions.py code will explicitly check to see if an extension
contains an "templatekeyword" attribute, and if so it will register any
keywords contained in this registry after calling extsetup().

Test Plan:
Added new unit tests to check the output of "hg help templates" for the
affected keywords.

Reviewers: #sourcecontrol, kulshrax, ikostia, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, net-systems-diffs@, yogeshwer, mjpieters

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

Signature: t1:4427729:1484831476:17b478a5e867dfc3f85402588c381bf8b1831107
2017-01-19 12:52:54 -08:00
Ryan McElroy
a702adbf6b phabdiff: make tasks regex more lenient
Summary: Let people put #, t, commas or no, etc!

Test Plan: existing and new tests

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, ullrich

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

Tasks: 15467918

Signature: t1:4411027:1484264937:cdc2452ac3ba920c153d3e0317972433da188a8e
2017-01-13 14:15:41 +00:00
Arun Kulshreshtha
db1e6df35f fbamend: silently drop --dest in restack instead of aborting
Summary:
The remotenames extension automatically adds a --dest option to `hg rebase`, which causes
restack to abort. Instead, we should just drop the 'dest' key and proceed.

Test Plan: Attempt to use `hg rebase --restack` in fbsource when the current bookmark is tracking a remote bookmark.

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Tasks: 15422257

Signature: t1:4399846:1484084585:4a6ec907032e7d8b1388980870b6d72cb560829f
2017-01-10 13:53:43 -08:00
Simon Farnsworth
a8da24f626 statprofext: remove dead file
Summary: Upstream Mercurial now has native support for statprof, rendering this file useless.

Test Plan: Remove statprofext.py* from my installed hg, confirm it still works. Build fb-hgext and run tests, confirm no new failures

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

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

Signature: t1:4397926:1484066120:0c1469d838a91a65fb57ecc858675256087e2c48
2017-01-10 10:10:58 -08:00
Thomas Jacob
dc2e79ae3f tweakdefaults: make --phabdiff use shortdate on --quiet as in default blame
Summary: Added some tests for this also

Test Plan: arc unit in fb-hgext

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 15360841

Signature: t1:4397881:1484066348:1b9fb24a30a9962de0dad858f4d57956a2c91dc4
2017-01-10 08:48:02 -08:00
Arun Kulshreshtha
041eae0180 fbamend: edit hint to mention hg restack instead of hg amend --fixup
Summary: To encourage people to learn about and use `hg restack` (which is a more general fixup tool), tell users about it instead of `hg amend --fixup`. I wasn't sure whether to advertise it as `hg rebase --restack` or just `hg restack`, so I've included both.

Test Plan: Do an amend in the middle of a stack and observe the new wording. Unit tests reflect changed wording.

Reviewers: durham, #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4390111:1483962208:46951c8f5e4c499840b0b4b0ee8ac1e1b6c14ca9
2017-01-09 11:09:02 -08:00
Stanislau Hlebik
dd1bfa42b8 phabdiff: precompile regexes
Summary:
I got the following profile results when profiling smartlog:

{P56936293}

It suggests that regex compiling takes too much time. I tend to think that
profiling is inaccurate in this case because with this diff I didn't get any
noticable speed up. But this diff won't do any harm.

Test Plan: arc unit

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4387265:1483724595:43de3c694109be2d4343d8ebdbc7ab79aa9edb04
2017-01-09 01:37:48 -08:00
Jun Wu
d185b8e43b sshaskpass: do not import mercurial
The sshaskpass is not only a mercurial extension, but also a script that
runs separately, in which case it cannot import mercurial modules. So let's
fallback to os.environ.
2017-01-05 17:04:34 +00:00
Jun Wu
79a8df7ff6 morestatus: suggest --clean for unfinished update state
Summary:
Without `--clean`, the user may not be able to abort cleanly.

Also, change "erase" to "discard" to be more consistent with the official
language. "changed" is replaced by "changes" as it looks like a grammar
mistake.

Test Plan: Updated existing tests

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4377376:1483464655:f695fd643509d7fabb88298bd1004727ee64ef76
2017-01-03 16:25:52 +00:00
Stanislau Hlebik
b3cc0d5817 pushrebase: close bundle file
Summary: bundle file should be closed to ensure that all the temporary files were deleted

Test Plan: arc unit

Reviewers: #sourcecontrol, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4377148:1483451990:2a1362d9e524a54ffedad8f2bc09fc622efe8ad4
2017-01-03 06:01:57 -08:00
Stanislau Hlebik
5f58694748 unit-tests: fixes
Summary:
test-check-code.t was updated in core mercurial so we have to fix it in
fb-hgext

Test Plan: arc unit

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Signature: t1:4377208:1483451688:bc382cdab07c6d6127d67c902458a2ccfa1373d1
2017-01-03 05:59:55 -08:00
Arun Kulshreshtha
bcc5f95132 smartlog: remove --limit option
Summary: The --limit option was carried over from the option list for `hg log`. However, it doesn't do anything in smartlog, so this diff removes it from the option list.

Test Plan: `hg smartlog --help` no longer shows `--limit`.

Reviewers: #mercurial

Subscribers: mjpieters

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

Tasks: 15186221
2016-12-22 12:07:45 -08:00
Martijn Pieters
5561f26b7b sparse: add rule import feature
Summary:
Make adding a set of rules efficient.

Currently buck autosparse writes directly to .hg/sparse, clobbering any
existing manual rules or profile settings. This is not optimal.

The command-line of hg sparse is too limited at the moment to add rules in any
other way (only one new rule per call!). The --import-rules option lets us
bulk-import and efficiently decide wether or not a refresh is needed.

Test Plan: arc unit

Reviewers: #sourcecontrol, andrasbelo

Reviewed By: andrasbelo

Subscribers: andrasbelo, mjpieters

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

Signature: t1:4358087:1482409901:42b2d32dc624579a3d35875ba1bb126d9539cc69
2016-12-22 12:50:08 +00:00
Martijn Pieters
1c54b7f189 perftweaks: start logging active sparse profiles
Summary: Log active profiles for any command that uses the repository.

Test Plan: arc unit

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: andrasbelo, mitrandir, mjpieters

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

Signature: t1:4346795:1482251224:a9b3568eeb7e57c61273ce0dc9f4d41abcd2888e
2016-12-20 16:34:33 +00:00
Kyle Lippincott
5c73644ae8 debian: Do not package hgext3rd/__init__.py
When installed into a path like /usr/lib/python2.7/dist-packages, this file
conflicts with the hgext3rd/__init__.py from mercurial itself.  Let's keep the
mercurial version the canonical one, and just skip packaging this one.

I added a warning to this repo's __init__.py about behavior divergences between
this __init__.py and mercurial's version.
2016-12-19 16:34:49 -08:00
Martijn Pieters
a678247319 perftweaks: start logging the dirstate size
Summary:
Logging dirstate sizes gives us a way to track sparse profile use; how big a
working copy do people actually have?

The logged info can be directed to Scuba via the sampling extension.

Test Plan: Run on a local test repo with the debugger attached. Goal

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: mitrandir, quark, mjpieters

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

Signature: t1:4340367:1481920819:d7358e0bdc2cc1422b36266374344e7d2b644ae5
2016-12-16 22:46:36 +00:00
Durham Goode
2e89e5591d pushrebase: fix handling merge commits where master is p2
Summary:
Previously, if during a pushrebaes a merge commit was rebased and the
parent commit that contained the original rebase destinations content (i.e.
master's content) was on the p2 side, it would all be thrown away.

This is because the pushrebase commit works by copying the destination-repo-p1, then
applying changes from the diff of the original-repo-p1 vs original-repo-commit.
Since all the rebase destination contents was in destination-repo-p2, it is all
lost here.

The solution is to track which commit is the latest one to contain the
destination bookmark contents, and make sure it is always p1 when rebasing merge
commits. This will ensure that the destination bookmark contents are preserved
all the way up to the new commit for that bookmark.

Test Plan:
Added a test. It fails before the change and passes after. Another
test was also affected, since the p1/p2 ordering is different.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Tasks: 15092414

Signature: t1:4336427:1481881555:a22b8c363f2f7a197cef192abf34bfca926ecdc2
2016-12-16 10:24:12 -08:00
Arun Kulshreshtha
bfa9bd7a91 fbamend: remove allowunstable hack
Summary: Move the enabling of unstable changesets from fbamend to allowunstable, keeping all of the wrapping in one place.

Test Plan: Unit test still passes. No change in functionality.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4288233:1481073858:a7432a9941e93fcadf5ad6502630a49c4e1207f7
2016-12-06 17:56:19 -08:00
Arun Kulshreshtha
e7a2ea79bc allowunstable: allow rebasing in the middle of a stack without --keep
Summary: This change enables "allowunstable" for the `hg rebase` command, which lets it create unstable changesets without full evolution enabled.

Test Plan: Create a stack of commits and attempt to rebase a commit in the middle of the stack, using a command like `hg rebase -r REV1 -d REV2` without the `--keep` flag. This will now work, and the old version of the rebased commit (with descendants) will render as an X in smartlog.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4287989:1481074215:80103f6bfd150e51cc152bc257146d3f9369b175
2016-12-06 17:56:17 -08:00
Alexander Mols
8391d808d0 myparent: commit template keywords based on your previous commit
Summary:
An extension to pre-fill your commit template based on your own
previous commit. Useful for stacked diffs where the commits are mostly related
and will have mostly the same reviewers, tasks, etc.

Test Plan: dogfooding + tests

Reviewers: #sourcecontrol, mjpieters, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Tasks: 12218809

Signature: t1:4265616:1480946835:ed18fadbd9068f2d2ec4799fa1ac176132b41e4b
2016-12-05 06:27:29 -08:00
Jun Wu
1a05e790ca linkrevcache: update documentation
Summary:
This patch changes docstring to make it clearer about how to use the
extensions. It provides some possibly useful details.

Besides, update `testedwith` to be consistent with other extensions.

Test Plan: My vim spellchecker seems happy.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, mjpieters

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

Signature: t1:4263123:1480668147:d042e9b52d0a2759ac360c87a2c87d2d3b0aa0f9
2016-12-02 00:59:48 +00:00
Pascal Hartig
a7cffaf493 hgext: githelp support for commit -C
Summary:
Add support for `git commit -C <commit>`/`git commit --reuse-message <commit>`.

E.g.

```
hg githelp -- git commit -C deadbeef
hg commit -M deadbeef
```

Test Plan: Added test case for the new feature

Reviewers: rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4258167:1480674937:4f21fd43272462c8c5eee40a02d0db7014c834d4
2016-12-02 10:41:54 +00:00
Jun Wu
5d5fedd10c tweakdefaults: fix check config test
Summary:
This fixes test-check-config-hg.t for tweakdefaults. And did some clean-up
for other minor issues.

I was trying to implement another feature (along with the clean-up) in
tweakdefaults and finally realized it's infeasible and drop the feature. But
the clean-up seems useful thus sent here.

Also change `cp -r` to `cp -R` to pass the usptream check-code test.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

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

Signature: t1:4253852:1480613350:398e9b234fcc2360dcb8a3e3ad4e5bc5c4377857
2016-11-30 20:58:08 +00:00
Michael Bolin
9b730c722c Perform stricter check to test whether a repo is sparse.
Test Plan:
Without this change, running `hg commit` in Eden was failing with the following:

```
AttributeError: 'shallowrepository' object has no attribute 'getsparsepatterns'
```

This is because our Eden mount is *shallow*, but not *sparse*, and
`shallowrepository` has a `sparsematch` method, so it yielded a false positive
for this check in `sparse.py`:

```
        if util.safehasattr(repo, 'sparsematch'):
```

Because the first thing that is called after this check is:

```
            _, _, profiles = repo.getsparsepatterns(ctx.rev())
```

it seems more appropriate to test for the `getsparsepatterns` attribute, anyway.

Reviewers: simpkins, durham

Differential Revision: https://phabricator.intern.facebook.com/D4248940
2016-11-29 18:28:48 -08:00
Arun Kulshreshtha
374b37caf5 allowunstable: update comment
Summary: In my rush to get the allowunstable extension landed before the holidays, I made several embarrassing typos in the doc comment at the top of the extension. This diff fixes the typos and makes the comment more clear.

Test Plan: The only change was in a comment, so this is a no-op. Unit tests still pass for good measure.

Reviewers: durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4242510:1480399263:a9822b5e762f1a94c322b15c2ddec9c1acb7df78
2016-11-29 10:18:59 -08:00
Jun Wu
f08e17d3ed testedwith: change testedwith to "ships-with-fb-hgext"
Summary:
Using `testedwith = 'internal'` is not a good habit [1]. Having it
auto-updated in batch would also introduce a lot of churn. This diff makes
them "ships-with-fb-hgext". If we do want to fill the ideal "testedwith"
information, we could put it in a centric place, like a "fbtestedwith"
extension rewriting those "ships-with-fb-hgext" on the fly.

Maybe having in-repo tags for tested Mercurial releases is also a good idea.

[1]: www.mercurial-scm.org/repo/hg/rev/2af1014c2534

Test Plan: `arc lint`

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4244689:1480440027:3dc18d017b48beba1176fbfd120351889259eb4b
2016-11-29 13:24:07 +00:00
Jun Wu
c030cc61cb tweakdefaults: do not use template for annotate if unnecessary (BC)
Summary:
Template lacks of the "padding" feature. There is a hard-coded 13-char wide
username, 5-char wide line number, which does not look well if the usernames
are too long or too short.

This patch restores the original annotate format which is different from
the current behavior. For example, given "-uc", it shows "user node" instead
of "node:user". It also tries to make the template version as close as the
non-template one, by adjusting the order, changing separators, and making
"-c" optional (could be hidden from the output).

Test Plan: Modified existing tests

Reviewers: #sourcecontrol, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4243830:1480437984:1c679c9db516bab905d027061326a7a1524922c6
2016-11-29 11:18:00 +00:00
Jun Wu
38e3389cbb build: fix build errors caused by chgserver moved to core
Test Plan: `arc diff`

Reviewers: #sourcecontrol, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Signature: t1:4244233:1480432440:104d3b082b9affddf1d44bb3cfc5f997eb7e9afa
2016-11-29 15:14:51 +00:00
Arun Kulshreshtha
73155a224e allowunstable: add allowunstable extension
Summary: Currently, the reason we can't perform operations such as histedit, split, and fold in the middle of a stack is that we do not have the experimental.evolution=allowunstable option enabled. It turns out all of these commands will do the "right thing" if this option is enabled. However, since we are uncertain of the ramifications of enabling this option globally, this new extension turns the option on for the duration of split, fold, and histedit, allowing those commands to be used in the middle of a stack without config changes.

Test Plan: See unit tests. Basically, create a stack and then attempt to use split, fold, or histedit somewhere in the middle.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 14598405

Signature: t1:4209315:1479744780:811e8bef02149a055376c0f105ac2d389dd60970
2016-11-28 10:43:34 -08:00
Arun Kulshreshtha
8408c71376 smartlog: add template keywords for split, fold, and histedit
Summary: Add template keywords for split, folded, and histedited successors. This will enable us to show "(Histedited as XXX)" annotations in smartlog.

Test Plan: By itself this should be a no-op. All unit tests still pass. The effects of this aren't visible unless a user uses a version of our facebook.rc config file that contains updated smartlog templates. See D4209113.

Reviewers: durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

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

Signature: t1:4209314:1479744837:8eeeeb7a031abfabeb302abde9e4b1f3d789a479
2016-11-28 10:43:32 -08:00
Jun Wu
d203784d68 pyflakes: fix all pyflakes issues
Summary: As the title.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, stash, rmcelroy

Reviewed By: stash, rmcelroy

Subscribers: rmcelroy, stash, mjpieters

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

Signature: t1:4232321:1480067588:54e91ece8fa6b5ff13b3ebc9279217c76bf96a24
2016-11-25 00:23:21 +00:00
Stanislau Hlebik
2a0e8205d4 extutil: create new package and move runshellfast here
Summary:
I'm going to use runshellfast in infinitepush.
To avoid copy-paste let's move it to the separate package.
Note: fastmanifest also has runshellfast but it's implementation
is a bit different and seems that it doesn't work with remotefilelog.
So I'll leave it alone for now.

Test Plan: python run-tests.py -j20

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4175836
2016-11-21 00:52:30 -08:00
Durham Goode
8e63595d58 catnotate: fix to work with manifestlog
Summary:
Upstream has refactored the manifest to be a manifestlog, so we need to update
our usage of it accordingly.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4180889:1479228547:378f91b556493e05ff0222449b43cf498c301467
2016-11-16 12:11:13 -08:00
Durham Goode
7a97fe8dca pushrebase: fix to work with new manifestlog
Summary:
Upstream has refactored the manifest class, so we need to update pushrebase to
work with the new structure. In particular, pushrebase takes advantage of the
manifest cache, so we need to carefully reconstruct the appropriate cache on the
bundle repo. We can't just .copy() it now because the cache contains manifestctx
instead of manifestdict, and the manifestctx contains a reference to the source
repo.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4180885:1479228506:a0ff114e158caab25da22f6116e5a4090f5515c0
2016-11-16 12:11:11 -08:00
Jun Wu
ca10807a38 fbamend: fix Python 2.6 syntax 2016-11-16 14:23:57 +00:00
Arun Kulshreshtha
9e77a16c75 fbamend: remove old implementation of hg next --rebase
Summary: Remove the old _nextrebase() function. This function is no longer used after the updates to `hg previous` and `hg next`.

Test Plan: All unit tests pass. This code is not called anywhere so removing it should be a no-op.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121784:1478305767:15a737545d0e85c175018e190cb92f722ebad7d8
2016-11-15 18:46:59 -08:00
Arun Kulshreshtha
97ed6a8afa fbamend: add new implementations of hg previous and hg next
Summary:
This diff replaces the `hg previous` and `hg next` commands from the evolve extension with new implementations. The new commands have several features not found in evolve:

  - Users can now move by multiple commits at a time. Example: `hg next 3`
  - Users can move all the way to the top or bottom of the current stack with the following new flags: `hg next --top` and `hg prev --bottom`
  - Users can rebase child commits on demand with `hg next --rebase`. This flag can be combined with the others to specify exactly how many commits to rebase. Example: `hg next --rebase 4` (move 4 commits up the stack, rebasing as needed) `hg next --rebase --top` (rebase all the way to the top of the stack)
  - When a user lands on a particular commit, if there is a bookmark it will be automatically activated. The user can also move to the previous or next commit with a bookmark with the `--bookmark` flag.
  - The user can pass the `--newest` flag to resolve ambiguity in situations where history is nonlinear. With the flag the command will always choose the commit with the higher rev number at each step.
  - The commands now show commit hashes instead of rev numbers when showing the user what commit they landed on.

Apologies in advance for the large diff. I've tried splitting it up as best as I could, but the unit tests introduced here significantly increase the size. I figured the unit tests should be part of this diff instead of being added in a separate one. This diff is almost entirely new code, so I hope that helps a little bit. Let me know if there's a better way to split this up.

Test Plan: See the new unit tests for an extensive look at the new commands in action. Essentially, all of the features mentioned above should work as expected.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: stash, mjpieters

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

Tasks: 14119420

Signature: t1:4121778:1478774243:a7131593222bc329f541e77e1d3ebd8222e47e79
2016-11-15 18:46:56 -08:00
Arun Kulshreshtha
79ca27552d fbamend: make inhibit extension's post-transaction callback fire after rebase
Summary: The new `hg next` and `hg previous` implementations rely on the inhibit extension to inhibit visible obsolete changesets, thereby preventing unstable descendants from appearing as "unstable" in smartlog for end users. The inhibit extension does this by registering a callback that runs whenever a transaction closes. However, it turns out that this callback isn't being called at the end of a rebase, so we need to add a transaction to call it ourselves.

Test Plan: All unit tests for fbamend still pass. Currently, there isn't a way to demonstrate the issue that occurs if this code isn't here; the new `hg previous` and `hg next` functions introduced in the next diff in this stack do provide a unit test to check for this behavior.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

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

Tasks: 14119420

Signature: t1:4121768:1479264251:841bd6473df810e3d663550ef48ec6948476f3a2
2016-11-15 18:46:52 -08:00
Jun Wu
127bd207b5 linkrevcache: wrap _adjustlinkrev to take advantage of the linkrev database
Summary:
Wrap `_adjustlinkrev` so it first tries the possibly faster path (linkrev
database). Then fallback to the original linkrev algorithm.

Also fixes an issue that `{k : v ...}` syntax does not work in Python 2.6.

Test Plan: Added a very simple test

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: durham, stash, mjpieters

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

Signature: t1:4143315:1479234110:07e87c7584e0cfd627b3f9e2fae1a2a34beb390f
2016-11-14 18:04:29 +00:00
Wez Furlong
9b5499d572 phabdiff: don't require a space when parsing the Tasks field
Summary: Allow for any number of spaces after the colon

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: markisaa

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

Tasks: 14532985
2016-11-15 12:28:21 -08:00
Jun Wu
6860161db4 linkrevcache: add a command to verify the linkrev database
Summary:
Adds a `debugverifylinkrevcache` to verify the linkrevs in the database,
against the vanilla adjustlinkrev algorithm.

Test Plan: A simple test is added. The code is also manually tested on my hg repo.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4143240:1479217639:bb9b5814b405b9e60a0722b01fc2c918c5a24b35
2016-11-14 18:04:29 +00:00
Jun Wu
6864d82976 linkrevcache: add a command to build the linkrev database
Summary:
This diff implements a `debugbuildlinkrevcache` command which builds the
linkrev database.

Test Plan: A simple test will be added when the cache can be verified.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, jsgf, mjpieters

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

Signature: t1:4143200:1479131313:858042c86b5894898333900f63ea0cd50c47e934
2016-11-14 18:10:30 +00:00
Jun Wu
de07b8a110 linkrevcache: attach the linkrev database to the repo object
Summary: This diff makes the linkrev database accessible via `repo._linkrevcache`.

Test Plan: A test will be added when the feature is more complete.

Reviewers: #sourcecontrol, jeroenv

Reviewed By: jeroenv

Subscribers: jeroenv, mjpieters

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

Signature: t1:4143175:1478558825:2c0eb0fa0f77cf004aee7c40ffc2a6ea417f6212
2016-11-14 18:08:30 +00:00
Jun Wu
dd91b969e6 linkrevcache: implement the database
Summary:
This diff implements some simple linkrev database classes which uses dbm to
store linkrev candidates.

Why not sqlite? sqlite's insertion seems to be much slower with index being
present, so we have to do manual buffering and do insertion in batch, not to
say parsing SQL itself can introduce overhead. If we really want sqlite for
some reason (i.e. its support for concurrent writer and reader seems to be
better), we can still implement it as a dbm engine.

Test Plan: A test will be added when there is something usable.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: jsgf, stash, mjpieters

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

Signature: t1:4143119:1479131795:5f6e368ebd1798b874cec28ac05b137eb3bea86e
2016-11-14 18:03:15 +00:00
Arun Kulshreshtha
1c6b719130 fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.

Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.

One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.

It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.

Test Plan:
See unit tests.

1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14041544

Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 11:25:19 -08:00
Arun Kulshreshtha
8afd0a8a75 fbamend: add helper functions for hg previous and hg next
Summary: Add some miscellaneous new helper functions that will be used in the new implementation of `hg previous` and `hg next`. These are just utility functions for things like setting bookmarks, printing out changeset lists, and hiding command line options. Also fixed a few typos in comments.

Test Plan: All tests still pass. This change should be a no-op as these functions are not called anywhere.

Reviewers: durham, quark, #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121764:1478162841:32362fef3727e67e46b5700d9242be5c0cd62a52
2016-11-03 11:11:41 -07:00
Arun Kulshreshtha
2e9aba5940 fbamend: rename/refactor wrapper functions
Summary: Do a minor refactor and rename of some of the wrapper functions in this file. There are no functional changes. These names were chosen to follow a consistent convention and be less confusing when taken together with the new `hg previous` and `hg next` functions that will be added in a later diff.

Test Plan: All tests still pass.

Reviewers: durham, quark, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121755:1478164041:d8c603c32554d1d7c1df9706386c015f90ad62c6
2016-11-03 11:11:39 -07:00
Jun Wu
93c918c92e absorb: fix an issue where changesets do not get deleted correctly
Summary:
The old code didn't test if the new commit will become empty correctly, if its
"memworkingcopy" contains changes inherited from its parent. This diff fixes
the problem.

Thanks @stash for discovering the issue!

Test Plan: Added a test case for this issue. Make sure the old code cannot pass.

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: mjpieters, stash

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

Signature: t1:4113438:1478077373:194104b902bdfe6827858c2916a7f3f0cd83ee6c
2016-11-01 21:16:13 +00:00
Jun Wu
6318d6eb2a smartlog: do not change node char for fake nodes
Summary:
The fake node has an illegal revision number that cannot be used in the
`allsuccessors` revset.

Test Plan: It should work in theory. I couldn't construct a testcase relatively quickly.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4082186:1477503381:ac646071af5ad0e63a83ca7199e62a75ef736bce
2016-10-26 18:33:10 +01:00
Arun Kulshreshtha
5ae81e0470 smartlog: show inhibited obsolete nodes as x's
Summary: Make nodes with visible successors render as 'x' in hg smartlog output. Previously these nodes were rendered as 'o' because the inhibit extension made them appear to be non-obsolete.

Test Plan:
1. Create a stack of commits.
2. Amend a commit in the middle of the stack.
3. Run `hg sl`, observe that although the precursor of the amended commit renders as an 'x'.
4. Run `hg unamend`, then update to a different commit (so the precursor is not the current commit and thus not rendered as '@').
5. Observe that the precursor now appears as 'o' again because it has no visible successors.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 13652083

Signature: t1:4071058:1477434742:f57bf5a07b6b9497472deb8445f5fc01a5379f8c
2016-10-25 17:22:22 -07:00
Arun Kulshreshtha
0943b06da1 fbamend: add config option to use restack instead of preamend bookmark
Summary: Added a configuration option to make fbamend use the functionality from `hg rebase --restack` instead of the previous bookmark-based approach in `hg amend`.

Test Plan: Enable the `fbamend.userestack` config option and attempt to use `hg amend`, `hg amend --fixup`, and `hg amend --rebase`. These should all work just as before, except that `hg amend` will no longer create .preamend bookmarks.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 13839177

Signature: t1:4062925:1477359251:0ece10599987d6b8e39384e9530866ffb2e50e58
2016-10-25 11:10:47 -07:00
Arun Kulshreshtha
c7f2693ddb fbamend: add metadata to obsmarkers created by hg next --rebase
Summary: `hg next --rebase` was not adding metadata to the obsolescence markers it manually creates (manual creation is necessary because of the --keep flag), which meant that `hg sl` output did not show "Rebased as XXX" annotations for commits rebased using this command. This change adds the metadata.

Test Plan:
1. Create a stack of commits.
2. Amend a commit that is at least 2 commits from the top of the stack. (This way rebasing this commit's child will not result in the entire old stack getting deinhibited.)
3. Run `hg next --rebase`.
4. Run `hg sl`, observe that the rebased child is annotated as "Rebased as XXX".

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14027474

Signature: t1:4060814:1477094781:5bf0b2b42eafcb2267ff6821e33d5e8fe7059eb0
2016-10-21 17:58:19 -07:00
Arun Kulshreshtha
1d80ea88ea fbamend: remove unused variables from unamend
Summary: These variables were unused, causing test-check-pyflakes.t to fail whenever fbamend.py is modified in a way that changes the line numbers of those assignments.

Test Plan: Unit tests still pass (except test-fbamend.t, which fails for reasons unrelated to this change)

Reviewers: durham, #sourcecontrol, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4055599:1477049676:84ec9a1036bb6d6873d497caed9feff701a8169b
2016-10-21 12:32:03 -07:00
Mateusz Kwapich
d85d95b667 integration tests for sqldirstate/fbhistedit and "hg amend" test for latter
Summary:
This diff was created when I was investigating hgamend exec not working
with histedit which resulted with [1].
This also brings some very small fixes for sqldirstate and fbamend that
I was too lazy to diff separately.

[1] https://patchwork.mercurial-scm.org/patch/16451/

Test Plan: ran tests

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3777784:1472227075:f2f8a9cad22bf0c45d4554709846b8aafb61d9a0
2016-10-21 06:01:59 -07:00
Jun Wu
e9776efcd7 patchpython: fix test-check tests
Summary: Resolve pyflakes issues caused by patchpython.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4051110:1476985498:3582ddf70780537a7902fece3ab847bc9effd744
2016-10-20 16:03:31 +01:00
Jun Wu
4816fb9b86 absorb: fix test-check issues
Summary: This diff fixes test-check issues related to `absorb`.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4050973:1476985180:1bcd81297933c1488372b6c4bb7e5ea46f8105b0
2016-10-20 14:59:20 +01:00
Jun Wu
c11cddecf5 test-check: backport test-check-execute from core hg
Test Plan: `arc unit`

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4037205:1476876512:e7659ce8add7fabacb50bb5fb3fe1f1d1744c304
2016-10-18 17:58:45 +01:00
Arun Kulshreshtha
6d9d6b699f Update revset in hg rebase --restack
Summary: Benchmarking `hg rebase --restack` against `hg evolve --all` showed that `hg rebase --restack` was spending a lot of time on a single revset to identify the current stack of commits. This diff changes the revset to an equivalent but more efficient one.

Test Plan:
All unit tests still pass.

For benchmarking, I created a stack of 4 commits on top of remote/master in fbsource/fbcode. I amended the second commit and then ran the command. Here is profiler output for both before and after the change:

Before (10.87 seconds): P56747821
After (7.58 seconds): P56747927

Based on the profiler output, this change results in a 30% performance improvement in this case.

Reviewers: durham, #sourcecontrol, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Tasks: 13976698

Signature: t1:4038630:1476825563:02da1d4e459f780de41d852f88da789513aba7dc
2016-10-18 14:20:37 -07:00
Jun Wu
da4275caa9 sshaskpass: backup tty fds in case they get overrided later
Summary:
The current `sshaskpass` implementation relies on `stdin` and `stderr` being
TTYs. That can not be guaranteed if pager is used. With chg enabled, the chg
client will call `attachio` when starting the pager, and it which will override
both `stdin` and `stderr` to the pipes created by the chg pager logic. This
causes failures when a paged command (like `hg diff`) needs interactive ssh
authentication (happens when remotefilelog cache misses).

This patch fixes it by backing up TTY fds inside the `sshaskpass` module. With
chg enabled, the first `attachio` (before starting pager) can provide TTY fds,
where we just back them up. The second `attachio` (after pager started) will
override `ui.fin/fout`, `sys.stdin/stdout` to non-tty fds but it does not matter
since we have backups.

Test Plan:
Run the following command in a remotefilelog repo:

```
rm /tmp/chg$UID /tmp/r -rf; chg diff --config remotefilelog.cachepath=/tmp/r --debug --pager=on
```

And confirm password prompt works as expected.

Reviewers: rmcelroy, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4032236:1476755400:80fc6007b6fb2f9fe83cf6570d80a2b431fc069f
2016-10-17 21:28:33 +01:00
Arun Kulshreshtha
37cf7bd354 Make hg rebase --restack smarter
Differential Revision: https://phabricator.intern.facebook.com/D4000348
2016-10-14 11:05:53 -07:00
Adam Simpkins
7f1c4eb449 [sparse] make sure "hg update --clean" correctly forgets about excluded files
Summary:
A user ran into a bug where a failed rebase left their repository in a state
where "hg status" reported many excluded files had been removed.

They weren't able to recover from this state, even using "hg update --clean ."
This was because the sparse extension was ignoring the actions to forget these
files from the dirstate.  The sparse extension should allow excluded files to
be forgotten.

Test Plan:
I tried writing a test case for this but wasn't able to figure out how to
trigger exactly the situation that the user's repository was in.  (It looks
like there were other bugs in "hg rebase --abort" that led to their repository
state.)

I was able to cause some other problems with files in the "g" type
("remote created") that "hg update --clean" wouldn't fix.  I haven't added
those test cases for now though, since that problem isnt' fixed by this diff.
It does seem like there are potentially other problems here that still need to
be addressed.

Reviewers: quark, rmcelroy, mjpieters, durham

Reviewed By: durham

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 13694820

Signature: t1:3966580:1475676328:48433e203ae702a50b40176e52f1ed90a5c45504
2016-10-13 11:49:58 -07:00
Jun Wu
82b158ed59 githelp: fix crash in mergebase
Summary: `_` does not take two arguments while `ui.status` does.

Test Plan: Added a test case

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4010079:1476298648:81e678fbe433aa8cca8b03c9eba50d9b78bbc9bb

Blame Revision: D2811887
2016-10-12 19:47:42 +01:00
Arun Kulshreshtha
a154bbaeb0 Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.

I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.

Test Plan:
See unit tests for complete commands.

1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: rmcelroy, quark, mjpieters

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

Tasks: 13651947

Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-11 17:41:07 -07:00
Adam Simpkins
89f30244e5 [phrevset] fix "invalid literal for int()" error
Summary:
Fix the revsetdiff() function to always return a revision number.

Previously if the revision information was retreived from phabricator rather
than being found locally we return a changeset string rather than a revision
number.  This fixes the code to convert the changeset string back to a revision
number.  If the specified commit does not exist in the local repository, we
throw an error indicating that the user should run "hg pull"

Test Plan:
Tested running "hg graft -r DXXXXXXX" with a diff that was not present in the
local repository yet.  Confirmed it now prints an error indicating that the
user needs to run "hg pull" to fetch this revision, whereas previously it
crashed with an "invalid literal for int()" error.

Reviewers: #sourcecontrol, durham, simonfar, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 11355408

Signature: t1:3997925:1476201895:9b5832dc28abdddaa281a848246476b78f5a9fe7
2016-10-11 11:13:58 -07:00