Commit Graph

27691 Commits

Author SHA1 Message Date
Martin von Zweigbergk
216d0e41ef diff: don't crash when merged-in addition is copied
Similar to what was explained in the previous commit, the diff code
expected copy source to be in "ctx1", which is not always the case
during a merge. This has been broken since before hg 2.0.

Also similar to the previous commit, we fix the problem by fixing up
the copy dict.
2016-01-14 10:22:55 -08:00
Martin von Zweigbergk
0c3407d70e diff: don't crash when merged-in addition was removed (issue4786)
During a merge, if the user removes a file that came from parent 2 and
did not exist in parent 1, the file's status will be "removed". This
surprises the diff code, which crashes because it expects removed
files exist in parent 1. This has been broken since ff976121fb34
(trydiff: use 'not in addedset' for symmetry with 'not in removedset',
2014-12-23).

Fix by fixing up the list of removed file, similar to how we currently
fix up the list of modified and added files during a merge.
2016-01-14 10:14:24 -08:00
Martin von Zweigbergk
cf817770b1 diff: move status fixup earlier, out of _filepairs()
This prepares for future patches, and it also lets us remove the ugly
"ctx1" argument to _filepairs() (ugly because of its assymmetry --
there's no "ctx2" argument).
2016-01-14 10:02:34 -08:00
Mads Kiilerich
9f1efa7c96 graft: warn when -r is combined with revisions as positional arguments
The behaviour in this case is undefined. Instead of silently doing something
"random" and surprising, at least issue a warning.

(This should perhaps be considered a "deprecation" and turned into an error in
a future release.)
2016-01-17 19:33:02 +01:00
Mads Kiilerich
200157f1b5 graft: clarify in help that -r is not just optional
Positional parameters are also treated as revisions, but the order of revisions
matters and it will often be wrong if the user understands it as `-r` taking
multiple revisions as `-r REV1 REV2`.

(Alternatively, `-r` could be turned into a no-op flag as the documentation
suggests. That would however be less "semantic markup" and I agree with the
implementation in 40cbb25097c8 but not the documentation.)
2016-01-17 19:33:02 +01:00
Gregory Szorc
a05892eae0 streamclone: use backgroundfilecloser (issue4889)
Closing files that have been appended to is slow on Windows/NTFS.
CloseHandle() calls on this platform often take 1-10ms - and that's
on my i7-6700K Skylake processor with a modern and fast SSD. Contrast
with other I/O operations, such as writing data, which take <100us.

This means that creating/appending thousands of files can add
significant overhead. For example, cloning mozilla-central creates
~232,000 revlog files. Assuming 1ms per CloseHandle(), that yields
232s (3:52) of wall time waiting for file closes!

The impact of this overhead can be measured most directly when applying
stream clone bundles. Applying these files is effectively uncompressing
a tar archive (read: it's very fast).

Using a RAM disk (read: no I/O wait), the difference in wall time for a
`hg debugapplystreamclonebundle` for a ~1731 MB mozilla-central bundle
between Windows and Linux from the same machine is drastic:

Linux:    ~12.8s (128MB/s)
Windows: ~352.0s (4.7MB/s)

Windows is ~27.5x slower. Yikes!

After this patch:

Linux:    ~12.8s (128MB/s)
Windows: ~102.1s (16.1MB/s)

Windows is now ~3.4x faster. Unfortunately, it is still ~8x slower than
Linux. Profiling reveals a few hot code paths that could likely be
improved. But those are for other patches.

This patch introduces test-clone-uncompressed.t because existing tests
of `clone --uncompressed` are scattered about and adding a variation for
background thread closing to e.g. test-http.t doesn't feel correct.
2016-01-14 13:44:01 -08:00
Gregory Szorc
ba2d05e908 streamclone: indent code
This will make the subsequent patch easier to read.
2016-01-02 16:11:36 -08:00
Gregory Szorc
49c61f06be scmutil: support background file closing
Closing files that have been appended to is relatively slow on
Windows/NTFS. This makes several Mercurial operations slower on
Windows.

The workaround to this issue is conceptually simple: use multiple
threads for I/O. Unfortunately, Python doesn't scale well to multiple
threads because of the GIL. And, refactoring our code to use threads
everywhere would be a huge undertaking. So, we decide to tackle this
problem by starting small: establishing a thread pool for closing
files.

This patch establishes a mechanism for closing file handles on separate
threads. The coordinator object is basically a queue of file handles to
operate on and a thread pool consuming from the queue.

When files are opened through the VFS layer, the caller can specify
that delay closing is allowed.

A proxy class for file handles has been added. We must use a proxy
because it isn't possible to modify __class__ on built-in types. This
adds some overhead. But as future patches will show, this overhead
is cancelled out by the benefit of closing file handles on background
threads.
2016-01-14 13:34:59 -08:00
Yuya Nishihara
c998aff68a templatekw: add {namespaces} keyword
This provides a general-purpose interface to all custom namespaces.

The {namespaces} keyword honors the definition order of namespaces as they
are kept by sortdict.
2016-01-12 23:56:48 +09:00
Yuya Nishihara
dbf185d983 templatekw: move shownames() helper to be sorted alphabetically
I'll add shownamespaces(), which is similar to this function. I want to put
them nearby.
2016-01-12 23:53:56 +09:00
Yuya Nishihara
e2a7f69128 templater: make get(dict, key) return a single value
This is necessary to obtain a _hybrid object from a dict. If get() yields
a value, it would be stringified.

I see no benefit to make get() lazy, so this patch just changes "yield" to
"return".
2016-01-16 13:53:32 +09:00
Yuya Nishihara
20aed11e76 templater: make _hybrid not callable to avoid conflicting semantics
In templater, a callable symbol exists for lazy evaluation, which should have
f(**mapping) signature. On the other hand, _hybrid.__call__(), which was
introduced by 4e182fb53989, generates mapping for each element.

This patch renames _hybrid.__call__() to _hybrid.itermaps() so that a _hybrid
object can be a value of a mapping dict.

  {namespaces % "{namespace}: {names % "{name }"}\n"}
                               ~~~~~
                               a _hybrid object
2016-01-16 13:42:37 +09:00
Ruslan Sayfutdinov
3f980f0f17 backout: commit changeset by default (BC)
Add --no-commit flag to prevent it. This should make the hg user
experience a little better. Some discussion can be found here:
http://markmail.org/message/7jm7ro2ias6hxywy
2016-01-15 13:46:33 -08:00
Danek Duvall
66247223e5 help: move Windows 9x information to appropriate place 2016-01-15 13:01:37 -08:00
Simon Farnsworth
1d446c79cb shelve: move commitfunc closer to use site
Supporting shelving of unknown files needs this code motion.

No functional changes.
2016-01-14 12:52:59 -08:00
Gregory Szorc
05359af187 commands: document clone bundles hooks and rollback behavior
The added content is inside a verbose container.

I figure it makes sense to explicitly document behavior, including
with the caveat it may change later. People can't say they weren't
warned!
2016-01-14 21:21:59 -08:00
Gregory Szorc
bdc9fb8c76 clonebundles: improve BUNDLESPEC documentation
Before the existence of `hg debugbundle --spec`, the process for
defining the BUNDLESPEC value in manifests was not very clear and not
trivial to automate, especially in the case of stream clone bundles.

This patch adds documentation to note the existence of
`hg debugbundle --spec`. We drop the reference to stream clone
requirements handling because it is now redundant with
`hg debugbundle --spec`. While we are here, we further reinforce the
importance of defining BUNDLESPEC.
2016-01-14 22:50:55 -08:00
Gregory Szorc
3a890f3e32 commands: teach debugbundle to print bundle specification
This seems like the most logical place to put this functionality.

Test coverage over existing known bundle specs has been added.
2016-01-14 22:57:55 -08:00
Gregory Szorc
274b1c944c commands: use context manager for opened bundle file 2016-01-14 21:27:53 -08:00
Gregory Szorc
6a6f7ee7dc exchange: implement function for inferring bundle specification
We don't currently have a mechanism for inferring bundle spec strings
from bundle files. This patch adds one.

This will eventually be used to make the producing of clone bundles
manifests easier.
2016-01-14 22:49:03 -08:00
Gregory Szorc
9128d3d945 streamclone: extract code for reading header fields
So it can be called from another consumer in a future patch.
2016-01-14 22:48:54 -08:00
Yuya Nishihara
6727c29486 encoding: escape U+007F (DEL) character in JSON
RFC 7159 does not state that U+007F must be escaped, but it is widely
considered a control character. As '\x7f' is invisible on a terminal, and
Python's json.dumps() escapes '\x7f', let's do the same.
2016-01-16 18:30:01 +09:00
timeless
fafbbff385 run-tests: skip threading for a single test (issue5040)
This version backs out 69d5cadd84a0 and implements it in
a more consistent manner.
2016-01-14 04:14:50 +00:00
Augie Fackler
54446bb7e0 cleanup: use modern @property/@foo.setter property specification
We can use this now that we're 2.6+, and this is more idiomatic modern
Python.
2016-01-16 10:50:28 -05:00
Mathias De Maré
53015f77fd buildrpm: use bash shebang, since we use bash features in the script
As suggested by Bryan O'Sullivan.
2016-01-15 16:16:25 +01:00
Matt Mackall
4343a7194d mac: ignore resource fork when checking file sizes
Some evil evil awful tool adds resource forks to files it's comparing.
Our Mac-specific code to do bulk stats was accidentally using "total
size" which includes those forks in the file size, causing them to be
reported as modified. This changes it to only care about the normal
data size and thus agree with what Mercurial's expecting.
2016-01-14 12:37:15 -06:00
Matt Mackall
a8fcfbf03d copies: fix detection of divergent directory renames
If we move all the files out of one directory, but into two different
directories, we should not consider it a directory rename. The
detection of this case was broken.
2016-01-13 10:10:05 -06:00
Bryan O'Sullivan
541db2c882 with: use context manager for transaction in strip 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
fd04392cbc with: use context manager for transaction in pushphase 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
8bfeb98530 with: use context manager for transaction in strip 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
49db6467b8 with: use a context manager for transaction in strip 2016-01-15 13:14:50 -08:00
Bryan O'Sullivan
da377129a6 with: use context manager in rebuildfncache 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
13360de2f3 with: use context manager for transaction in consumev1 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
8c6b71c1ce with: use context manager in _histedit 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
c72a4fb771 with: use context manager in amend 2016-01-15 13:14:50 -08:00
Bryan O'Sullivan
337c3199e2 with: use context manager for transaction in changegroup apply
(This needs some line wrapping due to the additional indent level. -mpm)
2016-01-15 13:14:50 -08:00
Bryan O'Sullivan
cc14be3d13 with: use context manager for transaction in rebase 2016-01-15 13:14:48 -08:00
Bryan O'Sullivan
1ac3200b15 with: use context manager for transaction in qimport 2016-01-15 13:14:47 -08:00
Bryan O'Sullivan
a9ed8a0db6 with: use context manager for transaction in qfinish 2016-01-15 13:14:47 -08:00
Bryan O'Sullivan
4a70f875ef with: use context manager for transaction in mercurial_sink 2016-01-15 13:14:47 -08:00
Bryan O'Sullivan
31c9d97ad8 transaction: turn a transaction into a Python context manager
This lets us greatly simply acquire/release cycles.

If the block completes without raising an exception, the transaction
is closed.

Code pattern before:

  try:
    tr = repo.transaction('x')
    # zillions of lines of code
    tr.close()
  finally:
    tr.release()

And after:

  with tr.transaction('x'):
    # ...
2016-01-15 13:14:47 -08:00
Bryan O'Sullivan
2c9c32a10b with: use context manager for lock in pushphase 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
155e1de602 with: use context manager in rebuildfncache again 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
cde011507a with: use context manager in streamclone consumev1 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
f646cafad4 with: use context manager in manifest 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
2caa7d79a8 with: use context manager in rename 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
f32abc8e35 with: use context manager in resolve 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
fa514efcb7 with: use context manager in unbundle 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
44384e880c with: use context manager in update 2016-01-15 13:14:49 -08:00
Bryan O'Sullivan
9e950df349 with: use context manager in bisect save_state 2016-01-15 13:14:49 -08:00