Commit Graph

12116 Commits

Author SHA1 Message Date
Pierre-Yves David
f7c8a82ddd localrepo: pass arbitrary kwargs from repo.pull to exchange.pull
We'll add bookmark-related arguments to `repo.pull` so we need to widen the
signature of `repo.pull`. We should probably kill `repo.pull` now that
`repo.push` is dead but this is outside the scope of this series.
2014-09-26 12:51:55 -07:00
Pierre-Yves David
c7f20ea1f1 pull: use other.url() as the source of a bookmark pull
We want to move the bookmarks movement into `exchange.pull`, for this purpose we
need to stop relying on variables from `command.pull`.
2014-09-26 10:59:29 -07:00
Yuya Nishihara
deb7a2b54f branches: reduce nesting in for loop 2014-10-02 21:58:10 +09:00
Mads Kiilerich
e49fb83975 i18n: use datapath for i18n like for templates and help
To avoid circular module dependencies we initialize i18n from util when
datapath is found.
2014-09-28 16:57:47 +02:00
Mads Kiilerich
634a855966 help: don't search randomly for help data - trust util.datapath
The search was introduced in 73b7669a499c without a convincing explanation why
it should be necessary ... except for consistency with templater handling.

Now, just keep it simple.
2014-09-28 16:57:47 +02:00
Mads Kiilerich
3326c1de0b templater: don't search randomly for templates - trust util.datapath
The search was introduced in 501e9ec9a85d. It might have been necessary back
then when using __file__ directly and frozen-ness wasn't considered. Now we
should know exactly where the templates can be found.
2014-09-28 16:57:37 +02:00
Mads Kiilerich
74b470ec55 templater: inline global 'path' list in templatepaths 2014-09-28 16:57:37 +02:00
Mads Kiilerich
374f35aab5 templater: introduce templatepaths for getting paths searched for templates
Avoid function with different return types depending on parameters.
2014-09-28 16:57:37 +02:00
Mads Kiilerich
e9c0145df2 util: introduce datapath for getting the location of supporting data files
templates, help and locale data is normally stored as sub folders in the
directory containing the source of the mercurial module. In a frozen build they
live as sub folders next to 'hg.exe' and 'library.zip'.

These different kind of data were handled in different ways. Unify that by
introducing util.datapath. The value is computed from the environment and is
always used, so we just calculate the value on module load.
2014-09-28 16:57:06 +02:00
Mads Kiilerich
9b9c077bd6 util: move _hgexecutable a few lines, closer to where it is used 2014-09-28 16:57:06 +02:00
Matt Mackall
667f516d70 bookmarks: fix divergent bookmark path normalization 2014-10-02 16:43:50 -05:00
Matt Mackall
8956f42fc4 exchange: remove a broken i18n abuse 2014-10-02 11:35:20 -05:00
Pierre-Yves David
6d9b081f23 bookmark: make the search for divergent names more robust
We translate the "url we update from" and "the url in the config" into their
canonical representation. This is useful for urls that have multiple equivalent
forms:

  /foo/bar/ == file:/foo/bar/ == file:///foo/bar


eg: hg pull --config path.bar=/foo/bar/ file:/foo/bar
2014-09-26 11:31:15 -07:00
Pierre-Yves David
fa008917c9 pull: gather all bookmark-pulling code together
Pulling bookmarks is done in two rounds. First we do a simple update, then we use
the content of the `bookmark` argument to possibly overwrite some bookmark
with their remote location.

The second step was not done right after the first one for some obscure reason.
We now perform them one after the other.
2014-09-25 17:53:27 -07:00
Pierre-Yves David
4af2b1bb81 push: perform bookmark export in the push function
This part is responsible for adding new bookmarks on the remote.  Before that,
it was done on its own in `commands.push`. The export is still not integrated
with the rest of the push process, but at least it now dwells in the right
function.
2014-09-25 02:53:29 -07:00
Pierre-Yves David
9695890ed2 push: add pushoperation.bkresult
This attribute will be used to carry the result of the bookmark push (when the
`push` function will effectively be doing any bookmarks pushes)
2014-09-25 00:57:36 -07:00
Pierre-Yves David
90372104e5 push: pass list of bookmark to exchange.push
Currently stored but not unused. This parameter will control bookmarks explicitly
pushed (added to the server if missing).
2014-09-25 01:49:20 -07:00
Pierre-Yves David
97a4fbb3c9 exchange: import bookmarks as bookmod
Using the original names makes it difficult to use `bookmarks` as a variable
name.
2014-09-25 15:26:09 -07:00
Pierre-Yves David
7d3ee75e4d push: sanitize handling of bookmark push return value
Mixing return and assignment does not make sense, let's unify this.
2014-09-25 02:53:49 -07:00
Pierre-Yves David
90dfcecb7c locarepo: remove the push method (API)
All the logic of this function is in the exchange.push function for some time.
We just stop calling `localrepo.push` in `command.push` to have access to more
information. Leaving `localrepo.push` in place will let third-party extensions
wrap it but it would never be called by `hg push` making the wrapping useless.
Therefore, the method is removed so that third-party code fail noisily and
get properly upgraded.
2014-09-25 01:43:24 -07:00
Pierre-Yves David
a4462c2e75 push: exchange.push instead of localrepo.push
The latter is going away.
2014-09-25 01:42:49 -07:00
Pierre-Yves David
5696781db1 clone: use exchange.push instead of localrepo.push
The latter is going away.
2014-09-25 01:41:26 -07:00
Pierre-Yves David
dbad87edcd push: use exchange.push in commands.push
To gain access to all results from the push, we need to have access to the
`pushoperation` object. We call `exchange.push` to do so.

It is impossible to just change the `localrepo.push` signature because the
change may be too subtle to be caught by external extension wrapping
`localrepo.push`.

This mean we'll have to kill `localrepo.push` because just using
`exchange.push` in `commands.py` would silently disable all wrapping around
`localrepo.push` by third-party extensions. So we'll remove it in a later
changeset to get such extensions to fail noisily.
2014-09-25 01:39:39 -07:00
Pierre-Yves David
d166108f19 push: exchange.push now returns the pushoperation object
Returning the pushop object gives access to more information (upcoming bookmark
push result for example). `localrepo.push` currently extracts the `cgresult` for
callers.
2014-09-25 02:21:59 -07:00
Pierre-Yves David
1c91d9eb8c push: rename pushop.ret to pushop.cgresult
We are about to introduce more results-related attributes on pushop (for
bookmarks) so we need a more distinctive name. We now use `cgresult` as
`pulloperation` does.
2014-09-25 00:55:39 -07:00
Pierre-Yves David
2c1c685c0b obsolete: use version constants in the format mapping 2014-09-16 15:57:51 -07:00
Pierre-Yves David
556c3d9a5e obsolete: use the version argument in encodemarkers
Recent scientific studies show that assigning a variable have no effect on
a unrelated constant. We therefore use the variable where we intended to in the
first place.
2014-09-16 15:56:38 -07:00
Pierre-Yves David
7fe702d01c obsolete: gather all contents related to format version 0 in a single place
All contents includes documentation, constants, and functions, so we
gather all of those things into a single location. The diff is confusing
because it cannot understand what code is semantically moved around in this
grand migration.
2014-09-12 14:41:43 +02:00
Pierre-Yves David
bfd39d13a8 revert: properly back up added files with local modification
These files were previously not backed up because the backup mechanism was not
smart enough. This leads to data lose for the user since uncommitted contents
were discarded.

We now properly move the modified version to <filename>.orig before deleting it.

We have to use a small hack to do a different action if "--no-backup" is
specified. This is needed because the backup process is actually a move (not a
copy) so the file is already missing when we backup. The internet kitten is a
bit disapointed about that, but such is life.

This patch concludes the "lets refactor revert" phases. We can now open the
"Lets find stupid bug with renames and merge" phases.

I'm sure that now that the code is clearer we could do it in another simpler
way, but I consider the current improvement good enough for now.
2014-08-31 13:01:00 +02:00
Pierre-Yves David
985e6cc94b revert: track added files with local modifications
Those files need to be backed up but are currently not. We compute the set of
them to be able to use a different backup strategy in the next changeset.
2014-08-30 02:39:08 +02:00
Pierre-Yves David
4b18de4a6a revert: distinguish between "check" and "backup" strategy
"check" behaves as backup did before. We check if the current file differs
from destination and we create a backup if it does. This is used for untracked
files that will be overwritten by formerly-deleted files. We have to do the manual
check since no status output can provide the content comparison.

"backup" is now doing unconditional backup. This can be used for files seen as
modified compared to both the target and the working directory. In such a case, we
know that the file differs from target without actually comparing any content.

This new "backup" strategy will be especially useful in the case of files added
between the target and the working directory -parent- with additional modifications
in the working directory -itself-. In that case we know we need to back it up, but we
cannot run the content check as the files does not exists in target.
2014-08-30 02:30:24 +02:00
Pierre-Yves David
9c3ba8614b revert: small refactoring in the way backup value are handled
The current backup value may have two different values:

  1. Do not try to do backup
  2. Do backup if applicable

We are about to move to:

  1. Do not try to do backup
  2. Do backup if applicable
  3. Do backup in all cases

So we change the current values to make room for the new one.
2014-08-30 02:28:27 +02:00
Matt Mackall
b738313af7 merge with stable 2014-10-01 15:05:09 -05:00
Matt Mackall
05afef1210 parsers: fix Py2.4 argument parsing issue
Since d0ec15e840e5, we were getting this strange message with Py2.4:

 TypeError: argument 1 must be impossible<bad format char>, not int

..because we were using the 'n' type specifier introduced in 2.5.

It turns out that offset is actually a revision number index, which
ought to be an int anyway. So we store it in an int, use the 'i'
specifier, rely on Py_ParseTuple for range checking, and rename it to
avoid type confusion.
2014-10-01 14:44:24 -05:00
Jordi Gutiérrez Hermoso
678a04feed diff: document the nobinary option
Since ce44c3c7c2be, we have a diff.nobinary option. This is handy, but
the only way I found out about it was by looking at the release notes
for 3.1, which is not something I normally do.
2014-09-30 16:59:07 -04:00
Yuya Nishihara
525193c247 templater: fix precedence of --style and --template options
Since 266cfa7de44d, --template option is ignored if --style is specified,
which is wrong according to the doc of show_changeset():

    Display format will be the first non-empty hit of:
    1. option 'template'
    2. option 'style'
    ...
2014-09-30 23:15:56 +09:00
Anton Shestakov
1119de7215 hgweb: refresh hgweb.repo on phase change (issue4061)
Make hgweb.refresh() also look at phaseroots file (in addition to 00changelog.i
file) and reload the repo when os.stat returns different mtime or size than
cached, signifying the file was modified.

This way if user changes phase of a changeset (secret <-> draft), there's no
need to restart hg serve to see the change.
2014-09-27 21:59:55 +09:00
Matt Mackall
5f07bb0a47 help: fix typo in log examples 2014-09-29 16:42:12 -05:00
Anton Shestakov
20c415845d hgweb: fail if an invalid command was supplied in url path (issue4071)
Traditionally, the way to specify a command for hgweb was to use url query
arguments (e.g. "?cmd=batch"). If the command is unknown to hgweb, it gives an
error (e.g. "400 no such method: badcmd").

But there's also another way to specify a command: as a url path fragment (e.g.
"/graph"). Before, hgweb was made forgiving (looks like it was made in
cd356f4efd91) and user could put any unknown command in the url. If hgweb
couldn't understand it, it would just silently fall back to the default
command, which depends on the actual style (e.g. for paper it's shortlog, for
monoblue it's summary). This was inconsistent and was breaking some tools that
rely on http status codes (as noted in the issue4071). So this patch changes
that behavior to the more consistent one, i.e. hgweb will now return "400 no
such method: badcmd".

So if some tool was relying on having an invalid command return http status
code 200 and also have some information, then it will stop working. That is, if
somebody typed foobar when they really meant shortlog (and the user was lucky
enough to choose a style where the default command is shortlog too), that fact
will now be revealed.

Code-wise, the changed if block is only relevant when there's no "?cmd" query
parameter (i.e. only when command is specified as a url path fragment), and
looks like the removed else branch was there only for falling back to default
command. With that removed, the rest of the code works as expected: it looks at
the command, and if it's not known, raises a proper ErrorResponse exception
with an appropriate message.

Evidently, there were no tests that required the old behavior. But, frankly, I
don't know any way to tell if anyone actually exploited such forgiving behavior
in some in-house tool.
2014-09-22 23:46:38 +09:00
Mike Hommey
d177b1d78f keepalive: fix how md5 is used
The code in keepalive dates from when it was importing the md5 module directly
and uses md5.new. Since then, what 'md5' means has been changed from an import
of the md5 module to being a function using the right module between hashlib
and md5, so the md5.new idiom doesn't work anymore.
2014-09-24 15:52:40 +09:00
Pierre-Yves David
d0e7545de8 revset: add an optimised baseset.__contains__ (issue4371)
The baseset class is based on a python list. This means that base.__contains__
was absolutely as crappy as list.__contains__. We now rely on __contains__ from
the underlying set.

This will avoid having to explicitly convert the baseset to a set (using
baseset.set()) whenever one want fast membership test.

Apparently there is already code that forgot to do such conversions since we
observe a massive speedup in some test.

revset #25: roots((0::) - (0::tip))
0) wall 2.079454 comb 2.080000 user 2.080000 sys 0.000000 (best of 5)
1) wall 0.132970 comb 0.130000 user 0.130000 sys 0.000000 (best of 65)

No regression is observed in benchmarks.

This change improve the issue4371 back to acceptable situation (but are still
slower than manual substraction)
2014-09-16 23:59:29 -07:00
Matt Mackall
2f833205d7 help: mention mode in hg log --removed help (issue4381) 2014-09-21 10:31:34 -05:00
Matt Mackall
4afe2f8b38 commit: catch changed exec bit on files from p1 (issue4382) 2014-09-21 10:07:06 -05:00
Mike Edgar
ab4953ab9b filelog: censored files compare against empty data, have 0 size
To support "status" operations against working directories that are
the children of censored revisions, filelog must define "cmp" and "size"
for censored content.
2014-09-14 20:32:34 -04:00
FUJIWARA Katsunori
0d1dc1fcfa dispatch: check shell alias again after loading extensions (issue4355)
Before this patch, the shell alias causes failure when it takes its
specific (= unknown for "hg") options in the command line, because
"_parse()" can't accept them.

This is the regression introduced by 7849ac1dbc57.

It fixed the issue that ambiguity between shell aliases and commands
defined by extensions was ignored. But it also caused that ambiguous
shell alias is handled in "_parse()" even if it takes specific options
in the command line.

To avoid such failure, this patch checks shell alias again after
loading extensions.

All aliases and commands (including ones defined by extensions) are
completely defined before the 2nd (= newly added in this patch)
"_checkshellalias()" invocation, and "cmdutil.findcmd(strict=False)"
can detect ambiguity between them correctly.

For efficiency, this patch does:

  - omit the 2nd "_checkshellalias()" invocation if "[ui] strict= True"

    it causes "cmdutil.findcmd(strict=True)", of which result should
    be equal to one of the 1st invocation before adding aliases

  - avoid removing the 1st "_checkshellalias()" invocation

    it causes "cmdutil.findcmd(strict=True)" invocation preventing
    shell alias execution from loading extensions uselessly
2014-09-10 00:41:44 +09:00
FUJIWARA Katsunori
906133d681 dispatch: make "_checkshellalias" reusable regardless of adding aliases
To reduce changes in the subsequent patch fixing issue4355, this patch
makes "_checkshellalias" reusable regardless of adding aliases.

In this patch, alias definitions are added and restored, only when
"precheck=True".
2014-09-10 00:41:44 +09:00
Mike Edgar
04a8ee7081 filelog: raise CensoredNodeError when hash checks fail with censor metadata
With this change, when a revlog revision hash does not match its content, and
the content is empty with a special metadata key, the integrity failure is
assumed to be intentionally caused to remove sensitive content from repository
history.

To allow different Mercurial functionality to handle this scenario differently
a more specific exception is raised than "ordinary" hash failures.

Alternatives to this approach include, but are not limited to:

- Calling a hook when hashes mismatch to allow arbitrary tombstone validation.
  Cons: Irresponsibly easy to disable integrity checking altogether.
- Returning empty revision data eagerly instead of raising, masking the error.
  Cons: Push/pull won't roundtrip the tombstone, so client repos are unusable.
- Doing nothing differently at this layer. Callers must do their own detection
  of tombstoned data if they want to handle some hash checks and not others.
  - Impacts dozens of callsites, many of which don't have the revision data
  - Would probably be missing one or two callsites at any given time
  - Currently we throw a RevlogError, as do 12 other places in revlog.py.
    Callers would need to parse the exception message and/or ensure
    RevlogError is not thrown from any other part of their call tree.
2014-09-03 22:14:20 -04:00
Mike Edgar
e100ea2d6a error: add CensoredNodeError, will be thrown when content deliberately erased
This change introduces the error plus a corresponding catch in dispatch, to
provide localized error messages.

The verb "censor" is used in this commit and all following to refer to erasing
the content of a revlog revision (filelog, for now) without recalculating node
IDs, leaving that revision invalid. Further work must be done to safely share
such revision data with compliant clients.

I find the analogy to censorship straightforward; for less politically
charged options, consider "erase", "excise", "expunge", or "blackhole".
2014-09-03 15:59:03 -04:00
Siddharth Agarwal
f1c5684fc4 files: cache repo.dirstate
For a large repo, 'hg files' goes from 2.27 seconds to 1.92.
2014-09-30 16:01:19 -07:00
Siddharth Agarwal
41071b4456 files: only check for removed, not unknown or missing
ctx.matches() doesn't return unknown files, and repo.dirstate[f] never returns
'!' for an answer.
2014-09-30 15:21:35 -07:00