Commit Graph

12741 Commits

Author SHA1 Message Date
Durham Goode
a5dab1deb5 hg: support treeonly mode on the server
Summary:
Once all clients are in treeonly mode, we can make the server tree only
mode as well and stop producing flat manifests entirely. This will speed up
pushes, save space, etc. This patch adds support for that mode.

Reviewed By: ryanmce

Differential Revision: D7148825

fbshipit-source-id: 15c899a58dd45af0c030c887c53f66347bc32b01
2018-04-13 21:51:27 -07:00
Durham Goode
f45c1af184 hg: disable cuniondatastore support for treemanifest
Summary:
The cstore doesn't contain our ondemand generator, nor our mutable data
store, so it's really not usable yet. Let's disable it for now until we can fix
up the issues that prevent us from using it (like having it report metrics).

Reviewed By: ryanmce

Differential Revision: D7148823

fbshipit-source-id: 5cc46af33c049b751c1c04916aafe0768d80ce7a
2018-04-13 21:51:26 -07:00
Durham Goode
b248124ba7 hg: allow hybrid manifest's to exist without revlogs
Summary:
Once we move to a treeonly world, there won't be any more manifest revlogs.
During the transition we'll still use hybrid manifest's though (the class, and
it will just resolve to treemanifests every time), so we need to support hybrid
manifests that don't actually have a revlog.

This also sets manifestlog._opener. We were already storing that on the other
manifestlog implementations, so we should do it on the main one for consistency
(and because this diff depends on it).

Reviewed By: ryanmce

Differential Revision: D7148821

fbshipit-source-id: 8f278a7bf4c0909423257165df59eae400a05a9e
2018-04-13 21:51:26 -07:00
Durham Goode
56fae19890 hg: convert received flat server changegroups to trees
Summary:
Previously the server would reject pushes that didn't use pushrebase,
since we relied on pushrebase to recreate the commits with the treemanifests.
Now that the flat-to-tree conversion logic is cleaner, we can use it to do the
conversion during a normal push.

Reviewed By: quark-zju

Differential Revision: D7143453

fbshipit-source-id: c13713e2ff59f1dff3ee1f44b7f8db7a92cfe1de
2018-04-13 21:51:26 -07:00
Mark Thomas
dc38cc38e1 progress: add progress.bar, a time-updated progress bar
Summary:
This adds `progress.bar`, which is a context manager that provides a
time-updated progress bar, analogous to `progress.spinner`.

Reviewed By: ryanmce

Differential Revision: D7211895

fbshipit-source-id: be07d363f10c09164e2324d31a71a7c795257c8a
2018-04-13 21:51:26 -07:00
Ryan McElroy
1fbd6b0194 progress: move time check earlier
Summary:
Profiling revealed significant time spent in progress output.
Micro-optimize to speed things up.

Reviewed By: farnz

Differential Revision: D7210618

fbshipit-source-id: dddd3eb0e0daa030bbe2d9b509a8516c099ebbe8
2018-04-13 21:51:26 -07:00
Ryan McElroy
7c94c47d99 debugcommands: introduce debugprogress
Summary: Command to help microoptimize the progress bar

Differential Revision: D7210616

fbshipit-source-id: 2f3fb4e3be6b45d51b65051a42e786d5f1ca158b
2018-04-13 21:51:25 -07:00
Durham Goode
dbd7c7241a hg: convert flat manifest changegroups into trees
Summary:
Previously, in treeonly mode we would ignore any flat manifests that
were received in changegroups (via bundles or pulls, etc). This ended up causing
data loss in practice when people applied old bundles from before the
treemanifest conversion. Instead of just dropping those manifests, let's convert
them on the fly. This may be expensive, but it's better than losing the data.

A future diff may add caching to reuse flat text to speed up applying multiple
deltas.

Reviewed By: quark-zju

Differential Revision: D7083038

fbshipit-source-id: d2e350325d7e9005c8ddd5462034040274f790ff
2018-04-13 21:51:24 -07:00
Stanislau Hlebik
a82197d560 use getcmdanddefaultopts in rage
Summary:
It makes sure that adding new options to the commands won't break them. For
example, rage sparse output was broken, and this diff fixes it.

Note that this changes behavior of the rage - if, say, smartlog extension is not enabled on the client, then there will be no output in the rage. Previously it wasn't the case. I think that's not the big problem, because:
a) The extensions are the most common ones and enabled everywhere
b) If they are disabled, then we'll immediately see a problem in hg rage.

However I need to change a test to make it pass. I need to add extensions and change grep output, because `hg rage --preview` has a few lines with `blackbox` in it.

Differential Revision: D7193297

fbshipit-source-id: dde2752ebc7dd3e3edea5c44576d0986f7d18744
2018-04-13 21:51:24 -07:00
Stanislau Hlebik
f4cba47550 fix infinitepush import lint in __init__.py
Differential Revision: D7211380

fbshipit-source-id: d1fdfd51998bb2e28feb2e8ff5456314331f1e38
2018-04-13 21:51:24 -07:00
Durham Goode
7c43ca7c6b hg: fix tests on OSX
Summary: sed -i without arguments doesn't work on OSX.

Reviewed By: farnz

Differential Revision: D7195193

fbshipit-source-id: a8eead927c94404a37ce5df956de82d29bc1b6a8
2018-04-13 21:51:24 -07:00
Stanislau Hlebik
1b816bd86e revert bisect change
Summary:
In D7001328 we've added a new feature that skips commtis if there are no
changes relative to the sparse checkout. Unfortunately that causes lots of
treepacks downloads and makes bisect unusable. Let's revert the change.

Reviewed By: ryanmce, farnz

Differential Revision: D7182016

fbshipit-source-id: 274b29ca6a7b4c3faf83883b64f5ad3b0289873e
2018-04-13 21:51:23 -07:00
Mateusz Moneta
4cfb665650 Update markers during hg pullbackup
Summary:
Before this change `hg pullbackup` did not set correct markers on commits.

This change make possible to see what changes already landed even when we are restoring repository from backup.
Before the change `fbclone` + `hg pullbackup` of repo with `C1` commit landed would result in:
```
o  o C2
|    |
o  o C1
|  /
|
o
```
after:
```
o  o C2
|    |
o  x C1
|  /
|
o
```

Reviewed By: StanislavGlebik

Differential Revision: D7032572

fbshipit-source-id: ffee3c7cc23c24a3df9a89c999c9dd2de226dbff
2018-04-13 21:51:23 -07:00
Jun Wu
af8ecd5f80 obsolete: copy obsmarkers from old commits automatically
Summary:
Rewriting a set of commits where there are replacement relationship among the
commits do not have an optimal UX today. For example, `rebase -s A -d Z` or
`metaedit A` in the below graph. B1, B2, C will all be replaced. But the new B1
and B2 replacement won't have the B1 -> B2 relationship, and the "new B1"
appears to be revived.

```
  o C
  |
  x  B1 (amended as B2)
  |
  | o B2
  |/
  o  A    o  Z
```

One solution is to avoid rebasing `obsolete()::`, as implemented in D7067121
for metaedit. That would result in

```
  o C
  |
  x  B1 (amended as B2) o new B2
  |                     |
  x  A                  o new A
```

The stack of A, B1, C is forced to break into two parts. This is fine for
power users. But n00b users would wonder why C is left behind. Per discussion
with simpkins at an internal post about the metaedit case, we think a more
linear history is more user-friendly. That is:

```
  o new C
  |
  x  new B1 (amended as *new* B2)
  |
  | o new B2
  |/
  o new A
```

The stack stays in a same shape.

This diff implements the "copying obsmarkers" behavior at the "createmarkers"
level so everything using that API would get the feature for free, including
metaedit and rebase.

D7067121 is reverted since the new UX is preferred. The test added is for
`metaedit` command, changes to rebase will be added in a later patch.

Differential Revision: D7121487

fbshipit-source-id: fd3c8a96ab434b131fb86d9882ccbdff8f63f05e
2018-04-13 21:51:23 -07:00
Durham Goode
bf42a6c236 hg: prevent treemanifest server from trying to prefetch nodes
Summary:
Recently we unified the client and server code paths a bit, which
can cause the treemanifest server to attempt to do a prefetch (which doesn't
make sense since it has no where to prefetch from). It ends up throwing an Abort
error about not having a remote server configured. The fix is to make the
prefetch path smarter about when it's run on the server and to throw a standard
MissingNodesError instead. That kind of error is already handled in the hybrid
repository case and we just eat it and server the flat manifests like normal.

Once we move to treeonly mode, that error handler will re-raise the exception so
real issues with missing nodes won't be hidden.

Reviewed By: phillco

Differential Revision: D7182283

fbshipit-source-id: 15ed6549d9d7da1fee0570e1fa10338545ed92b1
2018-04-13 21:51:23 -07:00
Durham Goode
bc5366b741 hg: add test for treemanifest and infinitepush rebundling
Summary:
There's a bug where infinitepush attempting to rebundle a bundle that
does not contain trees causes an exception because the server attempts to
prefetch those trees (which fails because there's no where to prefetch from).

This diff just adds a test for that case. The next diff will fix it.

Reviewed By: phillco

Differential Revision: D7182284

fbshipit-source-id: a3fbb576cf3318c81b18943e0f0d466aa65e54fb
2018-04-13 21:51:23 -07:00
Xinjie Lei
ef5e9eed07 Remove "bookprevnode" and "pushbackbookmarks"
Summary:
All of the repos that use commit cloud have remotenames extension enabled, so bookprevnode and pushbackbookmarks parameters are not used. Local bookmarks won't be updated after a push.

We remove "bookprevnode" and "pushbackbookmarks" and functions related to them.

Reviewed By: StanislavGlebik

Differential Revision: D7122411

fbshipit-source-id: 0c6b3bc3f41f5b03d4bb2bc297ae35d77c90fedf
2018-04-13 21:51:22 -07:00
Durham Goode
147d85a46e hg: backout automatic conversion of flat manifests to trees
Summary:
The feature that automatically converted flat manifests to trees is
dependent on the hg server not sending flat manifests to treeonly clients
(otherwise it's very, very slow). Since the server rpms got reverted, we need to
backout these changes until the server issues are fixed.

Reviewed By: farnz

Differential Revision: D7181025

fbshipit-source-id: 1e4aad04d15909a3ce4f69313419e50c14bc8c19
2018-04-13 21:51:22 -07:00
Durham Goode
4d44789410 hg: convert flat manifest changegroups into trees
Summary:
Previously, in treeonly mode we would ignore any flat manifests that
were received in changegroups (via bundles or pulls, etc). This ended up causing
data loss in practice when people applied old bundles from before the
treemanifest conversion. Instead of just dropping those manifests, let's convert
them on the fly. This may be expensive, but it's better than losing the data.

A future diff may add caching to reuse flat text to speed up applying multiple
deltas.

Reviewed By: quark-zju

Differential Revision: D7083038

fbshipit-source-id: 4912ec5ea5097163cede00158df821f116d92c9b
2018-04-13 21:51:22 -07:00
Jun Wu
3b8120083a changegroup: add a config to tweak deltabase selection
Summary:
This diff adds a config option to tweak deltabase in changegroup. It has 3
options:

  - Always null - always use "null" as delta base, effectively make
    everything full text
  - No external - delta bases cannot be a revision outside the changegroup
  - Default - the current behavior: delta bases can be anything that client
    thinks the server should have.

This gives Mononoke more time to bake delta related logic, as we can
choose "always null" first, then incrementally increase the complexity.

Reviewed By: phillco

Differential Revision: D7158585

fbshipit-source-id: 5f6d9a78d1108093e8d08b9f296568f4f7e7471b
2018-04-13 21:51:22 -07:00
Durham Goode
09c987f22f hg: don't send public trees during pull/push
Summary:
Currently if you push or pull a bunch of commits between peers we will
include all the trees as part of the push. If the source repo doesn't have all
the necessary trees, it will go to the server to get them. Since the other
machine can just as easily go to the server (and probably won't need most of
those trees anyways), lets just have the source client send all draft trees and
skip the public commits,

Reviewed By: phillco

Differential Revision: D7141623

fbshipit-source-id: 6d33ae9d4c9cc32bf6dfa76f733c87c06890d719
2018-04-13 21:51:22 -07:00
Durham Goode
d9979c9928 hg: update test to show what trees were downloaded
Summary:
A future diff is going to change what trees are sent during a peer to
peer push. Let's update this test so we can see the actual changes in the next
diff.

Reviewed By: singhsrb

Differential Revision: D7141626

fbshipit-source-id: 75e61e9c417d86c48ed1762d6ab67bd4204f67c7
2018-04-13 21:51:22 -07:00
Kostia Balytskyi
174c81d3c9 hg: remove -r option from sed call as it is not supported by OSX
Summary:
`-r` seems to be unneeded, as tests pass without it.

Also, it does not look like the regex itself uses anything not mentioned in `man re_format` on OSX, so we can just use the non-extended re.

Reviewed By: StanislavGlebik

Differential Revision: D7167503

fbshipit-source-id: 3c5c520e9bf2627523cabc771226fc37dc2e9171
2018-04-13 21:51:22 -07:00
Martijn Pieters
15383f0bd3 sparse: use manifest matcher when discovering profiles
Summary:
This echos the change in D7056650; there is no need to special-case
treemanifests here; delegation to the manifest .match method allows the
manifest to apply optimisations when available.

Differential Revision: D7100363

fbshipit-source-id: 66a35850a132f804efb407712d2e4db737c10cff
2018-04-13 21:51:22 -07:00
Martijn Pieters
3b4b3d8cbb sparse: make use of matchers for faster path listing
Summary:
The current code iterates over all files in the manifest, filtering against a prefix.

But a manifest supports using a matcher directly, and efficient implementations like the treemanifest will prune the tree to a much smaller subset rapidly based on the path in a matcher. Switching to using a matcher dramatically improves --cwd-list performance in fbsource, when treemanifests are available.

Reviewed By: quark-zju

Differential Revision: D7056650

fbshipit-source-id: 2bf62ea93680323a49c9282266118805881d7b02
2018-04-13 21:51:21 -07:00
Ryan McElroy
883f750613 merge: show progress when updating dirstate after update
Summary:
For large updates, the dirstate update can take a while. Let's show
progress so the user understands what is happening and how long to wait.

Reviewed By: quark-zju

Differential Revision: D6903133

fbshipit-source-id: f7f6c3c14e1d3221a383da4a6e311aa12a8d3a98
2018-04-13 21:51:21 -07:00
Aida Getoeva
93252b7fd2 Enable batch mode for SSH during background pushbackup
Summary:
Added passing BatchMode option to SSH call only when puchbackup runs in background.
Also fixed dummyssh in skipping options before hostname, added unittest.

Reviewed By: quark-zju

Differential Revision: D7119123

fbshipit-source-id: 2c8e66fee44cca5b23389cba8e21e3a0b237268e
2018-04-13 21:51:21 -07:00
Mark Thomas
629b2a9ec4 smartlog: always show latest public ancestor of draft commits
Summary:
Smartlog is supposed to show the latest public ancestor of all draft commits,
however this doesn't always happen.

The reason is a boundary error in the test for finding public commits.  If the
latest public ancestor is also the common ancestor (fairly normal), then it
will be excluded.

Reviewed By: quark-zju

Differential Revision: D7140139

fbshipit-source-id: 6999f7ad14f86653ebe4d4f6543b9c7533871cf2
2018-04-13 21:51:21 -07:00
Jun Wu
b7eb2e64e3 mdiff: use xdiff for diff calculation
Summary:
Let's switch to xdiff for its better diff quality and performance!

The test changes demonstrate xdiff's better diff quality.

Reviewed By: ryanmce

Differential Revision: D7135206

fbshipit-source-id: 1775df6fc0f763df074b4f52779835d6ef0f3a4e
2018-04-13 21:51:21 -07:00
Jun Wu
1ce8dceb3a tests: add tests for upcoming xdiff change
Summary:
The next test is going to switch bdiff to xdiff. This diff adds related tests
so we can clearly how xdiff improves the diff quality.

It also solves [issue5091](https://bz.mercurial-scm.org/5091) because xdiff
will shift hunks up and down to group them together. So that was also added as
a test. Although in a more complex case where the hunks are separated by some
common lines (ex. "Y"), xdiff won't help either.

Reviewed By: ryanmce

Differential Revision: D7147444

fbshipit-source-id: 3605290b5dfdfc7b8b004b38c7f7ee9534915380
2018-04-13 21:51:21 -07:00
Jun Wu
df73510ede tests: fix tests caused by tinit change
Reviewed By: singhsrb

Differential Revision: D7141028

fbshipit-source-id: 186955ce5f91befcdbbc1ccdc8ba7ff2c3e4fa92
2018-04-13 21:51:20 -07:00
Dino Wernli
bb69bca6b1 Make rebuilddirstate not crash due to existing corrupt dirstate files.
Summary: This change minimally addresses the issue that `debugrebuilddirstate` can crash if the dirstate file is very corrupt.

Reviewed By: markbt

Differential Revision: D7028370

fbshipit-source-id: 72fc7a2900a8bc1bb5f062454530b4fc4c806f09
2018-04-13 21:51:20 -07:00
Jun Wu
320fc31e4c tinit: add drawdag and setconfig functions
Summary: They help making tests easier to write.

Reviewed By: phillco

Differential Revision: D7121645

fbshipit-source-id: 9c7181d45c4e28155eb68f355cf1c4cfc077d191
2018-04-13 21:51:20 -07:00
Jun Wu
c6742cd74c run-tests: source tinit.sh for all .t tests
Summary:
`.t` tests have some highly repeatitive logics, like creating a repo, etc.
This patch adds a common shell file that defines frequently used functions.

For now, `newrepo` and `enable` are added. The latter can be used to
enable a feature (ex. obsstore), or an extension.

`test-fb-hgext-fbamend-next.t` and `test-fb-hgext-absorb.t` are migrated
to use the new shell functions.

Reviewed By: phillco

Differential Revision: D7121485

fbshipit-source-id: 167fcc20e4e30864199b6c5af0958b80bfb68817
2018-04-13 21:51:20 -07:00
Saurabh Singh
cc2a9a760d hg: remove facebook-hg-rpms related code
Summary:
Don't think this is required or used anymore and reveals information
about the structure of our project if we open source our mercurial.

Reviewed By: quark-zju

Differential Revision: D7128203

fbshipit-source-id: 4cdfa008631d08321a4d5a1c8f18cef429c35077
2018-04-13 21:51:20 -07:00
Alexandre Marin
c405d681aa make importer use mercurial's transaction
Summary:
The breakage we had on branch importer was related to filetransaction trying to
close a file that didn't exist. We're still not sure why this happens yet, but
the workaround was to use mercurial's transaction and to force not using workers,
which is this change.

Differential Revision: D7108127

fbshipit-source-id: 71fa63824984bfb91de3b732166f7bae496187ad
2018-04-13 21:51:19 -07:00
Stanislau Hlebik
584943bdd6 fix show failure if alias is set
Summary: dispatch.lazyaliasentry didn't work with slices i.e. lazyasliasentry[:2] failed. This diff fixes it

Reviewed By: farnz

Differential Revision: D7109779

fbshipit-source-id: c704cd44fea0944ae4be68df36d32df98b7fc09b
2018-04-13 21:51:19 -07:00
George Tupi
c420354af6 add --abort flag to hg graft
Summary: Add --abort flag to hg graft command for clearing interrupted graft state

Reviewed By: ryanmce

Differential Revision: D7060758

fbshipit-source-id: 3590f461ebfd901adf644d32231eb9b88efded53
2018-04-13 21:51:19 -07:00
Durham Goode
8038c6ea27 hg: support cg2 in pushrebase
Summary:
Previously pushrebase would only send changegroups using the cg1
format. remotefilelog will soon require cg2 (and it results in better deltas
anyway), so let's change pushrebase to allow using cg2.

Initially it is off by default. We will change it to be on by default once the
server has been upgrade to to handle the received part.

Reviewed By: mjpieters

Differential Revision: D7108732

fbshipit-source-id: ff4ad3a3fc2801aec4876db30c8130ce743b2e6a
2018-04-13 21:51:19 -07:00
Durham Goode
9808c98f7e hg: use base parameter when doing background prefetch
Summary:
When background prefetch is enabled, let's use the base parameter to
limit how many files we download. This makes the operation O(files changed), and
on windows results in a significant speed up.

Reviewed By: mjpieters

Differential Revision: D7108838

fbshipit-source-id: a46b8a7d897ee204b9a4c1f1c65d875dbd3e9bc7
2018-04-13 21:51:19 -07:00
Enji Cooper
23f1474946 Fix typos ("and and" -> "and")
Reviewed By: yfeldblum

Differential Revision: D7091797

fbshipit-source-id: cbba7e5c17e1b6d4446570fb7a2b888db8bcd17e
2018-04-13 21:51:19 -07:00
Martijn Pieters
42ac84e8cf sparse: clean up path handling, making it platform agnostic
Summary:
There is no need to strip path separators from the normalised path; normpath
will never leave any.

We also ensure that the path prefix we test ends in a path separator, to avoid
matching on sibling paths that happen to share a prefix.

Reviewed By: ryanmce

Differential Revision: D7056649

fbshipit-source-id: 10b78a78ba44fbc8d9c05fb7ffd0ffd1c1496a67
2018-04-13 21:51:18 -07:00
Durham Goode
acc5ababaa treemanifest: demand convert flat manifest to tree manifest in treeonly mode
Summary:
Eventually all the clients using the tree manifest will operate in
treeonly mode. In treeonly mode, we only read from tree manifests and
therefore, manifest related operations would fail for commits which only have
flat manifest. Example of such commits are old draft commits which were created
before the existence of tree manifest. One way to resolve this is to
automatically convert any flat manifests we come across to tree manifests. This
commit achieves that same.

Differential Revision: D7083033

fbshipit-source-id: 092fc7852ffc6d1b4130b5a1fc8d9e124cef4fcb
2018-04-13 21:51:18 -07:00
Durham Goode
0cb760c0ea hg: make mutablehistorypack implement the history store api
Summary:
This makes the mutable history pack implement the history store read
api so we can add it to the union store and read the contents of things that
have been written but not yet committed.

The mutablehistorypack fileentries variable has been changed to contain a dict
instead of a list so we can access it quickly during reads. The list is from a
legacy requirement where we used to maintain the order that the writer wrote in.
We no longer do that (instead we topologically sort what they've given us), so
switching from a list to a dict should be fine.

Differential Revision: D7083036

fbshipit-source-id: ae511db60ab6432059714a2271c175dc9683b8e1
2018-04-13 21:51:18 -07:00
Durham Goode
ac2fc36da3 hg: move all manifest writes to manifestlog.add
Summary:
Now that _writeclientmanifest is basically just calling
manifestlog.add, let's get rid of it.

Differential Revision: D7083029

fbshipit-source-id: eee18cefd5a6ae3d95bba58b419364fc9fdb15b3
2018-04-13 21:51:18 -07:00
Durham Goode
75da4fb2e6 hg: add add/removeStore to cuniondatapackstore
Summary:
In a future diff we'll need the ability to modify the union store on
the fly, so let's add addstore and removestore apis.

Reviewed By: ryanmce

Differential Revision: D7051102

fbshipit-source-id: 901a50720bfdf4e5c59714d092830e65edccdfce
2018-04-13 21:51:17 -07:00
Saurabh Singh
e1194f0102 remotetreedatastore: make MissingNodesError subclass of KeyError
Summary:
The union content store

 - iterates through all the stores it has until the current store has the
   content.
 - Or, it fails eventually if none of the stores have the content.

It does so by relying on the current store throwing a KeyError if it doesn't
have the content.

`remotetreedatastore` was throwing the MissingNodesError which means any
remaining stores after it would not even get a chance to look for the content.
This commit addresses the same.

Reviewed By: ryanmce

Differential Revision: D6867854

fbshipit-source-id: 784df195efcbe16f2e716968f3d93159afff6206
2018-04-13 21:51:16 -07:00
Phil Cohen
b177b338b7 rebase: tactical fix for rebase dropping flags
Summary:
The root issue is described in the new ``workingflags()`` function -- ``workingfilectx.flags()`` ought to read from the working copy, but instead reads from the working copy's p1.

Rather than force a big rewrite to adapt all the old code (which might be a waste if we end up rewriting the context classes), let's add a new function with the behavior we want, and callers can detect for it and call it.

simplemerge is the only callsite that needs this behavior, AFAICT.

Previous attempt: D6694292

Reviewed By: singhsrb

Differential Revision: D7083239

fbshipit-source-id: 6f30b877958d40106203e088fe724ab491b541b9
2018-04-13 21:51:16 -07:00
Mark Thomas
e453f31b7d hghave: remove hasattr test
Summary:
Remove the test for the `search` attribute on the passed-in regexp in
`hghave.matchoutput`.  It's not necessary, and causes new check-code errors.

Reviewed By: quark-zju

Differential Revision: D7098248

fbshipit-source-id: b5f18c0db3cfbb37c9f7e23e2cdfdef9cedd3f49
2018-04-13 21:51:16 -07:00
Adam Simpkins
0e49f78053 help: update the test to exclude eden help
Summary:
Some of our internal hg builds include the Eden extension now.  This was
causing the test-help.t test to fail since it included help output for the Eden
extension, but the test code did not expect this.

We unfortunately cannot update the test output to always expect help output for
Eden since the Eden extension is only included in buck-based builds.

Reviewed By: quark-zju, farnz

Differential Revision: D7063937

fbshipit-source-id: e503ddc6889e546b5333a8d9e3555097d689e24c
2018-04-13 21:51:16 -07:00
Adam Simpkins
1c3c143933 tests: cache the results of hghave checks
Summary:
Update run-tests.py to cache the results of hghave checks.  Some of the
linematch code can end up calling _hghave() hundreds of times in a row with the
same check.

This is particularly likely to happen on test failures, where a line with an
hghave check does not match the expected output.  In this case the same hghave
check will be re-run on each subsequent line of test output.

Reviewed By: quark-zju, farnz

Differential Revision: D7077677

fbshipit-source-id: 768a11df78924b75cde4c8b48c801b79194f7969
2018-04-13 21:51:15 -07:00
Mark Thomas
0a7ff59302 diff: add --only-files-in-revs option to limit files diffed
Summary:
Add a new `--only-files-in-revs` option to `hg diff`.  This filters the files
that are considered down to the set of files that are touched in either of the
two revisions.

Reviewed By: ryanmce

Differential Revision: D7070102

fbshipit-source-id: b9140cd3a212af9554ef5b76785210c1dbba8ee0
2018-04-13 21:51:15 -07:00
Stanislau Hlebik
a7bb5defb2 add --noprefix and --nodates option to show
Differential Revision: D7067556

fbshipit-source-id: 38aa09a544a1422e8762a7ebd697e55210ad20c5
2018-04-13 21:51:15 -07:00
Mateusz Kwapich
1ba076f3c1 metaedit: auto-rebase only non-obsoleted commits
Summary:
metaedit when metaediting a commit with obsolete & visible children did
autorebase all of them causing a divergence (which broke the restack)

Reviewed By: ryanmce

Differential Revision: D7067121

fbshipit-source-id: 679bc7acecde1cd648adcdddc9c8ac3ecc101208
2018-04-13 21:51:15 -07:00
Adam Simpkins
57b60abde8 bitmanipulation: fix the test build in opt mode
Summary:
When compiling with optimization enabled gcc complains that result is not
immediately initialized when created inside a constexpr function.

Differential Revision: D7065250

fbshipit-source-id: 5a829e775ce482c8a5ec9d1cfe279005ff11bb7e
2018-04-13 21:51:15 -07:00
George Tupi
d2fe0ef2cb crdump: include bookmarks in output
Summary: Including bookmarks in the crdump output

Reviewed By: sfbahr

Differential Revision: D7063784

fbshipit-source-id: 08d38d8a73a8448b3a184bfc3511cdaec01771fb
2018-04-13 21:51:15 -07:00
Mateusz Kwapich
847ef8adf9 remotefilelog: error gracefuly when the file is too big
Summary:
We don't really support files larger than 2G with files larger than
4G remotefilelog crashes badly.

Reviewed By: markbt

Differential Revision: D7066855

fbshipit-source-id: 40cdebbe703a7b3f13ce84174bf6f96565e8c3b7
2018-04-13 21:51:15 -07:00
Mateusz Kwapich
bf3aa2b73f add a test showcasing metaedit misbehaviour
Summary: It's bumping obsolete commits on metaedit.

Reviewed By: ryanmce

Differential Revision: D7067120

fbshipit-source-id: 051caacb86e54df873487b76f4d37a9c5a32a42a
2018-04-13 21:51:14 -07:00
Mark Thomas
13c825d200 arcdiff: handle -r option with --since-last-arc-diff
Summary:
If the user specifies a revision using `-r`, along with
`--since-last-arc-diff`, then show the differences for that revision, rather
than the working copy parent.

Differential Revision: D7068359

fbshipit-source-id: feffadeb45eed4e1d8bb9d8fc7040932ada31736
2018-04-13 21:51:14 -07:00
Mark Thomas
4df54adfd2 fbhistedit: don't create obsmarker for exec results
Summary:
The fbhistedit `exec` verb attempts to create an obsmarker if the working copy
parent is changed as a result of the command execution.

This isn't always valid to do: the command could have created a new commit
entirely, and the old working copy parent could be public, and thus not
obsoletable.

It's also not necessary.  If the command that ran during the exec did anything
that obsoleted commits (e.g. amend), then it should have created its own
obsmarker.

Differential Revision: D7066784

fbshipit-source-id: 326396828a06936c88154cfec6705f7834527a5f
2018-04-13 21:51:14 -07:00
Mark Thomas
3f16eb7c90 histedit: add test showing failure to insert a commit
Summary:
Inserting a commit after a public commit causes histedit to fail
when it tries to write out the obsmarkers.

Reviewed By: ryanmce

Differential Revision: D6820504

fbshipit-source-id: 1f73bde65eb87485b0712d6a365b846fd00ad48c
2018-04-13 21:51:14 -07:00
Stanislau Hlebik
1cc90e3064 merge: use relative path names
Summary:
Let's try to be consistent and print relative path names during merge. Note
that it changes test output for mq and subrepos, but we don't use these
features often, so it should be fine.

Differential Revision: D7067050

fbshipit-source-id: 3aba66e67657a1b1b30fcf239c03abd605eb5d9a
2018-04-13 21:51:14 -07:00
Mark Thomas
b44571c5bc treedirstate: implement fast debugpathcomplete with treedirstate
Summary:
`hg debugpathcomplete` is another example where the current implementation
iterates the whole dirstate looking for information that's in one directory.

With treedirstate, this can be made faster by using the tree structure.

Differential Revision: D7024784

fbshipit-source-id: 3c0b403887e85157b7eb2752abce5a0805e6ed1c
2018-04-13 21:51:14 -07:00
Gerardo Poggio
a9a16f92d8 ignore all errors when including config file
Summary:
"hg" only ignored ENOENT errors when including files (so it didn't abort when an included file didn't exist). But it aborted on every other error (e.g EPERM).
This diff makes it ignore any IOError and just print a warning.

Reviewed By: quark-zju

Differential Revision: D7029320

fbshipit-source-id: b1b8137cd575fc89fb5967e8d18fe82ab84a8f85
2018-04-13 21:51:14 -07:00
Kaley Huang
82cd0ac475 p4fastimport: handle deleted files + fix wrong parents
Summary:
Running `hg log --traceback --template '{file_copies}' -r XXXX` on a file with long history is slow for 2 reasons
- p4 fast importer preserves full history for deleted and re-added files
- p4 fast importer records the wrong parent of a file

This diff tries to fix these two issues.

In mercurial, if a file is added, deleted, and then added back, it should start a new file history when the file is added again.
For example,
commits        commit1      commit2                 commit3
actions          add a.txt      delete a.txt             add a.txt
timeline ------------X------------X------------------------X------------

`hg debugindex a.txt` at commit3 shows a.txt as a new file without previous history
   rev    offset  length  delta linkrev nodeid       p1           p2
     0         0       3     -1       0 b789fdd96dc2 000000000000 000000000000

However, this is different in p4. `p4 filelog test.txt` gives you

  //depot/Software/Apps/Main/Native/.castle/test.txt
  ... #3 change 523261 add on 2018/01/23 by zhihuih@devbig415 (text) 'test:add-again-same-file'
  ... #2 change 523254 delete on 2018/01/23 by zhihuih@devbig415 (text) 'testfile:delete'
  ... #1 change 523253 add on 2018/01/23 by zhihuih@devbig415 (text) 'testfile:add'

Currently, p4 fast importer preserves history the same way as p4, and this causes slowness (even timeout) in hg when it runs `hg log --traceback --template '{file_copies}' -r XXXX` on a revision that contains files with long history in p4 (mostly contributed by automation). To mitigate this, we want the p4 fast importer to behave the same way as hg, and starts a new history for a file that's added again.

Currently, p4 fast importer takes the tip of a filelog and treats that as the parent of the newly written entry diffusion/FBS/browse/master/fbcode/scm/hg/hgext/p4fastimport/importer.py;19ad9b05f50e3ff0265cdc7b4b45174dcf820343$468-469. This can be wrong when there are revisions from branches.

For example, if I edit file a in master in CL1, 2, 4, and I branch at CL3, and edit the file in branch in CL5, the current importer implementation will take filenode at CL4 as the parent of CL3
(CL1,2,3,4,5 corresponds to rev0,1,3,2,4)
{F120393661}

However, the correct behavior is to take filenode at CL2 as the parent of CL3
(CL1,2,3,4,5 corresponds to rev0,1,3,2,4)
{F120393662}

(This is also the example I use in `test-fb-hgext-p4fastimport-import-branch-filelogorder.t`, so if the description here looks confusing, please refer to the test)

Reviewed By: dsp

Differential Revision: D6962019

fbshipit-source-id: 24de76ae009e0d6f976d247087fe4702c99e0f82
2018-04-13 21:51:14 -07:00
Adam Simpkins
f4abe113fa treemanifest: support pulling from local repositories
Summary:
Update the treemanifest extension to also add a 'gettreepack()' function to
localpeer, and add the 'gettreepack' capability to localpeer if the repository
supports acting as a treemanifest server.

Also update the _addmanifestgroup() wrapper to only forbid it from being called
in a treemanifest server repository.  When pulling from a local treemanifest
server repository this function may need to be invoked in the client
repository.

Reviewed By: DurhamG

Differential Revision: D6980931

fbshipit-source-id: 61519c7deeaa0347650323a0002b89597e91d9cc
2018-04-13 21:51:14 -07:00
Thomas Jacob
0e6b93a0e0 Add support for RocksDB
Summary:
- Add support for RocksDB engine (developed as a drop in replacement for innodb) to hgsql to allow new xdb.hgsql.1-10 shards to host hg repos
- Prefer MySQL test DBs in same region
- Run all hgsql unit tests also for RocksDB engine
- Allow for nested ifs to make that possible (downside if you switch off rockdb tests, innodb tests are run twice)

Reviewed By: quark-zju

Differential Revision: D7014064

fbshipit-source-id: 073c36176aa7eaf74252ef33c3f47da594920b28
2018-04-13 21:51:13 -07:00
Adam Simpkins
ba78fd3db1 add some unit tests for bitmanipulation.h
Summary: Add some unit tests for the functions in bitmanipulation.h

Reviewed By: quark-zju

Differential Revision: D7018862

fbshipit-source-id: 2ffbb0c6776f702ae1e5f9a19bd6646d1d576af0
2018-04-13 21:51:13 -07:00
Phil Cohen
407941c6f3 conflictinfo: fix hg treating an interupted unshelve as a merge
Summary: Fixes T25823569. We need to check for mergestate last since some commands leave that file in addition to their own.

Reviewed By: DurhamG

Differential Revision: D7013846

fbshipit-source-id: 42730bbee81b4c3b3aa2280a48d57da703fab5dd
2018-04-13 21:51:13 -07:00
Phil Cohen
de4ccf5688 restack: remove old pre-obsolesence fixup
Summary:
Per discussion with @[100000771202578:kulshrax] [1], the new behavior is enabled everywhere, and is also vastly preferable. Let's nuke the old code, as well as the config declaration and all places that manually enabled it.

[1]

> also, it looks like the pre-restack logic is still in that function, and the modern restack code path is still gated by a config option
> we should probably remove that

Reviewed By: kulshrax

Differential Revision: D7031365

fbshipit-source-id: dcc620c292bac03fdc0aa144546d4628bb673046
2018-04-13 21:51:13 -07:00
Durham Goode
8c164692ec hg: make pushrebase and infinitepush tree part creation consistent
Summary:
The treemanifest extension now uses a pattern of
treemod._cansendtrees() to detect if it should send trees. pushrebase and
infinitepush were using a different pattern where they were sending trees if
they existed (in infinitepush's case it was ignoring the sendtrees config
entirely). Let's make these consistent.

The new behavior requires that trees exist for the commits we're trying to send.
In order for this to work, we'll need the logic that automatically converts a
flat manifest into a treemanifest so that we're never missing a tree we want to
send.

Reviewed By: markbt

Differential Revision: D7004982

fbshipit-source-id: 7dd6788173a0393d7a129123d5d62256d64b8a64
2018-04-13 21:51:13 -07:00
Durham Goode
5282ddbf02 hg: add test for setting treemanifest.sendtrees=True
Summary:
I will be enabling this config on its own more broadly soon. Let's add
a test just to verify it works without treeonly=True being set (which is what
most other tests already test).

Reviewed By: quark-zju

Differential Revision: D7004366

fbshipit-source-id: 5743fbfd23da7327d1779f8555c42a8845d60271
2018-04-13 21:51:13 -07:00
Ryan McElroy
2e0e2f49f6 remotenames: do not expect repo._remotenames to be set unconditionally
Summary:
There are cases when a local repo communicates to another local repo
where one of the repos has remotenames enabled and the other does not that lead
to crashes. We fix these cases by checking repo objects for _remotenames before
accessing that member variables.

Differential Revision: D7023300

fbshipit-source-id: e4df06671bfb8291f50c01b53750ccaa3f9df968
2018-04-13 21:51:13 -07:00
Ryan McElroy
b4e16cf52b remotenames: test various combinations of repos with and without extension
Summary:
Cases from sandcastle make it clear that there are circumstances where
a one local repo talks to another local repo, one with remotenames enabled and
the other without remotenames enabled, that crashes can happen.

Let's add a test case to find some of these so we can prove they are fixed.

Differential Revision: D7023299

fbshipit-source-id: ddc8a701ac7573bcc15f737df1c5e29ef3581201
2018-04-13 21:51:13 -07:00
Ryan McElroy
7096d79404 remotenames: do not over-check for svn/git push targets
Summary:
Previously, if the user had an svn or git push target set up, we would
bail from the normal push --to process even if the users were pushing to a
different location. This is silly. Instead, let's only bail if the user is
actually pushing to an svn or git destination repository.

This bug was discovered while testing the updated svn-to-hg sync scripts.

Differential Revision: D7023173

fbshipit-source-id: bec5e069bc043c2f73fb334bdaeb18a6fad93eef
2018-04-13 21:51:12 -07:00
Ryan McElroy
2298ee590a remotenames: do not crash if no bookmarks are passed to push discovery
Summary:
Today, there are cases where this function will be called but bookmarks
will not have been populated. We will eliminate one of these paths next,
but for safety, let's make sure we abort gracefully rather than with a
stacktrace by referencing something that does not exist.

Differential Revision: D7023172

fbshipit-source-id: 8e3b2afe9fe3b9d74d42aa5b947229418ec8c3ad
2018-04-13 21:51:12 -07:00
Serafeim Mellos
3a42733be6 Teach bisect to ignore empty commits on sparse checkouts
Summary: Skip empty commits in sparse repositories when doing bisection

Reviewed By: ryanmce, farnz

Differential Revision: D7001328

fbshipit-source-id: 8493d20389410b522e70ce41cc3e33ac9361781d
2018-04-13 21:51:12 -07:00
Rohit Yadav
4838457b17 remotefilelog: before creating filenode, check in manifest if the file exists
Summary:
When hg addremove needs to remove a file, remotefilelog tries to create a filenode in order to prefetch the removed files from the server.  If the file is not in the parent context manifest, this throws an exception.

To solve this we have to first check if the file exists or not in the parent manifest.  If the file does not exist in the manifest then we don't need to prefetch it, and addremove will behave like forget rather than remove.

Reviewed By: markbt

Differential Revision: D7009649

fbshipit-source-id: 0570bc00db546a455b9c2e4628740e24ca819dd6
2018-04-13 21:51:12 -07:00
Alexandre Marin
3560fd1139 Remove unnecessary/broken test
Summary:
Upon running `p4fastimport` tests locally I found out this test being deleted was not working.
It turns out I was using a newer version of p4d (2017.2) and the clowny behavior
around symlinks that it tests for was fixed in p4d 2017.1

I found out we use 2017.1 in our perforce servers:
diffusion/O/browse/opsfiles/branches/PROD/chef/cookbooks/other/fb_perforce/recipes/perforce_server.rb;1001845$125,125-126,333-334

Therefore, this test is not currently accurate or needed

Differential Revision: D7015278

fbshipit-source-id: 6e0e62371781a06bf194a624f4f557bddd3ccda4
2018-04-13 21:51:12 -07:00
Jun Wu
b58ff2f085 tests: run pyflakes tests in buck test
Summary:
Within buck test envirionment there is no guarnatee that `pyflakes` binary is
in `PATH`.  This patch builds pyflakes as a test dependency so buck test will
run `test-check-pyflakes.t` instead of skipping it.

Reviewed By: markbt

Differential Revision: D7008100

fbshipit-source-id: eca6f0174dbc9c12d45eca2f17f70a9805f13094
2018-04-13 21:51:12 -07:00
Kaley Huang
6425129a45 verify: add --rev support
Summary:
Currently, commits adding LFS files are not verified server-side since the LFS
extension explicitly skips hash checking during unbundle, to avoid overhead
downloading/reading LFS objects.

We'd like those commit hashes to be verified.  However, the existing verify
command does not scale with a huge repo.  So let's add `verify -r REV` support
to be able to incrementally verify a repo.

Reviewed By: quark-zju

Differential Revision: D6947227

fbshipit-source-id: 6ffda3a814822942630339fc7de62c3fcb284fda
2018-04-13 21:51:12 -07:00
Durham Goode
60f4968015 hg: add remotestore to history union store
Summary:
Previously we would only do ondemand downloading of tree blobs when
accessing data contents. When accessing just history we would just fail if the
data wasn't available locally. This adds the remote store to the history union
store so we can get history remotely.

Reviewed By: singhsrb

Differential Revision: D7003434

fbshipit-source-id: 839f8e84be35779ccb146d13ce3e1d6d1e7f46bd
2018-04-13 21:51:12 -07:00
Kostia Balytskyi
c17a144d34 hg: add debuglfsdownloadsize command
Summary:
This can be convenient when the size of LFS downloads between r1 and r2 is needed.

NB: this does not pay attention to sparse profiles and acts as if the checkout was full. We probably need to know how to do both.

Reviewed By: quark-zju

Differential Revision: D6938259

fbshipit-source-id: 52ab88be83339472f2eccafc746a191ff26c16c7
2018-04-13 21:51:12 -07:00
Durham Goode
5df613f729 hg: fix prefetch in treeonly mode
Summary:
remotefilelog prefetch was broken in treeonly mode since it referred to
the manifest revlog to get the parents. Let's switch to the more modern
manifestctx way of accessing parent information.

Reviewed By: quark-zju

Differential Revision: D6995267

fbshipit-source-id: e0c11fca0f2156be3f936a6e437e7a4d3dffe75b
2018-04-13 21:51:12 -07:00
Mark Thomas
fce9280599 tests: remove unused import sys
Summary:
quark-zju removed mangling of sys.path in D6974954.  The `import sys` is now no
longer needed.

Differential Revision: D6998711

fbshipit-source-id: 1d8298ce8d5077e3ae7ae3c88f2a2b7adf9712d3
2018-04-13 21:51:11 -07:00
Jun Wu
3c45a72e2a patchpython: remove the extension
Summary:
It was used to patch Python's `SocketServer`. Since we no longer use
`SocketServer` in command server's code path. The extension can be removed.

Reviewed By: ryanmce

Differential Revision: D6974976

fbshipit-source-id: 52353b55d812e494756833cefba896b6e64eaf9e
2018-04-13 21:51:11 -07:00
Jun Wu
406b752720 tests: use an environment variable for getdb.sh location
Summary:
Make `library.sh` read `$HGTEST_GETDB_PATH` for `getdb.sh` location. Unify
`getdb.sh` used by infinitepush and hgsql into one.

Reviewed By: ryanmce

Differential Revision: D6974635

fbshipit-source-id: 55bcebfbdaca7f43fb0cfca0d3e089e76cf9f24e
2018-04-13 21:51:11 -07:00
Jun Wu
51be4ac4b9 tests: do not mangle sys.path
Summary:
Mangling `sys.path` in `.py` tests could break tests running with `buck` opt
build. Because the bundled extensions won't be used, but files in the working
copy will. It's okay-ish for pure Python extensions. But native extensions will
have problems.

Reviewed By: ryanmce

Differential Revision: D6974954

fbshipit-source-id: 8a7f3d86e5c2fbf16cfcc971743d99585fe61b99
2018-04-13 21:51:11 -07:00
Jun Wu
6ecd47c391 smartlog: prefer gdbm to anydbm
Summary:
anydbm uses bsddb by default. bsddb is slower than gdbm and
is not available in buck build. Therefore use gdbm instead.

Differential Revision: D6994367

fbshipit-source-id: 948b991df31436d02f478d7a95f9924e1f8e0ed5
2018-04-13 21:51:11 -07:00
Mainak Sen
20bcf91c66 fbamend: a config flag for skipping autorebase for hg amend
Reviewed By: quark-zju

Differential Revision: D6947242

fbshipit-source-id: cf22cf5f514825d7e09aade90f1c9efdc7f73fa1
2018-04-13 21:51:11 -07:00
Durham Goode
7b90d5d33a hg: make mutabledatapack implement data API
Summary:
As part of producing only one pack file per transaction, we need to
change the mutabledatapack store to allow reads of written-but-not-finalized
data. This will allow us to add the mutabledatapack to the union store, and then
keep it alive for the duration of the transaction.

Reviewed By: quark-zju

Differential Revision: D6944348

fbshipit-source-id: 1e721bd8e07335a9c1f9c6b7595a765ec018c007
2018-04-13 21:51:11 -07:00
Kostia Balytskyi
7d4f6a9033 hg: start using imported mman-win32 in the portability headers
Summary:
Let's create a new portability header, which can be used on both Windows and
Posix.

Reviewed By: quark-zju

Differential Revision: D6970928

fbshipit-source-id: a3970c50260f52bfc0a9420a4ff11d93ace304b0
2018-04-13 21:51:10 -07:00
Jun Wu
90d95e9e94 fixcorrupt: improve usability
Summary:
We have seen several cases that 00changelog.i got filled with 0s at the end
after a hard reboot. Improve fixcorrupt tool to be able to detect and fix
that. Previously it will not treat node=nullid as corrupted, and it would
also trust linkrev=0, which will truncate the entire changelog.

Reviewed By: ryanmce

Differential Revision: D6952921

fbshipit-source-id: b77e85f23c304ebde3740d6ed70effa1bc792928
2018-04-13 21:51:10 -07:00
Mark Thomas
516c0b5131 hgsql: make sqlverify test print full error output
Summary:
`test-hgsql-verify.t` occassionally fails, however the error output is lost to
an invocation of grep.

Instead, capture the output of the call to `hg sqlverify`, and if it doesn't
contain the string we're looking for, print the whole output.

Reviewed By: DurhamG

Differential Revision: D6965336

fbshipit-source-id: 72c47bbafcdc2b3ba32dc307670f2d8b0ee09d16
2018-04-13 21:51:10 -07:00
Jun Wu
e5e4d70d16 inhibit: move part of logic to core
Summary:
inhibit has a very hacky way to disable obsmarker cycle check.
Move that to core to clean up the code.

Reviewed By: ryanmce

Differential Revision: D6956217

fbshipit-source-id: 18370721ec80e74008232e09049a057ee080e7d5
2018-04-13 21:51:10 -07:00
Jun Wu
ad0942500c flake8: enable some E checks
Summary: They look useful.

Reviewed By: DurhamG

Differential Revision: D6934534

fbshipit-source-id: 4179a50c073909a8139dfdd91885f729e7d0a4b3
2018-04-13 21:51:09 -07:00
Jun Wu
f1c575a099 flake8: enable F821 check
Summary:
This check is useful and detects real errors (ex. fbconduit).  Unfortunately
`arc lint` will run it with both py2 and py3 so a lot of py2 builtins will
still be warned.

I didn't find a clean way to disable py3 check. So this diff tries to fix them.
For `xrange`, the change was done by a script:

```
import sys
import redbaron

headertypes = {'comment', 'endl', 'from_import', 'import', 'string',
               'assignment', 'atomtrailers'}

xrangefix = '''try:
    xrange(0)
except NameError:
    xrange = range

'''

def isxrange(x):
    try:
        return x[0].value == 'xrange'
    except Exception:
        return False

def main(argv):
    for i, path in enumerate(argv):
        print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
        content = open(path).read()
        try:
            red = redbaron.RedBaron(content)
        except Exception:
            print('  warning: failed to parse')
            continue
        hasxrange = red.find('atomtrailersnode', value=isxrange)
        hasxrangefix = 'xrange = range' in content
        if hasxrangefix or not hasxrange:
            print('  no need to change')
            continue

        # find a place to insert the compatibility  statement
        changed = False
        for node in red:
            if node.type in headertypes:
                continue
            # node.insert_before is an easier API, but it has bugs changing
            # other "finally" and "except" positions. So do the insert
            # manually.
            # # node.insert_before(xrangefix)
            line = node.absolute_bounding_box.top_left.line - 1
            lines = content.splitlines(1)
            content = ''.join(lines[:line]) + xrangefix + ''.join(lines[line:])
            changed = True
            break

        if changed:
            # "content" is faster than "red.dumps()"
            open(path, 'w').write(content)
            print('  updated')

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
```

For other py2 builtins that do not have a py3 equivalent, some `# noqa`
were added as a workaround for now.

Reviewed By: DurhamG

Differential Revision: D6934535

fbshipit-source-id: 546b62830af144bc8b46788d2e0fd00496838939
2018-04-13 21:51:09 -07:00
Jun Wu
0daed9e7f6 flake8: resolve some F checks
Summary:
Solves issues below:
```
hgext/backups.py:18:1: F811 redefinition of unused 'registrar' from line 17
hgext/catnotate.py:1:1: F811 redefinition of unused 'util' from line 1
hgext/remotenames.py:57:5: F811 redefinition of unused 'registrar' from line 34
hgsubversion/setup.py:103:5: F401 'mercurial' imported but unused
hgsubversion/setup.py:109:5: F401 'hgsubversion.svnwrap.svn_swig_wrapper' imported but unused
i18n/polib.py:1281:29: F841 local variable 'exc' is assigned to but never used (Python 2)
i18n/polib.py:1427:13: F841 local variable 'typ' is assigned to but never used
i18n/polib.py:28:1: F401 'sys' imported but unused
mercurial/manifest.py:411:5: F811 redefinition of unused '_lazymanifest' from line 168
mercurial/posix.py:419:5: F811 redefinition of unused 'normcasefallback' from line 362
mercurial/posix.py:425:5: F811 redefinition of unused 'checkexec' from line 167
mercurial/posix.py:431:5: F811 redefinition of unused 'checklink' from line 234
mercurial/pycompat.py:29:5: F401 'http.cookiejar as cookielib' imported but unused
mercurial/pycompat.py:30:5: F401 'http.client as httplib' imported but unused
mercurial/pycompat.py:31:5: F401 'pickle' imported but unused
mercurial/pycompat.py:33:5: F401 'socketserver' imported but unused
mercurial/pycompat.py:34:5: F401 'xmlrpc.client as xmlrpclib' imported but unused
mercurial/statprof.py:573:36: F812 list comprehension redefines 'parent' from line 562 (Python 2)
mercurial/util.py:1076:5: F811 redefinition of unused 'nogc' from line 1051
mercurial/util.py:3221:5: F811 redefinition of unused 'dirs' from line 3184
tests/silenttestrunner.py:24:5: F811 redefinition of unused 'main' from line 6
tests/test-context.py:90:1: F811 redefinition of unused 'scmutil' from line 4
tests/test-fb-hgext-cstore-treemanifest.py:146:5: F811 redefinition of unused 'testDeeplyNested' from line 134
tests/test-fb-hgext-extutil.py:46:5: F811 redefinition of unused 'testbgcommandfailure' from line 37
tests/test_hgsubversion_util.py:47:1: F811 redefinition of unused 'svnwrap' from line 31 (Python 2)
tests/test_hgsubversion_util.py:49:1: F811 redefinition of unused 'svnwrap' from line 47 (Python 2)
```

Reviewed By: ryanmce

Differential Revision: D6934533

fbshipit-source-id: 8b51851a76fec88bb59107ed05a901d42c7326f8
2018-04-13 21:51:09 -07:00
Jun Wu
f5924da1d3 tests: improve test compatibility with different zlib
Summary:
When running with a Python runtime with a slightly different zlib module,
some `zlib.compress` outputs are different. Some tests are testing the
length, or the content of `zlib.compress` output, directly or indirectly.
That's causing issues.

This patch adds a `common-zlib` hghave test so it can be used to gate tests
checking zlib output. Some lengths are also changed to glob patterns to be
compatible.

Reviewed By: ryanmce

Differential Revision: D6937735

fbshipit-source-id: 2328a39d7f2022f16d51f61b6178568b26dfe2fb
2018-04-13 21:51:09 -07:00
Jun Wu
2946a1c198 codemod: use single blank line
Summary: This makes test-check-code cleaner.

Reviewed By: ryanmce

Differential Revision: D6937934

fbshipit-source-id: 8f92bc32f75b9792ac67db77bb3a8756b37fa941
2018-04-13 21:51:08 -07:00