Commit Graph

13907 Commits

Author SHA1 Message Date
Matt Harbison
8ed0a9ea81 subrepo: don't write .hgsubstate lines with empty subrepo state (issue4622)
The '' that is used to represent the state of a not-yet-committed
subrepo cannot be written to the file, because the code that parses
the file splits on ' ' and expects two parts.

Given that the .hgsubstate file is automatically rewritten on commit, it seems
a little strange that the file is written out during a merge.
2015-04-24 23:23:55 -04:00
Matt Harbison
83f972bb8d revert: restore the ability to revert across case only renames (issue4481)
This regressed in 39be809de631, in what looks like an unrelated change.

It seems sufficient to pass 'ignoremissing=True', but the restored try/except
has been there for six years since 3f24f7324cd8, so this seems safer for now.
Note that renaming directories in the filename doesn't appear to work- not sure
if this would end up throwing a different type of error when that is fixed.
2015-04-25 23:54:31 -04:00
Jordi Gutiérrez Hermoso
772b5e72a2 template-phases: do not show description or summary if empty
This is a copy of 942d64e0a1ee, but applied to the phases template,
which is itself almost a copy of the default template.

Perhaps we should rewrite these templates to use the %include syntax
afforded by config files. This change seems a bit too big for stable,
though.
2015-04-24 14:52:12 -04:00
Pierre-Yves David
1dc90191f8 bundle2: also save output when error happens during part processing
Until this changeset, we were only able to save output if an error happened
during the 'transaction.close()' phase. If the 'processbundle' call raised an
exception, the 'bundleoperation' object was never returned, so the reply bundle
was never accessible and no output could be salvaged. We introduce a quick (but
not very elegant) fix to gain access to any reply created during the processing.

This conclude this output related series. We should hopefully be able client-side to see the
whole server output, in a proper order.

The code is now complex enough that a refactoring of it would make sense on
default.
2015-04-23 16:36:18 +01:00
Pierre-Yves David
ae773fc61e bundle2: capture output issue during transaction close
We were capturing all output issue during bundle2 processing, and all output
issue during transaction rollback in case of failure. However, the output issue
during transaction commit was still roaming the land freely. It is now put back
in line.

This let the user see output from 'pretxnclose' and 'txnclose' (and related) in
the right order.
2015-04-23 14:54:45 +01:00
Pierre-Yves David
1e8ec29191 bundle2: also capture hook output during processing
External hook used to directly write on stdout and stderr. As a result their
output was not captured by the bundle2 processing. This resulted in confusing
out of order output on the client side. We are now capturing hooks output in
this context.
2015-04-23 17:03:58 +01:00
Pierre-Yves David
3ecff4d3f6 ui: allow capture of subprocess output
We want to capture hooks output during bundle2 processing. For this purpose we
introduce a new 'subproc' argument to 'ui.pushbuffer'. When set, the output of
sub process created through 'ui.system' will be captured in the buffer too.

This will be used in the next changeset.
2015-04-23 14:57:39 +01:00
Pierre-Yves David
47985fc815 bundle2: capture transaction rollback message output (issue4614)
The output from the transaction rollback was not included into the reply bundle.
It was eventually caught by the usual 'unbundle' output capture and sent to the
client but the result was out of order on the client side. We now capture the
output for the transaction release and transmit it the same way as all other
output.

We should probably rethink the whole output capture things but this would not be
appropriate for stable.

The is still multiple cases were output failed to be properly capture, they will
be fixed in later changesets.
2015-04-23 14:20:36 +01:00
Pierre-Yves David
dcc9ae4956 bundle2: issue remote output as "status" (issue4612)
Remote output should be silenced by --quiet. The issue was found while running
`test-largefiles-cache.t` so it will get tested once we switch bundle2 by
default.
2015-04-24 00:46:48 +01:00
Laurent Charignon
6fc9e8be66 record: edit patch of newly added files (issue4304)
I tried to fix this issue in the past and had to revert the fix. This is a
second attempt without the regression we found with the first one.

record defines special headers (of file) as headers whose hunk are not shown
to the user for editing, they are used to represent deleted, moved and new
files. Since we want to authorize editing the patch of newly added file we
make the newly added file with some content not special anymore. This entails
that we have to save their content before applying the backup to be able to
revert it if the patch does not apply properly.
We reintroduce the test showing that newly added files can be edited and that
their content is shown to the user.
2015-04-23 14:27:26 -07:00
FUJIWARA Katsunori
2a4f646cd6 revert: apply normallookup on reverted file if size isn't changed (issue4583)
Before this patch, reverting a file to the revision other than the
parent doesn't update dirstate. This seems to expect that timestamp
and/or size will be changed by reverting.

But if (1) dirstate of file "f" is filled with timestamp before
reverting and (2) size and timestamp of file "f" isn't changed at
reverting, file "f" is recognized as CLEAN unexpectedly.

This patch applies "dirstate.normallookup()" on reverted file, if size
isn't changed.

Making "localrepository.wwrite()" return length of written data is
needed to avoid additional (and redundant) "lstat(2)" on the reverted
file. "filectx.size()" can't be used to know it, because data may be
decoded at being written out.

BTW, interactive reverting may cause similar problem, too. But this
patch doesn't focus on fixing it, because (1) interactive (maybe slow)
reverting changes one (or both) of size/timestamp of reverted files in
many usecases, and (2) changes to fix it seems not suitable for stable
branch.
2015-04-24 23:52:41 +09:00
Martin von Zweigbergk
f1e241ceae revert: accept just -I/-X without paths or -a/-i (issue4592)
'hg revert -I foo' currently fails with

  abort: no files or directories specified
  (use --all to revert all files, or 'hg update 1' to update)

It doesn't seem intentional that -I/-X without other paths or
--all/--interactive should fail, and it doesn't seem that harmful to
allow it either, so let's just do that.
2015-04-22 16:38:36 -07:00
Laurent Charignon
7e6cda9955 record: change wording for record curses interface
We are using record and crecord in different context, not just for commiting
changes but also reverting and shelving changes. This diff changes the wording
from commiting to confirming changes to avoid confusing the users with what
they are doing.
2015-04-21 16:20:43 -07:00
Laurent Charignon
4fc3c4c465 record: fix record with change on moved file crashes (issue4619)
reverting fe807064739c, add a test to prevent the issue from coming back.
2015-04-22 13:56:30 -07:00
FUJIWARA Katsunori
29b6ee5ded unionrepo: use pathutil.normasprefix to ensure os.sep at the end of cwd
Since Python 2.7.9, "os.path.join(path, '')" doesn't add "os.sep" at
the end of UNC path (see issue4557 for detail).

This makes unionrepo incorrectly work, if:

  1. cwd is the root of UNC share (e.g. "\host\share"), and
  2. mainreporoot is near cwd (e.g. "\host\sharefoo\repo")
     - host of UNC path is same as one of cwd
     - share of UNC path starts with one of cwd
  3. "repopath" isn't specified in URI (e.g. "union:path/to/repo2")

For example:

  $ hg --cwd \host\share -R \host\sharefoo\repo incoming union:path\to\repo2

In this case:

  - os.path.join(r"\host\share", "") returns r"\host\share",
  - r"\host\sharefoo\repo".startswith(r"\host\share") returns True, then
  - r"foo\repo" is treated as repopath of unionrepo instead of
    r"\host\sharefoo\repo"

This causes failure of combining "\host\sharefoo\repo" and another
repository: in addition to it, "\host\share\foo\repo" may be combined
with another repository, if it accidentally exists.

This patch uses "pathutil.normasprefix()" to ensure "os.sep" at the
end of cwd safely, even with some problematic encodings, which use
0x5c (= "os.sep" on Windows) as the tail byte of some multi-byte
characters.

BTW, normalization before "pathutil.normasprefix()" isn't needed in
this case, because "os.getcwd()" always returns normalized one.
2015-04-22 23:38:55 +09:00
FUJIWARA Katsunori
8019b19ea2 bundlerepo: use pathutil.normasprefix to ensure os.sep at the end of cwd
Since Python 2.7.9, "os.path.join(path, '')" doesn't add "os.sep" at
the end of UNC path (see issue4557 for detail).

This makes bundlerepo incorrectly work, if:

  1. cwd is the root of UNC share (e.g. "\host\share"), and
  2. mainreporoot is near cwd (e.g. "\host\sharefoo\repo")
     - host of UNC path is same as one of cwd
     - share of UNC path starts with one of cwd
  3. "repopath" isn't specified in bundle URI
     (e.g. "bundle:bundlefile" or just "bundlefile")

For example:

  $ hg --cwd \host\share -R \host\sharefoo\repo incoming bundle

In this case:

  - os.path.join(r"\host\share", "") returns r"\host\share",
  - r"\host\sharefoo\repo".startswith(r"\host\share") returns True, then
  - r"foo\repo" is treated as repopath of bundlerepo instead of
    r"\host\sharefoo\repo"

This causes failure of combining "\host\sharefoo\repo" and bundle
file: in addition to it, "\host\share\foo\repo" may be combined with
bundle file, if it accidentally exists.

This patch uses "pathutil.normasprefix()" to ensure "os.sep" at the
end of cwd safely, even with some problematic encodings, which use
0x5c (= "os.sep" on Windows) as the tail byte of some multi-byte
characters.

BTW, normalization before "pathutil.normasprefix()" isn't needed in
this case, because "os.getcwd()" always returns normalized one.
2015-04-22 23:38:55 +09:00
FUJIWARA Katsunori
e36077823b dirstate: use pathutil.normasprefix to ensure os.sep at the end of root
419498227287 replaced "os.path.join(root, '')" by
"root.endswith(os.sep)" examination, because Python 2.7.9 changes
behavior of "os.path.join(path, '')" on UNC path.

But some problematic encodings use 0x5c (= "os.sep" on Windows) as the
tail byte of some multi-byte characters, and replacement above
prevents Mercurial from working on the repository, of which root path
ends with such multi-byte character, regardless of enabling win32mbcs.

This patch uses "pathutil.normasprefix()" instead of
"root.endswith(os.sep)" examination, to ensure "os.sep" at the end of
"dirstate._rootdir" even with problematic encodings.

"root" of dirstate can be passed to "pathutil.normasprefix()" without
normalization, because it is always given from "repo.root" =
"repo.wvfs.base", which is normalized by "os.path.realpath()".

Using "util.endswithsep()" instead of "str.endswith(os.sep)" also
fixes this problem, but this patch chooses "pathutil.normasprefix()"
to centralize "adding os.sep if endswith(os.sep)" logic into it.
2015-04-22 23:38:52 +09:00
Wagner Bruna
7e2d119543 bookmarks: add i18n hints to bookmark sync states 2015-04-21 21:02:08 -03:00
Wagner Bruna
a6d1f7d563 help: fix typos in txnclose and txnabort documentation 2015-04-21 21:01:05 -03:00
Kevin Bullock
6d5f979ecc util: fix the check for non-C99 compilers (issue4605) 2015-04-20 22:21:57 -05:00
Pierre-Yves David
e67e928ad2 pushkey: flush pending data before running a pre-pushkey hook (issue4607)
The pre-pushkey hook will likely validate the pushkey based on element
previously changed in the same transaction. We need to make theses data
available for the hook.
2015-04-20 17:16:05 +02:00
Pierre-Yves David
a8e00e4978 pushkey: use hook arguments from transaction when one exists
When pushkey is called during a transaction, we include its 'hookargs' when
running the pre-pushkey hooks. Having more data cannot hurt, especially the
transaction ID.
2015-04-20 17:15:50 +02:00
Augie Fackler
cffde55a69 util.h: also sniff for C99 before trying to use stdbool.h (issue4605)
stdbool.h isn't required until C99. Sigh.
2015-04-20 14:47:51 -04:00
Pierre-Yves David
bf28a4a61f changelog: fix readpending if no pending data exist (issue4609)
Since transaction are used for more than just changesets, it is possible
to have a transaction without new changesets at all. In this case no
''00changelog.i.a' are written. In all cases the 'changelog.readpending'
method is called if the repository has any pending data. The 'revlog' logic
provides empty content if the file is missing, so the whole operation
resulted in an empty changelog.

We now skip reading the pending file if it is missing.
2015-04-20 17:16:22 +02:00
Pierre-Yves David
cb2e913723 afterlock: add the callback to the top level lock (issue4608)
If 'wlock' is taken, we should add 'afterlock' callback to the 'wlock' instead.
Otherwise, running post transaction hook after 'lock' is release but 'wlock' is
still taken lead to a deadlock (eg: 'hg update' during a hook).

This situation is much more common since: b7067abc16c0

  push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
2015-04-20 15:27:55 +02:00
Pierre-Yves David
a7c2f06189 debuglock: access the lock file using the proper vfs
Before this fix, 'wlock' was always reported as "free" because '.hg/store/wlock'
have never been a thing.
2015-04-20 16:05:32 +02:00
Martin von Zweigbergk
1b5dc3517b status: pass matcher to pathcopies()
Just like 111a38b83cb8 (diff: pass the diff matcher to the copy logic,
2015-04-16) sped up 'hg diff --git $path', let's speed up 'hg st -C
$path'. On the Firefox repo, this speeds up

  hg st --rev tip~40000 --rev tip -C python

from 16s to 1.8s. Those two revisions differ in 100k files, out of
which 1k is in python/.
2015-04-19 21:43:53 -07:00
Yuya Nishihara
0a37922d8d annotate: prepare ancestry context of workingfilectx
_ancestrycontext is necessary for fast lookup of _changeid. Because we can't
compute the ancestors from wctx, we skip to its parents. 'None' is not needed
to be included in _ancestrycontext because it is used for a membership test
of filelog revisions.

repo:    https://hg.mozilla.org/releases/mozilla-beta/#062e49bcb2da
command: hg annotate -r 'wdir()' gfx/thebes/gfxWindowsPlatform.cpp
before:  51.520 sec
after:    1.780 sec
2015-04-18 15:27:03 +09:00
Yuya Nishihara
5b51ae23c8 committablefilectx: propagate ancestry info to parent to fix annotation
Before this patch, annotating working directory could include wrong revisions
that were hidden or belonged to different branches. This fixes wfctx.parents()
to set _descendantrev so that all ancestors can take advantage of the linkrev
adjustment introduced at a5aaaeedd6cb. _adjustlinkrev() can handle 'None'
revision thanks to bb19d597bbcd.
2015-04-18 14:10:55 +09:00
Yuya Nishihara
d32c454372 filectx: extract function to create parent fctx keeping ancestry info
committablefilectx.parents() should use this to take advantage of the linkrev
adjustment.
2015-04-18 14:03:41 +09:00
Yuya Nishihara
921251cb12 filectx: factor out creation of parent fctx
This series tries to fix wrong ancestry information on annotating working
directory. This change should slightly improves the readability of the next
patch.
2015-04-18 13:46:24 +09:00
Javi Merino
865602fca3 help: fix typo commited -> committed 2015-04-19 11:37:29 +01:00
Yuya Nishihara
230c1c62ef tags: do not abort if failed to write lock file to save cache
LockHeld wasn't enough to suppress error during acquiring lock. If .hg directory
is read-only, LockUnavailable will be raised.

  $ chmod ugo-w .hg
  $ hg identify
  abort: could not lock working directory of ...: Permission denied
2015-04-17 23:22:58 +09:00
Pierre-Yves David
fe42feb68e bundle2-localpeer: properly propagate the server output on error (issue4594)
In case of errors, output parts salvaged from the reply bundle need to be
processed for outputting their content. This concludes our quest for fixing
issue4594.
2015-04-16 04:01:51 -04:00
Pierre-Yves David
28bc9e7079 bundle2: add on more layer of exception catching in localrepo.unbundle
We are going to add output related logic in this function. We do the
indentation first to help next changeset readability. We need a new try except
because we want to handle output on any exception, including PushRaced ones.
2015-04-16 05:09:37 -04:00
Pierre-Yves David
0bbcf25859 bundle2-wireproto: properly propagate the server output on error (issue4594)
In case of errors, output parts salvaged from the reply bundle are re-injected
into the bundle carrying the exception.

We still need to fix the situation for non-wireprotocol push.
2015-04-16 03:17:37 -04:00
Pierre-Yves David
e97e706e0f bundle2: refactor error bundle creation for the wireprotocol
We want to add output information to the error bundle. Before doing this, we
rework the code to have a single bundler creation and return statement. This
will make the update with the output simpler as only one place will have to be
touched.
2015-04-16 03:56:50 -04:00
Pierre-Yves David
2d01ad7c2e bundle2: store the salvaged output on the exception object
The re-handling of output is happening in some 'unbundle' callers. We have to
transmit the output information to this place so we stick it on the exception.

This is the third step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output part from the aborted reply
into the exception bundle.
2015-04-16 03:17:01 -04:00
Pierre-Yves David
9291c81ebf bundle2: add a 'salvageoutput' method on bundle20
This method returns a copy of all 'output' parts added to the bundler.

This is the second step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output parts from the aborted reply
into the exception bundle.

The function will be used in a later patch.
2015-04-16 03:16:04 -04:00
Pierre-Yves David
ff72f63d50 bundle2: add a 'copy' method on parts
This is the first step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output parts from the aborted reply
into the exception bundle.

The function will be used in a later patch.
2015-04-16 03:15:28 -04:00
Pierre-Yves David
bfdd8d2ada hooks: add a 'txnabort' hook
This hook will be called whenever a transaction is aborted. This will make it
easy for people to clean up temporary content they may have created during a
transaction.
2015-04-16 05:36:49 -04:00
Pierre-Yves David
ce7797818b help: document the ''HG_TXNID'' environment variable during hooks
We forgot to document the new "transaction ID" mechanism.
2015-04-16 05:41:07 -04:00
Matt Harbison
041a91f971 match: add a subclass for dirstate normalizing of the matched patterns
This class is only needed on case insensitive filesystems, and only
for wdir context matches. It allows the user to not match the case of
the items in the filesystem- especially for naming directories, which
dirstate doesn't handle[1]. Making dirstate handle mismatched
directory cases is too expensive[2].

Since dirstate doesn't apply to committed csets, this is only created by
overriding basectx.match() in workingctx, and only on icasefs.  The default
arguments have been dropped, because the ctx must be passed to the matcher in
order to function.

For operations that can apply to both wdir and some other context, this ends up
normalizing the filename to the case as it exists in the filesystem, and using
that case for the lookup in the other context.  See the diff example in the
test.

Previously, given a directory with an inexact case:

  - add worked as expected

  - diff, forget and status would silently ignore the request

  - files would exit with 1

  - commit, revert and remove would fail (even when the commands leading up to
    them worked):

        $ hg ci -m "AbCDef" capsdir1/capsdir
        abort: CapsDir1/CapsDir: no match under directory!

        $ hg revert -r '.^' capsdir1/capsdir
        capsdir1\capsdir: no such file in rev 64dae27060b7

        $ hg remove capsdir1/capsdir
        not removing capsdir1\capsdir: no tracked files
        [1]

Globs are normalized, so that the -I and -X don't need to be specified with a
case match.  Without that, the second last remove (with -X) removes the files,
leaving nothing for the last remove.  However, specifying the files as
'glob:**.Txt' does not work.  Perhaps this requires 're.IGNORECASE'?

There are only a handful of places that create matchers directly, instead of
being routed through the context.match() method.  Some may benefit from changing
over to using ctx.match() as a factory function:

  revset.checkstatus()
  revset.contains()
  revset.filelog()
  revset._matchfiles()
  localrepository._loadfilter()
  ignore.ignore()
  fileset.subrepo()
  filemerge._picktool()
  overrides.addlargefiles()
  lfcommands.lfconvert()
  kwtemplate.__init__()
  eolfile.__init__()
  eolfile.checkrev()
  acl.buildmatch()

Currently, a toplevel subrepo can be named with an inexact case.  However, the
path auditor gets in the way of naming _anything_ in the subrepo if the top
level case doesn't match.  That is trickier to handle, because there's the user
provided case, the case in the filesystem, and the case stored in .hgsub.  This
can be fixed next cycle.

  --- a/tests/test-subrepo-deep-nested-change.t
  +++ b/tests/test-subrepo-deep-nested-change.t
  @@ -170,8 +170,15 @@
     R sub1/sub2/test.txt
     $ hg update -Cq
     $ touch sub1/sub2/folder/bar
  +#if icasefs
  +  $ hg addremove Sub1/sub2
  +  abort: path 'Sub1\sub2' is inside nested repo 'Sub1'
  +  [255]
  +  $ hg -q addremove sub1/sub2
  +#else
     $ hg addremove sub1/sub2
     adding sub1/sub2/folder/bar (glob)
  +#endif
     $ hg status -S
     A sub1/sub2/folder/bar
     ? foo/bar/abc

The narrowmatcher class may need to be tweaked when that is fixed.


[1] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068183.html
[2] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068191.html
2015-04-12 01:39:21 -04:00
Matt Harbison
8a1b99d29c match: move _normalize() into the match class
This will be overridden in an upcoming patch to also deal with dirstate
normalization on case insensitive filesystems.
2015-04-12 00:29:17 -04:00
Matt Harbison
cc76d4f63c subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Prior to ef4d6b79dd3a, the subrelpath() (now _relpath) for hgsubrepo was
calculated by removing the root path of the outermost repo from the root path of
the subrepo.  Since the root paths use platform specific separators, and the
relative path is printed by various commands, the output of these commands
require a glob (and check-code.py enforces this).

In an effort to be generic to all subrepos, ef4d6b79dd3a started calculating
this path based on the parent repo, and then joining the subrepo path in .hgsub.
One of the tests in test-subrepo.t creates a subrepo inside a directory, so the
path being joined contained '/' instead of '\'.  This made the test fail with a
'~' status, because the glob is unnecessary[1].  Removing them made the test
work, but then check-code complains.  We can't just drop the check-code rule,
because sub-subrepos are still joined with '\'.  Presumably the other subrepo
types have this issue as well, but there likely isn't a test with git or svn
repos inside a subdirectory.

This simply restores the exact _relpath value (and output) for hgsubrepos prior
to ef4d6b79dd3a.


[1] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068720.html
2015-04-15 11:49:44 -04:00
Matt Harbison
92a80db936 subrepo: backout 2ee77509c828 to restore reporelpath()
The path for hgsubrepo needs to be calculated slightly differently from other
subrepo types, but can reuse this.  See the next patch for details.
2015-04-15 11:23:26 -04:00
Matt Mackall
e8828f848c rollback: clear resolve state (issue4593) 2015-04-16 18:48:20 -05:00
Durham Goode
cd579fe2e0 diff: pass the diff matcher to the copy logic
This passes the existing diff matcher instance down to the copy logic so copy
tracing can be more efficient when possible and only trace copies for matching
files.

This only actually affects forwardcopies (i.e. Given A<-B<-C<-D, it works for
'hg diff -r B -r D foo.txt', but not for 'hg diff -r D -r B foo.txt') since
backward copies require walking all histories, and not just the individual
file's.

This reduces 'hg diff -r A -r B foo.txt' time from 15s to 1s when A and B have
80,000 files different.
2015-04-16 11:31:48 -07:00
Durham Goode
610230ad03 copies: add matcher parameter to copy logic
This allows passing a matcher down the pathcopies() stack to _forwardcopies().
This will let us add logic in a later patch to avoid tracing copies when not
necessary (like when doing hg diff -r 1 -r 2 foo.txt).
2015-04-16 11:29:30 -07:00
Martin von Zweigbergk
35368e1596 treemanifest: extract parse method from constructor
When we start to lazily load submanifests, it will be useful to be
able to create an treemanifest instance before manifest data gets
parsed into it. To prepare for this, extract the parsing code from
treemanifest's constructor to a separate method.
2015-04-12 23:01:18 -07:00
Martin von Zweigbergk
c1ccc70121 manifest: duplicate call to addrevision()
When we start writing submanifests to their own revlogs, we will not
want to write a new revision for a directory if there were no changes
to it. To prepare for this, duplicate the call to addrevision() and
move them earlier where they can more easily be avoided.
2015-04-12 14:37:55 -07:00
Laurent Charignon
8213891de3 record: add message when starting record's curses interface
We are adding this log message to reduce a confusion when a command prints
something just before starting the curses interface.

Since the interactive mode is taking over the entire screen, starts with no
delay and does wait for a key press, the user believes that messages printed
before opening the interactive mode were actually printed after using
interactive mode, not before.
The fix adds the line "Starting interactive mode" helping the user separate
the messages that were printed before and after the start of the
interactive mode.

One particular example where this was a problem is the revert command where we
first print the list of changes to be considered for revert, then opens the
curses interface right away without letting the user see the messages.
The user then selects the changes, validates and then see the messages from
before opening the interactive mode and is confused.
2015-04-16 14:26:50 -07:00
Mathias De Maré
3f5d166a19 subrepo: add include/exclude support for diffing git subrepos
Previously, git subrepos were ignored if any type of path selection
was done.
This can be solved by using subrepo status and filtering matching files.
2015-04-14 20:09:56 +02:00
Yuya Nishihara
eae9526460 revset: undocument wdir() until its command outputs get stable
wdir() implementation is still incomplete and shouldn't be advertised to
users. This patch will be backed out when

 - template values such as {rev} and {node} are settled
 - major commands and revsets work without crashing
2015-04-12 19:00:31 +09:00
Matt Mackall
4b6771a9f8 linkrev: fix issue with annotate of working copy
The introrev was appearing as None in new annotate tests, which the
code from the stable branch wasn't expecting.
2015-04-16 18:30:08 -05:00
Matt Mackall
9483b9f214 merge with stable 2015-04-16 17:30:01 -05:00
Yuya Nishihara
3af3ee9d07 annotate: always prepare ancestry context of base fctx (issue4600)
This patch extends the workaround introduced by d5844c5f6c7b. Even if the
base fctx is the same as intorrev, _ancestrycontext must be built for faster
_changeid lookup.

repo:    https://hg.mozilla.org/releases/mozilla-beta
command: hg annotate -r 4954faa47dd0 gfx/thebes/gfxWindowsPlatform.cpp
before:  52.450 sec
after:    1.820 sec
2015-04-16 22:33:53 +09:00
Martin von Zweigbergk
87d497396a dirstate.walk: don't report same file stat multiple times
dirstate.walk() generates pairs of filename and a stat-like
object. After "hg mv foo Foo", it generates one pair for "foo" and one
for "Foo", as it should. However, on case-insensitive file systems,
when it tries to stat to get the disk state as well, it gets the same
stat result for both names. This confuses at least
scmutil._interestingfiles(), making it think that "foo" was forgotten
rather than removed. That, in turn, makes "hg addremove" add "foo"
back, resulting in both cases in the dirstate, as reported in
issue4590.

This change only takes care of the "if unknown" branch. A similar fix
should perhaps be applied to the other branch.
2015-04-04 21:54:12 -07:00
Gregory Szorc
7af3081f5e tags: explicitly log which tags cache file is being written
We now have multiple tags cache files. Record exactly which file is
being written. This should help aid debugging into performance issues
with any single filter.
2015-04-16 11:59:36 -04:00
Gregory Szorc
7d23ec157b tags: write a separate tags cache file for unfiltered repos
Since we changed the format of the tags cache, we should bump the
filename. Before this patch, "tags" was being used for unfiltered
repositories. Change the naming scheme to be consistent and ensure
that a new cache file is used.

While I was here, I updated the docs to describe the existence of
multiple caches. I also added explicit test coverage for the creation of
the unfiltered tags cache.
2015-04-16 11:54:13 -04:00
Gregory Szorc
6f5d7e0985 tags: return empty list of heads for no .hgtags case
The caller only uses the heads to resolve tags from content of .hgtags.
Returning a non-empty array is pointless if there is no .hgtags file.
2015-04-16 11:32:46 -04:00
Gregory Szorc
0f9537f76f tags: change format of tags cache files
.hgtags fnodes are now written to a shared cache file. They don't need
to exist in the per-filter tags cache files. Stop writing them.

The format of the tags cache file has changed in a backwards
incompatible way. This should be acceptable, as we just established
per-filter tags cache files and no client should have per-filter tags
cache files that will need to be read. So no backwards compatbility
concern is present.

The new format has a single header line followed by resolved tags
entries.

The header line is similar to the old first line with a major
difference: we now compute and store a hash of the filtered revisions.
Before, if the set of filtered revs changed, we may return incorrect
results. We now detect that.

A test for verifying filtered rev change is handled properly has been
added.
2015-04-16 12:01:00 -04:00
Gregory Szorc
277556bcdd tags: don't read .hgtags fnodes from tags cache files
Now that we have a standalone and shared cache for .hgtags fnodes, the
.hgtags fnodes stored in the tags cache files are redundant.

Upcoming patches will change the format of the tags cache files to
remove this data and to improve the validation. To prepare for this, we
change the tags reading code to ignore all but the tip .hgtags fnodes
entries in existing tags cache files.

All fnodes lookups now go through our new shared cache, which is why
test output changed. Format of tags cache files has not yet changed.
2015-04-16 10:12:44 -04:00
Pierre-Yves David
3e542e8c99 devel-warn: add a prefix to all messages ("devel-warn: ")
We want to make the origin and importance of the message clear to developers.
2015-04-15 01:18:09 -04:00
Pierre-Yves David
c99cb9e546 push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
If the client allows "pushback", the bundle2 served back by the server may
contains parts that will write to the repository. Such parts may require the
'wlock' (eg: bookmark) so we acquire it in advance to make sure it got acquired
before the 'lock'.
2015-04-15 10:36:21 -04:00
Pierre-Yves David
b13ab55f2f unbundle: acquire 'wlock' when processing bundle2 (BC) (issue4596)
A bundle2 may contain bookmark updates (or other extension content) that
requires the 'wlock' to be written. As 'wlock' must be acquired before 'lock',
we must stay on the side of caution and use both in all case to ensure their
ordering.
2015-04-15 01:16:40 -04:00
Pierre-Yves David
22d9658ad9 wlock: do not warn for non-wait locking
We are warning about lock acquired in the wrong order because this can create
dead-lock situation. But non-wait acquisition will not block and therefore not
create a dead-lock. So we do not need to wait in such case.
2015-04-12 15:37:59 -04:00
Pierre-Yves David
23f376ba5d develwarn: include call site in the simple message version
Just displaying the warning makes it quite hard to recognise the guilty code
quickly and using --traceback for all calls is not very convenient. So we
include the call site with all simple message to help developer to recognise
errors sources.
2015-04-12 14:27:42 -04:00
Pierre-Yves David
ac5bf7b3e8 develwarn: handle the end of line inside the function itself
The traceback version should not have a end of line at all. The non-traceback
version will requires the same things soon.
2015-04-12 14:26:11 -04:00
Pierre-Yves David
d3e735bffe develwarn: refactor the developer warning logic
The logic is currently duplicated and we plan to make it a bit smarter. So we
move it into a function first to make the update more robust and simple.
2015-04-12 14:24:28 -04:00
Pierre-Yves David
517621994f lock: update the docstring with order information
Lock must be acquired in a specific order to avoid dead-lock. This was
documented on the wiki, but having this information in the docstring is also
useful.
2015-04-15 01:20:48 -04:00
Pierre-Yves David
16be4bee6c wlock: reword the devel warning
We change the wording of the developer warning:

  -  "lock" taken before "wlock"
  +  "wlock" acquired after "lock"

The goals here are to:

- Put the "subject" as the first word,
- use "acquired" instead of "taken" since it seems more accurate.
2015-04-12 13:28:35 -04:00
Pierre-Yves David
ffd22c7a3b wlock: only issue devel warning when actually acquiring the lock
Before this change, any call to 'wlock' after we acquired a 'lock' was issuing a
warning. This is wrong as the 'wlock' have been properly acquired before the
'lock' in a previous call.

We move the warning code to only issue such warnings when we are acquiring the
'wlock' -after- acquiring 'lock'. This is the expected behavior of this warning
from the start.
2015-04-12 10:01:48 -04:00
Pierre-Yves David
3c016842a8 bundle2: flush output in a part in all cases
We want to preserve output even when the unbundling fails (eg: hook output). So
we must make sure that everything we have is flushed into the reply bundle.

(This is related to issue4594)
2015-04-11 17:30:45 -04:00
Pierre-Yves David
f105df9465 bundle2: fix names for error part handler
The name is not very important but copy paste banshee got there. We make
distinctive name.
2015-04-11 16:55:14 -04:00
Pierre-Yves David
502fe91f02 transaction: introduce a transaction ID, to be available to all hooks
The transaction ID is built from the object ID and creation time stamp to make
sure it is unique.
2015-04-15 11:11:54 -04:00
Pierre-Yves David
bba1369f79 transaction: actually use tr.hookargs in pretxnclose
The 'tr.hookargs' is a dictionary containing all the arguments to be passed to
hooks. It is actually used for hooks now...
2015-04-14 13:07:41 -04:00
Pierre-Yves David
d9bafadc4d bundle2: use unbundle source as transaction name
This is what a bundle 1 push is doing. This got caught by trying to run the
whole test-suite using bundle2 for exchanges.
2015-04-11 13:58:36 -04:00
Pierre-Yves David
99746dff73 tags: have a different cache file per filter level
Currently whichever filter level asks for tags last will write the data on disk.
This create massive issues when tags are read for "visible" and "unfiltered"
on large and multi headed repository (like Mozilla central). See issue4550 for
details

Each filter level recomputes its own cache without direct collaboration but they
all share the same 'hgtagsfnodes' cache. And that is where most of the time is
spent.
2015-04-15 18:34:34 -04:00
Siddharth Agarwal
f6292cfad2 parsers: when available, use a presized dictionary for the file foldmap
On a repo with over 300,000 files, this speeds up perffilefoldmap:

before: wall 0.178421 comb 0.180000 user 0.160000 sys 0.020000 (best of 55)
after:  wall 0.164462 comb 0.160000 user 0.140000 sys 0.020000 (best of 59)
2015-04-15 14:35:44 -07:00
Gregory Szorc
d866fa83a1 tags: extract .hgtags filenodes cache to a standalone file
Resolution of .hgtags filenodes values has historically been a
performance pain point for large repositories, where reading individual
manifests can take over 100ms. Multiplied by hundreds or even thousands
of heads and resolving .hgtags filenodes becomes a performance issue.

This patch establishes a standalone cache file holding the .hgtags
filenodes for each changeset. After this patch, the .hgtags filenode
for any particular changeset should only have to be computed once
during the lifetime of the repository.

The introduced hgtagsfnodes1 cache file is modeled after the rev branch
cache: the cache is effectively an array of entries consisting of a
changeset fragment and the filenode for a revision. The file grows in
proportion to the length of the repository (24 bytes per changeset) and
is truncated when the repository is stripped. The file is not written
unless tag info is requested and tags have changed since last time.

This patch partially addresses issue4550. Future patches will split the
"tags" cache file into per-filter files and will refactor the cache
format to not capture the .hgtags fnodes, as these are now stored in
the hgtagsfnodes1 cache. This patch is capable of standing alone. We
should not have to wait on the tags cache filter split and format
refactor for this patch to land.
2015-04-15 17:42:38 -04:00
Eric Sumner
89d6b43acb extensions: extract partial application into a bind() function
We use partial function application for wrapping existing Mercurial functions,
and it's implemented separately each time.  This patch extracts the partial
application into a new bind() function that can be used on its own by extensions
when appropriate.

In particular, the evolve extension needs to wrap functions in the various
bundle2 processing dictionaries, which the pre-existing methods don't support.
2015-04-15 12:18:05 -04:00
Pierre-Yves David
c24d1f37c9 obsolete: experimental flag to get debug about obsmarkers exchange
The obsolescence markers exchange is still experimental. We (developer) need
more information about what is going on. I'm adding an experimental flag to add
display the amount of data exchanged during bundle2 exchanges.
2015-04-14 11:44:04 -04:00
Pierre-Yves David
eb2e7683a7 bundle2: add an 'idx' argument to the 'getbundle2partsgenerator'
This argument let extensions control in what order bundle2 part are generated
server side during a pull. This is useful to ensure the transaction is in a
proper state before some actions or hooks happens.
2015-04-14 14:59:37 -04:00
Pierre-Yves David
ff78e38dd6 bundle2: add an 'idx' argument to the 'b2partsgenerator'
This argument let extensions control in what order bundle2 part are generated
client side during a push. This is useful to ensure the transaction is in a
proper state before some actions or hooks happens.
2015-04-14 14:07:35 -04:00
Yuya Nishihara
2f81a23f54 hgweb: resurrect <span> tag on diffline to fix rendering in monoblue style
It was removed at 9d1f6b229886 as a useless tag, but it is necessary to
apply "div.diff pre span" style.

http://selenic.com/repo/hg/rev/9d1f6b229886?style=monoblue
2015-04-02 21:29:05 +09:00
Matt Harbison
cdcba76207 forget: cleanup the output for an inexact case match on icasefs
Previously, specifying a file name but not matching the dirstate case yielded
the following, even though the file was actually removed:

  $ hg forget capsdir1/capsdir/abc.txt
  not removing capsdir\a.txt: file is already untracked
  removing CapsDir\A.txt
  [1]

This change doesn't appear to cause any extra filesystem accesses, even if a
nonexistant file is specified.

If a directory is specified without a case match, it is (and was previously)
still silently ignored.
2015-03-31 17:42:46 -04:00
Matt Harbison
a3480284f9 dirstate: don't require exact case when adding dirs on icasefs (issue4578)
We don't require it when adding files on a case insensitive filesystem, so don't
require it to add directories for consistency.

The problem with the previous code was that _walkexplicit() was only returning
the normalized directory.  The file(s) in the directory are then appended, and
passed to the matcher.  But if the user asks for 'capsdir1/capsdir', the matcher
will not accept 'CapsDir1/CapsDir/AbC.txt', and the name is dropped.  Matching
based on the non-normalized name is required.

If not normalizing, skip the extra string building for efficiency.  '.' is
replaced with '' so that the path being tested when no file is specified, isn't
prefixed with './' (and therefore fail the match).
2015-03-31 11:11:39 -04:00
Nathan Goldbaum
08c916638d filemerge: clean up language in mergemarkertemplate help 2015-03-31 11:58:14 -07:00
Yuya Nishihara
4a691471f2 templates: fix "log -q" output of phases style
It had the same problem as be4dab229c78, name conflicts of {node} keyword.
2015-03-28 20:22:03 +09:00
Matt Harbison
e1c0e69712 win32: 'raise ctypes.WinError' -> 'raise ctypes.WinError()'
WinError is a function that creates an Error, not an Error itself.  This is a
partial backout of a9badcbcfb79.
2015-03-22 19:08:13 -04:00
Pierre-Yves David
41927328f0 mergecopies: reuse ancestry context when traversing file history (issue4537)
Merge copies is traversing file history in search for copies and renames.
Since 3.3 we are doing "linkrev adjustment" to ensure duplicated filelog entry
does not confuse the traversal. This "linkrev adjustment" involved ancestry
testing and walking in the changeset graph. If we do such walk in the changesets
graph for each file, we end up with a 'O(<changesets>x<files>)' complexity
that create massive issue. For examples, grafting a changeset in Mozilla's repo
moved from 6 seconds to more than 3 minutes.

There is a mechanism to reuse such ancestors computation between all files. But
it has to be manually set up in situation were it make sense to take such
shortcut. This changesets set this mechanism up and bring back the graph time
from 3 minutes to 8 seconds.

To do so, we need a bigger control on the way 'filectx' are instantiated during
each 'checkcopies' calls that 'mergecopies' is doing. We add a new 'setupctx'
that configure and return a 'filectx' factory. The function make sure the
ancestry context is properly created and the factory make sure it is properly
installed on returned 'filectx'.
2015-03-20 00:30:35 -07:00
Pierre-Yves David
ea1a0fd29f adjustlinkrev: handle 'None' value as source
When the source rev value is 'None', the ctx is a working context. We
cannot compute the ancestors from there so we directly skip to its
parents. This will be necessary to allow 'None' value for
'_descendantrev' itself necessary to make all contexts used in
'mergecopies' reuse the same '_ancestrycontext'.
2015-03-19 23:57:34 -07:00
Pierre-Yves David
7605b9a4cf adjustlinkrev: prepare source revs for ancestry only once
We'll need some more complex initialisation to handle workingfilectx
case. We do this small change in a different patch for clarity.
2015-03-19 23:52:26 -07:00
Pierre-Yves David
78f35efc70 annotate: reuse ancestry context when adjusting linkrev (issue4532)
The linkrev adjustment will likely do the same ancestry walking multiple time
so we already have an optional mechanism to take advantage of this. Since
4e4e9e954fae, linkrev adjustment was done lazily to prevent too bad performance
impact on rename computation. However, this laziness created a quadratic
situation in 'annotate'.

Mercurial repo: hg annotate mercurial/commands.py
before:   8.090
after:  36.300

Mozilla repo: hg annotate layout/generic/nsTextFrame.cpp
before:   1.190
after:  290.230


So we setup sharing of the ancestry context in the annotate case too. Linkrev
adjustment still have an impact but it a much more sensible one.

Mercurial repo: hg annotate mercurial/commands.py
before:  36.300
after:   10.230

Mozilla repo: hg annotate layout/generic/nsTextFrame.cpp
before: 290.230
after:    5.560
2015-03-19 19:52:23 -07:00
Yuya Nishihara
990aa241a1 templates: fix "log -q" output of default style
It was changed at ad92c202bbcd unintentionally due to name conflicts.
2015-03-14 22:34:27 +09:00
Yuya Nishihara
7445ebd638 hgweb: prevent loading style map from directories other than specified paths
A style name should not contain "/", "\", "." and "..". Otherwise, templates
could be loaded from outside of the specified templates directory by invalid
?style= parameter. hgweb should not allow such requests.

This change means subdir/name is also rejected.
2015-03-13 21:18:59 +09:00
Yuya Nishihara
d646851eb8 dirstate: make sure rootdir ends with directory separator (issue4557)
ntpath.join() of Python 2.7.9 does not work as expected if root is a UNC path
to top of share.

This patch doesn't take care of os.altsep, '/' on Windows, because root should
be normalized by realpath().
2015-03-06 00:14:22 +09:00
Pierre-Yves David
9d2643c9ed amend: check for directory renames for both merge parents (issue4516)
Before this change, amending a merge would lose the rename information for file
adding in the second parents and implicitly renamed into a new directory.

In case of the merge, we also look for directory rename data from the second
parent. This seems to fix the bug and does not show other issues from the test
suite.
2015-03-02 19:01:00 +00:00
Matt Harbison
721f888f2f transaction: really disable hardlink backups (issue4546) 2015-03-02 10:31:22 -05:00