Commit Graph

25421 Commits

Author SHA1 Message Date
Anton Shestakov
d76c5b8c5a hgweb: link to revision by node hash in paper & coal
Unlike other styles, paper and coal had only one link to current revision: in
the sidebar. Since those links now use symbolic revisions after 4b263b99440b,
it's nice to have a link that allows going from /rev/tip to /rev/<tip hash>,
for instance. Let's make the node hash in the page header that new link.
2015-06-18 17:06:18 +08:00
Anton Shestakov
fa79758539 hgweb: link to revision by node hash in gitweb & monoblue
This allows going from /rev/tip to /rev/<tip hash> with ease.
2015-06-18 16:14:10 +08:00
Matt Harbison
abed66c145 archive: report the node as "{p1node}+" when archiving a dirty wdir()
This is more useful than reporting all 'f's, allowing the archive to be diffed
against a specific revision to see what changed.
2015-06-16 23:14:45 -04:00
Pierre-Yves David
bc1afdedda phase: remove a 'for x in "foo bar".split()' idiom in phasecache.replace
I find this idiom fairly horrible.
2015-06-15 16:06:17 -07:00
Pierre-Yves David
9c488819f9 phase: document the replace method
This is a minor documentation update to answer a co-worker question.
2015-06-15 16:06:24 -07:00
Pierre-Yves David
d05c4e4635 revset: ensure we have loaded phases data in '_notpublic()'
If we are the very first rev access (or if the phase cache just got
invalidated) the phasesets will be None even if we support the native
computation. So we explicitly trigger a computation if needed.

This was not an issue before because requesting any phase information
would have triggered such computation.
2015-06-15 16:16:02 -07:00
Pierre-Yves David
32f3ec0b50 phase: rename getphaserevs to loadphaserevs
This function is:
- already loading the data in place,
- used once in the code.

So we drop the return value and change the name to make this obvious. We keep
the function public because we'll have to use it in revset.
2015-06-15 16:04:14 -07:00
Matt Harbison
0c2a919db5 test-subrepo-recursion: more aggressively regex 'unzip -l' output for 10.10
The output on 10.10 looks like this:

    Length     Date   Time    Name
   --------    ----   ----    ----
        172  01-01-80 00:00   .hg_archival.txt
         10  01-01-80 00:00   .hgsub
         45  01-01-80 00:00   .hgsubstate
          3  01-01-80 00:00   x.txt
         10  01-01-80 00:00   foo/.hgsub
         45  01-01-80 00:00   foo/.hgsubstate
          9  01-01-80 00:00   foo/y.txt
          9  01-01-80 00:00   foo/bar/z.txt
   --------                   -------
        303                   8 files

(2 digit year, shorter -- separators and closer columns).  We don't care about
any of that, so ignore it.
2015-06-17 16:45:25 -04:00
Pierre-Yves David
916b1666b3 contrib: introduce an all-revsets.txt file
This file should gather all revsets ever thought interesting by
anyone. That way one can check the impact of a change when touching
something revset-ish. See inline comments for details.

This file have been refilled with all the entry I could automatically
find from changeset descriptions. I assume we missed some not using
'revsetbenchmarks.py' output.
2015-06-16 22:15:30 -07:00
Pierre-Yves David
e4f090319c contrib: rename revsetbenchmarks.txt to 'base-revsets.txt'
We rename the file and document its purpose. We'll be introducing another file
gathering revsets useful for benchmark of the predicate themsleves in a coming
changesets.
2015-06-16 20:36:00 -07:00
Pierre-Yves David
254ba0361d revsetbenchmarks: add main documention for the script
This allow us to document the fact we can use comment in the file listing revsets.
2015-06-16 20:24:37 -07:00
Anton Shestakov
eb4bfc238e hgweb: don't dereference symbolic revision in paper & coal style (issue2296)
Let's make paper (and coal, since it borrows so much from paper) templates use
symbolic revision in navigation links.

The majority of links (log, filelog, annotate, etc) still use node hashes.

Some pages don't have permanent links to current node hash (so it's not very
easy to go from /rev/tip to /rev/<tip hash>), this will be addressed in future
patches.
2015-06-16 16:07:39 +08:00
Anton Shestakov
1ae5a3b17f hgweb: don't dereference symbolic revision in gitweb style
Let's make gitweb templates use symbolic revision in navigation links.

The majority of links (log, filelog, annotate, etc) still use node hashes.

Some pages don't have permanent links to current node hash (so it's not very
easy to go from /rev/tip to /rev/<tip hash>), this will be addressed in future
patches.
2015-06-16 14:37:53 +08:00
Anton Shestakov
8daea28f61 hgweb: don't dereference symbolic revision in monoblue style
Let's make monoblue templates use symbolic revision in navigation links.

The majority of links (log, filelog, annotate, etc) still use node hashes.

Some pages don't have permanent links to current node hash (so it's not very
easy to go from /rev/tip to /rev/<tip hash>), this will be addressed in future
patches.
2015-06-16 13:59:49 +08:00
Anton Shestakov
781227ef89 hgweb: don't dereference symbolic revision in spartan style
Let's make spartan templates use symbolic revision in navigation links.

The majority of links (log, filelog, annotate, etc) still use node hashes, and
many pages also have permanent link to current node hash (i.e. you can go from
/rev/tip to /rev/<tip hash> without manual url editing), so it's safe to
update navigation.
2015-06-16 11:52:10 +08:00
Anton Shestakov
90c74a4812 hgweb: provide symrev (symbolic revision) property to the templates
One of the features of hgweb is that current position in repo history is
remembered between separate requests. That is, links from /rev/<node_hash> lead
to /file/<node_hash> or /log/<node_hash>, so it's easy to dig deep into the
history. However, such links could only use node hashes and local revision
numbers, so while staying at one exact revision is easy, staying on top of the
changes is not, because hashes presumably can't change (local revision numbers
can, but probably not in a way you'd find useful for navigating).

So while you could use 'tip' or 'default' in a url, links on that page would be
permanent. This is not always desired (think /rev/tip or /graph/stable or
/log/@) and is sometimes just confusing (i.e. /log/<not the tip hash>, when
recent history is not displayed). And if user changed url deliberately to say
default instead of <some node hash>, the page ignores that fact and uses node
hash in its links, which means that navigation is, in a way, broken.

This new property, symrev, is used for storing current revision the way it was
specified, so then templates can use it in links and thus "not dereference" the
symbolic revision. It is an additional way to produce links, so not every link
needs to drop {node|short} in favor of {symrev}, many will still use node hash
(log and filelog entries, annotate lines, etc).

Some pages (e.g. summary, tags) always use the tip changeset for their context,
in such cases symrev is set to 'tip'. This is needed in case the pages want to
provide archive links.

highlight extension needs to be updated, since _filerevision now takes an
additional positional argument (signature "web, req, tmpl" is used by most of
webcommands.py functions).

More references to symbolic revisions and related gripes: issue2296, issue2826,
issue3594, issue3634.
2015-06-16 02:07:25 +08:00
Matt Harbison
0dc20be5d4 archive: support 'wdir()'
This is a step toward replacing the extdiff internals with archive, in order to
support 'extdiff -S'.  Only Mercurial subrepos are supported for now.

If a file is missing from the filesystem, it is silently skipped.  Perhaps it
should warn, but it cannot abort when working with extdiff because deleting a
file is a legitimate diff.
2015-06-16 23:06:57 -04:00
Matt Harbison
ba46b0e533 subrepo: allow a representation of the working directory subrepo
Some code cannot handle a subrepo based on the working directory (e.g.
sub.dirty()), so the caller must opt in.  This will be useful for archive, and
perhaps some other commands.  The git and svn methods where this is used may
need to be fixed up on a case by case basis.
2015-06-16 23:03:36 -04:00
Yuya Nishihara
83ca04362c templater: comment that gettemplate() has different name resolution order
I've tried to unify gettemplate() with buildtemplate(), but it didn't go well
because gettemplate() have to bypass mapping dict.

For example, web templates have '{tags%changelogtag}' and 'changelogtag' is
defined in both mapping, the default, and context.cache, sourced from map file.
In general, mapping shadows context variables, but gettemplate() have to pick
it from context.cache.
2015-06-16 22:13:19 +09:00
Yuya Nishihara
224d7d3d20 templater: drop strtoken argument from compiletemplate()
There's no "rawstring" template now.
2015-06-13 20:23:52 +09:00
Yuya Nishihara
7be294a6b8 templater: do not reevaluate rawstring as template (BC)
The previous patch made 'string' is always interpreted as a template. So
this patch removes the special handling of r'rawstring' instead. Now r''
disables template processing at all.
2015-06-10 21:44:43 +09:00
Yuya Nishihara
d95129ee92 templater: take any string literals as template, but not for rawstring (BC)
This patch series is intended to unify the interpretation of string literals.
It is breaking change that boldly assumes

 a. string literal "..." never contains template-like fragment or it is
    intended to be a template
 b. we tend to use raw string literal r"..." for regexp pattern in which "{"
    should have different meaning

Currently, we don't have a comprehensible rule how string literals are
evaluated in template functions. For example, fill() takes "initialindent"
and "hangindent" as templates, but not for "text", whereas "text" is a
template in pad() function.

  date(date, fmt)
  diff(includepattern, excludepattern)
  fill(text, width, initialident: T, hangindent: T)
  get(dict, key)
  if(expr, then: T, else: T)
  ifcontains(search, thing, then: T, else: T)
  ifeq(expr1, expr2, then: T, else: T)
  indent(text, indentchars, firstline)
  join(list, sep)
  label(label: T, expr: T)
  pad(text: T, width, fillchar, right)
  revset(query, formatargs...])
  rstdoc(text, style)
  shortest(node, minlength)
  startswith(pattern, text)
  strip(text, chars)
  sub(pattern, replacement, expression: T)
  word(number, text, separator)
  expr % template: T

  T: interpret "string" or r"rawstring" as template

This patch series adjusts the rule as follows:

 a. string literal, '' or "", starts template processing (BC)
 b. raw string literal, r'' or r"", disables both \-escape and template
    processing (BC, done by subsequent patches)
 c. fragment not surrounded by {} is non-templated string

  "ccc{'aaa'}{r'bbb'}"
   ------------------  *: template
   ---                 c: string
        ---            a: template
                ---    b: rawstring

Because this can eliminate the compilation of template arguments from the
evaluation phase, "hg log -Tdefault" gets faster.

  % cd mozilla-central
  % LANG=C HGRCPATH=/dev/null hg log -Tdefault -r0:10000 --time > /dev/null
  before: real 4.870 secs (user 4.860+0.000 sys 0.010+0.000)
  after:  real 3.480 secs (user 3.440+0.000 sys 0.030+0.000)

Also, this will allow us to parse nested templates at once for better error
indication.
2015-06-13 19:49:54 +09:00
Yuya Nishihara
138acd70e8 templater: move runtemplate function out of buildmap/runmap pair
The next patch will introduce buildtemplate function that should be defined
near runtemplate. But I don't want to insert it between buildmap and runmap.
2015-06-13 00:15:22 +09:00
Pierre-Yves David
17d4d70d6d phase: also overwrite phase's sets when replacing a phasecache
We need to copy this new attributes around too. This fix an issue where phases
data used by 'not public()' were not invalidated properly.
2015-06-15 16:08:22 -07:00
Pierre-Yves David
9f292fb23c phase: invalidate the phase's set cache alongside the revs
Invalidate was leaving set data around leading to possible bugs in revset.
2015-06-15 15:57:47 -07:00
Pierre-Yves David
49dfe34926 phase: also copy phase's sets when copying phase cache
We forgot to add such copy when we added the attributes.
2015-06-15 15:52:52 -07:00
Matt Harbison
bf8d482cfd verify: check the subrepository references in .hgsubstate
While hopefully atypical, there are reasons that a subrepository revision can be
lost that aren't covered by corruption of the .hgsubstate revlog.  Such things
can happen when a subrepo is amended, stripped or simply isn't pulled from
upstream because the parent repo revision wasn't updated yet.  There's no way to
know if it is an error, but this will find potential problems sooner than when
some random revision is updated.

Until recently, convert made no attempt at rewriting the .hgsubstate file.  The
impetuous for this is to verify the conversion of some repositories, and this is
orders of magnitude faster than a bash script from 0..tip that does an
'hg update -C $rev'.  But it is equally useful to determine if everything has
been pulled down before taking a thumb drive on the go.

It feels somewhat wrong to leave this out of verifymod (mostly because the file
is already read in there, and the final summary is printed before the subrepos
are checked).  But verifymod looks very low level, so importing subrepo stuff
there seems more wrong.
2015-06-16 16:15:15 -04:00
Matt Harbison
a1b56b9f59 context: override workingctx.hex() to avoid a crash
Since node is None for workingctx, it can't use the base class
implementation of 'hex(self.node())'.

It doesn't appear that there are any current callers of this, but there will be
when archive supports 'wdir()'.  My first thought was to use "{p1node}+", but
that would cause headaches elsewhere [1].

We should probably fix up localrepository.__getitem__ to accept this hash for
consistency, as a followup.  This works, if the full hash is specified:

  @@ -480,7 +480,7 @@
           return dirstate.dirstate(self.vfs, self.ui, self.root, validate)

       def __getitem__(self, changeid):
  -        if changeid is None:
  +        if changeid is None or changeid == 'ff' * 20:
               return context.workingctx(self)
           if isinstance(changeid, slice):
               return [context.changectx(self, i)

That differs from null, where it will accept any number of 0s, as long as it
isn't ambiguous.


[1] https://www.selenic.com/pipermail/mercurial-devel/2015-June/071166.html
2015-06-14 22:04:17 -04:00
Matt Harbison
5776a99bfa convert: update 'intermediate-source' in the destination's extras dictionary 2015-06-15 16:50:31 -04:00
Yuya Nishihara
5ddbe8ee34 check-code: ban use of '[[ ]]' in tests 2015-06-16 23:06:30 +09:00
Yuya Nishihara
277b13b7cf test-fileset: remove bashism, use test instead of '[[ ]]'
Debian dash complains about it.

  $TESTTMP.sh: 213: $TESTTMP.sh: [[: not found
2015-06-16 22:47:05 +09:00
Anton Shestakov
b5b3409fee tests: test symbolic revision (de)reference in all hgweb styles
Right now the way revisions get specified in hgweb urls is ignored, i.e. after
revision is resolved, only its node hash (or sometimes local revision number)
is used for all links in the templates. So, basically, every page for "tip"
revision (or any other symbolic rev id) will dereference it: lose the nice
symbolic name by putting node hash/local rev number in its place. The only
exception so far is archive links on some pages: /archive/tip.{bz2,gz,zip}.

The fact that this dereferencing is neither convenient nor intuitive is
reflected in issue2296, issue2826 and issue3594. issue3634 also mentions this.
But to fix this it's first needed to demonstrate and test the way templates
currently form links.

The new test file is separate from other hgweb tests, since it seems big and
distinct enough. And it's so big because links are formed in each template
independently, so it's necessary to test them all to avoid any inconsistent
behavior.
2015-06-03 18:30:25 +08:00
Siddharth Agarwal
2da9583582 dirstate: use a presized dict for the dirstate
This uses a simple heuristic to avoid expensive resizes.

On a real-world repo with around 400,000 files, perfdirstate:

before: ! wall 0.155562 comb 0.160000 user 0.150000 sys 0.010000 (best of 64)
after:  ! wall 0.132638 comb 0.130000 user 0.120000 sys 0.010000 (best of 75)

On another real-world repo with around 250,000 files:

before: ! wall 0.098459 comb 0.100000 user 0.090000 sys 0.010000 (best of 100)
after:  ! wall 0.089084 comb 0.090000 user 0.080000 sys 0.010000 (best of 100)
2015-06-16 00:46:01 -07:00
Siddharth Agarwal
bba072811f parsers: add an API to create a new presized dict 2015-06-15 22:41:30 -07:00
Siddharth Agarwal
1be06bc8f4 parsers: factor out code to create a presized dict
In upcoming patches we'll expose this as an API.
2015-06-15 22:37:33 -07:00
Siddharth Agarwal
58df3405ad parsers: drop Python 2.4 compat in make_file_foldmap 2015-06-15 22:29:29 -07:00
Augie Fackler
200363343c progress: respect ui.quiet (issue4726)
Caught when I was running the hgsubversion testsuite and it started
printing progress bars over top of my test output lines.
2015-06-16 14:11:58 -04:00
Matt Mackall
a42ba8607a merge with stable 2015-06-15 13:31:22 -05:00
Yuya Nishihara
bd614aebda templater: evaluate arguments passed to diff() appropriately
Before this patch, diff() crashed by passing non-string expression because
it didn't evaluate arguments at all.
2015-06-13 20:14:22 +09:00
Gregory Szorc
2f52f24ede parsers: do not cache RevlogError type (issue4451)
Index lookups raise RevlogError when the lookup fails. The previous
implementation was caching a reference to the RevlogError type in a
static variable. This assumed that the "mercurial.error" module was
only loaded once and there was only a single copy of it floating
around in memory. Unfortunately, in some situations - including
certain mod_wsgi configurations - this was not the case: the
"mercurial.error" module could be reloaded. It was possible for a
"RevlogError" reference from the first interpreter to be used by
a second interpreter. While the underlying thing was a
"mercurial.error.RevlogError," the object IDs were different, so
the Python code in revlog.py was failing to catch the exception! This
error has existed since the C index lookup code was implemented in
changeset 1e47437a1ca7, which was first released in Mercurial 2.2 in
2012.
http://emptysqua.re/blog/python-c-extensions-and-mod-wsgi/#static-variables-are-shared
contains more details.

This patch removes the caching of the RevlogError type from the
function.

Since pretty much the entire function was refactored and the return
value of the function wasn't used, I changed the function signature
to not return anything.

For reasons unknown to me, we were calling PyErr_SetObject()
with the type of RevlogError and an instance of RevlogError. This
was equivalent to the Python code "raise RevlogError(RevlogError)".
This seemed wonky and completely unnecessary. The Python code only
cares about the type of the exception, not its contents. So I got
rid of this complexity.

This is my first Python C extension patch. Please give extra scrutiny
to it during review.
2015-06-12 14:43:59 -07:00
Yuya Nishihara
54bbfd7f6b templater: do not preprocess template string in "if" expression (issue4714)
The problem was spotted at cd1b50e99ed8, that says "this patch invokes it
with "strtoken='rawstring'" in "_evalifliteral()", because "t" is the result
of "arg" evaluation and it should be "string-escape"-ed if "arg" is "string"
expression." This workaround is no longer valid since 72be08a15d8d introduced
strict parsing of '\{'.

Instead, we should interpret bare token as "string" or "rawstring" template.
This is what buildmap() does at parsing phase.
2015-06-08 18:14:22 +09:00
Laurent Charignon
e02fe4b93e crecord: fix three typos introduced while moving crecord into core
When moving crecord to core, I did a search an replace to remove all of the
variable with caps letter. Doing so, I unfortunately changed some commands
with capital letter shortcut to their lowercase counterpart. I fixed one
of these cases in bfcbb3995330. This patch fixes all of the remaining cases.
2015-06-05 12:57:21 -07:00
Laurent Charignon
8979893774 crecord: fix a typo introduced when moving crecord to core
When moving crecord to core, I did a search an replace to remove all of the
variable with caps letter. Doing so, I unfortunately changed the 'F' command
to 'f' leading to two 'f' commands, one never used. This patch fixes this
mistake and re enables the behavior of 'F'.
2015-06-05 10:44:34 -07:00
Matt Harbison
a1a73ad1ab hgwebdir: don't allow the hidden parent of a subrepo to show as a directory
Previously, if a subrepo parent had 'web.hidden=True' set, neither the parent
nor child had a repository entry.  However, the directory entry for the parent
would be listed (it wouldn't have the fancy 'web.name' if configured), and that
link went to the repo's summary page, effectively making it not hidden.

This simply disables the directory processing if a valid repository is present.
Whether or not the subrepo should be hidden is debatable, but this leaves that
behavior unchanged (i.e. it stays hidden).
2015-06-01 18:06:20 -04:00
Pierre-Yves David
9e0c5a2a51 pull: avoid race condition with 'hg pull --rev name --update' (issue4706)
The previous scheme was:

1) lookup node for all pulled revision,
2) pull said node
3) lookup the node of the checkout target
4) update the repository there.

If the remote repo changes between (1) and (3), the resolved name will be
different and (3) crash. There is actually no need for a remote lookup during
(3), we could just set the value in (1). This prevent the race condition and
save a possible network roundtrip.
2015-06-03 14:29:11 -07:00
Matt Harbison
7ed6e6b3e0 hgwebdir: avoid redundant repo and directory entries when 'web.name' is set
Previously, when 'web.name' was set on a subrepo parent and 'web.collapse=True',
the parent repo would show in the list with the configured 'web.name', and a
directory with the parent repo's filesystem name (with a trailing slash) would
also appear.  The subrepo(s) would unexpectedly be excluded from the list of
repositories.  Clicking the directory entry would go right to the repo page.

Now both the parent and the subrepos show up, without the additional directory
entry.

The configured hgweb paths used '**' for finding the repos in this scenario.


A couple of notes about the tests:

- The area where the subrepo was added has a comment that it tests subrepos,
  though none previously existed there.  One now does.

- The 'web.descend' option is required for collapse to work.  I'm not sure what
  the previous expectations were for the test.  Nothing changed with it set,
  prior to adding the code in this patch.  It is however required for this test.

- The only output changes are for the hyperlinks, obviously because of the
  'web.name' parameter.

- Without this code change, there would be an additional diff:

    --- /usr/local/mercurial/tests/test-hgwebdir.t
    +++ /usr/local/mercurial/tests/test-hgwebdir.t.err
    @@ -951,7 +951,7 @@
       /rcoll/notrepo/e/
       /rcoll/notrepo/e/e2/
       /rcoll/notrepo/f/
    -  /rcoll/notrepo/f/f2/
    +  /rcoll/notrepo/f/


     Test repositories inside intermediate directories

I'm not sure why the fancy name doesn't come out, but it is enough to
demonstrate that the parent is not listed redundantly, and the subrepo isn't
skipped.
2015-06-01 14:42:55 -04:00
Matt Mackall
73a534cbb5 Added signature for changeset 7788c5f5364b 2015-06-01 15:16:28 -05:00
FUJIWARA Katsunori
1d5cc643a1 templatekw: compare target context and its parent exactly (issue4690)
Before this patch, template keywords `{file_mods}`, `{file_adds}` and
`{file_dels}` use values gotten by `repo.status(ctx.p1().node(),
ctx.node())`.

But this doesn't work as expected if `ctx` is `memctx` or
`workingcommitctx`. Typical case of templating with these contexts is
customization of the text shown in the commit message editor by
`[committemplate]` configuration.

In this case, `ctx.node()` returns None and it causes comparison
between `ctx.p1()` and `workingctx`. `workingctx` lists up all changed
files in the working directory even at selective committing.

BTW, `{files}` uses `ctx.files()` and it works as expected.

To compare target context and its parent exactly, this patch passes
`ctx.p1()` and `ctx` without `node()`-nize. This avoids unexpected
comparison with `workingctx`.

This patch uses a little redundant template configurations in
`test-commit.t`, but they are needed to avoid regression around
problems fixed by 17e2fda16f58 and 2b999bc2d89a: accessing on `ctx`
may break `ctx._status` field.
2015-06-02 02:28:33 +09:00
FUJIWARA Katsunori
f215738702 i18n-ja: synchronized with 87267040cd32 2015-06-01 10:50:15 +09:00
Durham Goode
70caa9d8e9 histedit: fix keep during --continue
The --keep option was being serialized to the state file, but it wasn't actually
being used when running a histedit --continue. This fixes that.
2015-05-28 20:30:20 -07:00