Commit Graph

12013 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
cc2b59230c convert: transcode CVS log messages by specified encoding (issue5597)
Converting from CVS to Mercurial assumes that CVS log messages in "cvs
rlog" output are encoded in UTF-8 (or basic Latin-1). But cvs itself
is usually unaware of encoding of log messages, in practice.

Therefore, if there are commits, of which log message is encoded in
other than UTF-8, log message of corresponded revisions in the
converted repository will be broken.

To avoid such broken log messages, this patch transcodes CVS log
messages by encoding specified via "convert.cvsps.logencoding"
configuration.

This patch accepts multiple encoding for convenience, because
"multiple encoding mixed in a repository" easily occurs. For example,
UTF-8 (recent POSIX), cp932 (Windows), and EUC-JP (legacy POSIX) are
well known encoding for Japanese.
2017-07-11 02:10:04 +09:00
Gregory Szorc
596098a717 sslutil: check for missing certificate and key files (issue5598)
Currently, sslutil._hostsettings() performs validation that web.cacerts
exists. However, client certificates are passed in to the function
and not all callers may validate them. This includes
httpconnection.readauthforuri(), which loads the [auth] section.

If a missing file is specified, the ssl module will raise a generic
IOException. And, it doesn't even give us the courtesy of telling
us which file is missing! Mercurial then prints a generic
"abort: No such file or directory" (or similar) error, leaving users
to scratch their head as to what file is missing.

This commit introduces explicit validation of all paths passed as
arguments to wrapsocket() and wrapserversocket(). Any missing file
is alerted about explicitly.

We should probably catch missing files earlier - as part of loading
the [auth] section. However, I think the sslutil functions should
check for file presence regardless of what callers do because that's
the only way to be sure that missing files are always detected.
2017-07-10 21:09:46 -07:00
Jun Wu
573f8d2389 revset: define successors revset
This revset returns all successors, including transit nodes and the source
nodes (to be consistent with existing revsets like "ancestors").

To filter out transit nodes, use `successors(X)-obsolete()`.
To filter out divergent case, use `successors(X)-divergent()-obsolete()`.

The revset could be useful to define rebase destination, like:
`max(successors(BASE)-divergent()-obsolete())`. The `max` is to deal with
splits.

There are other implementations where `successors` returns just one level of
successors, and `allsuccessors` returns everything. I think `successors`
returning all successors by default is more user friendly. We have seen
cases in production where people use 1-level `successors` while they really
want `allsuccessors`. So it seems better to just have one single revset
returning all successors by default to avoid user errors.

In the future we might want to add `depth` keyword argument to it and for
other revsets like `ancestors` etc. Or even build some flexible indexing
syntax [1] to satisfy people having the depth limit requirement.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-July/101140.html
2017-07-10 10:56:40 -07:00
Augie Fackler
22265cfcba filterpyflakes: move self-test into test file
This will avoid a false positive on an upcoming check-code rule.

Differential Revision: https://phab.mercurial-scm.org/D18
2017-07-07 15:07:36 -04:00
Matt Harbison
3e6d53e7a7 test-subrepo: demonstrate a status problem when merge deletes a file
At the interactive update prompt, if (c) is chosen and then followed by `hg rm`,
both `status -R` and `status -S` show the file as 'R', and `files -R` shows no
files (OK, because explicitly removed files aren't supposed to be listed).  If
`rm` follows selecting (c), then both flavors of `status` list the file as '!',
and `files -R` lists the missing file.  So somehow, the (d) option has followed
a third path.
2017-07-09 16:38:04 -04:00
Matt Harbison
86a2e6550a subrepo: make the output references to subrepositories consistent
Well, mostly.  The annotation on subrepo functions tacks on a parenthetical to
the abort message, which seems reasonable for a generic mechanism.  But now all
messages consistently spell out 'subrepository', and double quote the name of
the repo.  I noticed the inconsistency in the change for the last commit.
2017-07-09 16:13:30 -04:00
Matt Harbison
557dc0142f subrepo: consider the parent repo dirty when a file is missing
This simply passes the 'missing' argument down from the context of the parent
repo, so the same rules apply.  subrepo.bailifchanged() is hardcoded to care
about missing files, because cmdutil.bailifchanged() is too.

In the end, it looks like this addresses inconsistencies with 'archive',
'identify', blackbox logs, 'merge', and 'update --check'.  I wasn't sure how to
implement this in git, so that's left for someone more familiar with it.
2017-07-09 02:55:46 -04:00
Matt Harbison
5a0fd7acbc archival: flag missing files as a dirty wdir() in the metadata file (BC)
Since the identify command adds a '+' for missing files, it's reasonable that
this does too.  Perhaps the node field's hex value should be p1+p2 for merges?
2017-07-09 02:46:03 -04:00
Matt Harbison
77bbbfde85 tests: tweak the subrepo dirty state tests
This is a continuation of 5ba3f753c9b1.  I overlooked that blackbox logs also
have a dirty marker.  Also, the `hg update --check` test was updating to a
revision where the deleted file wasn't tracked, which is why status seemed to
show the deleted file was restored.
2017-07-09 00:05:31 -04:00
Martin von Zweigbergk
8c3e639b61 match: remove unnecessary '^' from regexes
The regexes are passed to re.match(), which matches against the
beginning of the input, so the '^' doesn't do anything.

Note that unrooted patterns, such as globs and regexes from .hgignore
are instead achieved by adding '.*' to the expression given by the
user. (That's unless the user's expression started with '^', in which
case the '.*' is not added, perhaps to keep the regex cleaner?)
2017-07-09 22:53:02 -07:00
Gregory Szorc
d86e3657d2 sparse: move printing of sparse config changes function into core
As part of the port, all arguments now have default values of 0.
Strings are now also given the i18n treatment.
2017-07-08 13:34:19 -07:00
Jun Wu
ec32c2f725 histedit: use scmutil.cleanupnodes (BC)
This is marked as BC because the strip backup file name has changed.
2017-07-08 16:50:31 -07:00
Jun Wu
f9577750a4 histedit: unify strip backup files on success (BC)
Previously we wrote two different strip backup files on success. This patch
unifies them. It will make scmutil.cleanupnodes migration more smooth.
2017-07-08 16:50:31 -07:00
Jun Wu
e9417ea1fc histedit: remove moving bookmarks message on verbose (BC)
This is more consistent with other commands, like "commit -v" won't show
bookmark movement messages.

It will make migrating to scmutil.cleanupnodes easier.
2017-07-08 16:04:21 -07:00
Matt Harbison
a08884d35a test-largefiles-update: conditionalize output instead of tests 2017-07-08 18:47:50 -04:00
Matt Harbison
27bf97fb7e test-status-rev: conditionalize output instead of tests 2017-07-08 18:46:43 -04:00
Matt Harbison
a0f9751ffe test-mq: conditionalize output instead of tests 2017-07-08 18:46:12 -04:00
Matt Harbison
61a93561ae test-annotate: conditionalize output instead of tests 2017-07-08 18:38:44 -04:00
Matt Harbison
7e2264b4b2 test-addremove: conditionalize output instead of tests 2017-07-08 18:37:41 -04:00
Matt Harbison
376884a01f test-tools: conditionalize output instead of tests 2017-07-08 14:21:11 -04:00
Matt Harbison
1500e556f2 test-rebase: conditionalize output instead of tests
This should help prevent breakage like was fixed in the last patch.
2017-07-08 14:15:01 -04:00
Matt Harbison
b97aa8f347 tests: stabilize on Windows
I'm not sure if the difference on Windows for test-sparse.t is expected or not.
It looks like unless the leading '/' is followed by a drive letter, '/' is
resolved to 'C:/MinGW/msys/1.0'.  But both cases abort with "not under root"
instead of just warning.
2017-07-08 14:10:10 -04:00
Jun Wu
f50841989e revset: make repo.anyrevs accept customized alias override (API)
Previously repo.anyrevs only expand aliases in [revsetalias] config. This
patch makes it more flexible to accept a customized dict defining aliases
without having to couple with ui.

revsetlang.expandaliases now has the signature (tree, aliases, warn=None)
which is more consistent with templater.expandaliases. revsetlang.py is now
free from "ui", which seems to be a good thing.
2017-06-24 15:29:42 -07:00
Matt Harbison
b6162a8a97 tests: quote $PYTHON for Windows
When unquoted, MSYS sees the colon between the drive letter and path as a Unix
path separator and unhelpfully splits on it, feeding only the drive letter as
the command.  Much chaos ensues.

I vaguely remember trying to get the test runner to use /letter/path/to/exe
syntax the last time this happened, without success.  I doubt a check-code rule
would work, since sometimes it is quoted, and sometimes the quotes are escaped.
2017-07-07 01:05:20 -04:00
Jun Wu
41049ab36d amend: use scmutil.cleanupnodes (BC)
This is marked as BC because the strip backup file name has changed.
2017-06-26 15:28:28 -07:00
Jun Wu
936199e02d rebase: use scmutil.cleanupnodes (issue5606) (BC)
This patch migrates rebase to use scmutil.cleanupnodes API. It simplifies
the code and makes rebase code reusable inside a transaction.

This is a BC because the backup file is no longer strip-backup/*-backup.hg,
but strip-backup/*-rebase.hg. The latter looks more reasonable since the
directory name is "strip-backup" so there is no need to repeat "backup".

I think the backup file name change is probably fine as a BC, since we have
changed it before (2e51c9a7a08f) and didn't get complains. The end result
of this series will be a much more consistent and unified backup names:

  command  | old backup file suffix       | new backup file suffix
  -------------------------------------------------------------------
  amend    | amend-backup.hg              | amend.hg
  histedit | backup.hg (could be 2 files) | histedit.hg (single file)
  rebase   | backup.hg                    | rebase.hg
  strip    | backup.hg                    | backup.hg

(note: backup files are under .hg/strip-backup)

It also fixes issue5606 as a side effect because the new "delayedstrip" code
path will carefully examine nodes (safestriproots) to make sure orphaned
changesets won't get stripped by accident.

Some warning messages are changed to the new "warning: orphaned descendants
detected, not stripping HASHES", which provides more information about
exactly what changesets are left behind.

Another minor behavior change is when there is an obsoleted changeset with a
successor in the destination branch, bookmarks pointing to that obsoleted
changeset will not be moved. I have commented in test-rebase-obsolete.t
explaining why that is more desirable.
2017-07-07 18:51:46 -07:00
Jun Wu
daadde7a5c scmutil: make cleanupnodes delete divergent bookmarks
cleanupnodes takes care of bookmark movement, and bookmark movement could
cause bookmark divergent resolution as a side effect. This patch adds such
bookmark divergent resolution logic so future rebase migration will be
easier.

The revset is carefully written to be equivalent to what rebase does today.
Although I think it might make sense to remove divergent bookmarks more
aggressively, for example:

    F   book@1
    |
    E   book@2
    |
    | D book
    | |
    | C
    |/
    B   book@3
    |
    A

When rebase -s C -d E, "book@1" will be removed, "book@3" will be kept,
and the end result is:

    D   book
    |
    C
    |
    F
    |
    E   book@2 (?)
    |
    B   book@3
    |
    A

The question is should we keep book@2? The current logic keeps it. If we
choose not to (makes some sense to me), the "deleterevs" revset could be
simplified to "newnode % oldnode".

For now, I just make it compatible with the existing behavior. If we want to
make the "deleterevs" revset simpler, we can always do it in the future.
2017-06-26 13:13:51 -07:00
Jun Wu
74bc654a08 scmutil: make cleanupnodes handle filtered node
In some valid usecases, the "mapping" received by scmutil.cleanupnodes have
filtered nodes. Use unfiltered repo to access them correctly.

The added test case will fail with the old cleanupnodes code.

This is important to migrate histedit to use the cleanupnodes API.
2017-06-26 15:08:37 -07:00
David Demelier
d324b7a9bf configitems: add alias support in config
Aliases define optional alternatives to existing options. For example the old
option ui.user was deprecated and replaced by ui.username. With this mechanism,
it's even possible to create an alias to an option in a different section.

Add ui.user as alias to ui.username as an example of this concept.

The old alternates principle in ui.config is removed as it was used only for
this option.
2017-07-07 08:33:10 +02:00
Martin von Zweigbergk
d4520a7687 dispatch: fix typo suggestion for disabled extension
If the matching command lives in an in-tree extension (which is all we
scan for), and the user has disabled that extension with
"extensions.<name>=!", we were not finding it, because the path in
_disabledextensions was the empty string. If the user had set
"extensions.<name>=!<valid path>" it would work, so it seems like just
a mistake that it didn't work.
2017-07-07 00:13:53 -07:00
Martin von Zweigbergk
8ea70f4620 tests: add tests for typoed commands
This includes one test showing how disabling a command with e.g.
"extensions.rebase=!" results in the command not being
suggested. We'll fix that next.
2017-07-07 00:12:44 -07:00
Gregory Szorc
793c8fb431 sparse: move working directory refreshing into core
This is a pretty straightforward move of the code.

I converted the "force" argument to a keyword argument.

Like other recent changes, this code is tightly coupled with
working directory update code in merge.py. I suspect the code
will become more tightly coupled over time, possibly even moved
to merge.py. For now, let's get the code in core.
2017-07-06 14:53:08 -07:00
Martin von Zweigbergk
b2ef392aae tests: fix reference to undefined variable
The delaypush() function had a reference to "repo" that was clearly
supposed to be "pushop.repo". Instead of just fixing that, let's
extract "pushop.repo.ui" to a variable, since that's the only
piece of the repo that's needed in the function.

I have not looked into why I saw a different result in the test to
start with, but that's for another patch anyway.
2017-07-06 14:17:02 -07:00
Yuya Nishihara
7dafbbbbcf templatekw: add new-style template expansion to {manifest}
The goal is to allow us to easily access to nested data. The dot operator
will be introduced later so we can write '{p1.files}' instead of
'{revset("p1()") % "{files}"}' for example.

In the example above, 'p1' needs to carry a mapping dict along with its
string representation. If it were a list or a dict, it could be wrapped
semi-transparently with the _hybrid class, but for non-list/dict types,
it would be difficult to proxy all necessary functions to underlying value
type because several core operations may conflict with the ones of the
underlying value:

 - hash(value) should be different from hash(wrapped(value)), which means
   dict[wrapped(value)] would be invalid
 - 'value == wrapped(value)' would be false, breaks 'ifcontains'
 - len(wrapped(value)) may be either len(value) or len(iter(wrapped(value)))

So the wrapper has no proxy functions and its scope designed to be minimal.
It's unwrapped at eval*() functions so we don't have to care for a wrapped
object unless it's really needed:

  # most template functions just call evalfuncarg()
  unwrapped_value = evalfuncarg(context, mapping, args[n])
  # if wrapped value is needed, use evalrawexp()
  maybe_wrapped_value = evalrawexp(context, mapping, args[n])

Another idea was to wrap every template variable with a tagging class, but
which seemed uneasy without a static type checker.

This patch updates {manifest} to a mappable as an example.
2016-04-24 18:41:23 +09:00
Yuya Nishihara
c22459dc5d templater: adjust binding strength of '%' and '|' operators (BC)
This makes 'foo|bar%baz' parsed as '(foo|bar)%baz', not 'foo|(bar%baz)'.
Perhaps it was a mistake that '%' preceded '|'. Both '|' and '%' can be
considered a kind of function application, and '|' is more like a '.' operator
seen in OO languages. So IMHO '|' should have the same (or higher) binding as
'%'.

The BC breakage should be minimal since both '|' and '%' operators have
strict requirements for their operands and 'foo|bar%baz' was invalid:

 - right-hand side of '|' must be a symbol
 - left-hand side of '%' must be a dict or list
 - right-hand side of '%' must be a string or symbol
2017-04-24 21:37:11 +09:00
Boris Feld
bbf23f4d9a pull: use 'phase-heads' to retrieve phase information
A new bundle2 capability 'phases' has been added. If 'heads' is part of the
supported value for 'phases', the server supports reading and sending 'phase-
heads' bundle2 part.

Server is now able to process a 'phases' boolean parameter to 'getbundle'. If
'True', a 'phase-heads' bundle2 part will be included in the bundle with phase
information relevant to the whole pulled set. If this method is available the
phases listkey namespace will no longer be listed.

Beside the more efficient encoding of the data, this new method will greatly
improve the phase exchange efficiency for repositories with non-served
changesets (obsolete, secret) since we'll no longer send data about the
filtered heads.

Add a new 'devel.legacy.exchange' config item to allow fallback to the old
'listkey in bundle2' method.

Reminder: the pulled set is not just the changesets bundled by the pull. It
also contains changeset selected by the "pull specification" on the client
side (eg: everything for bare pull). One of the reason why the 'pulled set' is
important is to make sure we can move -common- nodes to public.
2017-09-24 21:27:18 +02:00
Boris Feld
386e89884f discovery: avoid dropping remote heads hidden locally
An extra post processing was added to recognize remote heads that are hidden
locally as "common" instead of "unknown". However, this processing was
removing such hidden heads from the remote heads sets.

It had no impact because we used to pull phase information from all remote
heads.

This series will replace the phase pulling operation to a more efficient
process but requires the unmodified pulled set information.
2017-09-20 05:47:33 +02:00
Jun Wu
53fcfd8fe0 test-patchbomb: use mocktime
The test was using system time for displaying ETAs, which could be flaky if
the sysload is high. This patch extracts mocktime.py from test-progress.t to
make sure test-patchbomb.t is unaffected by system time.

Differential Revision: https://phab.mercurial-scm.org/D844
2017-09-29 11:41:24 -07:00
Jun Wu
20382adb55 test-patchbomb: fix the test
With the experimental config `progress.estimate` removed, the progress
output in `test-patchbomb.t` has a minor change: it shows ETA since the
beginning.

(This could be folded into f428c3)
2017-09-28 10:37:53 -07:00
Jun Wu
c1e9f8f474 progress: make ETA only consider progress made in the last minute
This patch limits the estimate time interval to roughly the last minute
(configurable by `estimateinterval`) to be more practical. See the test
change for why this is better.

.. feature:: Estimated time is more accurate with non-linear progress

Differential Revision: https://phab.mercurial-scm.org/D820
2017-09-27 15:14:59 -07:00
Jun Wu
c712efe446 progress: demonstrate non-linear progress has a bad ETA experience
Previously, the ETA and speed assumes the progress is linear. Often, due to
network or other issues, it could be fast for the most time, and suddenly
slow down:

    [====================================================>         ]
     \___________________________________________/\______/
        very fast                                  suddenly much slower

This patch adds a test demonstrating the ETA could be way off in those
cases.

Differential Revision: https://phab.mercurial-scm.org/D819
2017-09-26 12:48:15 -07:00
Pulkit Goyal
ee400fb169 copytrace: add a a new config to limit the number of drafts in heuristics
The heuristics options tries to the default full copytracing algorithm if both
the source and destination branches contains of non-public changesets only. But
this can be slow in cases when we have a lot of drafts.

This patch adds a new config option experimental.copytrace.sourcecommitlimit
which defaults to 100. This value will be the limit of number of drafts from c1
to base. Incase there are more changesets even though they are draft, the
heuristics algorithm will be used.

Differential Revision: https://phab.mercurial-scm.org/D763
2017-09-21 15:58:44 +05:30
Igor Ippolitov
5f431ecb08 mail: encode long unicode lines in emails properly (issue5687)
af9f7f376059 introduced a bug: emails Content-Transfer-Encoding
is silently replaced with 'quoted-printable' while any other
encoding could be used by underlying code. The problem is revealed
when a long unicode line is encoded.

The patch implements proper check which works for any text and
encoding.
2017-09-26 16:14:57 +03:00
Jun Wu
a05655c958 chg: show timestamp with debug messages
Like `strace -tr`, this helps finding performance bottlenecks.

Differential Revision: https://phab.mercurial-scm.org/D807
2017-09-23 14:58:40 -07:00
Gregory Szorc
5398902f94 keepalive: add more context to bad status line errors
As the TODO in the test said, the previous error message was not
very helpful. Let's improve things.

Differential Revision: https://phab.mercurial-scm.org/D811
2017-09-25 11:05:16 +02:00
Gregory Szorc
fb62259fb6 tests: add interface checks for bundle, statichttp, and union peers
I forgot to add these when I initially wrote the test. They inherit
from localrepo.localpeer, so they should be explicitly tested.

Differential Revision: https://phab.mercurial-scm.org/D810
2017-08-18 20:20:38 -07:00
Pulkit Goyal
ed45fa92a4 uncommit: add a test for uncommit with uncommitondirtywdir config in merge
Differential Revision: https://phab.mercurial-scm.org/D809
2017-09-24 19:37:55 +05:30
Augie Fackler
cbad07ca10 patchbomb: add test that shows --to and --cc override matching config item
As far as I know this has always been true and is intentional (it's in
line with many other behaviors), but it wasn't tested.
2017-06-14 11:13:57 -04:00
Jun Wu
a18c4e0d85 blackbox: do not prevent 'chg init' from working
Previously, blackbox always appends to blackbox.log and creates the
directory for that file on demand. That could be an issue if:

  1. chg starts from `$REPO` directory, so `ui._bbrepo` is set.
  2. `rm -rf $REPO`.
  3. `chg init $REPO`, blackbox writes something and `init` will fail
     because `$REPO` directory is non-empty.

This patch fixes that by verifying whether vfs exists before re-using it.

Differential Revision: https://phab.mercurial-scm.org/D768
2017-09-21 11:03:37 -07:00
Augie Fackler
6fea4e0714 tests: add a test for blackbox with nested alias configurations
I've observed some weirdness around this, and needed to rule some
things out. There aren't any bugs in core around this, but it was nice
to have confirmation.
2017-09-11 20:07:41 -04:00
Augie Fackler
11bbe7db58 tests: clean up blackbox test around aliases a little bit 2017-09-11 20:06:52 -04:00
Mark Thomas
073ae56963 revlog: add option to mmap revlog index
Following on from Jun Wu's patch last October[1], we have found that using mmap
for the revlog index in repos with large revlogs gives a noticable performance
improvment (~110ms on each hg invocation), particularly for commands that don't
touch the index very much.

This changeset adds this as an option, activated by a new experimental config
option so that it can be enabled on a per-repo basis. The configuration option
specifies an index size threshold at which Mercurial will switch to using mmap
to access the index.

If the configuration option is not specified, the default remains to load the
full file, which seems to be the best option for smaller repos.

Some initial performance numbers for average of 5 invocations of `hg log -l 5`
for different cache states:

| Repo: | HG | FB |
|---|---|---|
| Index size: | 2.3MB | much bigger |
| read (warm): | 237ms | 432ms |
| mmap (warm): | 227ms | 321ms |
|   | (-3%) | (-26%) |
| read (cold): | 397ms | 696ms |
| mmap (cold): | 410ms | 888ms |
|   | (+3%) | (+28%) |

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088737.html

Test Plan:
`hg log --config experimental.mmapindex=true`

Differential Revision: https://phab.mercurial-scm.org/D477
2017-09-13 17:26:26 +00:00
Durham Goode
c00411b064 revlog: add revmap back to revlog.addgroup
The recent e85296920485 patch removed the linkmapper argument from addgroup, as
part of trying to make addgroup more agnostic from the changegroup format. It
turns out that the changegroup can't resolve linkrevs while iterating over the
deltas, because applying the deltas might affect the linkrev resolution. For
example, when applying a series of changelog entries, the linkmapper just
returns len(cl). If we're iterating over the deltas without applying them to the
changelog, this results in incorrect linkrevs. This was caught by the hgsql
extension, which reads the revisions before applying them.

The fix is to return linknodes as part of the delta iterator, and let the
consumer choose what to do.

Differential Revision: https://phab.mercurial-scm.org/D730
2017-09-20 09:22:22 -07:00
Martin von Zweigbergk
307606e338 rebase: also include other namespaces in changeset description
This makes use of the generic method of listing bookmarks and tags, so
other extensions that add other namespaces will get their names added
too.

This does mean that bookmarks will come before tags, just like we
apparently decided to order them in the "hg log" output. It doesn't
seem like people would be parsing the rebase output anyway. We also
did 9461eb4ff93e (rebase: use _ctxdesc in one more place, 2017-08-29)
recently, so now seems like a good time.

Differential Revision: https://phab.mercurial-scm.org/D741
2017-09-19 22:06:26 -07:00
Pulkit Goyal
8a6be941c9 copytrace: use the full copytracing method if only drafts are involved
This patch adds the functionality to use the full copytracing even if
`experimental.copytrace = heuristics` in cases when drafts are involved.

This is also a part of copytrace extension in fbext.

This also adds tests which are also taken from fbext.

.. feature::

   The `heuristics` option for `experimental.copytrace` performs full
   copytracing if both source and destination branches contains non-public
   changsets only.

Differential Revision: https://phab.mercurial-scm.org/D625
2017-09-03 20:06:45 +05:30
Martin von Zweigbergk
2881701c97 templates: introduce a obsfateoperation() function
Differential Revision: https://phab.mercurial-scm.org/D723
2017-09-15 10:43:22 -07:00
Martin von Zweigbergk
5d3d7b811c obsmarker: track operation by default
We added support for including the operation responsible for creating
the obsmarker in 44ba6434eaf4 (obsolete: add operation metadata to
rebase/amend/histedit obsmarkers, 2017-05-09). However, soon
thereafter, in 819cf35e629a (obsmarker: add an experimental flag
controlling "operation" recording, 2017-05-20), it was hidden behind a
config that was off by default. It seems unlikely that people will
manually turn it on, and obsmarkers/evolution as a whole is still
experimental anyway, so let's turn on the tracking by default.

Differential Revision: https://phab.mercurial-scm.org/D722
2017-09-15 10:42:49 -07:00
Pulkit Goyal
00565cf47d uncommit: add an experimental.uncommitondirtywdir config
There are people who wants to do `hg uncommit` on dirty working directory, so
this patch adds a config which can be used to the achieve that.

Adds tests for the same.

Differential Revision: https://phab.mercurial-scm.org/D735
2017-09-20 02:40:25 +05:30
Pulkit Goyal
060e15ae30 uncommit: don't allow bare uncommit on dirty working directory
As per IRC discussion and suggestion by Augie, we should not allow bare `hg
uncommit` on dirty working directory.

Differential Revision: https://phab.mercurial-scm.org/D734
2017-09-20 02:18:01 +05:30
Pulkit Goyal
cbd5fda657 uncommit: rename the flag 'empty' to 'keep' which retains empty changeset
This patch renames the flag 'empty' which retains the empty changeset if all
the files are uncommitted to 'keep'.

Differential Revision: https://phab.mercurial-scm.org/D726
2017-09-16 02:34:13 +05:30
Augie Fackler
b93ba13588 tests: avoid repr in test-bundle2-format.t
We don't *really* need it here, and it was making Python 3 harder.
2017-09-18 14:19:47 -04:00
Augie Fackler
91e7dc8d62 tests: port test-bundle2-format inline helper script to Python 3
We're now very close to this test passing.
2017-09-18 14:04:05 -04:00
Augie Fackler
dc633b89a0 bundle2: stop using %r to quote part names
Valid part names are restricted to [a-zA-Z0-9_:-]+, so I'm not worried
about having quoting present in places where we should have
predominantly valid part names. This will significantly ease the
Python 3 transition, and simultaneously isn't a BC because this is
only in error messages that should never be shown.
2017-09-18 13:35:43 -04:00
Jun Wu
042b7a7361 blackbox: set lastui even if ui.log is not called (issue5518)
`lastui` decides where (where is the `.hg`) to use if the current `ui`
object does not have a `_bbrepo` associated. Previously it only gets set in
`ui.log`, which means unless a `ui` with repo associated calls `log` with
tracked event, blackbox does not know where to write its log. This patch
makes `reposetup` set `lastui` so it so we could log some more events (see
test changes).

Differential Revision: https://phab.mercurial-scm.org/D655
2017-09-18 16:01:03 -07:00
Augie Fackler
f65126095d tests: update f helper script to work on Python 3 2017-09-18 13:37:32 -04:00
Augie Fackler
18842dd648 tests: fix run-tests XML reporting on Python 3
cdatasafe wants to work in terms of bytes, but of course we have a
unicode. Easy to work around, especially since we know we'll get utf-8
at the end.
2017-09-19 00:09:37 -04:00
Augie Fackler
cca5652bce tests: convert bisect support regex to binary
The bisection feature of run-tests still fails tests with this because
bisect itself doesn't work yet. We'll get there.
2017-09-19 00:08:52 -04:00
Augie Fackler
5d1dd806b5 tests: decode bytes path to hg command before hitting with shellquote 2017-09-19 00:08:12 -04:00
Augie Fackler
4eca20a289 tests: fix test-is-whitelisted check in run-tests
Again, look for bytes in a set of bytes objects.
2017-09-19 00:07:51 -04:00
Augie Fackler
0a1d05565a tests: fix run-tests "slow test" check
Look for bytes in a set of bytes objects.
2017-09-19 00:07:23 -04:00
Augie Fackler
2ec91e73fc tests: fix run-tests default values in Test constructor
As far as I can tell, default values are evaluated far earlier on
Python 3.6 than 2.7, meaning we've got to be more careful about when
we read the defaults dictionary for the kwarg defaults. Sigh.

With this change, test-run-tests.t is significantly less of a mess
under 3.6.
2017-09-19 00:06:57 -04:00
Augie Fackler
3cdfffa124 tests: add support for listing tests to run in a file
This will make it easier for us to run the tests in the python3
whitelist in buildbot.
2017-09-18 17:11:32 -04:00
Kevin Bullock
f0dbcd6ad0 merge with stable 2017-09-18 14:12:20 -05:00
Yuya Nishihara
407d4549be py3: convert system strings to bytes in doctest of formatter.py 2017-09-17 12:39:53 +09:00
Yuya Nishihara
50fbaed638 py3: use bytes os.sep in doctest of pathutil.py 2017-09-17 12:26:42 +09:00
Yuya Nishihara
012701ee30 py3: fix doctests in patch.py to be compatible with Python 3
We were lucky that parsepatch() could concatenate a character slice as if
it were a list of chunks.
2017-09-17 12:23:16 +09:00
Yuya Nishihara
b772b7f536 error: move patch.PatchError so it can easily implement __bytes__ (API) 2017-09-03 16:45:33 +09:00
Augie Fackler
f5d866f8ee tests: use int() instead of long() in test-pathencode.py 2017-09-16 11:48:05 -04:00
Augie Fackler
a832150cd3 tests: add xrange alias for test-pathencode.py 2017-09-16 11:47:53 -04:00
Yuya Nishihara
0284e70ec0 py3: use 'surrogatepass' error handler to process U+DCxx transparently
It's disallowed by default on Python 3.

https://docs.python.org/3/library/codecs.html#error-handlers
2017-09-16 22:55:48 +09:00
Yuya Nishihara
cd2add86f9 py3: iterate bytes as a byte string in store.lowerencode() 2017-09-03 17:28:47 +09:00
Yuya Nishihara
8a515cf238 py3: iterate bytes as a byte string in dagparser.py 2017-09-03 15:32:45 +09:00
Yuya Nishihara
81c2aaf747 py3: convert function name to bytes in ui.configwith() 2017-09-03 17:47:21 +09:00
Augie Fackler
34ec2fe8db drawdag: port to python 3 2017-08-23 01:23:16 -04:00
Augie Fackler
23df90a15a drawdag: add a couple of doctests to help with python3 porting 2017-08-23 10:51:26 -04:00
Augie Fackler
f2c654c577 drawdag: tagsmod.tag() takes a list of names, not a single name
We were getting lucky on Python 2 since we have only one-byte names,
but on Python 3 badness was happening.
2017-08-23 01:24:01 -04:00
Augie Fackler
af109efa42 bruterebase: port to python 3 2017-08-23 01:22:59 -04:00
Augie Fackler
e7f35bd20c tests: add and remove some (glob) markers
I have no idea if these changes are reasonable, but they look like
they'd help on the Windows buildbot.
2017-09-15 22:08:25 -04:00
Pulkit Goyal
64bd8ed9ad uncommit: move fb-extension to core which uncommits a changeset
uncommit extension in fb-hgext adds a uncommit command which by default
uncommits a changeset and move all the changes to the working directory. If
file names are passed, uncommit moves the changes from those files to the
working directory and left the changeset with remaining committed files.

The uncommit extension in fb-hgext does not creates an empty commit like the one
in evolve extension unless user has specified ui.alllowemptycommit to True.

The test file added is a combination of tests from test-uncommit.t,
test-uncommit-merge.t and test-uncommit-bookmark.t from fb-hgext.

.. feature::

   A new uncommit extension which provides `hg uncommit` using which one can
   uncommit part or all of the changeset. This command undoes the effect of a
   local commit, returning the affected files to their uncommitted state.

Differential Revision: https://phab.mercurial-scm.org/D529
2017-08-24 22:55:56 +05:30
Gregory Szorc
545ec2de44 show: use consistent (and possibly shorter) node lengths
`hg show` makes heavy use of shortest() to limit the length of the node
hash.

For the "stack" and "work" views, you are often looking at multiple
lines of similar output for "lines" of work. It is visually appeasing
for things to vertically align. A naive use of {shortest(node, N)}
could result in variable length nodes and for the first character of
the description to vary by a column or two.

We implement a function to determine the longest shortest prefix for
a set of revisions. The new function is used to determine the printed
node length for all `hg show` views.

.. feature::

   show: use consistent node length in views

Our previous shortest node length of 5 was arbitrarily chosen.

shortest() already does the work of ensuring that a partial node
isn't ambiguous with an integer revision, which is our primary risk
of a collision for very short nodes. It should be safe to go with the
shortest node possible.

Existing code is also optimized to handle nodes as short as 4.

So, we decrease the minimum hash length from 5 to 4.

We also add a test demonstrating that prefix collisions increase the
node length.

.. feature::

   show: decrease minimum displayed hash length from 5 to 4

Differential Revision: https://phab.mercurial-scm.org/D558
2017-09-13 21:15:46 -07:00
Gregory Szorc
f95c9311db show: pass the minimum length for nodes as a template keyword
This will allow us to make the displayed length configurable
and/or dynamic.

Differential Revision: https://phab.mercurial-scm.org/D556
2017-08-03 21:51:34 -07:00
Boris Feld
8744970b58 extensions: factor extra data loading out
Some of the extra data need to be registered earlier than they currently are
(eg: config items). We first factor out the logic to registered them in a small
function before reusing it in the next changeset.
2017-09-05 00:31:59 +02:00
Pulkit Goyal
a5baff1381 copytrace: move fast heuristic copytracing algorithm to core
copytrace extension in fb-hgext has a heuristic implementation of copy tracing
which is faster than the current copy tracing. The heuristic limits the search
of copies to just files that are either:

1) Renames in the same directory
2) Moved to other directory with same name

The default copytrace implementation is very slow as it finds all the new files
that were added from merge base up to the head commit and for each file it
checks whether it this was copied or moved version of a different file.

Stash@fb did analysis for the above heuristics on the fb repo and found that
among 2,443,768 moves/copies there are only 32,234 moves/copies which does not
fall under the above heuristics which is approx. 0.013 of total copies.

This patch moves the heuristics algorithm under config
`experimental.copytrace=heuristics`.

While moving fbext to core, this patch removes couple of less useful config
options named `sourcecommitlimit` and `maxmovescandidatestocheck`.

Tests are also added for the heuristics algorithm, which are basically copied
from fbext/tests/test-copytrace.t. The tests follow a pattern creating a server
repo and then cloning to a local repo to create public and draft changesets, the
distinction which will be useful in upcoming patches.

After this patch `experimental.copytrace` has the following behaviour:

1) `off`: turns off copytracing
2) `heuristics`: use the heuristic algorithm added in this patch.
3) everything else: use the full copytracing algorithm

.. feature::

   A new fast heuristic algorithm for copytracing which assumes that the files
   moves are either::
   1) Renames in the same directory
   2) Moves in other directories with same names
   You can use this algorithm by setting `experimental.copytrace=heuristics`.

Differential Revision: https://phab.mercurial-scm.org/D623
2017-09-03 03:49:15 +05:30
Durham Goode
c94bd0e75c changegroup: remove changegroup dependency from revlog.addgroup
Previously revlog.addgroup would accept a changegroup and a linkmapper and use
it to iterate of the deltas. As part of untangling the revlog-changegroup
interdependency, let's move the changegroup delta iteration logic to it's own
function and pass the simple iterator to the revlog instead.

This will make it easier to introduce non-revlogs stores in the future, without
reinventing any changegroup specific logic.

Differential Revision: https://phab.mercurial-scm.org/D688
2017-09-13 10:43:44 -07:00
Mark Thomas
3dfe8fba1c scmutil: don't append .orig to backups in origbackuppath (BC)
When ui.origbackuppath is set, .orig files are stored outside of the working
copy, however they still have a .orig suffix appended to them.  This can cause
unexpected conflicts, particularly when tracked files or directories have .orig
at the end.

This change removes the .orig suffix from files stored in an out-of-tree
origbackuppath.

Test Plan:
Update and run unit tests.

Differential Revision: https://phab.mercurial-scm.org/D679
2017-09-11 17:49:49 +00:00
Yuya Nishihara
53d5208ef2 doctest: enable tests by default on Python 3
Still several tests fail mostly because of the string issues, sigh. I'll
fix them one by one.
2017-09-03 15:09:04 +09:00
Yuya Nishihara
b2d9e161ed doctest: normalize b'', u'' and exception output on Python 3
The idea is described in the following page.

https://dirkjan.ochtman.nl/writing/2014/07/06/single-source-python-23-doctests.html

# no-check-commit
2017-08-24 22:33:28 +09:00
Yuya Nishihara
e116353ac2 debuginstall: do not pass exception object to formatter (issue5676) 2017-09-07 22:36:54 +09:00
Yuya Nishihara
c3d677e9b5 debuginstall: use codecs.lookup() to detect invalid encoding
encoding.fromlocal() never tries to decode an ascii string since 3cb2361c60fc,
and there's no universal non-ascii string which can be decoded as any valid
character set.
2017-09-07 22:27:23 +09:00
Yuya Nishihara
04508d7f1c extensions: fix wrapcommand/function of class instance
5f4c097a17d2 changed _updatewrapper() to copy the __name__ attribute, but
not all callable objects has __name__.

Spotted by loading mq with extdiff.
2017-09-10 23:37:14 +09:00
Durham Goode
6fe0002838 tests: split test-revset.t in half
This test has gotten so large that running it can exceed the normal timeout on
systems under load (like if we're running all the tests in parallel). This patch
splits the test cleanly in half.

Differential Revision: https://phab.mercurial-scm.org/D694
2017-09-12 15:12:27 -07:00
Phil Cohen
a1eba8f292 merge: pass wctx to premerge, filemerge
In the in-memory merge branch. we'll need to call a function (``flushall``) on
the wctx inside of _xmerge.

This prepares the way so it can be done without hacks like ``fcd.ctx()``.

Differential Revision: https://phab.mercurial-scm.org/D449
2017-09-11 13:03:27 -07:00
Boris Feld
60d92de7ba cmdutil: fix amend when passing a date
Following https://phab.mercurial-scm.org/D636, passing the same date that the
changeset to amend would results in no new commits but the output changed
from:

  $ hg amend -d '0 0'
  nothing changed
  [1]

to:

  $ hg amend -d '0 0'

Restore the old behavior by parsing the date passed as parameter so the
condition "date == old.date()" correctly works in cases both dates are
identical.

Add a test for covering this regression.

This bug was found thanks to Evolve test suite.

Differential Revision: https://phab.mercurial-scm.org/D691
2017-09-11 18:07:29 +02:00
Augie Fackler
85e2672134 merge with stable 2017-09-12 11:18:35 -04:00
Jun Wu
a97d2d42cb blackbox: fix rotation with chg
The added test will show:

  $ $PYTHON showsize.py .hg/blackbox*
  .hg/blackbox.log: < 500
  .hg/blackbox.log.1: < 500
  .hg/blackbox.log.2: < 500
  .hg/blackbox.log.3: < 500
  .hg/blackbox.log.4: < 500
  .hg/blackbox.log.5: >= 500

with previous code.

The issue is caused by blackbox caching file objects *by path*, and the
rotation size check could run on a wrong file object (i.e. it should check
"blackbox.log", but `filehandles["blackbox.log"]` contains a file object
that has been renamed to "blackbox.log.5").

This patch removes the "filehandlers" global cache added by 39bd7b0c79fe to
solve the issue.

I think the original patch was trying to make different ui objects use a same
file object if their blackbox.log path is the same. In theory it could also
be problematic in the rotation case. Anyway, that should become unnecessary
after D650.

Differential Revision: https://phab.mercurial-scm.org/D648
2017-09-06 19:27:30 -07:00
Jun Wu
7d887b076a test-blackbox: make it compatible with chg
Differential Revision: https://phab.mercurial-scm.org/D647
2017-09-06 18:31:25 -07:00
Durham Goode
21faf618dc changegroup: replace getchangegroup with makechangegroup
As part of reducing the number of changegroup creation APIs, let's replace
getchangegroup with calls to makechangegroup. This is mostly a drop in
replacement, but it does change the version specifier to be required, so it's
more obvious which callers are creating old version 1 changegroups still.

Differential Revision: https://phab.mercurial-scm.org/D669
2017-09-10 18:50:12 -07:00
Jun Wu
9bfa16c243 rebase: use unfiltered repo when loading state
Before this patch, `rebase --abort` may fail to do the cleanup:

  $ hg rebase --abort
  rebase aborted (no revision is removed, only broken state is cleared)

The added test case makes sure `--abort` works in this case.

Differential Revision: https://phab.mercurial-scm.org/D643
2017-09-06 15:23:19 -07:00
Jun Wu
8b33f0c213 rebase: do not crash rebasing merge with a parent having hidden successor
The added test will crash with previous code.

Differential Revision: https://phab.mercurial-scm.org/D640
2017-09-06 12:40:00 -07:00
Saurabh Singh
63cd1bdef8 cmdutil: remove redundant commitfunc parameter in amend (API)
Since the redundant commit during the amend has been been removed, there is no
need for commit callback function in amend now. Therefore, this commit removes
the unused parameter "commmitfunc" which was being used for this purpose.

Test Plan:
Ensured that all the tests pass

Differential Revision: https://phab.mercurial-scm.org/D635
2017-09-01 12:34:36 -07:00
Saurabh Singh
d207bf8f86 cmdutil: remove the redundant commit during amend
There was an extra commit made during the amend operation to track the
changes to the working copy. However, this logic was written a long time back
and newer API's make this extra commit redundant. Therefore, I am removing the
extra commit. After this change, I noticed that

  - Execution time of the cmdutil.amend improved by over 40%.
  - Execution time of "hg commit --amend" improved by over 20%.

Test Plan:
I ensured that the all the hg tests passed after the change. I had
to fix a few tests which were aware of the extra commit made during the amend.

Differential Revision: https://phab.mercurial-scm.org/D636
2017-09-01 12:34:36 -07:00
Pulkit Goyal
b8929368f2 copytrace: move the default copytracing algorithm in a new function
We are going to introduce a new fast heuristic based copytracing algorithm, so
lets make mergecopies the function which decides which algorithm to go with and
then calls the related function.

While I was here, I add a line in test-copy-move-merge.t saying its a test
related to the full copytracing algorithm.

Differential Revision: https://phab.mercurial-scm.org/D622
2017-09-03 02:34:01 +05:30
Pulkit Goyal
59fe14130c copytrace: replace experimental.disablecopytrace config with copytrace (BC)
This patch replaces experimental.disablecopytrace with experimental.copytrace.
Since the words does not means the same, the default value is also changed. Now
experimental.copytrace defaults to 'on'. The new value is not boolean value as
we will be now having two different algorithms (current one and heuristics one
to be imported from fbext) so we need this to be have more options than
booleans.

The old config option is not kept is completely replaced as that was under
experimental and we don't gurantee BC to experimental things.

.. bc::

   The config option for copytrace `experimental.disablecopytrace` is now
   replaced with `experimental.copytrace` which defaults to `on`. If you need to
   turn off copytracing, add `[experimental] copytrace = off` to your config.

Differential Revision: https://phab.mercurial-scm.org/D621
2017-09-03 01:52:19 +05:30
the31k
27daecb480 branches: correctly show inactive multiheaded branches
Issue being fixed here: `hg branches` incorrectly renders inactive multiheaded
branches as active if they have closed heads.

Example:

```
$ hg log --template '{rev}:{node|short} "{desc}" ({branch}) [parents: {parents}]\n'
4:2e2fa7af8357 "merge" (default) [parents: 0:c94e548c8c7d 3:7be622ae5832 ]
3:7be622ae5832 "2" (somebranch) [parents: 1:81c1d9458987 ]
2:be82cf30409c "close" (somebranch) [parents: ]
1:81c1d9458987 "1" (somebranch) [parents: ]
0:c94e548c8c7d "initial" (default) [parents: ]

$ hg branches
default                        4:2e2fa7af8357
somebranch                     3:7be622ae5832
```

Branch `somebranch` have two heads, the 1st one being closed (rev 2) and
the other one being merged into default (rev 3). This branch should be shown as
inactive one.

This happens because we intersect branch heads with repo heads to check branch
activity. In this case intersection in a set with one node (rev 2). This head
is closed but the branch is marked as active nevertheless.

Fix is to check branch activity by intersecting only open heads set.

Fixed output:

```
$ hg branches
default                        4:2e2fa7af8357
somebranch                     3:7be622ae5832 (inactive)
```

Relevant tests for multihead branches added to test-branches suite.

Implentation note about adding `iteropen` method:

At first I have tried to modify `iterbranches` is such a way that it would
filter out closed heads itself. For example it could have `closed=False`
parameter. But in this case we would have to filter closed tips as well.
Reasoning in terms of `hg branches` we actually are not allowed to do this.

Also, we need to do heads filtering only if tip is not closed itself. But if it
is - we are ok to skip filtering, because branch is already known to be inactive.

So we can't implement heads filtering in `iterbranches` in elegant way, because
we will end up with something like `closed_heads=False` or even
`closed_heads_is_tip_is_open`. Finally I decided to move this logic to the
`branches` function, adding `iteropen` helper method.

Differential Revision: https://phab.mercurial-scm.org/D583
2017-08-31 18:24:08 +03:00
Yuya Nishihara
f0fc1531a4 parser: stabilize output of prettyformat() by using byte-safe repr()
The format of leaf nodes is slightly changed so they look more similar to
internal nodes.
2017-09-03 21:17:25 +09:00
Jun Wu
eaaeecf0d5 revset: optimize "draft() & ::x" pattern
The `draft() & ::x` type query could be common for selecting one or more
draft feature branches being worked on.

Before this patch, `::x` may travel through the changelog DAG for a long
distance until it gets a smaller revision number than `min(draft())`. It
could be very slow on long changelog with distant (in terms of revision
numbers) drafts.

This patch adds a fast path for this situation, and will stop traveling the
changelog DAG once `::x` hits a non-draft revision.

The fast path also works for `secret()` and `not public()`.

To measure the performance difference, I used drawdag to create a repo that
emulates distant drafts:

          DRAFT4
           |
          DRAFT3 # draft
          /
  PUBLIC9999 # public
      |
  PUBLIC9998
      |
      .   DRAFT2
      .    |
      .   DRAFT1 # draft
      |   /
  PUBLIC0001 # public

And measured the performance using the repo:

  (BEFORE)
  $ hg perfrevset 'draft() & ::(DRAFT2+DRAFT4)'
  ! wall 0.017132 comb 0.010000 user 0.010000 sys 0.000000 (best of 156)
  $ hg perfrevset 'draft() & ::(all())'
  ! wall 0.024221 comb 0.030000 user 0.030000 sys 0.000000 (best of 113)
  (AFTER)
  $ hg perfrevset 'draft() & ::(DRAFT2+DRAFT4)'
  ! wall 0.000243 comb 0.000000 user 0.000000 sys 0.000000 (best of 9303)
  $ hg perfrevset 'draft() & ::(all())'
  ! wall 0.004319 comb 0.000000 user 0.000000 sys 0.000000 (best of 655)

Differential Revision: https://phab.mercurial-scm.org/D441
2017-08-28 14:49:00 -07:00
Jun Wu
ada59ccd75 check-code: forbid "\S" in egrep regular expression
BSD `egrep` does not like it. So let's forbid it.

Differential Revision: https://phab.mercurial-scm.org/D610
2017-09-01 16:44:30 -07:00
Saurabh Singh
e92757d9ec amend: add tests for amending only some files from commit to be amended
We do not have robust enough tests for scenarios where only some files in a
changeset are amended. This presents an interesting scenario because the
working copy could have modified versions of the remaining files in the
pre-amend changeset. Therefore, I have added some tests to ensure that amend
behaves as expected in these scenarios.

Test Plan:
Ensured that the test "test-commit-amend.t" passes.

Differential Revision: https://phab.mercurial-scm.org/D596
2017-09-01 12:34:34 -07:00
Yuya Nishihara
b2ddf3cabe test-editor-filename: fix portability of fake editor command
- /bin/bash doesn't exist on FreeBSD
 - edit is executed by cmd.exe on Windows
2017-09-02 21:49:45 +09:00
Michael Bolin
16648b82d6 editor: file created for diff action should have .diff suffix
This is a follow-up to https://phab.mercurial-scm.org/D464 (02b917f3e672) that
introduced the new file extension behavior. It erroneously changed `.diff` to
`.diff.hg.txt`.

Test Plan:
Verified `make tests` passes, particularly `test-editor-filename.t`.

Differential Revision: https://phab.mercurial-scm.org/D607
2017-09-01 20:28:26 +00:00
Jun Wu
286e29a1f9 test-amend: match output using conditional test case name
D466 (c5eb1c6ddc0a) allows output to be conditionally matched by test name.
This patch changes test-amend.t to use that feature, instead of duplicating
`hg amend` command or use `-q` to silence its output.

Differential Revision: https://phab.mercurial-scm.org/D601
2017-09-01 11:13:55 -07:00
Christophe de Vienne
87902af734 extensions: prohibit unicode defaults
If the default value of an option is a unicode string (something
than happen easily when using a 'from __future__ import unicode_literals'),
any value passed on the command line will be ignored because the fancyopts
module only checks for byte strings and not unicode strings.

Changing fancyopts behavior is easy but would make assumptions on how
the python3 port should be done, which is outside the scope of this patch.

The chosen approach is to stop an extension from being loaded when a unicode
default value is detected, with a hint for the developer.
2017-08-29 18:24:51 +02:00
Jun Wu
0886c75e25 run-tests: allow bisecting a different repo
Add `--bisect-repo` flag which accepts a different repo to bisect.

3rd party extensions may reuse `run-tests.py` from core to run tests. Test
failure could be caused by either a core hg change or the 3rd party
extension code itself. Having a way to specify which repo to bisect is
useful.

Differential Revision: https://phab.mercurial-scm.org/D578
2017-08-02 21:24:29 -07:00
Jun Wu
0f38c6c170 run-tests: extract prefix of bisect commands to a variable
This does not change any logic.

Differential Revision: https://phab.mercurial-scm.org/D577
2017-08-02 21:01:38 -07:00
Jun Wu
5b27abd5aa run-tests: pass --with-hg to run-tests.py command used by bisect
This makes `run-tests.py -l test-run-tests.t` 23 seconds faster on my
laptop. Inside the test, `$ rt --known-good-rev=0 test-bisect.t` took 24.9
seconds before, and 1.2 seconds after.

Differential Revision: https://phab.mercurial-scm.org/D576
2017-08-02 21:01:38 -07:00
Jun Wu
56e365cc2f import-checker: allow relative import a module being checked
This would make the checker more friendly for 3rd-party code. For example,

In remotefilelog/x.py, it may have:

    from . import shallowutils

That could trigger "relative import of stdlib module" if
"remotefilelog" was installed in the system. If the module being checked
conflicts with the system module, it makes sense to not treat that module as
system module. This patch makes it so.

Differential Revision: https://phab.mercurial-scm.org/D552
2017-08-28 13:43:25 -07:00
Michael Bolin
094c271fff editor: use an unambiguous path suffix for editor files
Changes the API of `ui.edit()` to take an optional `action` argument,
which is used when constructing the suffix of the temp file.
Previously, it was possible to set the suffix by specifying a `suffix` to the
optional `extra` dict that was passed to `ui.edit()`, but the goal is to
drop support for `extra.suffix` and make `action` a required argument.
To this end, `ui.edit()` now yields a `develwarn()` if `action` is not set
or if `extra.suffix` is set.

I updated all calls to `ui.edit()` I could find in `hg-crew` to specify the
appropriate `action`. This means that when creating a commit, instead
of the path to the editor file being something like:

`/tmp/hg-editor-XXXXXX.txt`

it is now something like:

`/tmp/hg-editor-XXXXXX.commit.hg.txt`

Some editors (such as Atom) make it possible to statically define a [TextMate]
grammar for files with a particular suffix. For example, because Git reliably
uses `.git/COMMIT_EDITMSG` and `.git/MERGE_MSG` as the paths for commit-type
messages, it is trivial to define a grammar that is applied when files of
either name are opened in Atom:

https://github.com/atom/language-git/blob/v0.19.1/grammars/git%20commit%20message.cson#L4-L5

Because Hg historically used a generic `.txt` suffix, it was much harder to
disambiguate whether a file was an arbitrary text file as opposed to one
created for the specific purpose of authoring an Hg commit message.

This also makes it easier to add special support for `histedit`, as it has its own
suffix that is distinct from a commit:

`/tmp/hg-histedit-XXXXXX.histedit.hg.txt`

Test Plan:
Added an integration test: `test-editor-filename.t`.

Manually tested: ran `hg ci --amend` for this change and saw that it
used `/tmp/hg-editor-ZZjcz0.commit.hg.txt` as the path instead of
`/tmp/hg-editor-ZZjcz0.txt` as the path.

Verified `make tests` passes.

Differential Revision: https://phab.mercurial-scm.org/D464
2017-08-30 20:25:56 +00:00
Augie Fackler
52fb3124b4 debugcommands: stabilize output of debugbundle by having a custom repr
We handle all dict-like things the same, and don't worry about it
actually being a repr.
2017-08-22 23:11:35 -04:00
Augie Fackler
48dbe73629 python3: replace sorted(<dict>.iterkeys()) with sorted(<dict>) 2017-08-22 20:06:58 -04:00
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
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
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
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
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
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
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
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
Augie Fackler
6a2406886b tests: update test-patch to pass our import checker 2017-08-22 16:59:02 -04:00
Augie Fackler
399e672e56 tests: update test-pager to pass our import checker 2017-08-22 16:58:57 -04:00
Augie Fackler
be5dcdb02a tests: update test-obsolete to pass our import checker 2017-08-22 16:58:52 -04:00
Augie Fackler
6cd5685c09 tests: update test-notify to pass our import checker 2017-08-22 16:58:47 -04:00
Augie Fackler
499e35d188 tests: update test-merge1 to pass our import checker 2017-08-22 16:58:43 -04:00
Augie Fackler
1b6ae5b5ea tests: update test-merge-symlinks to pass our import checker 2017-08-22 16:58:37 -04:00
Augie Fackler
c9814ada51 tests: update test-logtoprocess to pass our import checker 2017-08-22 16:58:28 -04:00
Augie Fackler
80fbfddb47 tests: update test-log to pass our import checker 2017-08-22 16:58:22 -04:00
Augie Fackler
e97a9bbde9 tests: update test-log-exthook to pass our import checker 2017-08-22 16:58:13 -04:00
Augie Fackler
6f701f209e tests: update test-largefiles-wireproto to pass our import checker 2017-08-22 16:58:07 -04:00
Augie Fackler
312f8ae32a tests: update test-largefiles-small-disk to pass our import checker 2017-08-22 16:57:37 -04:00
Augie Fackler
29f3197620 tests: update test-keyword to pass our import checker 2017-08-22 15:51:47 -04:00
Augie Fackler
b41cbf2e36 tests: update test-impexp-branch to pass our import checker 2017-08-22 15:51:37 -04:00
Augie Fackler
fdb9502c56 tests: update test-help to pass our import checker 2017-08-22 15:51:30 -04:00
Augie Fackler
bee02ba8da tests: update test-hardlinks to pass our import checker 2017-08-22 15:51:24 -04:00
Augie Fackler
6fec0d4521 tests: update test-glog to pass our import checker 2017-08-22 15:51:18 -04:00
Augie Fackler
1aebac4281 tests: update test-fncache to pass our import checker 2017-08-22 15:51:12 -04:00
Augie Fackler
71f181153f tests: update test-eol to pass our import checker 2017-08-22 15:51:06 -04:00
Augie Fackler
84bc4fa4db tests: update test-dirstate to pass our import checker 2017-08-22 15:50:59 -04:00
Augie Fackler
9767738e92 tests: update test-debugcommands to pass our import checker 2017-08-22 15:50:35 -04:00
Augie Fackler
e85cf68cd1 tests: update test-convert-clonebranches to pass our import checker 2017-08-22 15:50:27 -04:00
Augie Fackler
07679f3f36 tests: update test-commit to pass our import checker 2017-08-22 15:50:01 -04:00
Augie Fackler
3bf0b90e12 tests: update test-command-template to pass our import checker 2017-08-22 15:49:54 -04:00
Augie Fackler
bfd5f74f29 tests: update test-chg to pass our import checker 2017-08-22 15:49:20 -04:00
Augie Fackler
3260906bb2 tests: update test-bundle2-format to pass import checker 2017-08-22 15:05:51 -04:00
Augie Fackler
ee537483fc tests: update test-bundle2-pushback to pass the import checker 2017-08-22 15:04:36 -04:00
Augie Fackler
f8d9a41b22 tests: update test-bookmarks to pass the import checker 2017-08-22 15:04:14 -04:00
Augie Fackler
fca8e3aefa tests: update test-bisect to pass our module import checker 2017-08-22 14:58:39 -04:00
Augie Fackler
070f42ffe6 tests: update test-archive to pass our module import checker 2017-08-22 14:58:21 -04:00
Augie Fackler
abb025bbdf tests: update test-annotate to pass our module import checker 2017-08-22 14:58:10 -04:00
Rishabh Madan
f35bfd559f releasenotes: view admonition titles using -l flag
Since this extension is fairly new for almost all the contributors, remembering
the admonition (with titles) is difficult. The list (-l) flag provides
a list of all the active admonitions along with titles.

For usage, hg releasenotes -l returns the list.

Differential Revision: https://phab.mercurial-scm.org/D454
2017-08-28 04:11:58 +05:30
Martin von Zweigbergk
732c66f9a9 tests: move baduisetup test inside "#if demandimport"
The test case depends on the failure happening not at import time, but
at uisetup() time, so it doesn't make sense when demandimport is
disabled.

There was already a section for testing demandimport stuff, so I moved
it inside that existing section. As part of the move, I enabled the
extension using '--config' so subsequent tests don't get the bad
extension enabled.

Differential Revision: https://phab.mercurial-scm.org/D526
2017-08-26 16:00:07 -07:00
Jun Wu
6d78156438 test-casecollision-merge: fix the test
D30 (43976dd8adc8) makes the error message unpredictable, therefore the fix.

Differential Revision: https://phab.mercurial-scm.org/D494
2017-08-23 11:30:25 -07:00
Jun Wu
0d6dfaec17 run-tests: make per-line condition support testcase names
7340465bd added multiple test cases support. The latter has a problem -
output lines cannot be made conditional with `#if`:

```
  # COUNTEREXAMPLE: DOES NOT WORK
  #testcases A B
    $ command-foo
    common ouput
  #if A
    A's ouput
  #else
    B's ouput
  #endif
    common ouput
```

That's not trivial to fix (even if it works in test, `run-tests.py -i` may
be suboptimal because diff algorithm does not know how to skip the `#if`
lines, even if it does, it may have trouble figuring out whether a changed
line belongs to inside a `#if` block or outside).

Matching output lines conditionally is useful. 4eec2f04a added per-line
condition support for hghave. This patch extends that to also support test
case names.

Differential Revision: https://phab.mercurial-scm.org/D466
2017-08-20 09:46:27 -07:00
Yuya Nishihara
14e0bb89bd run-tests: pass unicode to Pygments
This is required on Python 3, and is more correct on Python 2 because
Pygments is a unicode library.
2017-08-24 22:20:02 +09:00
Yuya Nishihara
d5420b90d5 run-tests: factor out highlight functions 2017-08-24 22:15:40 +09:00
Yuya Nishihara
622a04a8fa run-tests: include "\n" in formatted message instead of calling writeln()
So we don't have to strip "\n" from pygments output.
2017-08-24 22:09:57 +09:00
Yuya Nishihara
a5ae36fcb1 encoding: add fast path of from/toutf8b() for ASCII strings
See the previous patch for why.

The added test seems not making much sense because ASCII strings should
never contain "\xed" and be valid UTF-8.

  (with mercurial repo)
  $ export HGRCPATH=/dev/null HGPLAIN=
  $ hg log --time --config experimental.stabilization=all -Tjson > /dev/null

  (original)
  time: real 6.830 secs (user 6.740+0.000 sys 0.080+0.000)
  time: real 6.690 secs (user 6.650+0.000 sys 0.040+0.000)
  time: real 6.700 secs (user 6.640+0.000 sys 0.060+0.000)

  (fast jsonescape)
  time: real 5.630 secs (user 5.550+0.000 sys 0.070+0.000)
  time: real 5.700 secs (user 5.650+0.000 sys 0.050+0.000)
  time: real 5.690 secs (user 5.640+0.000 sys 0.050+0.000)

  (this patch)
  time: real 5.190 secs (user 5.120+0.000 sys 0.070+0.000)
  time: real 5.230 secs (user 5.170+0.000 sys 0.050+0.000)
  time: real 5.220 secs (user 5.150+0.000 sys 0.070+0.000)
2017-04-23 13:08:58 +09:00
Yuya Nishihara
42ccee312b encoding: add fast path of from/tolocal() for ASCII strings
This is micro optimization, but seems not bad since to/fromlocal() is called
lots of times and isasciistr() is cheap and simple.

We boldly assume that any non-ASCII characters have at least one 8-bit byte.
This isn't true for some email character sets (e.g. ISO-2022-JP and UTF-7),
but I believe no such encodings are used as a platform default. Shift_JIS,
a major crap, is okay as it should have a leading byte in 0x80-0xff range.

  (with mercurial repo)
  $ export HGRCPATH=/dev/null HGPLAIN=
  $ hg log --time --config experimental.stabilization=all > /dev/null

  (original)
  time: real 7.460 secs (user 7.420+0.000 sys 0.030+0.000)
  time: real 7.670 secs (user 7.590+0.000 sys 0.080+0.000)
  time: real 7.560 secs (user 7.510+0.000 sys 0.040+0.000)

  (this patch)
  time: real 7.340 secs (user 7.260+0.000 sys 0.060+0.000)
  time: real 7.260 secs (user 7.210+0.000 sys 0.030+0.000)
  time: real 7.310 secs (user 7.260+0.000 sys 0.060+0.000)
2017-04-23 13:06:23 +09:00
Yuya Nishihara
a22ffac20b encoding: add function to test if a str consists of ASCII characters
Most strings are ASCII. Let's optimize for it.

Using uint64_t is slightly faster than uint32_t on 64bit system, but there
isn't huge difference.
2017-04-23 12:59:42 +09:00
Augie Fackler
38d077eb1e tests: update test-commandserver to pass our import checker 2017-08-22 14:26:25 -04:00
Augie Fackler
c781a5f62e tests: add blank output lines to test-commandserver
This helps the import checker notice when a Python heredoc has
ended. It's not perfect, but it gets nasty quick and I think the
better fix would be to add a real parser for .t-tests, which will have
to wait.
2017-08-22 16:37:56 -04:00
Augie Fackler
f804840943 tests: ensure demandimport test uses absolute_import 2017-08-22 15:50:53 -04:00
Augie Fackler
eaa8880ff9 tests: blacklist test-demandimport from test-check-module-imports
It just does too much weird import stuff to have a hope of passing the
checks.
2017-08-22 15:16:58 -04:00
Augie Fackler
2fbfd450ea tests: sort excluded test files in test-check-module-imports 2017-08-22 15:16:09 -04:00
Augie Fackler
c154e0a746 tests: blacklist some more entries in module import checks 2017-08-22 14:15:16 -04:00
David Demelier
f57348c7a4 bookmarks: allow deleting active bookmark using '.' 2017-08-24 09:23:06 +02:00
Boris Feld
e5f84ad7bf template: add minimal obsfate template function
The goal of this series is to have templates capable of displaying the
evolution of a changeset in a clean and human-readable way.

Add the succsandmarkers template return successors and markers so it can be
used separately like this:

> {succsandmarkers % "{get(succsandmarkers, "markers")|json};"}

The following patches will add template functions that takes successors and
markers as inputs and compute various obsfate fields from them.
2017-08-17 18:26:11 +02:00
David Demelier
fbe91693e0 bookmarks: allow renaming active bookmark using '.' 2017-08-21 08:52:46 +02:00
Augie Fackler
beda3d5545 i18n: update check-translation script to pass import checker 2017-08-22 14:14:52 -04:00
Jun Wu
10555b029c pushvars: do not mangle repo state
Setting `repo._shellvars` works but is not a clean way to pass the pushvars
information from the push command to the exchange operation. Therefore
change it to actually pass `pushvars` as a push operation argument instead.

This makes third party extension like remotenames easier to support pushvars
cleanly. The key value parsing and verification code has been moved to a
lower level so it's harder to be bypassed and easier to be used in
remotenames which could replace `push` command entirely.

Differential Revision: https://phab.mercurial-scm.org/D423
2017-08-16 15:48:48 -07:00
Pulkit Goyal
444d924446 morestatus: check whether the conflict message is None before printing
There are cases like bisect when the conflict message can be None. So we make
sure that we don't print None in that case.

Thanks to Martin for catching this.

Differential Revision: https://phab.mercurial-scm.org/D461
2017-08-21 16:43:37 +05:30
Rishabh Madan
973eda14de releasenotes: add check flag for use of admonitions and its validity
While using releasenotes extension, we will be using admonitions in commit messages.
The check (-c) flag will look for an admonition within the message. If it exists, it will
verify if it is stated under default or custom admonition. The check fails if the
admonition is not present in any of them. It also suggests similar admonitions
in case the admonition is invalid.

Differential Revision: https://phab.mercurial-scm.org/D368
2017-08-13 19:58:45 +05:30
Augie Fackler
b564e23b12 tests: stop using old except syntax in test-bundle2-format 2017-08-22 15:05:07 -04:00
Augie Fackler
28ce6eb339 tests: update test-archive to always use hashlib
We don't need the fallback to the old modules anymore.
2017-08-22 14:57:52 -04:00
Augie Fackler
99e384c15a md5sum: assume hashlib exists now that we're 2.7 only 2017-08-22 14:57:10 -04:00
Alex Gaynor
3b5dc143a9 tests: fixed a bytes/unicode confusion in the test runner
Differential Revision: https://phab.mercurial-scm.org/D483
2017-08-23 01:08:09 +00:00
Martin von Zweigbergk
43011a8bd8 run-tests: remove unused pygments token type
Differential Revision: https://phab.mercurial-scm.org/D478
2017-08-22 10:01:27 -07:00
Martin von Zweigbergk
7366797b32 run-tests: also highlight .py test files in summary messages
With the .t files highlighted, it's very easy to not even notice
failed .py tests.

Differential Revision: https://phab.mercurial-scm.org/D471
2017-08-21 22:13:51 -07:00
Jun Wu
d1a219dc9f test-revset: make it work with chg
chg currently triggers `reposetup` as a side effect of `hg serve` command.
Therefore change the test to not output during `reposetup` to be compatible
with chg.

Differential Revision: https://phab.mercurial-scm.org/D455
2017-08-20 10:55:05 -07:00
Matthieu Laneuville
f835a7751f run-tests: pre instantiate pygments objects
Pre instantiate pygments objects to minimize overhead (cf. 50fbad9bb2af)
2017-08-22 11:00:00 +02:00
Sean Farley
e18a90ab08 merge with stable 2017-08-21 21:35:06 -07:00
Jun Wu
13f8aae09c rebase: choose merge base without unwanted revisions
Previously, when there are 2 merge base candidates, we choose p1 blindly,
which may make the merge result to have "unwanted content". This patch makes
rebase smarter - choose a merge base that does not have "unwanted revs" if
possible. Since we don't really have a good solution when there are
"unwanted revs", abort in that case.

Differential Revision: https://phab.mercurial-scm.org/D340
2017-08-10 22:17:15 -07:00
Danny Hooper
54e3286e1e log: add a "graphwidth" template variable
Wrapping text in templates for 'hg log --graph' can't be done very well,
because the template doesn't know how wide the graph drawing is. The edge
drawing function needs to know the number of lines in the template output, so
we need to also determine how wide that drawing would be before we call the
edgefn or evaluate the template.

This patch makes edgefn compute the graph width and pass it into the template
so that we can do something like this:

COLUMNS=10 hg log --graph --template "{fill(desc, termwidth - graphwidth)}"
@  a a a a
|  a a a a
|  a a a a
o    a a a
|\   a a a
| |  a a a
| |  a a a

Using extensions to do this would be relatively complicated due to a lack of
hooks in this area of the code.

In the future it may make sense to have a more generic "textwidth" that tells
you how many columns you can expect to fill without causing the terminal to
wrap your output. I'm not sure there are other situations to motivate this yet,
or if it is entirely feasible.

Differential Revision: https://phab.mercurial-scm.org/D360
2017-08-15 10:15:31 -07:00
Boris Feld
e0873c6bda obsmarker: precnode was renamed into prednode
Update all calls to formatter.write first arguments to remove references to
precnode and use prednode consistently everywhere.

Differential Revision: https://phab.mercurial-scm.org/D414
2017-08-16 10:26:26 +02:00
Jun Wu
075caa84b6 rebase: remove messages for nullmerge and revignored (BC)
These states will be removed to make the code cleaner and more robust.
Remove their messages first to make review easier.

Differential Revision: https://phab.mercurial-scm.org/D25
2017-07-08 20:38:34 -07:00
Jun Wu
0f5023c94c rebase: remove revprecursor and revpruned states (BC)
Those states are no longer necessary for rebase to function properly. Remove
them to make the code cleaner.

Marked as BC because in a corner case where working parent is obsoleted, and
is skipped for rebase, we no longer move working parent after rebase
completes. That is better since if working parent is obsoleted, it should be
the user moving working parent back there (after a rebase) explicitly, in
that case, we shouldn't move working parent again.

Differential Revision: https://phab.mercurial-scm.org/D24
2017-07-08 20:38:34 -07:00
Jun Wu
d763d13686 rebase: move obsoleted not rebased messages earlier (BC)
A later patch will clean up those states. This patch moves the messages
earlier.

Marked as BC since the order of message has changed.

Differential Revision: https://phab.mercurial-scm.org/D23
2017-07-08 20:14:33 -07:00
Phil Cohen
567a5b0454 simplemerge: use contexts to read file data from, if passed
Differential Revision: https://phab.mercurial-scm.org/D374
2017-08-13 20:06:52 -07:00
Matthieu Laneuville
0502a8cd8b run-tests: also color the summary messages (skipped, failed...) 2017-08-11 14:21:49 +02:00
Gregory Szorc
e4ec4341f2 tests: verify that peer instances only expose interface members
Our abstract interfaces are more useful if we guarantee that
implementations conform to certain rules. Namely, we want to ensure
that objects implementing interfaces don't expose new public
attributes that aren't part of the interface. That way, as long as
consumers don't access "internal" attributes (those beginning with
"_") then (in theory) objects implementing interfaces can be swapped
out and everything will "just work."

We add a test that enforces our "no public attributes not part
of the abstract interface" rule.

We /could/ implement "interface compliance detection" at run-time.
However, that is littered with problems.

The obvious solutions are custom __new__ and __init__ methods.
These rely on derived types actually calling the parent's
implementation, which is no sure bet. Furthermore, __new__ and
__init__ will likely be called before instance-specific attributes
are assigned. In other words, they won't detect public attributes
set on self.__dict__. This means public attribute detection won't
be robust.

We could work around lack of robust self.__dict__ public attribute
detection by having our interfaces implement a custom __getattribute__,
__getattr__, and/or __setattr__. However, this incurs an undesirable
run-time penalty. And, subclasses could override our custom
method, bypassing the check.

The most robust solution is a non-runtime test. So that's what this
commit implements. We have a generic function for validating that an
object only has public attributes defined by abstract classes. Then,
we instantiate some peers and verify a newly constructed object
plays by the rules.

Differential Revision: https://phab.mercurial-scm.org/D339
2017-08-10 21:00:30 -07:00
Gregory Szorc
d5338b2208 wireproto: use new peer interface
The wirepeer class provides concrete implementations of peer interface
methods for calling wire protocol commands. It makes sense for this
class to inherit from the peer abstract base class. So we change
that.

Since httppeer and sshpeer have already been converted to the new
interface, peerrepository is no longer adding any value. So it has
been removed. httppeer and sshpeer have been updated to reflect the
loss of peerrepository and the inheritance of the abstract base
class in wirepeer.

The code changes in wirepeer are reordering of methods to group
by interface.

Some Python code in tests was updated to reflect changed APIs.

.. api::

   peer.peerrepository has been removed. Use repository.peer abstract
   base class to represent a peer repository.

Differential Revision: https://phab.mercurial-scm.org/D338
2017-08-10 20:58:28 -07:00
Augie Fackler
8beb33f58d scmutil: use util.shellquote instead of %r
Changes some output, but also resolves differences with Python 3.

Differential Revision: https://phab.mercurial-scm.org/D301
2017-07-26 23:47:54 -04:00
Matt Harbison
d8498c2750 test-pushvars: invoke shell script hook via sh for Windows
Invoking *.sh on Windows leads to the "what program should open this?" prompt,
which stalls the test and led to the recent series of exceptions on the Windows
test machine as the runner times out.
2017-08-14 22:26:48 -04:00
Matt Harbison
e25cbfab31 test-sparse: drop unnecessary globs 2017-08-14 22:20:53 -04:00
Jun Wu
7a9096496d rebase: change "result would have 3 parent" error message (BC)
The old error message "cannot use revision REV as base, result would have 3
parents" is confusing - why use REV as base? why add a new parent?.

This patch changes it to "cannot move parent", which seems better.

Differential Revision: https://phab.mercurial-scm.org/D342
2017-08-12 21:01:06 -07:00
Jun Wu
80b48fb03d drawdag: allow override file contents via comments
This makes drawdag more flexible, and allow us to create non-clean merges in
test cases.

Differential Revision: https://phab.mercurial-scm.org/D385
2017-08-14 07:02:38 -07:00
Jun Wu
87f820de49 rebase: rewrite core algorithm (issue5578) (issue5630)
"defineparents" is the core algorithm of rebase. The old code has too many
tech debts (like outdated comments, confusing assertions, etc) and is very
error-prone to be improved. This patch rewrites "defineparents" to make the
code easier to reason about, and solve a bunch of issues, including:

  - Assertion error: no base found (demonstrated by D212, issue5578)
  - Asymmetric result (demonstrated by D211, "F with one parent")
  - Wrong new parent (demonstrated by D262, "C':A'A'")
  - "revlog index out of range" (demonstrated by D262, issue5630)
  - "nothing to merge" (demonstrated by D262)

As a side effect, merge base decision has been made more solid - rebase now
prints out explicitly what could go wrong when it cannot find a unique
suitable merge base.

.. fix:: Issue 5578, Issue 5630

   Core rebase algorithm has been rewritten to be more robust.

Differential Revision: https://phab.mercurial-scm.org/D21
2017-08-10 21:30:31 -07:00
Boris Feld
61f35b42fd label: rename log.trouble into log.instability
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D259
2017-08-03 15:31:54 +02:00
Boris Feld
d833c9f0c7 label: rename trouble.X into instability.X
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D258
2017-08-03 15:30:41 +02:00
Boris Feld
bd1b933a37 label: rename changeset.troubled into changeset.unstable
The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D257
2017-08-03 14:32:50 +02:00
Boris Feld
a9fcc0d95e test: add a test for stabilization related labels
Differential Revision: https://phab.mercurial-scm.org/D256
2017-08-03 14:16:54 +02:00
Boris Feld
5489bbeda4 revset: rename bumped into phasedivergent
Don't touch bumped volatile set name, only the revset name. The volatile set
name will be updated in a later patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D252
2017-08-03 14:08:39 +02:00
Boris Feld
cf0c39bfeb revset: remane divergent into contentdivergent
Don't touch divergent volatile set name, only the revset name. The volatile
set name will be updated in a later patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D251
2017-08-03 14:01:51 +02:00
Boris Feld
aaaa0c98dc revset: rename unstable into orphan
Don't touch unstable volatile set name, only the revset name. The volatile set
name will be updated in a later patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D250
2017-08-03 13:48:39 +02:00
Boris Feld
c886c86073 test: update evolution config
evolution* config has been rewritten in stabilization* in the previous patch,
update tests file to use the new names.

Differential Revision: https://phab.mercurial-scm.org/D249
2017-08-04 18:41:16 +02:00
Pulkit Goyal
3f92988eda morestatus: move fb extension to core by plugging to hg status --verbose
morestatus extension in fbext use to show more context about the state of the
repo like the repository is in a unfinished merge state, or a rebase is going
on, or histedit is going on, listing the files which need to be resolved and
also suggesting ways to handle the situation.

This patch moves the extension directly to core by plugging it into the
--verbose flag of the status command. So now if you are in any unfinished state
and you do hg status -v, it will show you details and help related to the state.

The extension in fbext also shows context about unfinished update state
which is not ported to core as that plug in hooks to update command which need
to be tackled somewhat differently.

The following configuration will turn the behaviour on by default

[commands]
status.verbose = 1

You can also skip considering some states like bisect as follows:

[commands]
status.skipstates=bisect

This patch also adds test for the feature.

.. feature::

   ``hg status -v`` can now show unfinished state. For example, when in
   an unfinished rebase state, ``hg status -v`` might show::

   # The repository is in an unfinished *rebase* state.
   # No unresolved merge conflicts.
   # To continue:                hg rebase --continue
   # To abort:                   hg rebase --abort

Differential Revision: https://phab.mercurial-scm.org/D219
2017-08-03 05:12:35 +05:30
Boris Feld
657776f4e3 bundle2: fix transaction availability detection
Changeset aa97e972460f introduce more complex logic around
'bundleoperation.gettransaction'. In that process it turns the old "attribute"
into a proper method which breaks the code that detects the "transaction
availability".

The change was visible in 'test-acl.t', fixing this reverts the test changes.

Differential Revision: https://phab.mercurial-scm.org/D303
2017-08-09 17:01:21 +02:00
Gregory Szorc
b5802cf167 peer: remove non iterating batcher (API)
The last use of this API was removed in 3bcb9f9a4a63 in 2016. While
not formally deprecated, as of the last commit the code is no longer
explicitly tested. I think the new API has existed long enough for
people to transition to it.

I also have plans to more formalize the peer API and removing batch()
makes that work easier.

I'm not convinced the current client-side API around batching is
great. But it's the best we have at the moment.

.. api:: remove peer.batch()

   Replace with peer.iterbatch().

Differential Revision: https://phab.mercurial-scm.org/D320
2017-08-09 23:35:20 -07:00
Gregory Szorc
34a7acd6d7 wireproto: overhaul iterating batcher code (API)
The remote batching code is difficult to read. Let's improve it.

As part of the refactor, the future returned by method calls on
batchiter() instances is now populated. However, you still need to
consume the results() generator for the future to be set.  But at
least now we can stuff the future somewhere and not have to worry
about aligning method call order with result order since you can
use a future to hold the result.

Also as part of the change, we now verify that @batchable generators
yield exactly 2 values. In other words, we enforce their API.

The non-iter batcher has been unused since 3bcb9f9a4a63. And to my
surprise we had no explicit unit test coverage of it! test-batching.py
has been overhauled to use the iterating batcher.

Since the iterating batcher doesn't allow non-batchable method
calls nor local calls, tests have been updated to reflect reality.
The iterating batcher has been used for multiple releases apparently
without major issue. So this shouldn't cause alarm.

.. api::

   @peer.batchable functions must now yield exactly 2 values

Differential Revision: https://phab.mercurial-scm.org/D319
2017-08-09 23:29:30 -07:00
Gregory Szorc
014510187c wireproto: remove support for local results in @batchable (API)
@peer.batchable decorated generator functions have two forms:

    yield value, None

and

    yield args, future
    yield value

These forms have been present since the decorator was introduced.

There are currently no in-repo consumers of the first form. So this
commit removes support for it.

Note that remoteiterbatcher.submit() asserts the 2nd form. And
3bcb9f9a4a63 removed the last user of remotebatcher, forcing everyone
to remoteiterbatcher. So anything relying on this in the wild would
have been broken since 3bcb9f9a4a63.

.. api::

   @peer.batchable can no longer emit local values

Differential Revision: https://phab.mercurial-scm.org/D318
2017-08-09 22:52:05 -07:00