Summary:
`hg` also supports matching a date range via `util.matchdate`. For example,
`Apr 2000` would mean `Apr 1, 2000 0:0:0 to Apr 30, 2000 23:59:59`.
Implement that behavior. Also support other formats covered by `hg help dates`
including `> DATE`, `< DATE`, `DATE to DATE`, and `-DAYS`.
Reviewed By: sfilipco
Differential Revision: D17504706
fbshipit-source-id: db1c280b62a72f4e8128909ca6fd814d85d22491
Summary:
This is a feature that does not exist in hg. It has potential to unify the
`date` and `ago` revsets.
By using the `humantime` crate we can get this feature fairly easily.
Reviewed By: sfilipco
Differential Revision: D17504705
fbshipit-source-id: b888517114b91c847ae319552d07fe5a5a41cad3
Summary:
Dates like `13:00` or `Apr 2010` cannot be parsed directly. Support them by
filling the missing fields.
This is mostly porting from `mercurial.util.parsedate` and
`mercurial.util.strdate`, with a small bug fixed: default value for month/day
are set to "1" instead of "0".
Reviewed By: sfilipco
Differential Revision: D17504703
fbshipit-source-id: dac9f5e4946c8d838f50ef1d4677741f6e4bc771
Summary:
I'd like a native `blackbox`-like command that accepts something like:
--date 'since 3 hours ago'
--date 'since yesterday'
--date today
--date 'Apr 2019' (implies a range of a month)
--date 'Apr 2019 to Jul 2019'
--date '13:00 to 15:00' (implies within today)
With a goal that this can be a superset and replace hg's date utilities,
and it can be used in `log --date`, revsets, etc.
Sadly, none of the top public Rust crates can sasity the existing features
("13:00" implying "today", "Apr 2019" implies a range of a month are two
less-known features that the Rust date utilties do not handle).
So I started porting the Python code (`mercurial.util.parsedate`) to Rust.
The core `parse` function is just 40 lines now.
Reviewed By: sfilipco
Differential Revision: D17504704
fbshipit-source-id: bde356a8cedf3298b060220de499e3954ed9d88b
Summary:
By design, reading is lock-free but writing (including create_empty_log) needs
locks. Make create_empty_log take a lock reference to be more confident.
Reviewed By: xavierd
Differential Revision: D17810952
fbshipit-source-id: 57bf3ea8db691e04de0a083369258f6dbff7c79e
Summary:
With the latest change, logs are lazy. Looking up a deleted log is untested.
Let's add a test.
Reviewed By: xavierd
Differential Revision: D17810951
fbshipit-source-id: 8e0b898636f1c5e71760f00f7df696ac50c5b0f1
Summary:
It's a bit surprising to users that switching to a non-existing profile
triggers a full-checkout. Let's at least warn about it so they can cancel the
operation.
Reviewed By: quark-zju
Differential Revision: D17792720
fbshipit-source-id: 7d91394d3fa439ea1a5715d9a538ea30d3cd6e87
Summary:
Suggested by xavierd in D17742002, it's safer to just require a reference to
a lock to prove a lock was taken. So let's make the change.
Reviewed By: xavierd
Differential Revision: D17767455
fbshipit-source-id: c1675a98a60c4874eab0406c59b25603a35a8d83
Summary: ScopedDirLock does not need path.
Reviewed By: xavierd
Differential Revision: D17767454
fbshipit-source-id: ccafc00081f8eb14bf24534a8cc61e6ad5e794b9
Summary:
Brain-dump why this API exists, and what should new indexedlog internal code do
for new errors.
Reviewed By: xavierd
Differential Revision: D17763339
fbshipit-source-id: b04255a079908f2a80ac49c22cba0da5f1e92539
Summary:
Similar to the previous diff, this makes Log more friendly in case where an external
process runs `rm -rf` brutely.
Reviewed By: xavierd
Differential Revision: D17763340
fbshipit-source-id: 1306e7ecef44f53f7945922b0216ca0a05f45009
Summary:
In rare cases (ex. some other automation runs `rm -rf`), the `latest` file can
get deleted unexpectedly and cause an error. However, if `sync` is expected
to do a read-only refresh to load new data, it is harmless to stay "as-is" if
lastest cannot be read.
Reviewed By: xavierd
Differential Revision: D17763341
fbshipit-source-id: 6a493b8741b628f44709234bd69394d3b4eeb4de
Summary:
The code is broken:
- It happily deletes the `rotatelog/latest` file, which is unexpected by RotateLog.
- It can also delete `packs` on Windows, because `\packs\` never matches `/packs/`.
and suboptimal:
- It does unnecessary tests in inner loops.
- It does unnecessary subdir walks.
Fix them.
Reviewed By: singhsrb
Differential Revision: D17777647
fbshipit-source-id: 08afbb1439e36bb5194053e52e1901b538e42ba3
Summary:
Before this diff output from two lines was glued:
```
No known server bookmarkssearching for changes
```
Reviewed By: farnz
Differential Revision: D17786686
fbshipit-source-id: ddb96c7fa391f4ca07a18a7a2145fff2b9d249bb
Summary:
The auto recovery logic is more harmful than useful as it hides real errors and
can corrupt other running hg processes. Remove them so we can see the real
errors, and since we now have a proper `hg doctor` command that can fix things
more properly.
If this turned out to be an issue, we should investigate why data corruption
happened (they are only expected for force reboot / os crash cases), or add
some configurable auto recovery in the Python layer.
Reviewed By: xavierd
Differential Revision: D17755607
fbshipit-source-id: 0916b65d07da36af6c5aa6d2d6b69fa83d29d530
Summary: For now it just repairs indexedlog stores. We can add other stuff later.
Reviewed By: xavierd
Differential Revision: D17755606
fbshipit-source-id: 0599ac0e8e5c049f4cf96ae30df53c920dee21a6
Summary:
The side effects are undesirable as an error in the store can crash any repo command.
That makes it harder to implement a `doctor` command to fix the stores.
Reviewed By: xavierd
Differential Revision: D17755609
fbshipit-source-id: 3ba1774de965c4d896178adc47df805f6e465071
Summary: This exposes the repair API to the Python world.
Reviewed By: xavierd
Differential Revision: D17755604
fbshipit-source-id: fb5089a1f0648b18d4a338c3c73e939d5ce37bed
Summary: This just calls into the indexedlog repair API.
Reviewed By: xavierd
Differential Revision: D17755608
fbshipit-source-id: ff6c99cadfc900f8ab8c49fe887161492e08c692
Summary:
This runs an explicit "verify & repair" on all logs in a RotateLog and attempt
to fix the "latest" file.
Reviewed By: xavierd
Differential Revision: D17755605
fbshipit-source-id: eaab4a4e76060a4d094e2bbd42baca9f1e684240
Summary:
Use the new API `log::OpenOptions::delete_content` to ensure logs are empty.
This auto fixes issues where a stale directory with broken content can prevent
RotateLog from rotating things.
This has some side effects:
- Logs are logically empty but physically have some bytes - test change
- Reveals an integer overflow panic - fixed in logs.rs
Reviewed By: xavierd
Differential Revision: D17741995
fbshipit-source-id: 51904090dad60718deefa537cf4db91554f3ac31
Summary:
Previously, RotateLog loads as many logs as it can during initialization or
sync. However, that could be undesirable because loading too many logs can
take time. Make log loading lazy except for the `latest` log to reduce
overhead.
Reviewed By: xavierd
Differential Revision: D17740792
fbshipit-source-id: cde4c1799ed55d390dadaa5bd34f3d2c6d0e1cf7
Summary: This can be used in LogRotate to ensure new logs being created are empty.
Reviewed By: xavierd
Differential Revision: D17732138
fbshipit-source-id: 57c86e586decf6e26fa7ebe2d74a93afb4559f43
Summary:
Fix multiple issues. Namely:
- Move it to OpenOptions, since Log::repair requires a Log, and it's problematic to open a corrupted Log.
- Make it also repair indexes, since otherwise the performance would be terrible.
- Output some human messages about what was done.
- Make it safe (no SIGBUS) by not truncating data. This works because D16076658
made Log ignore the physical file length, and only use the metadata length.
- Added a strong test which drove a lot of fixes in this stack.
Reviewed By: xavierd
Differential Revision: D17741210
fbshipit-source-id: 9363dc2f38e66df30b5ed0323455bf67b68227c1
Summary:
Add extra metadata to help detect non-append-only changes and make Log::sync
handle it by automatically reloading log and indexes. This can reduce chances
that data were written to a different log incorrectly.
Reviewed By: xavierd
Differential Revision: D17732137
fbshipit-source-id: 33668913f1695a6c02af5b81a40214e5a521ef09
Summary:
Fix multiple issues. Namely:
- Make it composiable in 'repair' by adding a 'assume_locked' flavor.
- Make it possible to only rebuild corrupted indexes.
- Output some human messages about what was done.
Reviewed By: xavierd
Differential Revision: D17741997
fbshipit-source-id: d0f56544f69b2536459a7580e3c052d45454667d
Summary:
This allows `Log::open` logic to be used in cases where the directory lock was
already taken. Namely, in `repair`, `sync` and other write operations.
Yes, the old code is wrong and can deadlock.
Reviewed By: xavierd
Differential Revision: D17742002
fbshipit-source-id: 8fbe02bee3e77e00743212ea5b456128d4371362
Summary:
This is a small improvement. It turns out to be useful when debugging some
other issues.
Reviewed By: xavierd
Differential Revision: D17741994
fbshipit-source-id: 73e3ba2f222366c1b1c614da08f8869011eb87f8
Summary:
This allows Log to check whether logs are corrupted and decide whether to
rebuild them.
Reviewed By: xavierd
Differential Revision: D17741996
fbshipit-source-id: 37c0a2789465877680bf8ebc50afe5d132574f8e
Summary: Upcoming changes will break it. Remove it for now.
Reviewed By: xavierd
Differential Revision: D17742005
fbshipit-source-id: 762874568a87188f149ad297a708687e4b961570
Summary:
The new metadata is used to more reliably detect non-append-only changes.
This makes is possible to correctly reload or handle non-append-only cases, namely
`repair` and `rm -rf`.
Reviewed By: xavierd
Differential Revision: D17742003
fbshipit-source-id: effa2ede817bb155ba4614da1be2bc497f0f1eb9
Summary:
ChecksumTable::open fails if the on-disk checksum is broken. That makes it
harder to repair checksum issues. Add a new API to fix it.
This makes `repair` able to fix index checksum corruption, covered by an
upcoming test about `repair`.
Reviewed By: xavierd
Differential Revision: D17741998
fbshipit-source-id: e43f7599d1e7e119537b075dd94e56f61779c605
Summary:
Certain IO errors are surely data corruption - the data can be read
(no permission or resource errors), but does not meet expectations
(format or range).
This fixes some cases covered by an upcoming test about `repair`.
Reviewed By: xavierd
Differential Revision: D17742001
fbshipit-source-id: 8436d477a25efe09bd5a763371df913acbfccc68
Summary: This should fix lints about `stat` being redefined.
Reviewed By: kulshrax
Differential Revision: D17766500
fbshipit-source-id: ca326ae9d0c922c60ac26f0e367a70e11d20fcd3
Summary: The old code incorrectly only respects the last argument of `setconfig`.
Reviewed By: xavierd
Differential Revision: D17766375
fbshipit-source-id: ec70c10eb62803c9f3d8dde5d88f91d076a55049
Summary:
https://www.python.org/dev/peps/pep-0479/
If you are in a generator (a function that uses "yield") you are never allowed to raise StopIteration instead you should just `return` or pass out of scope (implicit return None)
Reviewed By: thatch
Differential Revision: D17749640
fbshipit-source-id: 9f1be673cf877ff193a0379a0208d037dd2d7bae
Summary:
Rust manifests are the future. Tests work well with them and we are looking
ahead at rolling them out. To protect against regressions on the Rust manifest
side we need to have an automated test story.
I think that the most effective thing we can do is to enable Rust Manifest for
all tests. The C++ codebase is not seeing any kind of modification and we plan
to delete as soon as Rust manifests roll out.
Reviewed By: xavierd
Differential Revision: D17728414
fbshipit-source-id: 59979d02e3cece83e73569a43d6fdbb7a29dc66d
Summary: This is a better way to wrap smartlog functionality.
Reviewed By: mitrandir77
Differential Revision: D17686738
fbshipit-source-id: 770b32c19c89a59aee0f8b25251faaae7685a4dd
Summary: The graphnode templatekw must be wrapped in the keywords dict, and the phabstatus template needs to work if the requested revision is hidden.
Reviewed By: mitrandir77
Differential Revision: D17685575
fbshipit-source-id: 5e4a8b45dfe6564af3f72de3511d834aa498d154
Summary:
Right now, not being able to find the mmap file can be seen as data corruption.
The only case that NotFound needs special handling is at open time.
This fixes some cases covered by an upcoming test about `repair`.
Reviewed By: xavierd
Differential Revision: D17741999
fbshipit-source-id: 1bd7c65c5a6381892723b31e2e749b22081e96d2
Summary: Now all `indexedlog` APIs use the new new Error type.
Reviewed By: xavierd
Differential Revision: D17732136
fbshipit-source-id: 8d306a08d8e8052d1c5e68fc5f05a9eed5c7d21f
Summary: This provides more details, and makes callsites simpler.
Reviewed By: xavierd
Differential Revision: D17732127
fbshipit-source-id: 0fe6dedee4ebb8874ea95505c86d8b107e3367ff