Commit Graph

12975 Commits

Author SHA1 Message Date
Matt Mackall
25fddcdd96 merge with stable 2014-12-22 17:26:21 -06:00
Martin von Zweigbergk
b74979cf01 merge: make calculateupdates() return file->action dict
This simplifies largefiles' overridecalculateupdates(), which no
longer has to do the conversion it started doing in 478d610ca1b0
(largefiles: rewrite merge code using dictionary with entry per file,
2014-12-09).

To keep this patch small, we'll leave the name 'actionbyfile' in
overrides.py. It will be renamed in the next patch.
2014-12-11 22:07:41 -08:00
Martin von Zweigbergk
00bed96a72 merge: let _forgetremoved() work on the file->action dict
By moving the conversion from the file->action dict after
_forgetremoved(), we make that method shorter by removing the need for
the confusing 'xactions' variable.
2014-12-11 21:58:49 -08:00
Martin von Zweigbergk
bb82d70631 merge: let _resolvetrivial() work on the file->action dict
By moving the conversion from the file->action dict after
_resolvetrivial(), we greatly simplify and clarify that method.
2014-12-11 21:06:16 -08:00
Martin von Zweigbergk
b0011a70aa merge: let bid merge work on the file->action dict
By moving the conversion from the file->action dict after the bid
merge code, bid merge can be simplified a little.

A few tests are affected by this change. Where we used to iterate over
the actions first in order of the action type ('g', 'r', etc.) [1], we
now iterate in order of filename. This difference affects the order of
debug log statements.

 [1] And then in the non-deterministic order of files in the manifest
     dictionary (the order returned from manifest.diff()).
2014-12-11 20:56:53 -08:00
Martin von Zweigbergk
75a7530afe merge: write manifestmerge() using dictionary with entry per file
In the same vein as 478d610ca1b0 (largefiles: rewrite merge code using
dictionary with entry per file, 2014-12-09), rewrite manifestmerge()
itself as dictionary with the filename as key. This will let us
simplify some of the other code in merge.py and eventually drop the
conversion in the largefiles code.

No difference in speed could be detected (well within the noise level
when run in Mozilla repo).
2014-12-08 13:24:10 -08:00
Pierre-Yves David
e0712f847d repoview: backout 542a704cdc0f
Monkey patching repoview does not really work and making it really work will
be really hard. So we better have it broken without complexity than broken with
extra complexity.
2014-12-17 12:21:07 -08:00
Eric Sumner
7be426bb53 incoming: handle phases the same as pull
Now that bundlerepo can move phases safely, 'hg incoming' can share its phase
handling code with pull to better reflect what would actually show up.
2014-12-18 12:33:17 -08:00
Eric Sumner
94a9b4156e bundlerepo: retract phase boundary
This patch makes bundrepo retract the phase boundary for new commits to 'draft'
status, which is consistent with the behavior of 'hg unbundle'.  The old
behavior was for commits to appear with the same phase as their nearest
ancestor in the base repository.

This affects several classes of operation:

* Inspecting a bundle with the -B flag
* Treating a bundle file as a peer (old: everything public, new: everything draft)
* Incoming command (neither old or new behavior is sensible -- fixed in next patch)
2014-12-18 12:22:43 -08:00
Eric Sumner
c8d74ee479 bundlerepo: implement safe phasecache
This patch makes bundlerepo use a subclass of phasecache that will allow phase
boundaries to be moved around, but will never write them to the underlying
repository.
2014-12-18 11:38:48 -08:00
Eric Sumner
94214b77a6 localrepo.__getitem__: add slicing support
This allows the python slice syntax to be used with revision numbers when
indexing into a repository, such as repo[8:]
2014-12-18 11:30:10 -08:00
Siddharth Agarwal
5bc4775669 ignore: resolve ignore files relative to repo root (issue4473) (BC)
Previously these would be considered to be relative to the current working
directory. That behavior is both undocumented and doesn't really make sense.
There are two reasonable options for how to resolve relative paths:
- relative to the repo root
- relative to the config file

Resolving these files relative to the repo root matches existing behavior with
hooks. An earlier discussion about this is available at
http://mercurial.markmail.org/thread/tvu7yhzsiywgkjzl.

Thanks to Isaac Jurado <diptongo@gmail.com> for the initial patchset that
spurred the discussion.
2014-12-16 14:34:53 -08:00
Chingis Dugarzhapov
3f0e231547 help: suggest '-v -e' to get built-in aliases for extensions (issue4461)
If extension name matches one of command names, suggest user to type
'hg help -v -e <extension>' to get full list of built-in aliases
2014-12-22 03:20:50 +01:00
Matt Mackall
5f5d6c186c branches: deprecate -a 2014-12-22 14:49:05 -06:00
Durham Goode
42321923c9 context: return dirstate parents in workingctx.ancestors()
workingctx.ancestors() was not returning the dirstate parents as part of the
result set. The only place this function is used is for copy detection when
committing a file, and that code already checks the parents manually, so this
change has no affect at the moment.

I found it while playing around with changing how copy detection works.
2014-12-18 09:37:14 -08:00
Mateusz Kwapich
158958d7b9 backout: add --commit option
Mercurial backout command makes a commmit by default only when the backed out
revision is the parent of working directory and doesn't commit in any other
case.

The --commit option changes behaviour of backout to make a commit whenever
possible (i.e. there is no unresolved conflicts). This behaviour seems more
intuitive to many use (especially git users migrating to hg).
2014-12-17 17:26:12 -08:00
Ryan McElroy
88ff1f64d6 share: add option to share bookmarks
This patch adds the -B/--bookmarks option to the share command added by the
share extension. All it does for now is create a marker, 'bookmarks.shared',
that will be used by future code to implement the sharing functionality.
2014-12-13 11:32:46 -08:00
Sean Farley
cc2595a676 templatekw: remove unneeded showtags
Now that we have the machinery of namespaces in-place, we use that instead of
hand-rolling our own template function.

Note, this can only be used for tags because both branches and bookmarks have
special case logic for 'default' and the current bookmark (which is something
outside the namespace api for now).
2014-12-15 09:40:02 -08:00
Sean Farley
96df4dc9b7 namespaces: generate template keyword when registering a namespace
For any namespace, we generate a template keyword. For example, given a
namespace 'babar', we automatically have the ability to use it in a template:

hg log -r . -T '{babars % "King: {babar}\n"}'

Furthermore, we only generate this keyword for a namespace if one doesn't
already exist. This is necessary for 'branches' and 'bookmarks' since both of
those have concepts of 'current' (something outside the namespace api) and also
allows extensions to override default behavior if desired.
2014-10-16 23:19:09 -07:00
Sean Farley
bb554af3db templatekw: add helper method to generate a template keyword for a namespace
This marks our second feature of the namespace api: automatic template keyword.
This patch adds a method that takes in a namespace and uses the node-to-name
map to output the list of names.
2014-12-14 19:15:37 -08:00
Sean Farley
01b442aa2a namespaces: add names method to return list of names for a given node
In the previous patch, we added a node-to-name map property. This patch just
exposes that interface to the api.
2014-12-14 18:54:50 -08:00
Sean Farley
0eb677308a namespaces: add nodemap property
This patch adds a node-to-name map property to the namespace. This is necessary
because we cannot simply invert the name-to-node map because we do not assume
the name-to-node map to be unique (for example, consider named branches: many
nodes have one branch name).

The node-to-name is helpful in log commands where we are already iterating over
a set of nodes and want to display some kind of naming information to the user.
2014-12-15 00:24:23 -08:00
Sean Farley
8649ff43b3 namespaces: add method to get template name of namespace
This patch adds the public api for getting the template name of a namespace so
that the next patch can use it to generate a template keyword automatically.
2014-12-14 19:12:27 -08:00
Sean Farley
840bbb8c70 namespaces: add template name of a namespace
The template name property will be used in upcoming patches to automatically
generate a template keyword. For example, given a namespace called 'babars', we
will automatically generate a template keyword 'babar' such that we can use it
in the following way,

$ hg log -r . -T '{babars % "King: {babar}\n"}'
2014-12-15 00:09:52 -08:00
FUJIWARA Katsunori
14f33673ea memctx: calculate manifest more efficiently
Before this patch, "memctx._manifest" updates all entries in the
(parent) manifest. But this is inefficiency, because almost all files
may be clean in that context.

On the other hand, just updating entries for changed "files" specified
at construction causes unexpected abortion, when there is at least one
newly removed file (see issue4470 for detail).

To calculate manifest more efficiently, this patch replaces
"pman.iteritems()" for the loop by "self._status.modified" to avoid
updating entries for clean or removed files

Examination of removal is also omitted, because removed files aren't
treated in this loop (= "self[f]" returns not None always).
2014-12-19 00:11:56 +09:00
Matt Mackall
0826b8e884 merge with stable 2014-12-18 16:41:59 -06:00
Eric Sumner
9823f2cb56 bundle2: lowercase part types
Since the capitalization no longer carries any meaning (previous diff), this
patch normalizes all of the bundle2 part type strings to lower case.
2014-12-17 15:11:26 -08:00
Eric Sumner
688d023c87 bundle2.bundlepart: make mandatory part flag explicit in API
This makes all bundle2 parts mandatory unless they are expressly made advisory
via the keyword parameter or the bundlepart.mandatory property.
2014-12-17 21:14:19 -08:00
FUJIWARA Katsunori
aeafaa296e memctx: calculate manifest correctly with newly-removed files (issue4470)
Before this patch, "memctx._manifest" tries to get (and use normally)
filectx also for newly-removed files, even though "memctx.filectx()"
returns None for such files.

To calculate manifest correctly even with newly-removed files, this
patch does:

  - replace "man.iteritems()" for the loop by "self._status.modified"
    to avoid accessing itself to newly removed files

    this also reduces loop cost for large manifest.

  - remove files in "self._status.removed" from the manifest

In this patch, amending is confirmed twice to examine both (1) newly
removed files and (2) ones already removed in amended revision.
2014-12-17 15:09:43 +09:00
FUJIWARA Katsunori
bcd06fbc9b memctx: calculate manifest including newly added files correctly
Before this patch, "memctx._manifest" calculates the manifest
according to the 1st parent. This causes the disappearance
of newly added files from the manifest.

For example, if newly added files aren't listed up in manifest of
memctx, they aren't listed up in "added" field of "status" returned by
"ctx.status()", and "{diff()}" (= "patch.diff") in "committemplate"
shows nothing for them.

To calculate manifest including newly added files correctly, this
patch puts newly added files (= ones in "self._status.added") into the
manifest.

Some details of changes for "test-commit-amend.t" in this patch:

  - "touch foo" is replaced by "echo foo > foo", because newly added
    empty file can't be shown in "diff()" output without "diff.git"
    configuration

  - amending is confirmed twice to examine both (1) newly added files
    and (2) ones already added in amended revision
2014-12-17 15:09:43 +09:00
FUJIWARA Katsunori
855293b5eb memctx: calculate exact status being committed from specified files
Before this patch, "memctx._status" is initialized by "(files, [], [],
[], [], [], [])" and this causes "memctx.modified" to include not
only modified files but also added and removed ones incorrectly.

This patch adds "_status" method to calculate exact status being
committed according to "files" specified at construction time.

Exact "_status" is useful to share/reuse logic of committablectx.

This patch is also preparation for issues fixed by subsequent patches.

Some details of changes for tests in this patch:

  - some filename lines are omitted in "test-convert-svn-encoding.t",
    because they are correctly listed up as "removed" files

    those lines are written out in "localrepository.commitctx" for
    "modified" and "added" files by "ui.note".

  - "| fixbundle" filterring in "test-histedit-fold.t" is omitted to
    check lines including "added" correctly

    "fixbundle" discards all lines including "added".
2014-12-17 15:09:38 +09:00
Eric Sumner
165755115f bundle2._processpart: forcing lower-case compare is no longer necessary
Encoding whether or not a part is mandatory in the capitalization of the
parttype is unintuitive and error-prone.  This sequence of patches separates
these concerns in the API to reduce programmer error and pave the way for
a potential change in how this information is transmitted over the wire.

Since the parttype and mandatory bit are separated in bundle2.unbundlepart
(see previous patch), there is no longer a need to remove the mandatory bit
before working with the parttype.
2014-12-12 12:31:41 -08:00
Eric Sumner
a5fc298ca7 bundle2.unbundlepart: decouple mandatory from parttype
Encoding whether or not a part is mandatory in the capitalization of the
parttype is unintuitive and error-prone.  This sequence of patches separates
these concerns in the API to reduce programmer error and pave the way for
a potential change in how this information is transmitted over the wire.

This patch separates the two pieces of information when reading the part header
so that it's unnecessary to know how they were combined during transmission.
2014-12-12 11:26:56 -08:00
Augie Fackler
a029bf7fdb memctx: fix manifest for removed files (issue4470)
filectxfn returns None for removed files, so we have to check for None
before computing the new file content hash for the manifest.

Includes a test that proves this works, by demonstrating that we can
show the diff of an amended commit in the committemplate.
2014-12-15 15:00:54 -05:00
Pierre-Yves David
8985258968 vfs: add a 'split' method
This method has the same behavior as the 'os.path.split' function, but having
it in vfs will allow handling of tricky encoding situations in the future.

In the same patch, we replace the use of 'os.path.split' in the transaction code.
2014-12-15 13:32:34 -08:00
Pierre-Yves David
329429e77c vfs: add a 'reljoin' function for joining relative paths
The vfs.join method only works for absolute paths. We need something
that works for relative paths too when transforming filenames. Since
os.path.join may misbehave in tricky encoding situations, encapsulate
the new join method in our vfs abstraction. The default implementation
remains os.path.join, but this opens the door to other VFSes doing
something more intelligent based on their needs.

In the same go, we replace the usage of 'os.path.join' in transaction code.
2014-12-15 13:27:46 -08:00
Matt Mackall
b2cec9668e subrepo: fix git subrepo ui argument 2014-12-18 12:07:03 -06:00
Matt Harbison
9b17eabeab subrepo: drop the 'ui' parameter to revert()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in revert is to emit status and warning messages, and to
check the verbose flag prior to printing the action to be performed on a file.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.  Unlike other methods where the matcher is passed along and narrowed, a
new matcher is created in each repo, and therefore the bad() method already used
the local repo's ui.
2014-12-13 19:44:55 -05:00
Matt Harbison
616ad7eb66 subrepo: drop the 'ui' parameter to removefiles()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in remove is to emit status and warning messages, and to
check the verbose flag prior to printing files to be removed.  The bad() method
on the matcher still uses the root repo's ui, because narrowing the matcher
doesn't change the ui object.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.
2014-12-13 19:36:50 -05:00
Matt Harbison
800917e351 subrepo: drop the 'ui' parameter to forget()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in forget is to emit status and warning messages, and to
check the verbose flag prior to printing files to be forgotten.  The bad()
method on the matcher still uses the root repo's ui, because narrowing the
matcher doesn't change the ui object.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.
2014-12-13 19:23:30 -05:00
Matt Harbison
418c3ff6d6 subrepo: drop the 'ui' parameter to cat()
This no longer needs to be explicitly passed because the subrepo object tracks
a 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in cat is to emit a status message when a subrepo is
missing.  The bad() method on the matcher still uses the root repo's ui, because
narrowing the matcher doesn't change the ui object.
2014-12-13 14:26:38 -05:00
Matt Harbison
7624013ead subrepo: drop the 'ui' parameter to archive()
The current state of subrepo methods is to pass a 'ui' object to some methods,
which has the effect of overriding the subrepo configuration since it is the
root repo's 'ui' that is passed along as deep as there are subrepos.  Other
subrepo method are *not* passed the root 'ui', and instead delegate to their
repo object's 'ui'.  Even in the former case where the root 'ui' is available,
some methods are inconsistent in their use of both the root 'ui' and the local
repo's 'ui'.  (Consider hg._incoming() uses the root 'ui' for path expansion
and some status messages, but also calls bundlerepo.getremotechanges(), which
eventually calls discovery.findcommonincoming(), which calls
setdiscovery.findcommonheads(), which calls status() on the local repo 'ui'.)

This inconsistency with respect to the configured output level is probably
always hidden, because --verbose, --debug and --quiet, along with their 'ui.xxx'
equivalents in the global and user level hgrc files are propagated from the
parent repo to the subrepo via 'baseui'.  The 'ui.xxx' settings in the parent
repo hgrc file are not propagated, but that seems like an unusual thing to set
on a per repo config file.  Any 'ui.xxx' options changed by --config are also
not propagated, because they are set on repo.ui by dispatch.py, not repo.baseui.

The goal here is to cleanup the subrepo methods by dropping the 'ui' parameter,
which in turn prevents mixing subtly different 'ui' instances on a given subrepo
level.  Some methods use more than just the output level settings in 'ui' (add
for example ends up calling scmutil.checkportabilityalert() with both the root
and local repo's 'ui' at different points).  This series just goes for the low
hanging fruit and switches methods that only use the output level.

If we really care about not letting a subrepo config override the root repo's
output level, we can propagate the verbose, debug and quiet settings to the
subrepo in the same way 'ui.commitsubrepos' is in hgsubrepo.__init__.

Archive only uses the 'ui' object to call its progress() method, and gitsubrepo
calls status().
2014-12-13 14:53:46 -05:00
Matt Harbison
cd1bf9c6ab subrepo: use 'self.ui' instead of 'self._repo.ui'
They are now equivalent, but the former is slightly more readable.
2014-12-13 22:44:22 -05:00
Matt Harbison
1edb20360b subrepo: reset 'self.ui' to the subrepo copy of 'ui' in the hgsubrepo class
Creation of the subrepo's '_repo' object creates a new 'ui' by combining the
parent repo's 'baseui' and reading in the subrepo's hgrc file.  This simply
avoids 'self.ui' and 'self._repo.ui' pointing to different objects, which seems
like a potential source of bugs.

Git and Svn subrepos are unchanged, because they don't have their own ui, and
have always used their parent's for their configuration.
2014-12-13 20:43:01 -05:00
Matt Harbison
f117154a7f subrepo: rename the '_ui' member to 'ui'
The localrepository class has a 'ui' member, so keeping the names the same will
allow for duck typing with subrepo instances when accessing 'ui'.  Changing this
is easier than finding all of the localrepository instance uses and renaming
that to '_ui'.
2014-12-13 15:19:38 -05:00
Matt Harbison
a6ccdfd8a5 subrepo: drop the '_ui' member in the subrepo subclasses
This member has existed in the base class since d4e8aa61370d.
2014-12-13 15:13:07 -05:00
Augie Fackler
dffa530fe5 graphmod: attempt to clarify documentation of groupbranchiter()
Thanks to Pierre-Yves for checking my cleanups here and helping me
understand the algorithm well enough to help document it.
2014-12-09 09:35:04 -05:00
Augie Fackler
05a78b6693 graphmod: rename graph-topological config to graph-group-branches
The latter suggests what the change is slightly better.
2014-12-08 15:20:28 -05:00
Pierre-Yves David
868b50f41b groupbranchiter: allow callers to select the first branch
Instead of just bootstrapping the algorithm with the first revision we
see, allow callers to pass revs that should be displayed first. All
branches are retained until we can display such revision.

Expected usage is to display the current working copy parent first.
2014-09-04 19:28:17 +02:00
Pierre-Yves David
31b9015754 groupbranchiter: support for non-contiguous revsets
The algorithm now works when some revisions are skipped. We now use "first
included ancestors" instead of just "parent" to link changesets with each other.
2014-09-04 19:05:36 +02:00
Pierre-Yves David
401e3ad848 groubranchhiter: indent most of the inner code
We are going to add an additional layer of indentation to support non-contiguous
revset. We do it in a pure code movement changeset to help the readability of
the next changeset.
2014-11-14 20:08:59 +00:00
Pierre-Yves David
849760925f graphlog: add a way to test the 'groupbranchiter' function
We add an experimental config option to use the topological sorting. I first
tried to hook the 'groupbranchiter' function in the 'sort' revset but this was useless
because graphlog enforces revision number sorting :(

As the goal is to advance on the topological iteration logic, I see this
experimental option as a good way to move forward.

We have to use turn the iterator into a list because the graphlog is apparently
not ready for pure iterator input yet.
2014-11-14 17:37:59 +00:00
Pierre-Yves David
7817904ce3 graphmod: add a function for topological iteration
This changeset introduces a function to perform topological (one branch after
the other) iteration over a set of changesets. This first version has a lot of
limitations, but the approach should be flexible enough to allow many
improvements in the future. This changeset aims to set the first stone more
than providing a complete solution.

The algorithm does not need to know the whole set of nodes involved
before emitting revision. This makes it a good candidate for usage in place
like `hg log` or graphical tools that need a fast first result time.
2014-09-04 18:19:32 +02:00
Sean Farley
a106407d01 namespaces: add branches
Note that the exception-catching from the previous branchtip check is moved up
to catch exceptions from the try block surrounding the namespace lookup.
2014-10-17 15:27:12 -07:00
Sean Farley
066d5cf84a namespaces: add tags 2014-10-17 15:27:33 -07:00
Ryan McElroy
28a1fb3f8a namespaces: remove weakref; always pass in repo
It turns out that maintaining a reference of any sort (even weak!) to the repo
when constructed doesn't work because we may at some point pass in a repoview
filtered by something other than what the initial repo was.
2014-12-14 19:11:44 -08:00
Sean Farley
11ae771651 changectx: use names api to simplify and extend node lookup
Previously, changectx had to know about each type of name (bookmark, tag, etc.)
to look up. Now, we use repo.namenodes to simplify (and extend) this.
2014-10-16 23:27:54 -07:00
Sean Farley
d27dee10d8 namespaces: add a method to the first matching node for a given name 2014-10-17 15:28:40 -07:00
Sean Farley
80fbfb49cc namespaces: add bookmarks to the names data structure
This marks the first use of abstracting our different types of named objects
(bookmarks, tags, branches, etc.) and upcoming patches will use this to
simplify logic.
2014-12-14 12:53:50 -08:00
Sean Farley
d9e45fae2c namespaces: add a convenience property for the weakref _repo 2014-12-14 16:22:24 -08:00
Sean Farley
2b5c02f672 namespaces: pass repo to __init__
We store repo as a weakref so that we can prevent a cycle between namespaces
and localrepo.
2014-12-14 15:35:57 -08:00
Sean Farley
94c99a3639 namespaces: add a function to turn single results into lists 2014-12-14 15:04:40 -08:00
Sean Farley
06715bc235 namespaces: add a method to register new namespaces 2014-10-17 11:25:51 -07:00
Sean Farley
6f6baebff4 namespaces: introduce a generic way to map between names and nodes
This patch begins the work to provide a way to register a namespace to handle
'names'. Benefits of this would be,

- improved templating: This would provide {name} which could output any branch,
  bookmark, tag, or any extension registered namespace all without having the
  extension doing any extra work

- improved tab completion: Since this provides a single source of all 'names',
  tab completion would not need to know of each namespace

- changeset lookup: Similar to before, a unified place to get all 'names' will
  allow finding changesets without any extension code having to reimplement
  this

Also, 6c946e059d3b has shown us that for internal code which expects a certain
type of method or behavior, we should provide an easy way for extensions to
check this behavior.
2014-12-14 12:29:28 -08:00
Mads Kiilerich
81928dfd67 statichttprepo: update profile of __call__ in mock vfs object
New code paths could fail because the old statichttprepo profile couldn't
handle the usual parameters.

Instead, reuse a more generic profile also used in readonlyvfs.
2014-12-14 19:27:58 +01:00
Mathias De Maré
2f2a712a16 subrepo: add revert support without backup for git subrepos
Previously, git subrepos did not support reverting.
This change adds basic support for reverting
when '--no-backup' is specified.
A warning is given (and the current state is kept)
when a revert is done without the '--no-backup' flag.
2014-12-14 11:34:51 +01:00
Martin von Zweigbergk
dccbc7f7f3 match: make 'always' and 'exact' functions, not classes
There is no reason for classes 'always' and 'exact' not to be just
functions that return instances the plain 'match' class.
2014-11-01 22:56:49 -07:00
Kyle Lippincott
c159f48f64 debugindex: respect --debug flag to show full nodeids 2014-12-13 13:56:05 -08:00
Siddharth Agarwal
2a54eb4599 localrepo.clone: add a way to override server preferuncompressed
Without this patch, if the server sets preferuncompressed, there's no way for
clients to override that and force a non-streaming clone. With this patch, we
extend the meaning of --pull to also override preferuncompressed and force a
non-streaming clone.
2014-12-12 14:06:36 -08:00
Siddharth Agarwal
20ccc02149 hg.clone: set 'stream' depending on whether --pull was requested or not
In an upcoming patch we'll differentiate between the two in localrepo.
2014-12-12 14:02:56 -08:00
Martin von Zweigbergk
c0d62c5e7b merge: perform case-collision checking on final set of actions
When there are multiple common ancestors, we should check for case
collisions only on the resulting actions after bid merge has run. To
do this, move the code until after bid merge.

Move it past _resolvetrivial() too, since that might update
actions. If the remote changed a file and then reverted the change,
while the local side deleted the file and created a new file with a
name that case-folds like the old file, we should fail before this
patch but not after.

Although the changes to the actions caused by _forgetremoved() should
have no effect on case collisions, move it after that, too, so the
next person reading the code won't have to think about it.

Moving it past these blocks of code takes it to the end of
calculateupdates(), so let's even move it outside of the method, so we
also check collisions in actions produced by extensions overriding the
method.
2014-11-14 05:53:04 -08:00
Mads Kiilerich
b420dd92b1 spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Martin von Zweigbergk
1932d029e7 merge: move cd/dc prompts after largefiles prompts
By moving the cd/dc prompts out of calculateupdates(), we let
largefiles' overridecalculateupdates() so the unresolved values
(i.e. 'cd' or 'dc' rather than 'g', 'r', 'a' and missing). This allows
overridecalculateupdates() to ask the user whether to keep the normal
file or the largefile before the user gets the cd/dc prompt. Whichever
answer the user gives, we make overridecalculateupdates() replace 'cd'
or 'dc' action, saving the user one annoying (and less clear)
question.
2014-12-11 21:21:21 -08:00
Matt Harbison
2698dc9dd4 addremove: automatically process a subrepository's subrepos
Since addremove on the top of a directory tree will recursively handle sub
directories, it should be the same with deep subrepos, once the user has
explicitly asked to process a subrepo.  This really only has an effect when a
path that is a subrepo (or is in a subrepo) is given, since -S causes all
subrepos to be processed already.  An addremove without a path that crosses into
a subrepo, will still not enter any subrepos, per backward compatibility rules.
2014-11-30 22:47:53 -05:00
Matt Harbison
a7a84e8adc addremove: support addremove with explicit paths in subrepos
Git and svn subrepos are currently not supported.
2014-11-09 23:46:25 -05:00
Matt Harbison
3b63e95b8e addremove: add support for the -S flag
Git and svn subrepos are currently not supported.  It doesn't look like git or
svn have these commands natively, so that's an area for a git or svn expert.
2014-11-24 23:51:26 -05:00
Matt Harbison
3c47e94de7 commit: propagate --addremove to subrepos if -S is specified (issue3759)
The recursive addremove operation occurs completely before the first subrepo is
committed.  Only hg subrepos support the addremove operation at the moment- svn
and git subrepos will warn and abort the commit.
2014-11-24 22:27:49 -05:00
Matt Harbison
b38e7353da subrepo: store the ui object in the base class
This will be used in the next patch to print a warning from the base class.  It
seems better than having to explicitly pass it to a new method, since a lot of
existing methods also require it.
2014-11-26 16:13:38 -05:00
Matt Harbison
44b25f2773 commit: abort if --addremove is specified, but fails
This will be required when subrepo support is added, in order to ensure
consistent commits when a subrepo flavor doesn't support addremove.
2014-11-26 15:16:22 -05:00
Matt Harbison
d639c093a5 addremove: warn when addremove fails to operate on a named path
It looks like a bad path is the only mode of failure for addremove.  This
warning is probably useful for the standalone command, but more important for
'commit -A'.  That command doesn't currently abort if the addremove fails, but
it will be made to do so prior to adding subrepo support, since not all subrepos
will support addremove.  We could just abort here, but it looks like addremove
has always silently ignored bad paths, except for the exit code.
2014-11-26 14:27:36 -05:00
Matt Harbison
9e4d7cc2d3 scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns
This will make it easier to support subrepository operations.
2014-11-09 19:57:02 -05:00
Martin von Zweigbergk
d0a73727c6 merge: extract _resolvetrivial() function
We would eventually like to move the resolution of modify/delete and
delete/modify conflicts to the resolve phase. However, we don't want
to move the checks for identical content that were added in
99b29d2bd5ed (merge: before cd/dc prompt, check that changed side
really changed, 2014-12-01). Let's instead move these out to a new
_resolvetrivial() function that processes the actions from
manifestmerge() and replaces any false cd/dc conflicts. The function
will also provide a natural place for us to later add code for
resolving false 'm' conflicts.
2014-12-03 13:50:28 -08:00
Martin von Zweigbergk
b1b9996e9d merge: don't treat 'diverge' and 'renamedelete' like actions
See earlier patch for motivation.
2014-12-09 16:49:55 -08:00
Martin von Zweigbergk
0abe09b21d merge: move dr/rd warning messages out of applyupdates()
As preparation for making 'dr' and 'rd' actions no longer actions,
move the reporting from applyupdates() to its caller update(). This
way we won't have to pass additonal arguments to applyupdates() when
they are no longer actions. Also, the warnings are equally unrelated
to applyupdates() as they are to recordupdates(), as they don't result
in any changes to either the working copy or the dirstate.

See earlier patch for additional motivation.
2014-12-09 14:18:31 -08:00
Martin von Zweigbergk
6ddc19cb79 merge: don't report progress for dr/rd actions
It is easier to reason about certain algorithms in terms of a
file->action mapping than the current action->list-of-files. Bid merge
is already written this way (but with a list of actions per file), and
largefiles' overridecalculateupdates() will also benefit. However,
that requires us to have at most one action per file. That requirement
is currently violated by 'dr' (divergent rename) and 'rd' (rename and
delete) actions, which can exist for the same file as some other
action.

These actions are only used for displaying warnings to the user; they
don't change anything in the working copy or the dirstate. In this
way, they are similar to the 'k' (keep) action. However, they are even
less action-like than 'k' is: 'k' at least describes what to do with
the file ("do nothing"), while 'dr' and 'rd' or only annotations for
files for which there may exist other, "real" actions.

As a first step towards separating these acitons out, stop including
them in the progress output, just like we already exclude the 'k'
action.
2014-12-05 16:13:26 -08:00
Mathias De Maré
60f4f56e86 subrepo: add partial diff support for git subrepos
So far, git subrepositories were silently ignored for diffs.
This patch adds support for git subrepositories,
with the remark that --include and --exclude are not supported.
If --include or --exclude are used, the subrepo is ignored.
2014-12-10 10:32:51 +01:00
Mathias De Maré
ab1dd2eee7 subrepo: extend git version check to 3 digits
This allows more flexibility when a version check is required.
Some git features are introduced in a version where only
the 3rd digit changes.
2014-12-10 08:41:21 +01:00
Mathias De Maré
5ced47caed subrepo: move git version check into a separate method
This allows checking the git version in other methods,
instead of only being able to check if the version is ok or not.
2014-12-10 08:33:03 +01:00
Pierre-Yves David
511030e86e transaction: remove the 'onabort' mechanism
It has no known users. If someones needs similar functionality, a new 'addabort'
method similar to 'addfinalize' should be added.
2014-12-04 13:52:46 -08:00
Pierre-Yves David
61ff2e647d transaction: remove the redundant 'onclose' mechanism
It is superseded by the 'addfinalize' function and all its user have been
migrated.
2014-12-04 13:51:41 -08:00
Pierre-Yves David
2aefc26e19 fncache: document the fact fncache is outdate at hook run time
Using 'addfinalize' to generate 'fncache' means that no pending version of the
file will be generated for the hooks. We would have to use the
'addfilegenerator' method to get such result. However the 'fncachevfs' (who
decide that a write is necessary) have no access to the transaction to register
such file generation at add time. Having the transaction accessible to the 'vfs'
is too much trouble for no benefit. This outdated 'fncache' file at hook time is
not expected to be an issue.

The previous move from 'onclose' to 'addfinalize' had no impact on this timing.
I'm documenting it now because I looked at it.
2014-12-04 16:35:03 -08:00
Pierre-Yves David
4b96dc117e fncache: drop dedicated 'onclose' function in favor of 'tr.addfinalize'
Now that we have a shiny generic mechanism, we can use it.
2014-12-04 13:49:45 -08:00
Matt Mackall
cabaf089d4 merge with stable 2014-12-09 13:32:19 -06:00
Matt Mackall
bbeb8fdbb4 graft: drop cset description from empty commit message
This is either already redundant in the output or too verbose in quiet
mode.
2014-12-09 12:39:23 -06:00
Mads Kiilerich
549a1e034f graft: show hashes in user-facing messages
Graft was in various places just showing the revision number in status
messges. Instead, also show the stable and more useful short hash.
2014-12-09 03:38:23 +01:00
Mads Kiilerich
5877ceecfe graft: give helpful warning for empty grafts
It was just showing a status message with the internal revision number.
Instead, show a warning like

note: graft of 27:3aaa8b6725f0 "28" created no changes to commit

(message tweaked in-flight by mpm)
2014-12-09 03:38:23 +01:00
Mads Kiilerich
d138d31de7 graft: show more useful status information while grafting
Show status messages with first line of commit description and names, like
  grafting 12:2647734878ef "fork" (tip)

This gives more context for the user when resolving conflicts.
2014-12-09 03:38:23 +01:00
Matt Harbison
f2d468fb0a repoview: allow methods on the proxy class to be replaced
It doesn't seem to be a common idiom for repo instances, but the status() method
is replaced in largefiles' purge() override.  Since __setattr__ is implemented
in repoview to setattr() on the unfiltered repo, the replacement method wouldn't
get called unless it was invoked with the unfiltered repo, because the filtered
repo remains unchanged.

Since this doesn't seem to be commonly used, I didn't bother to filter out
methods that perhaps shouldn't be replaced, such as changelog().
2014-12-07 10:52:56 -05:00
Pierre-Yves David
0701311291 obsstore: cache size computation for fm1 node
We have two different types of node type (sha1 and sha256, only sha1 is used
now) and therefor different sizes for them. We now compute the value once
instead of redoing the computation every loop. This has no visible performance
impact.
2014-11-26 23:23:33 -08:00
Pierre-Yves David
0fb7a735b0 obsstore: prefetch struct.calcsize
This function is widely used and worth but be at module level. No specific
performance boost is visible, but this is more consistent.
2014-11-26 23:21:20 -08:00
Pierre-Yves David
ff08bc7b93 obsstore: disable garbage collection during initialization (issue4456)
Python garbage collection is triggered by container creation. So code that
creates a lot of tuples tends to trigger GC a lot. We disable the gc during
obsolescence marker parsing and associated initialization. This provides an
interesting speedup (25%).

Load marker function on my 58758 markers repo:
before: 0.468247 seconds
after:  0.344362 seconds

The benefit is a bit less visible overall. With python2.6 on my system I see:
after:  0.60
before: 0.53

The difference is probably explained by the delaying of a costly GC. (but there
is still a win). Marking involved tuples, lists and dicts as ignorable by the
garbage collector should give us more benefit. But this is another adventure.

Thanks goes to Siddharth Agarwal for the lead.
2014-11-26 16:58:31 -08:00
Pierre-Yves David
dd01dca5ec dirstate: use the 'nogc' decorator
Now that we have a generic way to disable the gc, we use it. however, we have too
use it in a baroque way. See inline comment for details.
2014-12-04 05:43:15 -08:00
Pierre-Yves David
a756e8c469 util: add a 'nogc' decorator to disable the garbage collection
Garbage collection behave pathologically when creating a lot of containers. As
we do that more than once it become sensible to have a decorator for it. See
inline documentation for details.
2014-12-04 05:43:40 -08:00
Martin von Zweigbergk
72e9071545 merge: make 'keep' message more descriptive
Most merge action messages don't describe the action itself, they
describe the reason the action was taken. The only exeption is the 'k'
action, for which the message is just "keep" and instead there is a
code comment folling it that says "remote unchanged". Let's move that
comment into the merge action message.
2014-12-03 14:03:20 -08:00
Matt Harbison
e5bd4011a8 addremove: restore the relative path printing when files are named
This fixes the previously mentioned issue with 7d5fcea60c78, and undoes its
corresponding test change.

The test change demonstrates the correctness when a file is specified (i.e. the
glob is required on Windows because relative paths use '\' and absolute paths
use '/').  It is admittedly very subtle, but there will be a more robust test in
the addremove -S v3 series.
2014-12-04 23:08:27 -05:00
Matt Harbison
25fa81d27a match: introduce uipath() to properly style a file path
Several methods print files relative to the repo root, unless files are named on
the command line, in which case they are printed relative to cwd.  Since the
check relies on the 'pats' parameter, which needs to be replaced by a matcher
when adding subrepo support, this logic gets folded into the matcher to tidy up
the callers.

Prior to 7d5fcea60c78, this style decision was based off of whether or not the
'pats' list was empty.  That change altered the check to test match.anypats()
instead, in order to make paths printed consistent when -I/-X is specified.
That however, changed the style when a file is given to the command.  So now we
test the pattern list to get the old behavior for files, as well as test -I/-X
to get the consistency for patterns.
2014-12-04 23:04:55 -05:00
Matt Mackall
004a613006 merge with stable 2014-12-05 12:10:56 -06:00
Martin von Zweigbergk
7526f0e8b8 merge: don't overwrite conflicting file in locally renamed directory
When the local side has renamed a directory from a/ to b/ and added a
file b/c in it, and the remote side has added a file a/c, we end up
overwriting the local file b/c with the contents of remote file
a/c. Add a check for this case and use the merge ('m') action in this
case instead of the directory rename get ('dg') action.
2014-12-03 11:02:52 -08:00
Martin von Zweigbergk
24dc017945 merge: don't ignore conflicting file in remote renamed directory
When the remote side has renamed a directory from a/ to b/ and added a
file b/c in it, and the local side has added a file a/c, we end up
moving a/c to b/c without considering the remote version of b/c. Add a
check for this case and use the merge ('m') action in this case
instead of the directory rename ('dm') action.
2014-12-03 10:56:07 -08:00
Martin von Zweigbergk
0483da3f64 merge: duplicate 'if f in copied' into each branch 2014-11-23 15:08:50 -08:00
Martin von Zweigbergk
1f5f9eefce merge: branch code into {n1 and n2, n1, n2} top-level cases
There are three high-level cases that are of interest in
manifestmerge(): 1) The file exists on both sides, 2) The file exists
only on the local side, and 3) The file exists only on the remote
side. Let's make this clearer in the code.

The 'if f in copied' case will be broken up into the two applicable
branches in the next patch.
2014-11-23 14:09:10 -08:00
Ryan McElroy
cf43c21202 bookmarks: factor out repository lookup from writing bookmarks file
This will allow the share extension to extend bookmarks functionality to share
bookmarks between repositories.
2014-12-02 20:31:19 -08:00
Mike Edgar
343ab73738 parsers: ensure revlog index node tree is initialized before insertion
Currently, the revlog index C implementation assumes its node tree will be
initialized before a new element is inserted by revnum. For example, revlog.py
executes 'self.index.insert(-1, e)' in _addrevision(). This is only safe
because the node tree has been initialized by a "node in self.nodemap"
check made in addrevision().

(For context, this was discovered while developing an experimental revlog
mixin which stores "elided nodes" via a separate code path from
_addrevision(); that new code path segfaults without this patch.)
2014-12-04 12:02:02 -05:00
Yuya Nishihara
72198a2056 revset: add 'only' to DoS-safe symbols
There is no reason to disable it in hgweb because the same query can be
written without using 'only()'.
2014-12-03 22:56:42 +09:00
Yuya Nishihara
f62323518b revset: move 'only' so that functions are sorted alphabetically 2014-12-03 22:52:54 +09:00
John Coomes
310ded0ea2 add: use lexists so that broken symbolic links are added
This restores the add behavior prior to 83750c0d774f and matches the
behavior of addremove.
2014-12-03 14:33:29 -08:00
Ryan McElroy
468da3b11a bookmarks: factor out bookmark file opening for easier extensibility 2014-11-27 00:24:25 -08:00
Siddharth Agarwal
c24b872cf4 diff: explicitly honor all diffopts
'hg diff' should naturally honor all diffopts.
2014-11-18 22:18:05 -08:00
Siddharth Agarwal
21ee5b69d0 annotate: explicitly only honor whitespace diffopts
The whitespace ones are the only ones the annotate logic cares about anyway, so
there's no visible impact.
2014-11-18 22:16:46 -08:00
Siddharth Agarwal
bf23516938 jsonchangeset: don't honor whitespace and format-changing diffopts
JSON is meant to be parsed by computers, and format changes can break them.
2014-11-18 22:13:05 -08:00
Martin von Zweigbergk
81df1b38d5 merge: display modify/delete conflict prompts in sorted order
The order is determined by manifest.diff(), which currently is not
sorted. There are currently no tests for this, but we will soon add
some that would be flaky without this patch.
2014-11-26 10:25:27 -08:00
Eric Sumner
973f0c3522 bundle2-push: provide transaction to reply unbundler
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

This diff adds an experimental config option "bundle2.pushback" which provides
a transaction to the reply unbundler during a push operation.  This behavior is
opt-in because of potential security issues: the response can contain any part
type that has a handler defined, allowing the server to make arbitrary changes
to the local repository.
2014-11-21 15:50:38 -08:00
Eric Sumner
154e42b303 bundle2.processbundle: let callers request default behavior
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

The default transaction getter for processbundle is a private function that
raises an exception; this diff lets calling code pass None as the transaction
getter to explicitly request this default behavior.

The next diff will check a config option to determine whether to provide a
transaction to the reply bundle processor.  If one shouldn't be provided, the
code needs a way to specify that the default behavior should be used.
2014-11-24 16:04:44 -08:00
Eric Sumner
bd16762201 push: elevate phase transaction to cover entire operation
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

Most pushes already open a transaction in order to sync phase information.
This diff replaces that transaction with one that spans the entire push
operation.

This transaction will be used in a later patch to guard repository changes
made during the reply handler.
2014-11-21 15:06:38 -08:00
Eric Sumner
f1a430fbce pull: extract transaction logic into separate object
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.

Aside from the transaction logic, the pulloperation class is used primarily as
a logic-free data structure for storing state information.  This diff extracts
the transaction logic into its own class that can be shared with push
operations.
2014-11-21 14:32:57 -08:00
Siddharth Agarwal
113c428a6d patch.difffeatureopts: add a feature for format-changing diffopts
Typically, callers that are interested in this set are also interested in the
others. We still add it as a first-class flag for convenience.
2014-11-18 17:22:03 -08:00
Siddharth Agarwal
542813a378 patch.difffeatureopts: add a feature for whitespace diffopts
These aren't exactly format-breaking features -- just ones for which patches
applied to a repo will produce incorrect commits, In any case, some commands
like record and annotate only care about this feature.
2014-11-18 17:09:26 -08:00
Siddharth Agarwal
8c24c56a7e patch.difffeatureopts: add a feature for diff.git
This deserves to be its own feature -- indeed, this is often the only feature
several commands care about.
2014-11-18 17:10:14 -08:00
Siddharth Agarwal
3864c7a9bb patch: rename diffopts to diffallopts
This is meant to be used when all features are explicitly requested. diffopts
is kept as an alias for now -- it will go away soon.
2014-11-18 21:43:38 -08:00
Siddharth Agarwal
56b105c2c6 patch: add a new function to initialize diffopts by feature
Not all callers are interested in all diffopts -- for example, commands like
record (which use diff internally) break when diffopts like noprefix are
enabled. This function will allow us to add flags that callers can use to
enable only the features they're interested in.
2014-11-18 16:53:22 -08:00
Siddharth Agarwal
e42499560a patch.diffopts: use a dict for initialization
In upcoming patches we'll conditionally add to and remove from the dict.
2014-11-18 16:00:54 -08:00
Martin von Zweigbergk
242bbe216d addremove: print relative paths when called with -I/-X (BC)
For "hg addremove 'glob:*.py'", we print any paths added or removed as
relative to the current directory, but when "hg addremove -I
'glob:*.py'" is used, we use the absolute path (relative from the repo
root). It seems like they should be the same, so change it so we use
relative paths in both cases. Continue to use absolute paths when no
patterns are given.
2014-12-01 21:48:32 -08:00
Matt Mackall
289d6b53bc merge with stable 2014-12-01 19:34:11 -06:00
Mathias De Maré
76a33af9ab subrepo: add status support for ignored files in git subrepos
Retrieving the status of a git subrepo did not show ignored
files. Using 'git ls-files', we can retrieve these files
and display the correct status.
2014-11-28 20:16:15 +01:00
Pierre-Yves David
c52ad3f03b manifest: document the extra letter in working copy manifest node
As the second developer to get confused by this in November, I'm adding some
documentation for the next poor soul.
2014-11-26 15:37:01 -08:00
Mads Kiilerich
9389b9fa07 merge: 0 is a valid ancestor different from None
Most internal functions can take either a hash or an integer. Merge did however
not handle 0 as revision 0. Now it does.
2014-11-30 19:26:53 +01:00
Matt Mackall
4abfc94f18 merge with stable 2014-11-27 12:25:01 -06:00
Martin von Zweigbergk
bdbe0fa90a merge: use None as filename for base in 'both created' conflicts
Instead of using a file that we know is not in the common ancestor's
maniffest, let's use None. This is safe as the only place that cares
about the value (applyupdates) already checks if the item exists in
the ancestor.
2014-11-24 16:17:02 -08:00
Martin von Zweigbergk
96d97f796c merge: break out "both renamed a -> b" case
We can further limit the scope of the 2-way merge case by breaking out
the case where the file was not created from scratch on both sides but
rather renamed in the same way (and is therefore a 3-way merge). This
involves copying some code, but it makes it clearer which case the
"Note:" in the code refers to.
2014-11-24 16:42:36 -08:00
Martin von Zweigbergk
dd435d36bb merge: separate out "both created" cases
When 'f' is not in 'ma', 'a' will be 'nullid' and all the if/elif
conditions that check whether some one nodeid is equal to 'a' will
fail, and the else-clause will instead apply. We can make that more
explicit by creating a separate 'm' action for the case where 'a' is
'nullid'. While it does mean copying some code, perhaps it makes it a
little clearer which codepaths are possible, and which cases the
"Note:" in the code refers to. It also lets us make the debug action
messages a little more specific.
2014-11-24 16:16:34 -08:00
Martin von Zweigbergk
b78125e6ba merge: indent to prepare for next patch 2014-11-24 16:11:22 -08:00
Matt Harbison
6b20f5bf8e add: check for the existence of a file matched inexactly before adding it
The change in 02ecc94fb657 created a problem on Windows and OS X:

    --- /usr/local/mercurial/tests/test-issue660.t
    +++ /usr/local/mercurial/tests/test-issue660.t.err
    @@ -47,6 +47,8 @@
     Should succeed - shadow removed:

       $ hg add b
    +  adding b/b
    +  b/b does not exist!

Prior to the failing 'hg add', the file 'b/b' was added and committed, then 'b'
was recursively deleted from the filesystem, file 'b' was created and the delete
was recorded with 'hg rm --after'.  This add is attempting to record the
existence of file 'b'.

A filesystem that is not case sensitive prevents dirstate.walk() from skipping
its step 3, and step 3 has the effect of inserting removed files into the walk
list.  The Linux code doesn't run through step 3, and didn't exhibit the
problem.  It's not clear why a non case sensitive filesystem triggers step 3,
given that the path normalization occurs in step 2.

Prior to 02ecc94fb657, part of the check here was 'f not in repo.dirstate'
instead of 'f not in wctx'.  Files in the 'r' state are filtered out of
context.__contains__() but not dirstate.__contains__().  Therefore the removed
file name wasn't added to the list of files to add when checking against
dirstate.  That change was to allow removed files to be readded, but adding a
file that doesn't exist is nonsensical.  If the user specifies a missing file,
it will be an exact match and will still fail.
2014-11-19 22:27:55 -05:00
Martin von Zweigbergk
663d394fe9 merge: remove obsolete check for untracked files in 'dm' action
Since 4a56fba99974 (merge: don't use unknown(), 2012-02-09), untracked
files are no longer included in the manifest diff, so there is no need
to check exclude them when renaming files for directory moves with the
'dm' action.
2014-11-24 09:50:27 -08:00
Martin von Zweigbergk
52b3a1afd7 merge: remove dead assignment in applyupdates() 2014-11-23 23:10:34 -08:00
Martin von Zweigbergk
3e76cdec1c merge: move calculateupdates() before applyupdated()
calculateupdates() happens before applyupdates(), so move it before in
the code. That also moves it close to manifestmerge(), which is a good
location as calculateupdates() is the only caller of manifestmerge().
2014-11-21 13:06:04 -08:00
Martin von Zweigbergk
527ed28755 merge: remove unused variables from _checkcollision() 2014-11-24 11:28:46 -08:00
Matt Mackall
174e7f793d merge with stable 2014-11-22 17:09:04 -06:00
Martin von Zweigbergk
d69dae068a merge: consistently use single quotes for non-user-facing strings
Because I'm getting tired of searching for both 'O' and "O".
2014-11-20 16:39:32 -08:00
Pierre-Yves David
9fc6abae03 localrepo: add a currenttransaction method
This method returnx the current transaction or None: it will allow a
cache writer to hook in an existing transaction.
2014-11-13 11:12:47 +00:00
Pierre-Yves David
8f926bef9a repoview: extract actual hidden cache writing in its own function
This will allow the generation of this cache within the transaction. Relying on
the transaction will reduce the chance of reader seeing bad cache.
2014-11-13 11:11:17 +00:00
Martin von Zweigbergk
c71ba3444e dirstate: speed up repeated missing directory checks
In a mozilla repo with tip at bb3ff09f52fe,

  hg update tip~1000 && time hg revert -nq -r tip .

displays ~4:20 minutes. With tip~100, it runs in ~11 s. With revision
100000, it did not finish in 12 minutes.

Revert calls dirstate.status() with a matcher that matches each file
in the target revision. The main problem [1] lies in
dirstate._walkexplicit(), which looks for matching deleted directories
by checking whether each path is prefix of any path in the
dirstate. With m files in the dirstate and n files in the target
revision that are not in the dirstate, this is clearly O(m*n). Let's
improve by keeping a lazily initialized set of all the directories in
the dirstate, so the time becomes O(m+n).

After this patch, the 4:20 minutes become 5.5 s, while for a single
missing path, it slows down from 1.092 s to 1.150 s (best of 4). The
>12 min case becomes 5.8 s.

 [1] A narrower optimization would be to make revert take the fast
     path for '.' and '--all'.
2014-11-19 23:15:07 -08:00
Martin von Zweigbergk
2916dab85b revert: access status fields by name rather than index
For better readability.
2014-11-19 17:07:27 -08:00
FUJIWARA Katsunori
4a1c867054 subrepo: remove "_getstorehashcachepath" referred by no other code paths 2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
ba433385a7 subrepo: replace direct file APIs around "writelines" by "vfs.writelines"
This patch also replaces "self._getstorehashcachepath" (building
absolute path up) by "self._getstorehashcachename" (building relative
path up), because "vfs.writelines" requires relative path.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
86bc73ffa9 vfs: add "writelines"
This patch allows "writelines" to take "mode" and "notindexed"
arguments, because subsequent patch for subrepo requires both.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
f60bafa1b3 vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode
This patch uses "False" as default value of "notindexed" argument,
even though "vfs.makedir()" uses "True" for it, because "os.mkdir()"
doesn't set "_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED" attribute to newly
created directories.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
59f23cabee subrepo: replace direct file APIs around "readlines" by "vfs.tryreadlines"
This patch also replaces "self._getstorehashcachepath" (building
absolute path up) by "self._getstorehashcachename" (building relative
path up), because "vfs.tryreadlines" requires relative path.

This patch makes "_readstorehashcache()" return "[]" (returned by
"vfs.tryreadlines()"), when cache file doesn't exist, even though
"_readstorehashcache()" returned '' (empty string) in such case before
this patch.

"_readstorehashcache()" is invoked only by the code path below in
"_storeclean()":

            for filehash in self._readstorehashcache(path):
                if filehash != itercache.next():
                    clean = False
                    break

In this case, "[]" and '' don't differ from each other, because both
of them cause avoiding iteration of "for loop".
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
b1ff97d24c vfs: add "readlines" and "tryreadlines"
This patch allows "readlines" and "tryreadlines" to take "mode"
argument, because "subrepo" requires to read files not in "rb"
(binary, default for vfs) but in "r" (text) mode in subsequent patch.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
38f496a6bb subrepo: add "_cachestorehashvfs" to handle cache store hash files via vfs
This "vfs" object will be used by subsequent patches to handle cache
store hash files without direct file APIs.

This patch decorates "_cachestorehashvfs" with "@propertycache" to
delay vfs creation, because it is used only for cooperation with other
repositories.

In this patch, "/" is used as the path separator, even though
"self._repo.join" uses platform specific path separator (e.g. "\\" on
Windows). But it is reasonable enough, because "store" and other
management file handling already include such implementation, and they
work well.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
82551da514 subrepo: remove "_calcfilehash" referred by no other code paths 2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
d95af73d10 subrepo: replace "_calcfilehash" invocation by "vfs.tryread"
"_calcfilehash" can be completely replaced by simple "vfs.tryread"
invocation.

    def _calcfilehash(filename):
        data = ''
        if os.path.exists(filename):
            fd = open(filename, 'rb')
            data = fd.read()
            fd.close()
        return util.sha1(data).hexdigest()

Building absolute path "absname" up by "self._repo.join" for files in
"filelist" is avoided, because "vfs.tryread" does so internally.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
617a0e35a6 subrepo: replace "os.path.exists" by "exists" via wvfs of the parent
Existance of specified "path" should be examined by "exists" via wvfs
of the parent repository, because the working directory of the parent
repository may be in UTF-8 mode. Wide API should be used via wvfs in
such case.

In this patch, "/" is used as the path separator, even though "path"
uses platform specific path separator (e.g. "\\" on Windows). But it
is reasonable enough, because "store" and other management file
handling already include such implementation, and they work well.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
42cf1cdb87 subrepo: avoid redundant "util.makedirs" invocation
"util.makedirs" for the (sub-)repository root of "hgsubrepo" is also
executed in the constructor of "localrepository", if "create" is True
and ".hg" of it doesn't exist.

This patch avoids redundant "util.makedirs" invocation in the
constructor of "hgsubrepo".
2014-11-19 18:35:14 +09:00
Martin von Zweigbergk
1d09a87f4e merge: remove confusing comment about --force
manifestmerge() has a piece of code that's roughly:

  if not force and different:
      abort
  else:
      # if different: old untracked f may be overwritten and lost
      ...

The comment only talks about what happens when 'different' is true,
and in combination with the if-block above, that must mean that it is
only about what happens when 'force and different'. It seems quite
fine that files are overwritten when 'force' is true, so let's remove
the comment. As it stands, it can easily be interpreted as a TODO
(which is how I interpreted it at first).
2014-11-19 08:50:08 -08:00
Pierre-Yves David
160c394fe7 phases: read pending data when appropriate
If we are called by a hook and pending data exists, read those.
2014-10-17 22:23:06 -07:00
Pierre-Yves David
4012eb31b0 bookmark: read pending data when appropriate
If we are called by a hook and pending data exists, read it.
2014-09-28 21:27:48 -07:00
Pierre-Yves David
3ace7493d7 transaction: write pending generated files
Such file are generated with a .pending prefix. It is up to the reader to
implement the necessary logic for reading pending files.

We add a test to ensure pending files are properly cleaned-up in both success and
error cases.
2014-10-17 22:19:05 -07:00
Pierre-Yves David
58e32f1eeb transaction: have _generatefile return a boolean
The function returns True if any files were generated. This will be
used to know if any pending files have been written.
2014-10-17 21:57:32 -07:00
Pierre-Yves David
81a1fe4d5b transaction: allow generating files with a suffix
This will allow us to generate temporary pending files. Files
generated with a suffix are assumed temporary and will be cleaned up
at the end of the transaction.
2014-09-29 01:29:08 -07:00
Matt Mackall
3f845e51cb transaction: fix some docstring grammar 2014-11-19 09:52:05 -06:00
Pierre-Yves David
ecac877d99 transaction: accept a 'location' argument for registertmp
This will allow generation of temporary files outside of store. This will be
useful for bookmarks.
2014-11-12 14:57:41 +00:00
Martin von Zweigbergk
f29370d747 update: remove unnecessary check for unknown files with --check
As far as I and the test suite can tell, the checks in manifestmerge()
already report the errors (whether or not --check is given), so we
don't need to call merge.checkunknown(). Since this is the last call
to the method, also remove the method.
2014-11-18 16:14:32 -08:00
Siddharth Agarwal
fba9f14547 setdiscovery: avoid a full changelog graph traversal
We were definitely being suboptimal here: we were constructing two full sets,
one with the full set of common nodes (i.e. a graph traversal) and one with all
nodes. Then we subtract one set from the other. This whole process is
O(commits) and causes discovery to be significantly slower than it should be.

Instead, keep track of common incrementally and keep undecided as small as
possible.

This makes discovery massively faster on large repos: on one such repo, 'hg
debugdiscovery' over SSH with one commit missing on the client and five on the
server went from 4.5 seconds to 1.5. (An 'hg debugdiscovery' with no commits
missing on the client, i.e. connection startup time, was 1.2 seconds.)
2014-11-16 00:40:29 -08:00
Siddharth Agarwal
1a87e8b8c3 ancestor: add a way to remove ancestors of bases from a given set
This and missingancestors can share state, which will turn out to be perfect
for set discovery.
2014-11-14 19:40:30 -08:00
Siddharth Agarwal
0d3efeefd2 ancestor: add a way to add to bases of a missing ancestor object
This will be useful for setdiscovery, since with that we incrementally add to
our knowledge of common nodes.
2014-11-14 17:21:00 -08:00
Siddharth Agarwal
8c7869477d ancestor: add a way to test whether a missing ancestor object has bases
This is pretty trivial so there's no unit test coverage for it.

This will be used by setdiscovery.
2014-11-16 00:39:29 -08:00
Siddharth Agarwal
078961d745 ancestor: remove now-unused missingancestors function
Callers should use revlog.incrementalmissingrevs instead.
2014-11-14 16:53:40 -08:00
Siddharth Agarwal
2d669c474b revlog: switch findmissing* methods to incrementalmissingrevs
This will allow us to remove ancestor.missingancestors in an upcoming patch.
2014-11-14 16:52:40 -08:00
Siddharth Agarwal
5692148f49 revlog: add a method to get missing revs incrementally
This will turn out to be useful for discovery.
2014-11-16 00:39:48 -08:00
Siddharth Agarwal
b865bfbae7 ancestor.missingancestors: turn into a state-keeping class
This allows multiple efficient missing ancestor queries against the same set of
bases. In upcoming patches we'll also define ways to grow the set of bases.

The fact that the test output hasn't changed establishes this patch's
correctness.
2014-11-14 23:44:38 -08:00
Siddharth Agarwal
1ff25a7ef5 ancestor.missingancestors: calculate start point after filtering revsvisit
Any revs that are filtered out are also in basesvisit, which means they
wouldn't be returned in the missing list anyway. There's no need to explore
such revs or their ancestors.

The 'if not revsvisit' check moves down because we can't call max() on an empty
set.
2014-11-14 13:47:25 -08:00
Siddharth Agarwal
6cb962f9f8 ancestor.missingancestors: don't discard from basesvisit
We only actually care about whether revsvisit is empty, so we can let
basesvisit grow to arbitrary size.

It turns out that this actually helps performance. For a large repo with
hundreds of thousands of commits, hg perfrevset 'only(0, tip)' (basically the
worst case, involving a full DAG traversal) goes from 1.63 seconds to 1.50. hg
perfrevset 'only(tip, 0)' remains unchanged at 1.98 seconds.
2014-11-14 11:33:52 -08:00
Siddharth Agarwal
7103eb28ea ancestor.lazyancestors: take parentrevs function rather than changelog
Principle of least privilege, and it also brings this in line with
missingancestors.
2014-11-14 14:36:25 -08:00
Matt Harbison
8766c8079f remove: avoid a bogus warning about no tracked files when removing '.'
Previously, any files relative to the root of the repo that match the -I
patterns would be deleted, but the command exited with 1 after printing a
warning:

   $ hg remove -S -I 're:.*.txt' .
   removing sub1/sub2/folder/test.txt
   removing sub1/sub2/test.txt
   not removing .: no tracked files
2014-11-16 00:24:23 -05:00
Matt Harbison
c0a7d4f5bc remove: support remove with explicit paths in subrepos 2014-11-12 23:15:20 -05:00
Matt Harbison
17e7835237 remove: recurse into subrepositories with --subrepos/-S flag
Like 'forget', git and svn subrepos are currently not supported.  Unfortunately
the name 'remove' is already used in the subrepo classes, so we break the
convention of naming the subrepo function after the command.
2014-11-15 21:36:19 -05:00
Yuya Nishihara
1c7ce2bd17 cmdserver: protect pipe server streams against corruption caused by direct io
Because pipe-mode server uses stdio as IPC channel, other modules should not
touch stdio directly and use ui instead.  However, this strategy is brittle
because several Python functions read and write stdio implicitly.

    print 'hello'  # should use ui.write()
    # => ch = 'h', size = 1701604463 'ello', data = '\n'

This patch adds protection for such mistakes.  Both stdio files and low-level
file descriptors are redirected to /dev/null while command server uses them.
2014-11-15 13:50:43 +09:00
Yuya Nishihara
2808848bc1 cmdserver: postpone creation of pipe server until run()
This makes it easy to swap file descriptors while running command server.
2014-11-15 13:04:41 +09:00
Yuya Nishihara
0c88d9a994 cmdserver: use given streams as pipe channels like other commands
Because commandserver itself is an hg subcommand, it shouldn't use stdio
directly in principle.
2014-11-15 12:43:35 +09:00
Siddharth Agarwal
b3be1bdf41 revset.only: use cl.findmissingrevs
ancestor.missingancestors is really an implementation detail.
2014-11-14 16:38:58 -08:00
Martin von Zweigbergk
edf3f3461a manifestmerge: use already existing fl2 synonym for m2.flags(f)
Probably not a noticeable performance gain, but shortens the code
slightly.
2014-11-14 09:33:28 -08:00
Martin von Zweigbergk
6584c8e690 merge: drop underscore prefix from _checkunknown()
The method has been called from commands.py since 8d9ca2ac2fe8
(update: just merge unknown file collisions, 2012-02-09), so drop the
underscore prefix that suggests that it's private.
2014-11-13 23:12:15 -08:00
Pierre-Yves David
46df0be40b transaction: drop special handling for phases and bookmarks generation
We are still doing double backups, but now that we have proper
location handling this is less of an issue. Dropping this simplifies
the code before we add some pending-related logic.

This also ensures we actually test the new 'location' mechanism.
2014-11-12 14:47:48 +00:00
Pierre-Yves David
b9594d1c53 transaction: use 'location' instead of 'vfs' objects for file generation
The argument is now a location name. The location must be present in the
'vfsmap' provided to the transaction at creation time.
2014-10-17 20:53:42 -07:00
Pierre-Yves David
c1cac6ba41 transaction: use 'location' instead of 'vfs' in the addbackup method
This unlock the backup of file outside of store (eg: bookmarks).
2014-11-05 01:59:32 +00:00
Pierre-Yves David
414fa72b29 addbackup: handle file in subdirectory
The current naming scheme ('journal.backups.<file>') resulted is bad directory
name when 'file' was in a subdirectory. We now extract the directory name and
create the backupfile within it.

We plan to use file in a subdirectory for cachefile.
2014-11-14 00:14:23 +00:00
Pierre-Yves David
70e9add6df addbackup: use the vfs for the backup destination too
The backup file location was always computed using the opener, bypassing the
'location' setting. (And making the feature broken.)
2014-11-14 14:54:55 +00:00
Pierre-Yves David
cec71977a9 transaction: set backupentries version to proper value
Now that all mechanisms are in place, we can advertise it with a
proper new version.
2014-11-13 11:17:36 +00:00
Pierre-Yves David
4c03465397 transaction: support cache file in backupentries
We do not want to abort if anything wrong happen while handling a cache file.
Cache file have way to be invalidated and if old/bad version stay no
misbehavior will happen. Proper value will eventually be computed and the wrong
will be righten.

This changeset use the transaction reporter (usually writing on stderr) to write
details about failed cache handling. This will only apply to write operation
using a transaction. The usual update during read only operation will stay a
debug message.

I was on the way to bring these message back to debug level when I realised it
could be a feature. People with write access to the repository are likely to
have the power to fix error related to cache (and it is valuable to fix them).
So let the things as is for now.
2014-11-13 11:17:09 +00:00
Pierre-Yves David
382c5bbb8d transaction: use the location value when doing backup
We finally use the 'location' value coupled with the 'vfsmap' to restore backup
for the right file.
2014-10-17 21:04:35 -07:00
Pierre-Yves David
53a1a60278 transaction: pass a vfs map to the transaction
The goal is to allow access to file outside ofthe store directory from the
transaction. The obvious target are the `bookmarks` file. But we can envision
usage for cache too.

We keep passing a main opener explicitly because a lot of code rely on this
default opener. The main opener (operating on store) is using an empty key ''.
2014-10-17 20:49:39 -07:00
Pierre-Yves David
d772e961ee transaction: change the on disk format for backupentries
We need to store new data to improve the current transaction logic:

- location: We want to generate and backup file outside of the 'store' (eg:
  bookmarks, or various cache files). This requires knowing and preserving where
  each file is located. The value of this new field is a string. It will be used
  as a key for a vfs mapping.

- cache: We would like to handle cache file in the transaction code. This
  Will help to have cache consistent with the repository state and avoid
  performance issue on big repository like Mozilla. However, failure to handle
  cache file should not result in a transaction failure. We add a new field that
  carry this information. The value is boolean, A True value mean any error
  while handling this file can be ignored.

Those two mechanisms are not implemented yet, but they are now persisted in the
on disk file. Support for new mechanisms is coming in later changeset.

We update the file format now and will introduce the new features in later
changeset. The format version is set to 0 until we actually support the new feature.
This will prevent misunderstanding between incomplete and final client.

Support for reading both version 1 and (future) version 2 could be achieved
(using default value when reading version 1) but has not been seen as necessary
for now.
2014-11-05 01:52:46 +00:00
Siddharth Agarwal
8354d9169f revlog: cache chain info after calculating it for a rev (issue4452)
This dumb cache works surprisingly well: on a repository with typical delta
chains ~50k in length, unbundling a linear series of 5000 revisions (changelogs
and manifests only) went from 60 seconds to 3.
2014-11-13 21:36:38 -08:00
Martin von Zweigbergk
455810026c manifest: add matches() method
Move the code in context._manifestmatches() into a new
manifest.matches(). It's a natural place for the code to live and it
allows other callers to easily use it. It should also make it easier
to optimize the new method in alternative implementations of the
manifest (same reasoning as with manifest.diff()).
2014-10-22 21:38:30 -07:00
Martin von Zweigbergk
cfd2a961bd context.status: pass status tuple into _buildstatus
By passing a status tuple (instead of the current list), we can access
the status fields by name and make it a little more readable.
2014-11-12 22:20:36 -08:00
Martin von Zweigbergk
f2e6b819eb context.status: avoid de- and reconstructing status tuple
We can just modify the status tuple we got from dirstate.status()
instead of deconstructing it and constructing a new instance, thereby
simplifying the code a little.
2014-11-12 22:07:31 -08:00
Martin von Zweigbergk
7de43e79f4 context.status: make _dirstatestatus() return an status tuple
Letting _dirstatestatus() return an scmutil.status instance also means
that _buildstatus() will always return such an instance, so we can
remove the conversion from the call sites.
2014-11-12 16:51:11 -08:00
Martin von Zweigbergk
38e47fc778 context.status: wipe deleted/unknown/ignored fields when reversed
It makes no sense to request reverse status (i.e. changes from the
working copy to its parent) and then look at the deleted, unknown or
ignored fields. If you do, you would get the result from the forward
status (changes from parent to the working copy). Instead of giving a
nonsensical answer to a nonsensical question, it seems a little saner
to return empty lists. It might be best if we could prevent the caller
accessing these lists, but it's doubtful it's worth the trouble.
2014-11-12 21:19:07 -08:00
Siddharth Agarwal
48ef0179c1 patch.trydiff: add support for noprefix 2014-11-12 23:50:21 -08:00
Siddharth Agarwal
ce2b0fd888 mdiff.unidiff: add support for noprefix 2014-11-12 23:29:14 -08:00
Siddharth Agarwal
4d6e85ce0c diff: add a --noprefix option
See previous patch descriptions for the motivation.

The tests reflect the current state of the world -- as we add support we'll see
changes in the test output.
2014-11-13 00:13:48 -08:00
Siddharth Agarwal
37a8021dad patch.diffopts: add support for noprefix
In an upcoming patch we'll enable support as an option to 'hg diff' as well.

The tests reflect the current state of the world -- as we add support we'll see
changes in the test output.
2014-11-13 00:08:44 -08:00
Siddharth Agarwal
ccd6611ec9 patch.diffopts: allow a setting to be forced in plain mode
Upcoming patches will add an option that will almost certainly break diff
output parsers when enabled. Add support for forcing an option to something in
plain mode, as a fallback. Options passed in via the CLI are not affected,
though -- it is assumed that any script passing the option in explicitly knows
what it is doing.
2014-11-12 23:47:25 -08:00
Siddharth Agarwal
dabae3afed patch.diffopts: break get function into if statements
We're going to add another condition here, and with the current structure that
becomes just too confusing.
2014-11-12 23:44:17 -08:00
Siddharth Agarwal
535dc77081 mdiff.diffopts: add a new noprefix option
By popular demand, we introduce an option to disable the 'a/' and 'b/'
prefixes in diff output. This makes copying and pasting filenames from diff
output easier.

This option will be implemented and documented in upcoming patches. To ensure
that existing scripts that parse output don't break, we will ensure that this
prefix is disabled in plain mode. A straight 'hg export | hg import' without
HGPLAIN=1 will still be broken though, but there's little that can be done
about that.
2014-11-12 23:25:32 -08:00
Siddharth Agarwal
3deaceac88 mdiff.diffopts: add doc comment for nobinary 2014-11-12 23:19:44 -08:00
Pierre-Yves David
500808d844 changelog: register changelog.i.a as a temporary file
The file is registered to make sure the transaction is cleaned up in all cases.
2014-11-08 17:08:09 +00:00
Pierre-Yves David
84cb2b6041 transaction: allow registering a temporary transaction file
During the transaction, files may be created to store or expose data
involved in the transaction (eg: changelog index data are written in
a 'changelog.i.a' for hooks). But we do not have an official way to
record such file creation and make sure they are cleaned up. The lack
of clean-up is currently okay because there is a single file involved
and a single producer/consumer.

However, as we want to expose more data (bookmarks, phases, obsmarker)
we need something more solid. The 'backupentries' mechanism could
handle that. Temporary files can be encoded as a backup of nothing
'('', <temporarypath>)'. We "need" to attach it to the same mechanism
as we use to be able to use temporary transaction files outside of
.'store/' and 'backupentries' is expected to gain such feature.

This changeset makes it clear that we should rename 'backupentries' to
something more generic.
2014-11-05 09:27:08 +00:00
Pierre-Yves David
82498ec61b transaction: always generate file on close
The conditionnal was buggy and file were only generated if "onclose" was
defined. By luck, "onclose" was always defined.
2014-11-13 10:22:47 +00:00
Matt Harbison
7fc45849db remove: move most of the implementation into cmdutils.remove()
This will allow access to the reusable parts from subrepos, similar to add(),
forget(), etc.
2014-11-09 12:31:34 -05:00
Siddharth Agarwal
1acd4cfca4 revlog: increase I/O bound to 4x the amount of data consumed
This doesn't affect normal clones since they'd be bound by the CPU bound below
anyway -- it does, however, improve generaldelta clones significantly.

This also results in better deltaing for generaldelta clones -- in generaldelta
clones, we calculate deltas with respect to the closest base if it has a higher
revision number than either parent. If the base is on a significantly different
branch, this can result in pointlessly massive deltas. This reduces the number
of bases and hence the number of bad deltas.

Empirically, for a highly branchy repository, this resulted in an improvement
of around 15% to manifest size.
2014-11-11 20:08:19 -08:00
Siddharth Agarwal
fe51051ee5 revlog: bound based on the length of the compressed deltas
This is only relevant for generaldelta clones.
2014-11-11 20:01:19 -08:00
Siddharth Agarwal
27976ad2dc revlog: compute length of compressed deltas along with chain length
In upcoming patches to the revlog, we're going to split up the notions of
bounding I/O and bounding CPU.
2014-11-11 19:54:36 -08:00
Siddharth Agarwal
6e115e5383 revlog: store fulltext when compressed delta is bigger than it
This is a very silly case and not particularly likely to happen in the wild,
but it turns out we can hit it in a couple of places. As we tune the storage
parameters we're likely to hit more such cases.

The affected test cases all have smaller revlogs now.
2014-11-11 21:41:12 -08:00
Siddharth Agarwal
e5d387f47e revlog: make a predicate clearer with parens 2014-11-11 21:39:56 -08:00
Pierre-Yves David
a818f5fbca transaction: extract backupentry registration in a dedicated function
We are about to use the 'backupentry' mechanism to allow cleaning up
transaction-related temporary files (such as 'changelog.i.a'). We start
by extracting the entry registration into its own method for easy reuse.

At that point, I would like to rename the backup-file related variable to
something generic but I'm a bit short of ideas.
2014-11-05 13:06:24 +00:00
Pierre-Yves David
8259127ccb transaction: pass the transaction to 'postclose' callback
This mirrors the API for 'pending' and 'finalize' callbacks. I do not have
immediate usage planned for it, but I'm sure some callback will be happy to
access transaction related data.
2014-11-08 16:35:15 +00:00
Pierre-Yves David
29f854f61a transaction: pass the transaction to 'finalize' callback
The callback will likely need to perform some operation related to the
transaction (eg: registering file update). So we better pass the current
transaction as the callback argument. Otherwise callback that needs it has to
rely on horrible weak reference trick.

This allow already allow us to slay a wild weak reference usage.
2014-11-08 16:31:38 +00:00
Pierre-Yves David
92bf4dcbdc transaction: pass the transaction to 'pending' callback
The callback will likely need to perform some operation related to the
transaction (eg: backing files up). So we better pass the current transaction as
the callback argument. Otherwise callback that needs it has to rely on horrible
weak reference trick.

The first foreseen user of this is changelog._writepending. We would like it to
register the temporary file it create for cleanup purpose.
2014-11-08 16:27:50 +00:00
Pierre-Yves David
6ab03ec965 transaction: gather backupjournal logic together in the __init__
The initialisation of file-backup related variable were a bit scattered, we
gather them together.
2014-11-05 10:22:17 +00:00
Pierre-Yves David
b91f1df8cd transaction: handle missing file in backupentries (instead of using entries)
The case where a backup of a missing file was requested was previously
handled by the 'entries' list. As the 'backupentries' is about to gain
ability to backup files outside of '.hg/store', we want it to be able
to handle the missing file too.

Reminder: using 'addbackup' on a missing file means that such file needs to be
deleted if we rollback the transaction.
2014-11-05 01:38:48 +00:00
Yuya Nishihara
b2ed607f5e util.system: remove unused handling of onerr=ui
In our code, onerr is None or util.Abort.  It smells bad to overload ui and
exception class.
2014-11-08 13:14:19 +09:00
Yuya Nishihara
ceda6fbba9 util.system: use ui.system() in place of optional ui.fout parameter 2014-11-08 13:06:22 +09:00
Yuya Nishihara
c3aa617f2e ui: introduce util.system() wrapper to make sure ui.fout is used
This change is intended to avoid future problem of data corruption under
command server.  out=ui.fout is mandatory as long as command server uses
stdout as IPC channel.
2014-11-08 12:57:42 +09:00
Yuya Nishihara
990e90eeb6 hook: remove redundant code to redirect http hook output to client stream
out=ui and out=ui.fout should be the same here.  ui.fout was introduced at
7d217b512ae2, which was not available when out=ui was added at 5716839ccf7d.
2014-11-12 22:21:51 +09:00
Sean Farley
93b998c77a sortdict: add insert method
Future patches will allow extensions to choose which order a namespace should
output in the log, so we add a way for sortdict to insert to a specific
location.
2014-10-15 12:39:19 -07:00
Sean Farley
8ea5f6192f sortdict: add iteritems method
Future patches will start using sortdict for log operations where order is
important. Adding iteritems removes the headache of having to remember to use
items() if the object is a sortdict.
2014-11-09 13:15:28 -08:00
Martin von Zweigbergk
98fbfc44f9 addremove: add back forgotten files (BC)
After running "hg forget README && hg addremove", README will still be
reported as removed, while "hg forget README && hg add README" adds it
back so it gets reported as clean. It seems like they should behave
the same. Furthermore, it seems like no files should remain untracked
after 'hg addremove && hg commit' (or 'hg commit -A'). For these
reasons, change the behavior of addremove so it does add forgotten
files back.

The problem is with scmutil._interestingfiles(), which reports the
file as removed, so scmutil.addremove() does not add it. Fix by
teaching _interestingfiles() to report forgotten files separately from
removed files and make addremove() add forgotten files back. However,
do not treat forgotten files as sources for rename detection. Note
that since removed and forgotten files are treated the same before
this change, forgotten files were considered sources for rename
detection.

Also update the other caller, marktouched(), in the same way as
addremove().
2014-11-08 23:13:39 -08:00
Martin von Zweigbergk
42c14b3ed1 add: add back forgotten files even when not matching exactly (BC)
I accidentally did 'hg forget .' and tried to undo the operation with
'hg add .'. I expected the files to be reported as either modified or
clean, but they were still reported as removed. It turns out that
forgotten files are only added back if they are listed explicitly, as
shown by the following two invocations. This makes it hard to recover
from the mistake of forgetting a lot of files.

  $ hg forget README && hg add README && hg status -A README
  C README
  $ hg forget README && hg add . && hg status -A README
  R README

The problem lies in cmdutil.add(). That method checks that the file
isn't already tracked before adding it, but it does so by checking the
dirstate, which does have an entry for forgotten files (state 'r'). We
should instead be checking whether the file exists in the
workingctx. The workingctx is also what we later call add() on, and
that method takes care of transforming the add() into a normallookup()
on the dirstate.

Since we're changing repo.dirstate into wctx, let's also change
repo.walk into wctx.walk for consistency (repo.walk calls wctx.walk,
so we're simply inlining the call).
2014-11-10 14:51:18 -08:00
Martin von Zweigbergk
abccb5c328 context.status: explain "caching reasons" more fully
Where we "load earliest manifest first for caching reasons", elaborate
on what "caching reasons" refers to. Text provided by Matt in
http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/73235/focus=73578.
2014-11-11 10:16:54 -08:00
Augie Fackler
10400a5ca1 localrepo: rename revlog.maxchainlen to format.maxchainlen
This is more consistent with other option names, as spotted by Pierre-Yves. Thanks!
2014-11-11 10:35:06 -05:00
Mateusz Kwapich
3433abb6a8 revlog: add config variable for limiting delta-chain length
The current heuristic for deciding between storing delta and full texts
is based on ratio of (sizeofdeltas)/(sizeoffulltext).

In some cases (for example a manifest for ahuge repo) this approach
can result in extremely long delta chains (~30,000) which are very slow to
read. (In the case of a manifest ~500ms are added to every hg command because of that).

This commit introduces "revlog.maxchainlength" configuration variable that will
limit delta chain length.
2014-11-06 14:20:05 -08:00
Mateusz Kwapich
1a554418d5 debugrevlog: fix computing chain length in debugrevlog -d
The chain length was computed correctly only when generaldelta
feature was enabled. Now it's fixed.

When generaldelta is disabled the base revision in revlog index is not
the revision we have delta against - it's always previous revision.

Instead of incorrect chainbaseandlen in command.py we are now using two
single-responsibility functions in revlog.py:
 - chainbase(rev)
 - chainlen(rev)
Only chainlen(rev) was missing so it was written to mimic the way the
chain of deltas is actually found during file reconstruction.
2014-11-06 14:08:25 -08:00
Pierre-Yves David
1d1e3a5b9c transaction: factorise append-only file registration
The addition is done in two different places but differs slightly. We factorise
this addition to ensure it is consistent in all places.
2014-11-05 10:13:01 +00:00
Pierre-Yves David
b9cd014175 transaction: document tr.add 2014-11-05 13:00:48 +00:00
Pierre-Yves David
9a1f491fee transaction: drop backupentries logic from startgroup and endgroup
The `startgroup` and `endgroup` methods are used in a very specific
context to wrap a very specific operation (revlog truncation). It does
not make sense to perform any other operations during such a "group"
(eg:file backup). There is currently no user of backupfile during a
"group" so we drop the group-specific code and restrict authorized
operations during "group".
2014-11-05 10:05:38 +00:00
Pierre-Yves David
483eb136e7 transaction: document startgroup and endgroup
These enigmatic methods are only used in repair. We document them to clarify
there purpose and user.
2014-11-05 10:00:15 +00:00
Pierre-Yves David
36a4f98617 transaction: mark backup-related attributes private
As the transaction is gaining more functions and attributes, it is important to clarify
what is part of the public API.
2014-11-05 09:31:57 +00:00
Pierre-Yves David
63c82fbc8a transaction: document the contents of tr.backupentries
Now that all items are known we can document it.
2014-11-05 01:30:29 +00:00
Pierre-Yves David
9d5b590e75 transaction: drop the third item in tr.backupentries
This third item is always None and never used.
2014-11-05 01:33:16 +00:00