Commit Graph

10051 Commits

Author SHA1 Message Date
Thomas Arendsen Hein
6ca8967a44 hgweb: urlescape all urls, HTML escape repo/tag/branch/... names
Without this, repository paths or names containing e.g. & characters or html
tags yielded strange results, possibly allowing cross-site scripting attacks.
2013-02-01 20:43:35 +01:00
Matt Mackall
a1152e87ba merge with crew 2013-02-01 15:14:05 -06:00
Kevin Bullock
21ba139cdc hgweb: rename 'currentbaseline' template keyword to 'basenode'
Shorter and clearer. This keyword represents the node we're currently
diffing against.
2013-02-01 10:12:41 -06:00
Kevin Bullock
3cf3843b51 hgweb: rename 'changesetbaseline' template to 'difffrom'
More accurately reflects what it will be used for, and is also shorter.
This template is used to change which rev the current rev is diff'd
against. For example, if you're at '/rev/P1:REV', this would link to a
path like '/rev/P2:REV'.

Example usage in a template:

    {parent%difffrom}
2013-02-01 09:58:25 -06:00
Pierre-Yves David
6c0cbcf3ba hgweb: remove baseline info from paper template
The user interface introduced in 3ff83729b63f is not considered ready
for prime time yet. The internal code stays in place for custom template
usage. The feature is ultimately wanted and will be re-enabled soon. The
current issue is only related to the visual of the current interface.
2013-02-01 05:40:06 +01:00
Angel Ezquerra
b6d710beb8 hgwebdir: use web.prefix when creating url breadcrumbs (issue3790)
The web.prefix setting was being ignored when creating the index URL
breadcrumbs.

We only need to fix hgwebdir and not hgweb because hgweb gets the complete URL
request, including the prefix, while hgwebdir gets a "subdir" which does not
include the prefix.

This fix is slightly different of what was suggested on the bug tracker. In
there it was suggested to hide the prefix itself from the breadcrumb. I think
that would be a better solution, but it would require changing all the index
templates and passing the prefix to the template engine, which may be too big
a change for stable during the freeze. For now this fixes the problem, and the
fix could be improved during the next cycle.
2013-01-31 22:36:22 +01:00
Pierre-Yves David
32e4185163 hgweb: add a web.view to control filtering
This options add a new `web.view` to control filter level of hgweb.

This option have two purposes:

1) Allow fall back to unfiltered version in case a yet undetected by critical
   bug is found in filtering after 2.5 release

2) People use hgweb as a local repoviewer. When they have secret changesets,
   they wants to use "visible" filter not "served"

(modified by mpm, documentation deferred)
2013-01-31 19:56:55 +01:00
Pierre-Yves David
090c6ed52d hgweb: returns 404 for unknow revision instead of 500
I noticed that access to filtered revision returned HTTP 500 code (internal
server error). Investigation shown that it was the case for unknown revision
too. That wrong and we now properly return a 404 for revision not found.
2013-01-31 22:30:52 +01:00
Pierre-Yves David
271a03e73f subrepo: allows to drop courtesy phase sync (issue3781)
Publishing server may contains draft changeset when they are created locally. As
publishing is the default, it is actually fairly common. Because of this
"inconsistency" phases synchronization may be done even to publishing server.

This may cause severe issues for subrepo. It is possible to reference read-only
repository as subrepo. Push in a super repo recursively push subrepo. Those
pushes to potential read only repo are not optional, they are "suffered" not
"choosed". This does not break because as the repo is untouched the push is
supposed to be empty. If the reference repo locally contains draft changesets, a
courtesy push is triggered to turn them public. As the repo is read only, the
push fails (after possible prompt asking for credential). Failure of the
sub-push aborts the whole subrepo push. This force the user to define a custom
default-push for such subrepo.

This changeset introduce a prevention of this error client side by skipping the
courtesy phase synchronisation in problematic situation. The phases
synchronisation is skipped when four conditions are gathered:
- this is a subrepo push, (normal push to read-only repo)
- and remote support phase
- and remote is publishing
- and no changesets was pushed (if we pushed changesets, repo is not read only)

The internal config option used in this version is not definitive. It is here to
demonstrate a working fix to the issue.

In the future we probably wants to track subrepo changes and avoid pushing to
untouched one. That will prevent any attempt to push to read-only or unreachable
subrepo.

Another fix to prevent courtesy push from older clients to push to newer server
is also still needed.
2013-01-31 01:44:29 +01:00
Siddharth Agarwal
f56fcc5796 bookmarks: factor out delete divergent code
Deleting divergent bookmarks is more generally useful than just in
bookmarks.update.
2013-01-30 15:35:00 -08:00
Matt Harbison
b344797c5f share: backout f48752441ca0, except the test
Locating the share source when no default path is available is now handled in
subrepo._abssource(), so unconditionally setting a default path (and the
associated problems) can be avoided.

The test change reflects the fact that a default path is no longer set on the
resulting share.
2012-11-27 21:31:59 -05:00
Matt Harbison
90844b4729 subrepo: use sharepath if available when locating the source repo
This is an alternative fix for issue3518, enabling sharing of repositories with
subrepos, without unconditionally setting the default path in the resulting
repo's hgrc file.  Better test coverage is added here, but won't prove this code
is working until f48752441ca0 is backed out.

The problem with the original fix is, if a default path is not available to be
copied over from the share source, the default path on the resulting repo is set
to the source location.  Since that's where the actual repository is stored, the
path is essentially self-referential, so push, pull, incoming and outgoing
effectively operate on itself.  While incoming and outgoing make it look like
nothing was changed, push currently hangs (see issue3657).  In this case where
there is not a real default path, these operations should abort with
"default(-push) not found", like the source repo would.  Note this problem with
the original fix affected repos without subrepos too.
2012-11-27 20:56:27 -05:00
Mads Kiilerich
adb98eb255 merge: fix UnboundLocalError (issue3791)
A wrong variable name was introduced in 84dc2a17eab4 for a case without test
coverage.

The variable name is fixed and a test case is introduced.
2013-01-30 19:29:36 +01:00
Yuya Nishihara
26e354a203 parsers: fix memleak of revlog cache entries on strip
Since 2852b9b207e9, raw_length can be reduced on strip, but corresponding cache
entries still have refcount. They are not dereferenced by _index_clearcache(),
and never freed.

To reproduce the problem, run "hg pull" and "hg strip null" several times
in the same process.
2013-01-28 19:05:35 +09:00
Pierre-Yves David
11f4fbd0aa hgweb: fix navigation label (issue3792)
Latest refactoring (6653e43a8a16) was buggy and used a variable from
another loop.  Tests are run on repo too small to cache that.
2013-01-30 17:32:17 +01:00
Mads Kiilerich
aaa8484e61 profiling: add documentation of lsprof 'sort' and 'nested' 2013-01-29 20:03:51 +01:00
Mads Kiilerich
bba6c5042a OS X: try cheap ascii .lower() in normcase before making full unicode dance
This is similar to what is done in encoding.lower, introduced in e7a5733d533f.

This has been seen making 'hg up' and 'hg st' in a 50000+ files repo 13%
faster.

This might make Mercurial slightly slower for users who mainly use non-ASCII
filenames. That is a reasonable trade-off.
2013-01-29 17:01:41 +01:00
Pierre-Yves David
d3771a5324 pull: fix crash when pulling changeset that get hidden locally (issue3788)
When you have obsolescence marker that apply to a pulled changesets, the added
changeset is immediately filtered. Then the list of added changeset needs to be
build against and unfiltered repo.
2013-01-29 15:26:10 +01:00
Pierre-Yves David
efe098ab89 hgweb: prevent traceback during search when filtered (issue3783)
The search needs to iterate over the repo using changelog.revs like the rest of
the Mercurial code.
2013-01-29 16:44:51 +01:00
Kevin Bullock
c8bd540ea2 bookmarks: hide bookmarks on filtered revs from listkeys
Don't expose unserved changesets to remote repos. Thanks to Sean Farley
<sean.michael.farley@gmail.com> for tracking down the issue and
Pierre-Yves David <pierre-yves.david@ens-lyon.org> for the fix.
2013-01-27 15:13:53 -06:00
Kevin Bullock
921b868783 bookmarks: don't use bookmarks.listbookmarks in local computations
bookmarks.listbookmarks is for wire-protocol use. The normal way to get
all the bookmarks on a local repository is repo._bookmarks.
2013-01-27 14:24:37 -06:00
Pierre-Yves David
d33c391bb4 discovery: outgoing pass unfiltered repo to findcommonincoming (issue3776)
We noa pass an unfiltered repo in the same way `localrepo.push` does. This does
not alter outgoing behavior and prevents possible crash with computing
common/missing.

The `findcommonincoming` code could be simplified to make this unnecessary, but
this is too much change for the freeze.
2013-01-28 13:56:11 +01:00
Kevin Bullock
95941cafe7 bookmarks: show active bookmark even if not at working dir
If the active bookmark doesn't point at a parent of the working dir
(e.g. a pull moved it out from under us), we nonetheless show it as
active. This follows on 13ea5e437ff8 in removing the dichotomy (at least
in the UI) between "current" and "active" bookmarks.
2013-01-27 11:29:14 -06:00
Kevin Bullock
dd5421b6fc hgweb: don't attempt to show hidden bookmarks (issue3774)
localrepository._bookmarks is unfiltered, but hgweb gets a filtered
repo. This fixes the resulting traceback on the 'bookmarks' page.
2013-01-25 11:43:54 -06:00
Kevin Bullock
03497018d8 hgweb: fetch tipmost unfiltered rev thru the changelog
This fixes a traceback when tip is filtered (e.g. because it's secret).
See issue3783, for which this is a partial fix.
2013-01-25 14:50:18 -06:00
Kevin Bullock
573de12159 help: update verbose 'clone' help to include '@' bookmark 2013-01-25 16:11:16 -06:00
Kevin Bullock
e5bcfe1e27 help: document '@' bookmark in 'help bookmarks' and 'help clone' 2013-01-25 11:06:30 -06:00
FUJIWARA Katsunori
1fc2644404 revset: evaluate sub expressions correctly (issue3775)
Before this patch, sub expression may return unexpected result, if it
is joined with another expression by "or":

  - "^"/parentspec():
    "R or R^1" is not equal to "R^1 or R". the former returns only "R".

  - "~"/ancestorspec():
    "R or R~1" is not equal to "R~1 or R". the former returns only "R".

  - ":"/rangeset():
    "10 or (10 or 15):" is not equal to "(10 or 15): or 10". the
    former returns only 10 and 15 or grater (11 to 14 are not
    included).

In "or"-ed expression "A or B", the "subset" passed to evaluation of
"B" doesn't contain revisions gotten from evaluation of "A", for
efficiency.

In the other hand, "stringset()" fails to look corresponding revision
for specified string/symbol up, if "subset" doesn't contain that
revision.

So, predicates looking revisions up indirectly should evaluate sub
expressions of themselves not with passed "subset" but with "entire
revisions in the repository", to prevent "stringset()" from unexpected
failing to look symbols in them up.

But predicates in above example don't so. For example, in the case of
"R or R^1":

  1. "R^1" is evaluated with "subset" containing revisions other than
     "R", because "R" is already gotten by the former of "or"-ed
     expressions

  2. "parentspec()" evaluates "R" of "R^1" with such "subset"

  3. "stringset()" fails to look "R" up, because "R" is not contained
     in "subset"

  4. so, evaluation of "R^1" returns no revision

This patch evaluates sub expressions for predicates above with "entire
revisions in the repository".
2013-01-23 22:52:55 +09:00
Kevin Bullock
dc307a1121 update: update to current bookmark if it moved out from under us (issue3682)
If the current bookmark (the one listed in .hg/bookmarks.current)
doesn't point to a parent of the working directory, e.g. if it was moved
by a pull, use that as the update target instead of the tipmost
descendent.

A small predicate is (finally) added to the bookmarks module to check
whether the current bookmark is also active.
2013-01-21 13:47:10 -06:00
FUJIWARA Katsunori
b0f6d79cda doc: use "tag" revset predicate instead of "tagged" for example in help
"tag" predicate is officially described in help, but "tagged" is not,
even though the latter works as same as the former.
2013-01-24 00:21:22 +09:00
Bryan O'Sullivan
9937540784 graphmod: don't try to visit nullrev (issue3772) 2013-01-23 00:20:26 -06:00
Sean Farley
5d92124a63 log: remove any ancestors of nullrev (issue3772)
For the special case, ":null" we remove the implied revision 0 since that
wouldn't make any sense here. A test case is added to make sure only nullrev is
shown.
2013-01-23 00:12:52 -06:00
Sean Farley
e896ac7d6a help: add documentation for new template functions 2013-01-22 18:40:23 -06:00
Pierre-Yves David
093fc83eab changectx: fix the handling of tip
We can not use `len(repo,changelog)`, it may be a filtered revision. We now use
`repo,changelog.tip()` to fetch this information.

The `tip` command is also fixed and tested

Thanks goes to Idan Kamara for the initial report.
2013-01-22 11:39:14 +01:00
Pierre-Yves David
ea74bd73ed bisect: use changelog for iteration
With changelog filtering, we can not use xrange anymore. We have to use the
changelog to do the iteration. This way, the changelog excludes filtered
revision and we can safely use what we iterate over.

Without this changes, bisect crash with a traceback if there is filtered
revision in the repo. Tests have been updated.
2013-01-22 03:23:02 +01:00
Pierre-Yves David
988fc3a302 documentation: update to new filter names
Changeset 7f7f8386b285 change filter names but forgot some documentation
updates.
2013-01-21 19:40:15 +01:00
Wagner Bruna
3b2e42fb86 debugsuccessorssets: fix typos in docstring 2013-01-21 13:47:14 -02:00
Matt Mackall
000c66e909 merge: only sort manifests in debug mode (issue3769) 2013-01-20 17:18:00 -06:00
Matt Mackall
197aa5594e pathencode: don't use alloca() for safety/portability 2013-01-19 17:20:39 -06:00
Pierre-Yves David
e0122c56e3 branchmap: display filtername when updatebranch fails to do its jobs
We have a very handy assert at the ends of `branchmap.updatecache` that check
the resulting branchmap is actually valid.

I know we do not like assert in mercurial but this one is very handy for
debugging. There is really not reason for `branchmap.updatecache` to have this
kind of issue but this happened and handful of time during the development of
this or introduction of other related feature. I advice to keep it around until
we are a bit more confident with the new code.
2013-01-19 02:29:56 +01:00
Mads Kiilerich
84f8ae3223 scmutil: localize and improve 'not under root' message 2013-01-18 01:24:29 +01:00
Pierre-Yves David
d6838f12a9 repoview: cache filtered changelog
Creating a new changelog object for each access is costly and prevents efficient
caching changelog side. This introduced a x5 performance regression in log
because chunk read from disk were never reused. We were jumping from about 100
disk read to about 20 000.

This changeset introduce a simple cache mechanism that help the last changelog
object created by a repoview. The changelog is reused until the changelog or the
filtering changes.

The cache invalidation is much more complicated than it should be. But MQ test
show a strange cache desync. I was unable to track down the source of this
desync in descent time so I'm not sure if the issue is in MQ or core. However
given the proximity to the 2.5 freeze, I'm choosing the inelegant but safe route
that makes the cache mechanism safer.
2013-01-18 23:43:32 +01:00
Pierre-Yves David
f539d0189a repoview: protect base computation from weird phase root
If for some reason the phase roots contains nullid, the set of filtered revs
will contains -1. That confuse Mercurial a lot. In particular this corrupt the
branchcache.

Standard code path does not result in nullid phase root. It can only result from
altered `.hg/store/phaseroots` or buggy extension. However better safe than
sorry.
2013-01-17 17:51:30 +01:00
Siddharth Agarwal
40f1d2ce96 posix: don't compare atime when determining if a file has changed
A file's atime might change even if the file itself doesn't change. This might
cause us to invalidate caches more often than necessary.

Before this change, hg add often resulted in the dirstate being parsed twice
on systems that track atime. After this change, it is only parsed once. For a
repository with over 180,000 files, this speeds up hg add from 1.2 seconds to
1.0.
2013-01-18 15:55:16 -08:00
Simon Heimberg
9e6ca20cff repo: repo isolation, do not pass on repo.ui for creating new repos
A repo should not get the configuration from an other repo, so create it with
the global configuration in repo.baseui.
This is done too when recreating a repo. The repo configuration is reread
anyway. And now deleted repo configuration does not persist.
2012-10-10 21:55:49 +02:00
Johan Bjork
7b64b304ec diff: fix binary file removals in git mode.
With the previous version, a binary file removal diff generated with
2013-03-04 22:34:11 +00:00
Siddharth Agarwal
6857870aa1 manifestmerge: drop redundant flags calls 2013-03-24 16:56:25 -07:00
Siddharth Agarwal
65dea36afd manifestmerge: use dicthelpers.diff and join
This patch improves manifestmerge performance significantly.

In a repository with 170,000 files, the following results were observed on a
clean working directory. Revision '.' adds one file.

hg perfmergecalculate -r .
- before: 0.41 seconds
- after: 0.13 seconds

hg perfmergecalculate -r .^
- before: 0.53 seconds
- after: 0.24 seconds

Comparing against '.' is much faster than comparing against '.^' because with
'.', the wctx and p2 manifest strings have the same identity, so comparisons
are simply pointer equality. With '.^', the strings have different identities
so we need to perform memcmps.

Any operation that uses manifestmerge benefits.
- hg update . goes from 2.04 seconds to 1.75
- hg update .^ goes from 2.52 seconds to 2.25
- hg rebase -r . -d .~6 (involves 4 merges) goes from 11.8 seconds to 10.8
2013-03-25 17:41:06 -07:00
Siddharth Agarwal
81b84a1325 manifestdict: add a method to diff _flags
This will be used in an upcoming patch.
2013-03-24 17:17:38 -07:00
Siddharth Agarwal
b037c134fd mercurial: implement diff and join for dicts
Given two dicts, diff returns a dict containing all the keys that are present
in one dict but not the other, or whose values are different between the
dicts. The values are pairs of the values from the dicts, with missing values
being represented as an optional argument, defaulting to None.

Given two dicts, join performs what is known as an outer join in relational
database land: it returns a dict containing all the keys across both dicts.
The values are pairs as above, except they aren't compared to see if they're
the same.
2013-03-25 17:40:39 -07:00
Siddharth Agarwal
b321ec2b67 manifestmerge: rename n to n1 and n2
An upcoming patch will combine the two loops into one, so it's important to
distinguish between nodes in m1 and nodes in m2.
2013-03-24 16:43:25 -07:00
Siddharth Agarwal
a6bf485dee dirstate.walk: fast path none-seen + match-always case for step 3
This case is a common one -- e.g. `hg diff`.

For a repository with 170,000 files, this speeds up perfstatus from 0.95
seconds to 0.88.
2013-03-22 17:03:49 -07:00
Siddharth Agarwal
5e52c298d1 dirstate.walk: fast path match-always case during traversal
This case is a common one -- e.g. `hg status`.

For a repository with 170,000 files, this speeds up perfstatus --unknown from
2.15 seconds to 2.09.
2013-03-22 17:03:00 -07:00
Siddharth Agarwal
68d46b6a0a dirstate.walk: remove subrepo and .hg from results before step 3
An upcoming patch will speed dirstate.walk up by not querying the results dict
when it is empty. This ensures it is in some common cases.

This should be safe because subrepos and .hg aren't part of the dirstate.
2013-03-25 14:12:39 -07:00
Kevin Bullock
666c5947d4 merge with stable 2013-03-25 12:12:41 -05:00
Bryan O'Sullivan
9875c114cd debugpathcomplete: satisfy the code checker 2013-03-21 22:29:31 -07:00
Bryan O'Sullivan
25ebd629ba pathcomplete: complete directories more conservatively
Suppose we want to perform a single-level completion (i.e. without
--full) of "fi" in a repo containing "fee", "fie/dead", "fie/live",
and "foe".

If we give back "fie/" as the only answer, the shell will consider
the completion to be unambiguous, and will append a space after the
completion.  We can't complete "fie/live" or "fie/dead" without
first backspacing over that space.

We used to thus create two fake names, "fie/a" and "fie/b", to force
the shell to consider the completion to be ambiguous. It would then
stop at "fie/" without appending a space, allowing us to hit tab
again to complete "fie/live" or "fie/dead".

The change here arises from realising that we only need to force
the shell to consider a completion as ambiguous if we have exactly
one directory and zero files as possible completions.

This prevents spurious names from showing up as possible completions
when they don't need to be invented in the first place.
2013-03-21 22:10:54 -07:00
Bryan O'Sullivan
d521a241b2 completion: add a debugpathcomplete command
The bash_completion code uses "hg status" to generate a list of
possible completions for commands that operate on files in the
working directory. In a large working directory, this can result
in a single tab-completion being very slow (several seconds) as a
result of checking the status of every file, even when there is no
need to check status or no possible matches.

The new debugpathcomplete command gains performance in a few simple
ways:

* Allow completion to operate on just a single directory. When used
  to complete the right commands, this considerably reduces the
  number of completions returned, at no loss in functionality.

* Never check the status of files. For completions that really must
  know if a file is modified, it is faster to use status:

  hg status -nm 'glob:myprefix**'

Performance:

Here are the commands used by bash_completion to complete, run in
the root of the mozilla-central working dir (~77,000 files) and
another repo (~165,000 files):

All "normal state" files (used by e.g. remove, revert):

                            mozilla    other
  status -nmcd 'glob:**'       1.77     4.10 sec
  debugpathcomplete -f -n      0.53     1.26
  debugpathcomplete -n         0.17     0.41

("-f" means "complete full paths", rather than the current directory)

Tracked files matching "a":

                            mozilla    other
  status -nmcd 'glob:a**'      0.26     0.47
  debugpathcomplete -f -n a    0.10     0.24
  debugpathcomplete -n a       0.10     0.22

We should be able to further improve completion performance once
the critbit work lands. Right now, our performance is limited by
the need to iterate over all keys in the dirstate.
2013-03-21 16:31:28 -07:00
Bryan O'Sullivan
59cec2d504 completion: add a debuglabelcomplete command
When completing a "label" (a symbolic name for a commit), the
bash_completion script currently has to invoke hg three times. For
a large repository, the cost of starting up and loading all the
necessary context over and over is very high.

For instance, in mozilla-central:

  time (export HGPLAIN=1; hg tags -q; hg bookmarks -q; hg branches) >/dev/null
  0.446 sec

Compare with the debuglabelcomplete command that this commit adds:

  time hg debuglabelcomplete >/dev/null
  0.148 sec

This greatly helps responsiveness.
2013-03-21 10:51:18 -07:00
Kevin Bullock
0ac9eb1b2b merge 2013-03-18 19:59:05 -05:00
Kevin Bullock
e1d6f97b9f applyupdates: assign variable before we try to use it (issue3855)
The variable 'fd' was getting used with a value left over from a prior
iteration, causing a KeyError: '.hgsubstate'.
2013-03-18 16:37:20 -05:00
Kevin Bullock
8d329cb6b6 revset: don't abort when regex to tag() matches nothing (issue3850)
This makes the tag("re:...") revset consistent with branch("re:...").
2013-03-18 16:04:10 -05:00
Kevin Bullock
9a9dfa03ff bookmarks: moving the active bookmark deactivates it
After this change, moving the active bookmark somewhere other than the
current changeset (i.e., with --rev) deactivates it. Previously it would
remain in .hg/bookmarks.current, which seems like a bug.
2013-03-16 22:48:22 -05:00
Kevin Bullock
8d31377f62 bookmarks: allow (re-)activating a bookmark on the current changeset
Allow a bookmark that points to the current changeset to be made the
active bookmark without requiring --force. Previously, this would've
aborted with:

  abort: bookmark 'Z' already exists (use -f to force)
2013-03-16 21:36:44 -05:00
Kevin Bullock
f416be4da5 bookmarks: allow moving a bookmark forward to a descendant
Allow 'hg bookmark MARK', with an existing bookmark MARK, to move the
bookmark forward to the current or specified revision, if the target
revision is a descendant of the revision the bookmark currently points
to. Prints a status message including the revision the bookmark was
formerly at:

  $ hg bookmark Z
  moving bookmark 'Z' forward from 663762316562

Test coverage is added.
2013-03-15 23:39:07 -05:00
Durham Goode
474ac2b31e rebase: fix --collapse when a file was added then removed
When a series of commits first adds a file and then removes it,
hg rebase --collapse prompts whether to keep the file or delete it. This is
due to it reusing the branch merge code. In a noninteractive terminal it
defaults to keeping the file, which results in a collapsed commit that is
has a file that should be deleted. This bug resulted in developers accidentally
commiting unintentional changes to our repo twice today, so it's fairly
important to get fixed.

This change allows rebase --collapse to tell the merge code to accept the
latest version every time without prompting.

Adds a test as well.
2013-03-15 11:23:29 -07:00
Augie Fackler
31c30e1b53 Merge 2013-03-17 23:27:14 -05:00
Bryan O'Sullivan
bbd075858d grep: use re2 if possible
Since re2 is enormously faster than Python's re module, this should
help performance, ceteris paribus. grep currently has other huge
performance problems that mask any gain :-(
2013-03-11 12:07:33 -07:00
Bryan O'Sullivan
ced9b7970b util: add flag support to compilere 2013-03-11 12:06:13 -07:00
Durham Goode
3b156f49f8 blackbox: add backup bundle paths to blackbox logs
Writes the backup bundle paths to the blackbox so it's easy to see which
backup bundle is associated with which command when you are debugging an
issue.

Example output:

2013/03/13 10:39:56 durham> strip tip
2013/03/13 10:39:59 durham> saved backup bundle to /data/users/durham/www-hg/.hg/strip-backup/e5fac262363a-backup.hg
2013/03/13 10:40:03 durham> strip tip exited 0 after 7.97 seconds
2013-03-13 10:43:51 -07:00
Durham Goode
83b3faf2ec strip: make --keep option not set all dirstate times to 0
hg strip -k was using dirstate.rebuild() which reset all the dirstate
entries timestamps to 0.  This meant that the next time hg status was
run every file was considered to be 'unsure', which caused it to do
expensive read operations on every filelog. On a repo with >150,000
files it took 70 seconds when everything was in memory.  From a cold
cache it took several minutes.

The fix is to only reset files that have changed between the working
context and the destination context.

For reference, --keep means the working directory is left alone during
the strip. We have users wanting to use this operation to store their
work-in-progress as a commit on a branch while they go work on another
branch, then come back later and be able to uncommit that work and
continue working.  They currently use 'git reset HARD^' to accomplish
this in git.
2013-03-06 20:13:09 -08:00
Durham Goode
97bdc357fb sshpeer: store subprocess so it cleans up correctly
When running 'hg pull --rebase', I was seeing this exception 100% of the
time as the python process was closing down:

Exception TypeError: TypeError("'NoneType' object is not callable",) in
<bound method Popen.__del__ of <subprocess.Popen object at 0x937c10>> ignored

By storing the subprocess on the sshpeer, the subprocess seems to clean up
correctly, and I no longer see the exception. I have no idea why this actually
works, but I get a 0% repro if I store the subprocess in self.subprocess,
and a 100% repro if I store None in self.subprocess.

Possibly related to issue 2240.
2013-03-08 16:59:36 -08:00
Durham Goode
2d704dd602 blackbox: fix exception when logging commands with format characters
When running commands like 'hg export -o mypatch-%N.patch', the blackbox
would throw an exception because it tried to format %N. This change
prevents it from trying to format the command string.
2013-02-28 10:12:26 -08:00
Angel Ezquerra
8d01e97626 hgweb: change manifest archive links to only archive the current directory
When the web server shows the manifest for a single, non top directory, append
the path to the directory to the archive links. This makes the web server
generate archive files that only include the current directory (and its
subdirectories).

Note that archive links in other pages (e.g. changeset) or at the top of the
manifest are unchanged. Directory archive links have an extra "/" at the end
which does not impact the result of the archive operation. Keeping it there
made the implementation of this feature simpler.
2013-02-26 21:20:35 +01:00
Angel Ezquerra
ec145a5631 hgweb: teach archive how to download a specific directory or file
The archive web command now takes into account the "file" request entry, if one
is provided.

The provided "file" is processed as a "path" corresponding to a directory or
file that will be downloaded.

With this change hgweb can to process requests such as:

    http://mercurial.selenic.com/hg/archive/tip.zip/mercurial/templates

This will download all files on the mercurial/templates directory as a zip file.
It is not possible to specify file patterns ('glob', 'relglob', 'path',
'relpath', 're', 'relre' nor 'set'). The server will reject those with a
403 HTTP error response.

Note that this is a first step to add support for downloading directories from
the web interface. A following patch will modify the archiveentry map entry on
the different templates so that it adds the current folder path to the archive
links.
2013-02-10 11:52:05 +01:00
Dan Villiom Podlaski Christiansen
17ccef70f8 minirst: optimize HTML table generation a bit
avoid a couple of array copies and string interpolations
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
e6781fbadb minirst: HTML formatter tweaks
output table rows on distinct lines
don't make the first row a table header
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
5ff9149ead minirst: CGI escape strings prior to embedding it in the HTML 2013-02-09 17:44:25 -05:00
Dan Villiom Podlaski Christiansen
768b2c3969 minirst: don't generate TH elements for the first row in table
We mainly use them for option tables -- browsers bolding and centering
them looks wrong.
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
d045d03b91 help: use a full header for topic titles
...for prettier HTML!
2013-02-10 12:58:57 +01:00
Dan Villiom Podlaski Christiansen
9e387ff40b hgweb: generate HTML documentation
It's generated from the raw ReST source, as returned from help.help_().
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
3950055bca help: move the majority of the help command to the help module
We move the logic for generating the unformatted ReST source to the
help module, in order to eventually avoid calling commands.help_()
from hgweb.

No functionality change.
2013-02-09 21:51:21 +00:00
Dan Villiom Podlaski Christiansen
e500e66efd hgweb help: split up long lines (in generated output) 2013-02-09 21:51:21 +00:00
Kevin Bullock
9b7121a10b merge with stable 2013-03-01 10:05:37 -06:00
Bryan O'Sullivan
95f0609257 util: add a timed function for use during development
I often want to measure the cost of a function call before/after
an optimization, where using top level "hg --time" timing introduces
enough other noise that I can't tell if my efforts are having an
effect.

This decorator allows a developer to measure a function's cost with
finer granularity.
2013-02-28 13:11:42 -08:00
Bryan O'Sullivan
ae3da7aa9a util: generalize bytecount to unitcountfn
This gives us a function we can reuse to count units of other kinds.
2013-02-28 12:51:18 -08:00
Thomas Arendsen Hein
ccfa414386 help: new SHA-1 fingerprint of hg.intevation.org in hostfingerprints example
The certificate was updated in March 2012.
You can verify the certificate by using the Root CA certificate downloadable
from https://ssl.intevation.de/
The intermediate CA is sent by https://hg.intevation.org/
2013-02-28 21:34:44 +01:00
Mads Kiilerich
00a100f5a5 merge with stable 2013-02-28 14:51:59 +01:00
Matt Mackall
6a8972ec32 merge with crew 2013-02-22 13:46:54 -06:00
Matt Mackall
b88b659df4 templater: properly handle file_copies with % 2013-02-22 13:45:46 -06:00
Bryan O'Sullivan
1f74847761 localrepo: iterate over manifest key/value pairs in status
This saves us a couple of dict lookups in the common case, and improves
the performance of the status method by 5% (measured with util.timed)
in a repo with a large manifest.
2013-02-22 10:05:22 -08:00
Bryan O'Sullivan
905d64bf45 match: more accurately report when we're always going to match
This improves the performance of log --patch and --stat by about
20% for moderately large manifests (e.g. mozilla-central) for the
common case of no -I/-X patterns.
2013-02-21 12:55:39 -08:00
Kevin Bullock
66cb0bab34 scmutil: fix NameError on windows
Forgot to import util in mercurial.scmwindows. Error was introduced in:

changeset:   18862:bf7bac95e297
user:        Kevin Bullock <kbullock@ringworld.org>
date:        Tue Feb 12 11:36:21 2013 -0600
summary:     scmutil: split platform-specific bits into their own modules
2013-02-21 13:16:02 -06:00
Bryan O'Sullivan
b87176491b commands: exit from the log loop at the right time
Previously, we'd run the iterator one more time than necessary,
potentially doing a lot of extra work in the process.
2013-02-20 11:31:41 -08:00
Bryan O'Sullivan
e37e16da0f cmdutil: use a small initial window with --limit
In a large repo, running a command like "log -l1 -p" was expensive because
it would always traverse 8 commits, as 8 was the initial window size.

We now choose the lesser of 8 or the limit, speeding up the "log -l1 -p"
case by a factor of 5.
2013-02-20 11:31:38 -08:00
Bryan O'Sullivan
0aa6f05307 worker: handle worker failures more aggressively
We now wait for worker processes in a separate thread, so that we can
spot failures in a timely way, wihout waiting for the progress pipe
to drain.

If a worker fails, we recover the pre-parallel-update behaviour of
failing early by killing its peers before propagating the failure.
2013-02-20 11:31:34 -08:00
Bryan O'Sullivan
0da2636c99 worker: fix a race in SIGINT handling
This is almost impossible to trigger due to the tiny time window involved.
2013-02-20 11:31:31 -08:00
Bryan O'Sullivan
9f53401ffd worker: on error, exit similarly to the first failing worker
Previously, if a worker failed, we exited with status 1. We now exit
with the correct exit code (killing ourselves if necessary).
2013-02-20 11:31:27 -08:00
Kevin Bullock
d93d5152ce merge with stable 2013-02-19 13:35:39 -06:00
Matt Mackall
4b3c7a1260 merge with stable 2013-02-18 13:21:27 -06:00
Matt Mackall
8091c8a1c3 httppeer: improve protocol check
Pre-0.6c hgweb used text/plain for protocol responses. This meant
that a web server could serve a static file and confuse a client into
generating a nasty traceback.

Now we insist that text/plain protocol responses not include a
Content-Length, which older hgweb didn't generate but will typically
be produced for static files.
2013-02-17 14:34:53 -06:00
Matt Mackall
a4ec314909 httppeer: avoid large dumps when we don't see an hgweb repo
When we don't get an hgweb protocol response, we dump the response to
the user for diagnostic purposes (it might be a cgitb message, for
instance).

But if we try to clone a bundle, we don't want to show the
entire bundle in the error message. Also, we don't want fetch the
full bundle multiple times during fallback. So we only fetch 1k here.
2013-02-17 14:41:31 -06:00
Simon Heimberg
e0c976111f dispatch: also a separate warning message on aliases with --config
As mentioned in bug 2043, --config is also not supported in an alias. So report
this the same way as the other "early" options.

Example with alias.broken = stat --config a.config=1

Before:
  $ hg broken
  abort: Option --config may not be abbreviated!

After:
  $ hg broken
  error in definition for alias 'broken': --config may only be given on the command line
2013-02-12 22:15:31 +01:00
Kevin Bullock
f74ef64c15 extensions: remove erroneous comment
We actually -do- use the 'ui' argument to print a debug statement.
2013-02-14 13:56:02 -06:00
Durham Goode
7b7c4c6333 blackbox: do not translate the log messages
User 'timeless' in irc mentioned that having the blackbox be
translated would result in logs that:

- may be mixed language, if multiple users use the same repo
- are not google searchable (since searching for english gives more
  results)
- might not be readable by an admin if the employee is using hg in
  his native language

And therefore we should log everything in english.
2013-02-13 12:51:30 -08:00
Kevin Bullock
d24c25031a scmutil: split platform-specific bits into their own modules
This parallels what's done for the util module, which imports either
mercurial.posix or mercurial.windows as 'platform' and then slurps the
appropriate functions into its own namespace.
2013-02-12 11:36:21 -06:00
Kevin Bullock
1ada567a36 backout: call cmdutil.commit directly instead of commands.commit
This cleans up the messiness of having one command call another, and
makes the backout command robust against changes to the commit command.
2013-02-12 16:36:44 +00:00
Kevin Bullock
6f2a9a513a commit: factor out status printing into a helper function
We create a new function commitstatus() in cmdutil that handles printing
the status message(s) after a commit. This will allow other commit-like
commands to use it, and in particular is step 2 towards removing
backout's call to commands.commit.
2013-02-12 16:32:14 +00:00
Kevin Bullock
cdcb425321 backout: remove unnecessary dict copy
This is step 1 to remove backout's call to commands.commit. We don't use
the options again anywhere below except for backout's own purposes,
specifically choosing a merge tool, so we just write the commit options
in directly.
2013-02-12 16:05:00 +00:00
Kevin Bullock
86981724b1 backout: remove unnecessary frobbing of addremove option
There's no way for addremove to show up in backout's opts dictionary. It
was being set manually because cmdutil.commit expected it to be there
(and would throw an exception if it wasn't). This was fixed waaaaaaay
back in:

changeset:   5829:e05e83ad9d2b
user:        Kirill Smelkov <kirr@mns.spb.ru>
date:        Thu Jan 10 12:07:18 2008 +0300
summary:     cmdutil.commit: extract 'addremove' from opts carefully
2013-02-12 15:47:30 +00:00
Kevin Bullock
979acf9af6 backout: use cmdutil.revert directly instead of commands.revert
Before this change, backout would explicitly set the options it passed
to commands.revert in order to fall thru most of its logic and call
cmdutil.revert. This change makes it clearer what backup is trying to
accomplish and makes it robust against changes to the revert command.
2013-02-12 15:07:17 +00:00
Bryan O'Sullivan
9b9339ed49 util: make ensuredirs safer against races 2013-02-13 12:20:10 -08:00
Durham Goode
e35379ebe6 blackbox: only show new heads on incoming
The blackbox was logging every head after every incoming group.
Now we only log the heads that have changed.

Added a test.  Moved the hooks test to the bottom of the file since
the hooks interfer with the tests after it.
2013-02-13 11:07:01 -08:00
Durham Goode
484931bacf blackbox: log incoming changes via ui.log()
Logs incoming changes to a repo to ui.log(). Includes the number of changes
and the hashes of the heads after the new changes.

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: cb9a9f314b8b

Currently the blackbox logs the unix user that is performing the push/pull.
It would be nice to log the http authorized user as well so it works with
hgweb, but that's outside the scope of this commit.
2013-02-09 09:04:48 -08:00
Durham Goode
86c94b36d9 blackbox: logs python and extension hooks via ui.log()
Logs python and extension hooks to ui.log() for viewing in the blackbox.

Example log lines:
2013/02/09 08:35:19 durham> pythonhook-preupdate: hgext.eol.preupdate finished in 0.01 seconds
2013/02/09 08:35:19 durham> exthook-update: echo hooked finished in 0.02 seconds
2013-02-09 09:04:32 -08:00
Durham Goode
49b2c47b06 blackbox: log the commands that are run
Uses ui.log to log which commands are run, their exit code, the time taken,
and any unhandled exceptions thrown.

Example log lines:
2013/02/09 08:35:19 durham> add foo
2013/02/09 08:35:19 durham> add exited 0 after 0.02 seconds

Updates the progress tests because they use a mocked time.time() which these
changes affect.
2013-02-09 09:04:14 -08:00
Durham Goode
4add84adea blackbox: adds a blackbox extension
Adds a blackbox extension that listens to ui.log() and writes the messages to
.hg/blackbox.log. Future commits will use ui.log() to log commands, unhandled
exceptions, incoming changes, and hooks.  The extension defaults to logging
everything, but can be configured via blackbox.track to only log certain events.
Log lines are of the format:  "date time user> message"

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: d84ced58aaa
2013-02-12 14:08:33 -08:00
Bryan O'Sullivan
ede7482a3a scmutil: create directories in a race-safe way during update
With the new parallel update code, it is possible for multiple
workers to try to create a hierarchy of directories at the same
time. This is hard to trigger in general, but most likely during
initial checkout.

To deal with these races, we introduce a new ensuredirs function
whose contract is to ensure that a directory hierarchy exists - it
will ignore a failure that implies that the desired directory already
exists.
2013-02-11 16:15:12 -08:00
Bryan O'Sullivan
e5c9237feb Merge 2013-02-11 14:50:54 -08:00
Thomas Arendsen Hein
dddbcf14eb merge with crew-stable 2013-02-11 16:57:46 +01:00
Kevin Bullock
d86fa541fd import: don't rollback on failed import --exact (issue3616)
The checkexact() helper function was calling repo.rollback() from inside
an open transaction. In addition to being insane, this is unnecessary
because import will release the transaction on an exception.

It turns out that this has been broken since the feature was first
introduced, first released in v1.0:

changeset:   4263:3e8ce73e04cd
user:        Brendan Cully <brendan@kublai.com>
date:        Thu Mar 22 10:44:59 2007 -0700
files:       mercurial/commands.py mercurial/patch.py
description:
Add import --exact.
When this option is set, import will apply the patch (which must
be generated by export) to the parents specified in the patch,
and check that the node produced by the patch matches the node
ID in the patch.
2013-02-10 23:01:12 +00:00
Benoit Boissinot
431f8fbd16 merge crew and main 2013-02-11 01:21:24 +01:00
Benoit Boissinot
e6adbab04a merge crew and main 2013-02-11 01:17:50 +01:00
Siddharth Agarwal
ddf37d440b manifestmerge: fix order in which manifests are fetched
If the manifest of an earlier revision on the same delta chain is read before
that of a later revision, the revlog remembers that we parsed the earlier
revision and continues applying deltas from there onwards. If manifests are
parsed the other way round, we have to start over from the fulltext.

For a fresh clone of mozilla-central, updating from 29dd80c95b7d to its parent
aab96936a177 requires approximately 400 fewer zlib.decompress calls, which
results in a speedup from 1.10 seconds to 1.05.
2013-02-10 16:55:01 +00:00
Siddharth Agarwal
e15d936707 merge: run _forgetremoved after manifestmerge
_forgetremoved can trigger manifest construction, but we only want it to
happen after manifestmerge, so that our attempt to read the manifests in the
right order in an upcoming patch actually works.
2013-02-10 12:16:46 +00:00
Siddharth Agarwal
98fa475598 dirstate: disable gc while parsing the dirstate
This prevents a performance regression an upcoming patch would otherwise
introduce because it indirectly delays parsing the dirstate a bit.
2013-02-10 16:23:14 +00:00
Dan Villiom Podlaski Christiansen
50755dee9e hgweb: consistent author name width
Paper & coal use a sligtly shorter name length of 12em in the log view
than gitweb's 15em. Names too long for 12em is not entirely unheard
of, and hence increasing the length is appropriate; hgweb should
remain usable on 1024x768.
2013-02-10 13:14:31 +01:00
Durham Goode
5317973684 dirstate: fix generator/list error when using python 2.7
util.statfiles returns a generator on python 2.7 with c extensions disabled.
This caused util.statfiles(...) [0] to break in tests. Since we're only
stat'ing one file, I just changed it to call lstat directly.
2013-02-10 12:23:39 -08:00
Angel Ezquerra
4651989f9b extensions: obsolete and remove interhg extension
With the addition of the websub filter extension this extension is no longer
needed. We maintain a sort of backwards compatibility by reading the [interhg]
section and using it as we would use the [websub] section.
2013-02-09 11:00:42 +01:00
Angel Ezquerra
e25f843231 hgweb: apply the websub filter to revision descriptions
In order to use this, add a [websub] section to your configuration and add
websub expressions such as:

italic = s/\b_(\S+)_\b/<i>\1<\/i>/
bold = s/\*\b(\S+)\b\*/<b>\1<\/b>/
issues = s|issue(\d+)|<a href="http://bts.example.org/issue\1">issue\1</a>|i
bugzilla = s!((?:bug|b=|(?=#?\d{4,}))(?:\s*#?)(\d+))!<a href="http://bz.selenic.com/\2">\1</a>!i

This also adds documentation (proofed by Kevin!) to the config help section.
2013-02-09 16:48:21 +01:00
Mads Kiilerich
ef317883c7 export: show 'Date' header in a format that also is readable for humans
'export' is the official export format and used by patchbomb, but it would only
show date as a timestamp that most humans might find it hard to relate to. It
would be very convenient when reviewing a patch to be able to see what
timestamp the patch will end up with.

Mercurial has always used util.parsedate for parsing these headers. It can
handle 'all' date formats, so we could just as well use a readable one.

'export' will now use the format used by 'log' - which is the format described
as 'Unix date format' in the templating help. We assume that all parsers of '#
HG changeset patch'es can handle that.
2013-02-08 22:54:17 +01:00
Angel Ezquerra
ed79324ad4 hgweb: add websub template filter
The purpose of this new filter is to make it possible to partially replace the
functionality of the interhg extension. The idea is to be able to define regular
expression based substitutions on a new "websub" config section. hgweb will then
be able to apply these substitutions wherever the "websub" filter is used on a
template.

This first revision just adds the code necessary to load the websub expressions
and adds the websub filter, but it does not add any calls to the websub filter
itself on any of the templates. That will be done on the following revisions.
2013-02-08 18:05:32 +01:00
David Schleimer
1dc36ff74c commit: factor out post-commit cleanup into workingctx
This pulls some of the logic for the cleanup that needs to happen
after a commit has been made otu of localrepo.commit and into
workingctx.  This is part of a larger refactoring effort that will
eventually allow us to perform some types of merges in-memory.
2013-02-08 05:36:08 -08:00
David Schleimer
21ed11fec2 localrepo: use workingctx for validation in commit
This changes localrepo.commit to use the workingctx it creates form
the munged output of localrepo.status while running some precommit
validation.  Specifically, it uses functions that were already present
on the workingctx.  I believe this is a net readabilty improvement,
and that this makes these lines consistent with the refactoring in a
subsequent patch that pulls some of the validation logic into
workingctx so that it can be reused elsewhere.
2013-02-08 05:36:08 -08:00
David Schleimer
6086bc3471 localrepo: create context used for actual commit earlier
localrepo.commit creates a workingctx, calls self.status, does some
munging on the changes status returns, does some validation on those
changes, and then creates a new workingctx from the changes.  This
moves the creation of the new workginctx ahead of some validation,
with the intention of refactoring some of that validation logic into
the workingctx, so that it can be reused elsewhere.
2013-02-08 05:36:07 -08:00
Durham Goode
89fa09c11d addremove: don't audit the path for paths already in the dirstate
Now that dirstate.walk returns None for paths under symlink directories,
addremove doesn't need to validate each path it sees to look for files
under symlinks.

On a large repository this brings addremove from 6.3 seconds down to 3.65 (42%)
since addremove no longer has to stat every directory of every file to determine
if the file is inside a symlink directory. I put it through our benchmark and
see no perf hit to any other commands.
2013-02-05 14:36:19 -08:00
Durham Goode
b4e95fed5e dirstate: walk returns None for files that have a symlink in their path
Previously dirstate.walk would return a stat object for files in the dmap
that have a symlink to a directory in their path.  Now it will return None
to indicate that they are no longer considered part of the repository. This
currently only affects walks that traverse the entire directory tree (ex:
hg status) and not walks that only list the contents of the dmap (ex: hg diff).

In a situation like this:
  mkdir foo && touch foo/a && hg commit -Am "a"
  mv foo bar
  ln -s bar foo

'hg status' will now show '! foo/a', whereas before it incorrectly considered
'foo/a' to be unchanged.

In addition to making 'hg status' report the correct information, this will
allow callers to dirstate.walk to not have to detect symlinks themselves,
which can be very expensive.
2013-02-04 14:27:15 -08:00
Durham Goode
2aa5fd3151 pathauditor: add check() method
The pathauditor currently throws exceptions when it encounters an invalid
path. This change adds a method to allow people to treat it as a boolean.
This is currently used by scmutil.addremove and in a subsequent patch it
will be used by dirstate.walk
2013-02-05 14:24:14 -08:00
Matt Mackall
2f3cd110be summary: add missing space for updated active bookmark display 2013-02-09 22:54:34 +00:00
Kevin Bullock
fe0a5f965c summary: show active bookmark even if not at current changeset
Before this change, 'hg summary' would not show the active bookmark
unless it pointed to the working directory parent. After this change, it
will show it in parentheses, like so:

parent: 18581:f0ff45fe6700 tip
 summary: simplify handling of active bookmark
branch: default
bookmarks: [crew]
commit: (clean)
update: (current)
2013-02-08 21:47:22 +00:00
Kevin Bullock
9d31a18963 summary: simplify handling of active bookmark 2013-01-27 11:53:46 -06:00
Pierre-Yves David
306badf4c6 outgoing: fix possible filtering crash in outgoing (issue3814)
If there is no outgoiing changesets but we have filtered revision in outgoing.excluded
We run into a filtering related crash. The excluded revision should not be there
in the first place but discovery need cleanup in default, not stable.
2013-02-09 17:54:01 +00:00
Augie Fackler
e8c901fc2d parsedate: understand "now" as a shortcut for the current time 2013-02-09 15:39:22 -06:00
Augie Fackler
8671b3e731 export: clobber files with -o (bc) (issue3652)
This violated user expectation. Updated the code to clobber files, but
preserve the behavior of appending multiple patches requested in a
single export. Includes tests.
2013-02-09 15:38:57 -06:00
Bryan O'Sullivan
88fa66b36f merge: don't call copies.mergecopies unless we need to
This reduces the amount of time we spend calculating when doing a clean
non-merge update. In a large repo, the time dropped from 10.1 seconds
to 3.4.
2013-02-09 21:24:36 +00:00
Bryan O'Sullivan
f7ffd2b365 merge: rename p1 to wctx in manifestmerge
This is always a workingctx, and this name is more in line with other
functions in this module.
2013-02-09 21:24:24 +00:00
Siddharth Agarwal
52f9cd4b20 manifestmerge: handle abort on local unknown, remote created files
This replaces the _checkunknown call in calculateupdates with a more
performant version. On a repository with over 150,000 files, this speeds up an
update by 0.6-0.8 seconds, which is up to 25%.

This does not introduce any UI changes. There is existing test coverage for
every case, mostly in test-merge*.t.
2013-02-09 15:36:00 +00:00
Siddharth Agarwal
ace5cac25b manifestmerge: pass in branchmerge and force separately
This will be used in an upcoming patch.
2013-02-08 15:23:23 +00:00
Siddharth Agarwal
d7fd97bac5 manifest: use a size 3 LRU cache to store parsed manifests
Previously, the manifest cache would store the last manifest parsed. We could
run into situations with operations like update where we would try parsing the
manifest for a revision r1, then r2, then r1 again. This increases the cache
size to 3 to avoid that bit of performance fragility.
2013-02-09 15:43:02 +00:00
Siddharth Agarwal
b13982495e util: add an LRU cache dict
In certain cases we would like to have a cache of the last N results of a
given computation, where N is small. This will be used in an upcoming patch to
increase the size of the manifest cache from 1 to 3.
2013-02-09 15:41:46 +00:00
Augie Fackler
010dfef31a byterange: remove now-unused sys import 2013-02-09 07:44:22 -06:00
Augie Fackler
f03df466e2 changelog: hexlify node when throwing a LookupError on a filtered node
The non-hexlified node was leaking all the way out to the web
interface, and wasn't consistent with the behavior for nonexistent
nodes.
2013-02-09 06:07:32 -06:00
Augie Fackler
bdb75bb2c5 byterange: remove old two-arg raise trick
We don't care about the original traceback, and this was frustrating
any efforts to make the code work on Python 3.3.
2013-02-08 17:14:12 -06:00
Benoit Boissinot
41300c28e0 revlog: document v0 format 2013-02-09 12:08:02 +01:00
Benoit Boissinot
077bafacf4 templater: add get() function to access dict element (e.g. extra) 2013-02-08 23:49:14 +01:00
Benoit Boissinot
b38415dcd7 templates: export extra as a dict to templates
Currently only useful with the json filter.
2013-02-08 21:55:46 +01:00
Kevin Bullock
a386213f4a merge with stable 2013-02-08 14:26:00 +00:00
Mads Kiilerich
e4f8deae3f hgweb: simplify internal staticfile return codes 2013-02-10 18:24:29 +01:00
Mads Kiilerich
5787baee50 spelling: fix some minor issues found by spell checker 2013-02-10 18:24:29 +01:00
Mads Kiilerich
2aa6f19508 bundlerepo: replace basemap with the base field in the index
Bundle revisions had some info in their fake revlog intries and some info in a
dict with all the bundle revisions. This dict was used to get the stored data
and to distinguish repo revisions from bundle revisions.

Real repo revisions and bundle revisions will now be distinguished by comparing
with the tip revision of the original repo. This reintroduces something similar
to disktiprev which was unused and removed in 822a1e6e3d7b and let that replace
the O(reposize) dict.
2013-02-08 23:26:00 +01:00
Mads Kiilerich
dcbf8a9bfc profiling: replace '+' markup of nested lines with indentation
The display of nested lines for hg --profile was very non-obvious and made it
look like sort didn't work.

The '+' immediately before CallCount was not related to the CallCount and did
not mean plus in any integer sense.

The '+' before module looked like a part of the module name and not like ascii
art.

Instead we now indent the subordinate module names to clearly show the
structure.
2013-02-08 22:54:48 +01:00
Augie Fackler
f53ce130e2 Merge crew and main. 2013-02-10 04:04:22 -06:00
Bryan O'Sullivan
7bc15afd4e merge: don't fiddle with name lookups or i18n in hot loops
We perform attribute dereferences and i18n lookups before looping.
2013-02-09 15:51:32 -08:00
Bryan O'Sullivan
9f400d1ba0 merge: apply non-interactive working dir updates in parallel
This has a big effect on the performance of working dir updates.

Here are the results of update from null to the given rev in several
repos, on a Linux 3.2 system with 32 cores running ext4, with the progress
extension enabled.

repo             rev           plain  parallel   speedup
hg               76a842fb67cc    0.9       0.3       3
mozilla-central  fe1600b22c77   42.8       7.7       5.5
linux-2.6        9ef4b770e069   31.4       4.9       6.4
2013-02-09 15:51:32 -08:00
Bryan O'Sullivan
5d849a878a worker: allow a function to be run in multiple worker processes
If we estimate that it will be worth the cost, we run the function in
multiple processes. Otherwise, we run it in-process.

Children report progress to the parent through a pipe.

Not yet implemented on Windows.
2013-02-09 15:51:32 -08:00
Bryan O'Sullivan
8ef1da44b3 worker: partition a list (of tasks) into equal-sized chunks 2013-02-09 15:51:32 -08:00
Bryan O'Sullivan
998baaf4d8 worker: estimate whether it's worth running a task in parallel
Not implemented for Windows yet.
2013-02-09 15:51:26 -08:00
Bryan O'Sullivan
46bf2f5a6f worker: count the number of CPUs
This works on the major platforms, and falls back to a safe guess of
1 elsewhere.
2013-02-09 15:22:12 -08:00
Bryan O'Sullivan
614bf1f422 merge: report non-interactive progress in chunks
Instead of a monotonic count, getupdates yields the number of files it
has updated since it last reported, and its caller sums the numbers when
updating progress.

Once we run these updates in parallel, this will allow worker processes
to report progress less often, reducing overhead.
2013-02-09 15:22:09 -08:00
Bryan O'Sullivan
a4f361dc0f merge: handle subrepo merges and .hgsubstate specially
In an upcoming patch, we will update .hgsubstate in a non-interactive
worker process. Merges of subrepo contents will still need to occur in the
master process (since they may be interactive), so we move that code into
a place where it will always run in what will become the master process.
2013-02-09 15:22:08 -08:00
Bryan O'Sullivan
5278db7f07 merge: split out mostly-non-interactive working dir updates
In a later patch, we'll run these updates in parallel.
2013-02-09 15:21:58 -08:00
Siddharth Agarwal
9334236621 dirstate: move pure python dirstate packing to pure/parsers.py 2013-01-17 23:46:08 -08:00
Durham Goode
fe6e42c6ab bookmark: don't allow integers as bookmark/branch/tag names
Bookmarks/branches/tags shouldn't be allowed to be integers because that
overlaps with revision numbers.  Right now if a user created one they can't
use it anyway because the revision numbers take precedence.

The check only happens when creating a new bookmark/etc from a command so it
shouldn't affect existing bookmarks/branches/tags or importing branches from
git.

This fix was prompted by us having a user create a bookmark named "404" then
accidentally checkout a very old version of our repository.
2013-02-05 16:22:53 -08:00
Matt Mackall
f4f7c447ad merge with stable 2013-02-06 14:43:29 -06:00
Durham Goode
4d8644ea85 addremove: don't perform m.exact/rel until needed
Moves the m.exact and m.rel calls within the conditionals they are used in.
On a large repo this brings addremove from 7.1 seconds down to 6.3 (13%).
2013-02-04 14:10:09 -08:00
Durham Goode
633431ef38 addremove: don't call lexists, isdir, and islink
The dirstate walk results contain the stat information for each path, so we
don't need to query it again.  On a large repo this makes addremove go from
8.35 seconds to 7.1 (15%).
2013-02-04 14:06:20 -08:00
Durham Goode
74fdcdca03 addremove: only query dirstate once per path
Previously the addremove code queried the dirstate 4 times per path. Now it
only does so once.  On a large repo this brings addremove from 9.5 seconds
to 8.35 seconds (12%).
2013-02-04 14:01:40 -08:00
Matt Mackall
e3c59d236d merge with stable 2013-02-04 16:39:02 -06:00
Matt Mackall
15bc341744 bdiff: simplify overflow checks
Rather than check that each delta start, end, and length is within 32
bits, we simply check that the input strings are under 4GB.
2013-02-02 16:15:22 -06:00
Mads Kiilerich
a13d45eee6 profiling: introduce limit configuration option
The number of output lines was hardcoded to 30.

There was a 'nested' configuration options that controlled something else
related to counting the number of output lines.

This introduces the profiling.limit configuration option for controlling the
number of profiling output to show.
2013-02-04 02:46:53 +01:00
Mads Kiilerich
4310c010e8 merge: inline act()
The act function had become very trivial and mainly shuffled arguments around
and made it harder to see what really was going on.
2013-02-04 02:46:53 +01:00
Mads Kiilerich
2ec21b22f5 merge: don't indent "local changed %s which remote deleted" prompt
It was usually not shown in a context where indentation helped readability and
it was inconsistent with other prompts.
2013-02-04 02:46:53 +01:00
Mads Kiilerich
c2bd1c416f merge: backout manifest sorting and workarounds for cost of it
Backout f6ac62c2cfa7 and 14f4258e3526 which no longer are needed.
2013-02-04 02:46:38 +01:00
Mads Kiilerich
ee476759ff merge: delay debug messages for merge actions
Show messages at a point where the actions have been sorted, thus preparing for
backout of 14f4258e3526.

This makes manifestmerge more of a silent operation, just like 'copies' is.

Indent 'preserving' messages to make them subordinate to the action logging so
they fit in the new context. (The 'preserving' messages are quite redundant and
could also be removed completely.)
2013-01-24 23:57:44 +01:00
Mads Kiilerich
3da557a087 merge: make all action tuples have the same length - keep args as tuple 2013-01-24 23:57:44 +01:00
Mads Kiilerich
e4cb2af2e8 merge: delay prompts a bit and show them in (extra) sorted order
Preparing for backout of 14f4258e3526.

The number of prompts will for all relevant cases be significantly smaller than
the total number of files in the manifests. We can thus afford to sort the
prompts more than we can afford to sort the manifests.
2013-01-24 23:57:44 +01:00
Antonio Zanardo
a6143a0b42 commit: show active bookmark in commit editor helper text
If there is an active bookmark while committing, the bookmark name
will be visible inside the commit message helper, below the branch
name.

This should make easier for the user to detect a mistaken commit
parent, while working for example with a bookmark centric workflow
like topic branches.

The active bookmark is checked to be in the working directory, as
pointed by Kevin Bullock, because otherwise committing would not
advance it. In other words, this would not show the active
bookmark name if the user changed the working tree parents with
'hg debugsetparents', for example.
2013-02-02 15:37:17 -02:00
Paul Cavallaro
a9ed690f88 dates: support 'today' and 'yesterday' in parsedate (issue3764)
Adding support to parsedate in util module to understand the more idiomatic
dates 'today' and 'yesterday'.

Added unified tests and docstring tests for added functionality.
2013-01-23 09:51:45 -08:00
Paul Cavallaro
4a3134830c revset: change ancestor to accept 0 or more arguments (issue3750)
Change ancestor to accept 0 or more arguments. The greatest common ancestor of a
single changeset is that changeset. If passed no arguments, the empty list is
returned.
2013-01-28 12:19:21 -08:00
Augie Fackler
34ec9a8cb4 hg: replace DirCleanup class with normal try/finally use 2012-10-05 18:10:56 -05:00
Bryan O'Sullivan
c4e1eeb2a3 store: switch to C-based hashed path encoding 2012-12-12 13:09:37 -08:00
Bryan O'Sullivan
561ba86d03 pathencode: implement both basic and hashed encoding in C 2012-12-12 13:09:36 -08:00
Bryan O'Sullivan
0914e7afb6 pathencode: implement hashed encoding in C
This will be used by an upcoming patch.
2012-12-12 13:09:36 -08:00
Bryan O'Sullivan
e632a0600d pathencode: implement the "mangling" part of hashed encoding in C
This will be used by an upcoming patch.
2012-12-12 13:09:35 -08:00
Bryan O'Sullivan
480e769e36 pathencode: add a SHA-1 hash function
This will be used by an upcoming patch.

This calls out to the Python hash implementation.

An earlier version of this function implemented SHA-1 directly, but
the amount of extra code didn't seem like a good tradeoff compared
to the small big-picture increase in performance (long paths are
uncommon).
2012-12-12 13:09:34 -08:00
Bryan O'Sullivan
dea2c50032 store: implement lowerencode in C 2012-12-12 13:09:33 -08:00
Pierre-Yves David
64c0cafb9c hgweb: run with "served" filter
This changeset enable the "served" filter on all repo used by hgweb.

Hgweb misbehave in a lot of when filtering changeset are present but I do not
expect normal people to have secret or obsolete changeset on they server.
Misbehavior will be gradually fixed later.
2013-01-15 22:34:56 +01:00
Pierre-Yves David
afe0e7e52e hgweb: walk the graph through the changelog
This is necessary to enforce filtering. The result is a bit buggy (may provide
less changeset than expected, but it will stop crashing on filtered revision
access.

Note that changelog.revs can not represents empty iteration like xrange did. So
we have to explicitly prevent call when there is nothing to do.
2013-01-16 14:22:43 +01:00
Pierre-Yves David
fecb76e6b6 hgweb: use changelog for iteration
Iterating through changelog is  necessary to enforce filtering.
2013-01-11 01:08:00 +01:00
Pierre-Yves David
33157b2eac hgweb: ignore filtered revision in revnav
This changeset checks that a revision is known before adding it to the
navigation.

This will prevent traceback on filtered repository. This changeset result in an
incorrect behaviors, Navigation link may be dropped without any replacement.
However this bad navigation generation is much better than a crash
2013-01-16 14:19:28 +01:00