Commit Graph

30976 Commits

Author SHA1 Message Date
Pulkit Goyal
e51666942e store: slice over a bytestring to get characters instead of ascii values
On Python 2,

>>> a = b'abc'
>>> a[1]
'b'

Whereas on python 3,

>>> a = b'abc'
>>> a[1]
98
>>> a[1:2]
b'b'

This does not change behaviour on python 2.
2017-03-08 00:40:15 +05:30
Pierre-Yves David
151773bf84 vfs: use 'vfs' module directly in 'mercurial.hg'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:27:42 +01:00
Pierre-Yves David
12f94cda0a vfs: extract 'vfs' class and related code to a new 'vfs' module (API)
The 'scmutil' is growing large (1500+ lines) and 2/5 of it is related to vfs.
We extract the 'vfs' related code in its own module get both module back to a
better scale and clearer contents.

We keep all the references available in 'scmutil' for now as many reference
needs to be updated.
2017-03-01 11:00:12 +01:00
Pierre-Yves David
e5cb48ac36 vfs: replace 'scmutil.opener' usage with 'scmutil.vfs'
The 'vfs' class is the first class citizen for years. We remove all usages of
the older API. This will let us remove the old API eventually.
2017-03-02 03:52:36 +01:00
Durham Goode
f3dc8f389b fsmonitor: remove use of repo.opener
This has been deprecated, so we need to switch to the appropriate vfs apis.
2017-03-07 12:52:00 -08:00
Kim Alvefur
977cd43980 help: align description of 'base rev' with reality [issue5488]
The text about revlogs seems to be wrong about -1 being used to indicate
the start of a delta chain. Attempt to correct this.
2017-02-28 15:19:08 +01:00
Kyle Lippincott
2dc3df2798 help: fix internals.changegroups
Add information about tree manifests, copy edit the text and fix up a few
ambiguities.

The document also contains a few additional fixes from Siddharth Agarwal
<sid0@fb.com>, who used it to build a parser for changegroups in Rust.
2017-03-01 18:37:34 -08:00
Yuya Nishihara
bef32f9011 share: drop 'relshared' requirement as well 2017-03-03 00:11:51 +09:00
Yuya Nishihara
42f38a34a0 share: fix typo to drop 'shared' requirement on unshare
This must be a typo and it seems correct to drop the requirement since the
repo is no longer a shared repository.
2017-03-03 00:11:18 +09:00
FUJIWARA Katsunori
c23eb09a4f similar: compare between actual file contents for exact identity
Before this patch, similarity detection logic (for addremove and
automv) depends entirely on SHA-1 digesting. But this causes incorrect
rename detection, if:

  - removing file A and adding file B occur at same committing, and
  - SHA-1 hash values of file A and B are same

This may prevent security experts from managing sample files for
SHAttered issue in Mercurial repository, for example.

  https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html
  https://shattered.it/

Hash collision itself isn't so serious for core repository
functionality of Mercurial, described by mpm as below, though.

  https://www.mercurial-scm.org/wiki/mpm/SHA1

This patch compares between actual file contents after hash comparison
for exact identity.

Even after this patch, SHA-1 is still used, because it is reasonable
enough to quickly detect existence of "(almost) same" file.

  - replacing SHA-1 causes decreasing performance, and
  - replacement of it has ambiguity, yet

Getting content of removed file (= rfctx.data()) at each exact
comparison should be cheap enough, even though getting content of
added one costs much.

  ======= ============== =====================
  file    fctx           data() reads from
  ======= ============== =====================
  removed filectx        in-memory revlog data
  added   workingfilectx storage
  ======= ============== =====================
2017-03-03 02:57:06 +09:00
Jun Wu
a2a0eb3ac0 localrepo: handle rename with hardlinks properly
In "aftertrans", we rename "journal.*" to "undo.*". We expect "journal.*"
files to disappear after renaming.

However, if "journal.foo" and "undo.foo" refer to a same file (hardlink),
rename may be a no-op, leaving both files on disk, according to Linux
manpage [1]:

    If oldpath and newpath are existing hard links referring to the same
    file, then rename() does nothing, and returns  a  suc‐ cess status.

The POSIX specification [2] is not very clear about what to do.

To be safe, remove "undo.*" before the rename so "journal.*" cannot be left
on disk.

[1]: http://man7.org/linux/man-pages/man2/rename.2.html
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/
2017-03-02 21:49:30 -08:00
Jun Wu
3c38af4dff dirstate: avoid unnecessary load+dump during backup
Previously, dirstate.savebackup unconditionally dumps the dirstate map to
disk. It may require loading dirstate first to be able to dump it. Those
operations could be expensive if the dirstate is big, and could be avoided
if we know the dirstate file is up-to-date.

This patch avoids the read and write if the dirstate is clean. In that case,
we just do a plain copy without any serialization.

This should make commands which use transactions but do not touch dirstate
faster. For example, "hg bookmark -r REV NAME".
2017-03-01 18:21:06 -08:00
Jun Wu
0bbf2239d3 dirstate: try to use hardlink to backup dirstate
This should be more efficient once util.copyfile has real hardlink support.
2017-03-01 17:59:21 -08:00
Durham Goode
c93b79c0e6 dirstate: track updated files to improve write time
Previously, dirstate.write() would iterate over the entire dirstate to find any
entries that needed to be marked 'lookup' (i.e. if they have the same timestamp
as now). This was O(working copy) and slow in large repos. It was most visible
when rebasing or histediting multiple commits, since it gets executed once per
commit, even if the entire rebase/histedit is wrapped in a transaction.

The fix is to track which files have been editted, and only check those to see
if they need to be marked as 'lookup'. This saves 25% on histedit times in very
large repositories.

I tested this by adding temporary debug logic to verify that the old files
processed in the loop matched the new files processed in the loop and running
the test suite.
2017-03-05 16:20:07 -08:00
Simon Farnsworth
8539b5a667 hook: give exthooks tags for blocking time
The ui.system autogenerated tag isn't really useful - as they're named, let's
use the name the user gave us.
2017-03-06 03:09:15 -08:00
Simon Farnsworth
17c528e46d filemerge: tag merge tool for blocked times
Merge tools can take a while - let's ensure that they're appropriately tagged
2017-03-06 03:19:40 -08:00
Simon Farnsworth
cd8b635c8b hgk: set a blocked tag when the user invokes view 2017-03-06 03:27:52 -08:00
Simon Farnsworth
947a0b6d19 transplant: set a blockedtag when invoking external filter 2017-03-06 03:27:41 -08:00
Simon Farnsworth
d6cdf14b5e config: set blockedtag when invoking configuration edit 2017-03-06 03:27:24 -08:00
Simon Farnsworth
63ca96dec0 bisect: set a blockedtag when running the check command
So that the hg bisect data clearly shows the bisect command separately to the
main data set.
2017-03-06 03:26:30 -08:00
Simon Farnsworth
36d4b32d0f dispatch: set a blockedtag when running an external alias 2017-03-06 03:25:44 -08:00
Simon Farnsworth
6929f48253 patch: set a blockedtag when running an external filter 2017-03-06 03:25:29 -08:00
Simon Farnsworth
bdb0a7478b sshpeer: set a blockedtag when starting ssh
So that the data is readable.
2017-03-06 03:25:09 -08:00
Denis Laxalde
de480b0802 revert: always display hunks reversed when reverting to parent
When reverting to the parent of working directory, operation is "discard" so
we want hunks to be presented in the same order as the diff (i.e. "reversed").
So we do not query the experimental.revertalternateinteractivemode option in
this case and always set "reversehunks" to True.
2017-03-06 14:11:21 +01:00
Pierre-Yves David
a1ad299f67 fileset: add a 'status(...)' predicate to control evaluation context
Same as 'revs', this predicate does not select files but switches the evaluation
context. This allow to match file according arbitrary status call. We can now
express the same query as 'hg status'.

The API (two 'revsingle' class) have been picked instead of a single 'revs'
revset for multiple reasons:

 * it is less confusing to express
 * it allow to express more query (eg: backward status, cross branch status)
2017-03-03 14:08:20 +01:00
Pierre-Yves David
5b29e72b25 fileset: allow to specify a basectx for status
This will be used for a predicates that defines the status range of a match.
2017-03-03 14:08:06 +01:00
Pierre-Yves David
5be5f101f6 fileset: add revs(revs, fileset) to evaluate set in working directory
Unlike other functions, "revs()" does not select files but switches the
evaluation context. This allow to match file with property in another revision
that the one currently evaluated.

This changeset is based on work from Yuya Nishihara.
2017-03-03 12:44:56 +01:00
Yuya Nishihara
123bfcf3e9 fileset: add function to switch revision where fileset will be evaluated
If the subset isn't filtered yet, i.e. if fullmatchctx, the new subset is
recalculated from scratch. Otherwise, it is narrowed by the existing subset.
2015-01-24 19:41:56 +09:00
Yuya Nishihara
19f5256d23 fileset: extract function that builds status tuple only if necessary
This function will be used to recalculate status when mctx.ctx is switched.
2015-01-24 19:13:39 +09:00
Yuya Nishihara
69310d762a fileset: build initial subset in fullmatchctx class 2015-01-24 18:56:02 +09:00
Yuya Nishihara
081bed02eb fileset: extract function that builds initial subset from ctx or status
This function will be used to recalculate subset when mctx.ctx is switched.
2015-03-24 23:10:49 +09:00
Yuya Nishihara
b8e9d7ad88 fileset: add class to host special handling of initial subset
Future patches will add a function to switch mctx.ctx object so that we can
forcibly evaluate a fileset expression in a specified revision. For example,
new "revs()" function will be used to match predicate agains another revision

  $ hg revert 'set:revs(42, added())'

fullmatchctx class is similar to revset.fullreposet. It will allow us to
recalculate the subset only if it is not filtered yet.
2015-01-24 19:55:14 +09:00
Yuya Nishihara
5fab4a9d55 patchbomb: add config knob to generate flags by template (issue5354)
This can be used to flag patches by branch or topic automatically. Flags
optionally given by --flag option are exported as {flags} template keyword,
so you can add --flag V2.
2017-02-25 18:41:00 +09:00
Yuya Nishihara
7697dd4d5b patchbomb: pass around ui and revs that are needed for flag template
See the next patch for why.
2017-02-25 18:35:34 +09:00
Yuya Nishihara
cc7b1af6b2 patchbomb: build patch texts by _getpatchmsgs()
Now _getpatchmsgs() knows revision numbers, which allows us to generate flags
by applying a template to changectx objects.
2017-02-25 18:28:04 +09:00
Yuya Nishihara
2fae5e032d patchbomb: drop internal option for pbranch extension (API)
I want to move _getpatches() to _getpatchmsgs() to make sure each patch text
is tied with the corresponding revision number. This helps adding templater
support.

IIRC, the pbranch extension doesn't work with the recent Mercurial versions,
so the removal of this option wouldn't hurt.
2017-02-25 18:25:17 +09:00
Yuya Nishihara
be15dfae52 patchbomb: factor out function that builds a prefix string to patch subject
I'll add templating support.
2017-02-25 18:16:41 +09:00
Yuya Nishihara
bc9edb1202 formatter: add argument to change output file of non-plain formatter
This allows us to build data not written to the console. That would be
doable by ui.pushbuffer()/popbuffer(), but changing the file object seems
cleaner.
2015-01-18 18:04:44 +09:00
Augie Fackler
3322b24b9d schemes: move re construction to module-level and python3-ify
This makes the schemes extension load correctly in Python 3.
2017-03-03 13:25:30 -05:00
Augie Fackler
601a6ec266 dispatch: cope with sys.version being unicode on Python 3 2017-03-03 13:29:50 -05:00
Augie Fackler
5bdccc39a5 dispatch: allow testedwith to be bytes or str 2017-03-03 13:29:25 -05:00
Augie Fackler
80c3da0d7d ui: fix ui.traceback on Python 3 2017-03-03 14:09:14 -05:00
Augie Fackler
85e23a6604 ui: fix opts labeling on ui.warn et al for Python 3
This is a step towards fixing extension load warnings on Python
3. Note that I suspect there are still some bugs in this area and that
things like color won't work, but the code at least executes and
prints text to the console correctly now.
2017-03-03 14:08:24 -05:00
Augie Fackler
96fc868b4a config: add sanity assert that files are opened as binary
This helps with some debugging in Python 3, and shouldn't hurt
anything in Python 2. The unusual construction using getattr is done
so that StringIO/BytesIO instances can be used as well as real files.
2017-03-03 12:55:11 -05:00
Martin von Zweigbergk
4ad88a61e0 update: for "noconflict" updates, print "conflicting changes" on conflict
With experimental.updatecheck=noconflict, if the update is aborted
because of conlicts, "uncommitted changes" is not quite
accurate. Let's use "conflicting changes" instead. Also fix the hint
to recomment --clean, not --merge, since that's what we do for other
failed updates.
2017-03-06 23:21:27 -08:00
Martin von Zweigbergk
1db93fafc0 tests: fix test-update-branches to remove non-conflicting file
I was clearly very sloppy when I wrote the test case for
experimental.updatecheck=noconflict. The test case that checks that
one can move between commits with a removed file was deleting a file
that was modified between the source and target commits, which
resulted in a "change/delete" conflict. Since that is a conlict, the
update correctly failed. Let's fix the test by removing a file that is
not modified between the two commits.
2017-03-06 23:19:57 -08:00
Yuya Nishihara
7ca440fb7f branches: populate all template keywords in formatter
This is a usage example of fm.context().
2017-02-25 17:08:42 +09:00
Yuya Nishihara
36d684e2c3 formatter: add support for changeset templating
Some formatter-based commands provide fields that are identical to the ones
defined in templatekw, but we had to specify them manually to support all
changeset-based template keywords.

This patch adds fm.context() that populates all templatekw. These keywords
are available only in template output, so we still need to set important
keywords via fm.data() if they should be available in e.g. JSON output.

Currently fm.context() takes only 'ctx' argument. It will eventually be
extended to take 'fctx' to support file-based keywords (e.g. {path}) seen
in hgweb.
2017-02-25 17:00:07 +09:00
Yuya Nishihara
a69b51cf89 templatekw: move defaulttmpl constant from changeset_templater
These templates are used when rendering inner lists of some template keywords,
so it makes sense to define them in templatekw. This allows us to reuse them
to create a templateformatter knowing changectx.
2017-02-25 16:38:26 +09:00
Yuya Nishihara
d9d27f710f formatter: drop filters argument from maketemplater()
It's unused now. I want to keep the high-level API simple.
2017-02-25 22:04:30 +09:00