Commit Graph

33765 Commits

Author SHA1 Message Date
Jun Wu
bd039f3688 pager: do not start pager if ui has been pushbuffer-ed
The `pushbuffer`, `popbuffer` APIs are intended to capture internal output.
They will prevent `ui.write` from writing to the actual `ui.fout`. So a
pager won't receive the output and do the right thing. In general, it does
not make sense to start a pager if ui is in the "pushbuffer" mode.

Differential Revision: https://phab.mercurial-scm.org/D574
2017-08-30 14:04:55 -07:00
Jun Wu
4cd80fdd9c revset: do not flip "and" arguments when optimizing
Rewrite `flipand(y, x)` to `andsmally(x, y)` so the AST order is unchanged,
which could be more friendly to developers.

Differential Revision: https://phab.mercurial-scm.org/D579
2017-08-30 16:05:12 -07:00
Yuya Nishihara
507a4c9e22 revset: make match function follow given subset if specified (API)
This should be sensible default since mfunc(subset) is roughly equivalent
to 'subset & mfunc'. The order argument is still there so we can specify
'anyorder' if the order doesn't really matter.
2017-08-30 22:51:28 +09:00
Yuya Nishihara
abe6c88072 revset: move order argument to run-time match function
We no longer need the order flag to build a parsed tree.
2017-08-30 22:41:36 +09:00
Yuya Nishihara
389688d31e revset: fix example describing how ordering is determined
It was 'X & !Y' before.
2017-08-30 23:53:30 +09:00
Yuya Nishihara
3de7eef1fb revset: move order constants from revsetlang
Thanks to the recent refactor, the ordering rule is fully processed at
runtime.
2017-08-30 22:32:47 +09:00
Denis Laxalde
5c30bad3cd tag: use filtered repo when creating new tags (issue5539)
When pruning a changeset that added a tag and then adding another tag, the
"pruned" tag gets restored. This is because the tag creation step (tags._tag()
call in tags.tag()) is currently done on the unfiltered repo. This behavior
has been there from ba5c1b80e99a which backs out 39c37a1a9e2d with no clear
reason but caution on unthought situations at that time. In this changeset, we
pass the filtered repo to tags._tag(), preventing "pruned" tags to reappear.
This somehow restores 39c37a1a9e2d, though now we arguably have a valid use
case for.
2017-08-29 11:25:22 +02:00
Martin von Zweigbergk
45124be9f2 extensions: add wrappedfunction() context manager
Several extensions exist that temporarily want to wrap a function (at
least narrowhg, any many of the extensions in hg-experimental). That's
why we have the unwrapfunction() that was introduced in c8cda8f6f043
(extensions: add unwrapfunction to undo wrapfunction, 2016-08-10).

This patch adds a simple wrappedfunction() that returns a context
manager.

Differential Revision: https://phab.mercurial-scm.org/D472
2017-08-21 16:46:05 -07:00
David Soria Parra
6d9f90fa8d mdiff: add a --ignore-space-at-eol option
Add an option that only ignores whitespaces at EOL. The name of the option is
the same as Git.

.. feature::

   Added `--ignore-space-at-eol` diff option to ignore whitespace differences
   at line endings.

Differential Revision: https://phab.mercurial-scm.org/D422
2017-08-29 18:20:50 -07:00
Jun Wu
a2849aacae revset: improve documentation about ordering handling
The old documentation is a bit confusing. Namely, it's unclear whether
`define` means "I should ALWAYS define a new order", or "I should SOMETIMES
define a new order", and if it's the latter, what's the difference between
`define` and `any`?

This patch clarifies that and adds more examples.

Differential Revision: https://phab.mercurial-scm.org/D523
2017-08-25 11:20:34 -07:00
Jun Wu
647a38e249 revset: remove order information from tree (API)
Keeping `order` in tree makes AST operation harder. And there could be
invalid cases if trees could be generated and compounded freely, like:

  SetA(order=define) & SetB(order=define)
                                  ^^^^^^ couldn't be satisfied

This patch changes the code to calculate order on the fly, during tree
traversal. Optimization of reordering `and` arguments is preserved by
introducing a new internal operation `flipand`.

.. api::

   revset.stringset() now takes 'order' as the last argument.

Differential Revision: https://phab.mercurial-scm.org/D451
2017-08-20 10:55:11 -07:00
Jun Wu
31517054b3 revset: drop optimization about reordering "or" set elements
The reordering optimization is more important for "and" than "or", given the
implementation details about "addset" and "filteredset" - reordering "or"
may help "__contains__" test but not iteration, reordering "and" could help
both. We are going to simplify the tree to remove ordering information.
Removing "or" reordering optimization would make things simpler.

This effectively reverts 6820a8a645ef. It tracks back to the "orset"
function added by the initial commit of revset (c9ce8ecd6).

In the future, we might consider optimization at runtime (ex. do reordering
and rewrites inside "orset").

Differential Revision: https://phab.mercurial-scm.org/D561
2017-08-28 23:44:47 -07:00
Jun Wu
0bba32af82 rebase: use _ctxdesc in one more place
This simplifies the code.

Differential Revision: https://phab.mercurial-scm.org/D566
2017-08-29 17:51:54 -07:00
Jun Wu
4e250e8aa3 rebase: move working parent and bookmark for obsoleted revs (BC)
Previously, obsoleted revs with successors in destination are completely
ignored. That caused some inconvenience when working copy is obsoleted. Most
commands avoid working copy being obsoleted, but `hg pull` is an exception.

This patch makes rebase able to move bookmarks or working parent for those
obsoleted revs. It does so by keeping the obsoleted revs in `state` and
marking them as "skipped, rebased to desired destination" during run-time.

This reverts part of the behavior change of 80d53a39fbcc and D24.

Differential Revision: https://phab.mercurial-scm.org/D527
2017-08-27 02:47:47 -07:00
Jun Wu
fc9e88f730 rebase: remove an unnecessary adjustdest in clearrebased
`rev` being "skipped" could currently be caused by moving `rev` does not
create a new commit. In this case, `state[rev]` is already changed to `p1`,
and is a sane destination for bookmark or working parent movement. Therefore
an additional destination adjustment is unnecessary.

Differential Revision: https://phab.mercurial-scm.org/D565
2017-08-29 17:49:13 -07:00
Jun Wu
3d0b72dc6a rebase: sort destmap topologically
Previously rebase source and destination could not overlap. But with the
multi-destination support, source and destination could reasonably partially
overlap. That requires another topological sort on `{sourcerev: destrev}`
graph (destmap). This patch implements that.

If a revision's destination is itself, the error message gets changed from
"source is ancestor of destination" to "source and destination form a
cycle". Not marking as BC since automation should depend on exit code, not
error message.

Differential Revision: https://phab.mercurial-scm.org/D470
2017-08-21 20:22:07 -07:00
Jun Wu
973c4f76d4 rebase: initial support for multiple destinations
This patch defines `SRC` (a single source revision) and `ALLSRC` (all source
revisions) to be valid names in  `--dest` revset if `--src` or `--rev` is
used. So destination could be defined differently according to source
revisions. The names are capitalized to make it clear they are "dynamically
defined", distinguishable from normal revsets (Thanks Augie for the
suggestion).

This is useful, for example, `-r 'orphan()' -d 'calc-dest(SRC)'` to solve
instability, which seems to be a highly wanted feature.

The feature is not completed, namely if `-d` overlaps with `-r`, things
could go wrong. A later patch will handle that case.

The feature is also gated by `experimental.rebase.multidest` config option
which is default off.

Differential Revision: https://phab.mercurial-scm.org/D469
2017-08-29 17:27:37 -07:00
Jun Wu
4706eacb8d rebase: change internal format to support destination map
A later patch will add multiple destination support. This patch changes
internal state and the rebase state file format to support that. But the
external interface still only supports single destination.

A test was added to make sure rebase still supports legacy state file.

The new state file is incompatible with old clients. We had done similar
state file format change before: 5eac7ab, 92409f8, and 72412af. The state
file is transient, so the impact of incompatibility is limited. Besides,
the old client won't support multiple destinations anyway so it does not
really make sense to make the file format compatible with them.

Differential Revision: https://phab.mercurial-scm.org/D348
2017-08-11 00:32:19 -07:00
Jun Wu
7eaa8f29d7 rebase: rewrite _computeobsoletenotrebased
The old code stores successors of all related nodes together, which works
fine if destination is unique. A future patch would make destination
non-unique so let's change the implementation to test successors for
rebaseset separately.

Differential Revision: https://phab.mercurial-scm.org/D347
2017-08-11 00:31:52 -07:00
Michael Bolin
d92f944789 util: use ~ as a suffix for a temp file in the same directory as a source file
Tools like Buck have patterns to ignore the creation of files (in the working
copy) that match certain patterns:

39278a4f07/src/com/facebook/buck/cli/Main.java (L259-L299)

When Buck sees a new source file (as reported by Watchman), it has to invalidate
a number of caches associated with the directory that contains the file.
Using a standard suffix, such as `~`, would make it easier for Buck and others
to filter out these types of file creation events.

The other uses of `tempfile.mkstemp()` in Hg do not appear to be problematic
because they (generally speaking) do not specify the `dir` parameter, so the
new file is created in the system-appropriate temp directory, which is outside
the working copy.

Test Plan:
`make tests`

Differential Revision: https://phab.mercurial-scm.org/D468
2017-08-22 00:38:38 +00:00
Martin von Zweigbergk
9e0298dbb7 morestatus: simplify check for unresolved merge conflicts
Differential Revision: https://phab.mercurial-scm.org/D546
2017-08-28 14:47:18 -07:00
Martin von Zweigbergk
6082a05ee3 tests: rename test-terse-status.t to test-status-terse.t
When looking for status tests, most people would probably look for
"test-status*", so it would be nice if they could find it there. This
also let's them run (most) status tests with "run-tests.py
test-status*".

Differential Revision: https://phab.mercurial-scm.org/D547
2017-08-28 15:06:34 -07:00
Jun Wu
3f18e3a17c metadataonlyctx: don't crash when reusing the manifest with deletions
This was originally fixed by Mateusz Kwapich for the `metaedit` command in
fb-hgext with a test for the `metaedit` command. It didn't get upstreamed
because `metaedit` was not in core.

This patch fixes the crash and adds a test about `metadataonlyctx` to
avoid future regressions.

Differential Revision: https://phab.mercurial-scm.org/D550
2017-08-28 16:58:59 -07:00
Jun Wu
795e6cde00 context: make parents and text optional in metadataonlyctx
The metadataonlyctx is to copy an existing context with some minor metadata
changes. If the caller only wants to change "extra", or "user", ideally it
does not have to read and pass "parents" and "text" information.

This patch makes "parents" and "text" optionally to convenient callers.

Differential Revision: https://phab.mercurial-scm.org/D548
2017-08-28 16:49:41 -07:00
Boris Feld
064d0d5ec9 test: add more obsmarker tests for pruning scenarios
The obsfate output in cases of pruning is not ideal right now, add some tests
so have these scenarios around.
2017-08-17 18:09:32 +02:00
Boris Feld
75dd8c8d61 template: better prune support in obsfate
successorssets don't returns good results for pruned commit, add a workaround
for simple cases.

A proper fix would require a large rework of successorssets algorithm, I will
send a separate series for this refactoring.
2017-07-03 17:38:56 +02:00
Boris Feld
f0beef3fad template: compute dates in obsfatedate
Extract the dates from obsmarkers. Compute the min and max date from the
obsmarker range list.
2017-07-03 15:34:10 +02:00
Boris Feld
6c65874220 template: compute user in obsfateusers
Extract, deduplicate users informations from obs markers in order to display
them.

Print all users for the moment, we might want to display users only in verbose
mode later.
2017-07-03 15:34:00 +02:00
Boris Feld
26b4084486 template: compute verb in obsfateverb
Add a template function obsfateverb which use the markers information to
compute a better obsfate verb.

The current logic behind the obsfate verb is simple for the moment:

- If the successorsets is empty, the changeset has been pruned, for example:

    Obsfate: pruned

- If the successorsets length is 1, the changeset has been rewritten without
  divergence, for example:

    Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a

- If the successorsets length is more than 1, the changeset has diverged, for
  example:

    Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a

As the divergence might occurs on a subset of successors, we might see some
successors twice:

    Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc; split
    as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc
2017-07-03 15:33:27 +02:00
Augie Fackler
169f5af21b contrib: add test-check-module-imports.t to the Python 3 whitelist
This has the benefit of also catching most (if not all!) old-style
print statements and except statements.
2017-08-22 17:16:13 -04:00
Augie Fackler
86f77ea3a7 tests: update test-obsolete to pass our import checker 2017-08-22 17:15:20 -04:00
Augie Fackler
07f2388ec1 tests: update test-largefiles-cache to pass our import checker 2017-08-22 17:15:14 -04:00
Augie Fackler
7c12659d0a tests: update test-inherit-mode to pass our import checker 2017-08-22 17:15:09 -04:00
Augie Fackler
af6f453ff6 tests: update test-relink to pass our import checker 2017-08-22 17:11:30 -04:00
Augie Fackler
b5e3304e45 tests: update test-strip to pass our import checker 2017-08-22 16:59:26 -04:00
Augie Fackler
e5c9fa4092 tests: update test-share to pass our import checker 2017-08-22 16:59:21 -04:00
Augie Fackler
58c23bd117 tests: update test-requires to pass our import checker 2017-08-22 16:59:17 -04:00
Augie Fackler
da58a4fdbf tests: update test-progress to pass our import checker 2017-08-22 16:59:12 -04:00
Augie Fackler
41137de614 tests: update test-patchbomb to pass our import checker 2017-08-22 16:59:06 -04:00
Augie Fackler
16ad9b6bae merge with stable 2017-08-28 17:40:03 -04:00
Jun Wu
45a4782018 record: fix revert -i for lines without newline (issue5651)
This is a regression caused by 10c1efcbeb1e. Code prior to 10c1efcbeb1e
seems to miss the "\ No newline at end of file" line.

Differential Revision: https://phab.mercurial-scm.org/D528
2017-08-27 13:39:17 -07:00
Michael Bolin
3b574ea901 dirstate: perform transactions with _copymap using single call, where possible
This replaces patterns such as this:

```
if f in self._copymap:
    del self._copymap[f]
```

with this:

```
self._copymap.pop(f, None)
```

Although eliminating the extra lookup/call may be a negligible performance win
in the standard dirstate, alternative implementations, such as
[sqldirstate](https://bitbucket.org/facebook/hg-experimental/src/default/sqldirstate/)
may see a bigger win where each of these calls results in an RPC,
so the savings is greater.

Test Plan:
`make tests`

Differential Revision: https://phab.mercurial-scm.org/D493
2017-08-23 18:24:57 +00:00
Jun Wu
f873da355e pull: do not prompt "hg update" if update.requiredest is set
Previously, after pull, we show:

  (run 'hg update' to get a working copy)

unconditionally. People might run `hg update` and get an exception if
`update.requiredest` is set, and get a bit frustrated. This patch changes
the code to not prompt `hg update` in that case.

Differential Revision: https://phab.mercurial-scm.org/D516
2017-08-24 20:25:16 -07:00
Martin von Zweigbergk
75ce730bf8 changelog: abort on attempt to write wdir revision
Similar to the previous patch which prevented writing the null
revision to any revlog, but this is for the wdir revision.

Thanks to Jun for pointing this out.

Differential Revision: https://phab.mercurial-scm.org/D524
2017-08-25 22:05:10 -07:00
Jun Wu
e80bc134f5 phabsend: show associated Differential Revisions with --confirm
Often people running `phabsend --confirm` just want to check whether a
commit will trigger a creation of new Differential Revision, or update an
existing one. This patch implements that. The `--confirm` message was
changed to use node instead of revision number to be consistent with what
`phabsend` outputs.

An example output looks like:

  D487 - a80f447973a0 test-extension: enable demandimport explicitly
  D494 - cf440ea6e47e test-casecollision-merge: fix the test
  NEW - 0a6b97147128 phabsend: polish the docstring a bit
  Send the above changes to https://phab.mercurial-scm.org/ (yn)?

Differential Revision: https://phab.mercurial-scm.org/D514
2017-08-24 17:44:08 -07:00
Jun Wu
6ce8fb7684 phabsend: print the actual URL with --confirm
Sometimes people have multiple Phabricator endpoints set in multiple repos.
It seems better for `--confirm` to prompt about the Phabricator endpoint
patches being sent to.

Differential Revision: https://phab.mercurial-scm.org/D513
2017-08-24 17:31:33 -07:00
Jun Wu
edfba89554 phabsend: detect patch change with larger context
Previously phabsend has an optimization that will skip uploading a diff if
the patch (with context line number = 1) remains unchanged. That could be
confusing:

  Aug 24 15:52:28 <martinvonz> phillco: something is wrong with phabricator'your patches/
  Aug 24 15:52:45 <martinvonz> ... with phabricator's view of your patches again
  Aug 24 15:53:38 <martinvonz> if i phabread D388 and then D399, i get a version of filemerge.py with "a, b, c" somewhere on line 344, which is not what phabricator shows for D399
  Aug 24 15:53:51 <martinvonz> junw: maybe that's more for you ^

Fix that by checking context with 32767 lines, which is the same as what
will be actually sent.

Differential Revision: https://phab.mercurial-scm.org/D512
2017-08-24 17:25:18 -07:00
Jun Wu
3969533711 phabsend: make --amend the default
The local tag feature was intended to make `phabsend` closer to `email`
workflow. But its experience is not great in multiple ways:

  - after rebase, obsoleted changesets are still visible because of tags
  - without obsstore, the association information will get lost
  - even with obsstore, things could go wrong with graft, export+import
  - no easy way to tell which Differential Revision a commit is associated

Therefore make `--amend` the default. People wanting the old behavior can
use `--no-amend`.

Differential Revision: https://phab.mercurial-scm.org/D511
2017-08-24 16:52:28 -07:00
Jun Wu
e2464e037c phabsend: polish the docstring a bit
Differential Revision: https://phab.mercurial-scm.org/D510
2017-08-24 17:26:10 -07:00
Peter Vitt
0725932203 record: make the m key open an editor for the commit message (issue5667)
With the former crecord extension, the user could edit the commit
message while he was de-/selecting hunks. By pressing 'm', an editor
showed up to edit the commit message.

With record being part of mercurial, this feature is not available
anymore. However, the help text still mentions it.

As the infrastructure needed is still present, this feature is quite
easily ported from the crecord extension to mercurial.

It seems there is no test coverage for record ui, so I tested this patch
manually on my local machine.
2017-08-28 13:43:31 +02:00