Commit Graph

30334 Commits

Author SHA1 Message Date
Jun Wu
5b83a79f69 chgserver: call "load" for new ui objects
After 81ed7b0f8a46, we need to call "ui.load" explicitly to load config
files.
2016-12-05 21:36:35 +00:00
Pulkit Goyal
6e996c4d4c localrepository: remove None as default value of path argument in __init__()
The path variable in localrepository.__init__() has a default value None. So
it gives us a option to create an object to localrespository class without
path variable. But things break if you try to do so. The second line in the
init which will be executed when we try to create a localrepository object
will call os.path.expandvars(path) which returns

TypeError: argument of type 'NoneType' is not iterable

I checked occurrences when it is called and can't find any piece of code
which calls it without path variable. Also if something is calling it, its
should break.
2016-12-04 23:22:34 +05:30
Pulkit Goyal
849c625bac py3: use pycompat.sysstr() in __import__()
__import__() on Python 3 accepts strings which are different from that of
Python 2. Used pycompat.sysstr() to get string accordingly.
2016-12-01 13:12:04 +05:30
Pulkit Goyal
4245797c62 py3: avoid use of basestring
"In this case, result is a source variable of a list to be returned, it
shouldn't be unicode. Hence we can use bytes instead of basestring here." -Yuya
2016-11-30 23:51:11 +05:30
Pulkit Goyal
bf0008abe9 py3: use unicodes in __slots__
__slots__ in Python 3 accepts only unicodes and there is no harm using
unicodes in __slots__. So just adding u'' is fine. Previous occurences of this
problem are treated the same way.
2016-11-30 23:38:50 +05:30
Mateusz Kwapich
3de25e93ce memctx: allow the metadataonlyctx thats reusing the manifest node
When we have a lot of files writing a new manifest revision can be expensive.
This commit adds a possibility for memctx to reuse a manifest from a different
commit. This can be beneficial for commands that are creating metadata changes
without any actual files changed like "hg metaedit" in evolve extension.

I will send the change for evolve that leverages this once this is accepted.
2016-11-21 08:09:41 -08:00
Mateusz Kwapich
529860b433 localrepo: make it possible to reuse manifest when commiting context
This makes the commit function understand the context that's reusing manifest.
2016-11-17 10:59:15 -08:00
Mateusz Kwapich
55fff531e4 manifest: expose the parents() method 2016-11-17 10:59:15 -08:00
Gregory Szorc
a071fc938c httppeer: assign Vary request header last
In preparation for adding another value to it in a subsequent patch.

While I was here, I added some empty lines because walls of text
are hard to read.
2016-11-28 21:07:51 -08:00
Gregory Szorc
6a4fd5ab05 wireproto: only advertise HTTP-specific capabilities to HTTP peers (BC)
Previously, the capabilities list was protocol agnostic and we
advertised the same capabilities list to all clients, regardless of
transport protocol.

A few capabilities are specific to HTTP. I see no good reason why we
should advertise them to SSH clients. So this patch limits their
advertisement to HTTP clients.

This patch is BC, but SSH clients shouldn't be using the removed
capabilities so there should be no impact.
2016-11-28 20:46:42 -08:00
Gregory Szorc
2220c845b2 protocol: declare transport protocol name
We add an attribute to the HTTP and SSH protocol implementations
identifying the transport so future patches can conditionally
expose capabilities on a per-transport basis.
2016-11-28 20:46:59 -08:00
Mads Kiilerich
ecd76cc19e bdiff: early pruning of common prefix before doing expensive computations
It seems quite common that files don't change completely. New lines are often
pretty much appended, and modifications will often only change a small section
of the file which on average will be in the middle.

There can thus be a big win by pruning a common prefix before starting the more
expensive search for longest common substrings.

Worst case, it will scan through a long sequence of similar bytes without
encountering a newline. Splitlines will then have to do the same again ...
twice for each side. If similar lines are found, splitlines will save the
double iteration and hashing of the lines ... plus there will be less lines to
find common substrings in.

This change might in some cases make the algorith pick shorter or less optimal
common substrings. We can't have the cake and eat it.

This make hg --time bundle --base null -r 4.0 go from 14.5 to 15 s - a 3%
increase.

On mozilla-unified:
perfbdiff -m 3041e4d59df2
! wall 0.053088 comb 0.060000 user 0.060000 sys 0.000000 (best of 100) to
! wall 0.024618 comb 0.020000 user 0.020000 sys 0.000000 (best of 116)
perfbdiff 0e9928989e9c --alldata --count 10
! wall 0.702075 comb 0.700000 user 0.700000 sys 0.000000 (best of 15) to
! wall 0.579235 comb 0.580000 user 0.580000 sys 0.000000 (best of 18)
2016-11-16 19:45:35 +01:00
Yuya Nishihara
0a5e04d63d formatter: add overview of API and example as doctest 2016-10-22 15:02:11 +09:00
Yuya Nishihara
1d44bd2bbb ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.

ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
2016-10-22 14:35:10 +09:00
Jun Wu
35a3247fa1 check-code: add a rule to forbid "cp -r"
See the commit message of the previous patch for the reason. In short,
according to the current POSIX standard, "-r" is "removed", and "-R" is the
current standard way to do "copy file hierarchies".
2016-11-30 19:23:04 +00:00
Jun Wu
3ee7ba0bd8 tests: replace "cp -r" with "cp -R"
The POSIX documentation about "cp" [1] says:

  ....

  RATIONALE
    ....
    Earlier versions of this standard included support for the -r option to
    copy file hierarchies. The -r option is historical practice on BSD and
    BSD-derived systems. This option is no longer specified by POSIX.1-2008
    but may be present in some implementations. The -R option was added as a
    close synonym to the -r option, selected for consistency with all other
    options in this volume of POSIX.1-2008 that do recursive directory
    descent.

    The difference between -R and the removed -r option is in the treatment
    by cp of file types other than regular and directory. It was
    implementation-defined how the - option treated special files to allow
    both historical implementations and those that chose to support -r with
    the same abilities as -R defined by this volume of POSIX.1-2008. The
    original -r flag, for historic reasons, did not handle special files any
    differently from regular files, but always read the file and copied its
    contents. This had obvious problems in the presence of special file
    types; for example, character devices, FIFOs, and sockets.
    ....

  ....

  Issue 6
    The -r option is marked obsolescent.
    ....

  Issue 7
    ....
    The obsolescent -r option is removed.
    ....

  (No "Issue 8" yet)

Therefore it's clear that "cp -R" is strictly better than "cp -r".

The issue was discovered when running tests on OS X after 2e4d149e62aa.

[1]: pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html
2016-11-30 19:25:18 +00:00
Martijn Pieters
ca91b8fcf4 posix: give the cached symlink a real target
The NamedTemporaryFile file is cleared up so checklink ends up as a dangling
symlink, causing cp -r in tests to complain on both Solaris and OS X. Use
a permanent file instead when there is a .hg/cache directory.
2016-11-30 16:39:36 +00:00
Kostia Balytskyi
9b01b1d353 shelve: move patch extension to a string constant
We are using 'name + ".patch"' pattern throughout the shelve code to
identify the existence of a shelve with a particular name. In two
cases however we use 'name + ".hg"' instead. This commit makes
'patch' be used in all places and "emphasizes" it by moving
'patch' to live in a constant. Also, this allows to extract file
name without extension like this:
    f[:-(1 + len(patchextension))]
instead of:
    f[:-6]
which is good IMO.

This is a first patch from this initial "obsshelve" series. This
series does not include tests, although locally I have all of
test-shelve.t ported to test obs-shelve as well. I will send tests
later as a separate series.
2016-11-29 07:20:03 -08:00
Kevin Bullock
8647dcca4a merge with stable 2016-12-01 15:55:45 -06:00
Kevin Bullock
4cdf2cb0d1 Added signature for changeset 6c3b7e698555 2016-12-01 14:13:28 -06:00
Kostia Balytskyi
69bbbd3ecf shelve: fix use of unexpected working dirs in test-shelve.t
Fixing some clowniness where we created ~four levels of nested repos
and once (my test case :( ) did not even cd into a created repo.
2016-11-29 04:11:05 -08:00
Jun Wu
b1b31fa46d crecord: change the verb according to the operation
This will make crecord consistent with record when being used in the revert
situation. It will say "Select hunks to revert / discard" accordingly.

This should make the revert crecord interface less confusing.
2016-11-28 23:38:46 +00:00
Jun Wu
221bb95fba crecord: change help text for the space key dynamically
A follow-up of the previous patch, to make the text simple and clear about
whether it's to "select" or "deselect".
2016-11-28 23:37:29 +00:00
Jun Wu
45c2358700 crecord: rewrite status line text (BC)
Previously, we display fixed text in the 2-line status header. Now we want
to customize some word there to make the "revert" action clear. However, if
we simply replace the verb using '%s' like this:

  "SELECT CHUNKS: (j/k/up/dn/pgup/pgdn) move cursor; "
  "(space/A) toggle hunk/all; (e)dit hunk;"),
  " (f)old/unfold; (c)onfirm %s; (q)uit; (?) help " % verb
  "| [X]=hunk %s **=folded, toggle [a]mend mode" % verb

It could cause trouble for i18n - some languages may expect things like
"%(verb) confirm", for example.

Therefore, this patch chooses to break the hard-coded 2-line sentences into
"segment"s which could be translated (and replaced) separately.

With the clean-up, I'm also changing the content being displayed, to make it
cleaner and more friendly to (new) users, namely:

  - Replace "SELECT CHUNKS" to "Select hunks to record". Because:
    - To eliminate "hunk" / "chunk" inconsistency.
    - "record" is used in the "text" UI. Do not use "apply", to make it
      consistent.
    - To make it clear you are choosing what to record, not revert, or
      discard etc. This is probably the most important information the user
      should know. So let's put it first.
    - "to record" could be replaced to others depending on the operation.
      The follow-up patches will address them.
  - Move "[x]" and "**" legends first to explain the current interface. New
    users should understand what the legends mean, followed by what they can
    do in the interface.
  - Replace "j/k/up/dn/pgup/pgdn" with "arrow keys". Because:
    - "arrow keys" is more friendly to new users.
    - Mentioning "j/k" first may make emacs users angry. We should stay
      neutral about editors.
    - "pgup/pgdn" actually don't work very well. For example, within a hunk
      of 100-line insertion, "pgdn" just moves one single line.
    - Left/Right arrow keys are useful for movement and discovery of
      "expanding" a block.
  - Replace "fold/unfold" with "collapse/expand", "fold" is well known as
    a different meaning in histedit and evolve.
  - Replace "(space/A) toggle hunk/all" to "space: select". Because:
    - "A: toggle all" is not that useful
    - It's unclear how "hunk" could be "toggled" to a dumb user. Let's
      make it clear it's all about "select".
    - A follow-up will make it use "unselect" when we know the current item
      is selected.
  - Remove "(f)old". Use arrow keys instead.
  - Remove "toggle [a]mend mode". It's just confusing and could be useless.
  - Remove "(e)dit hunk". It's powerful but not friendly to new users.
  - Replace "(q)uit" to "q: abort" to make it clear you will lose changes.

The result looks like the following in a 73-char-width terminal:

  Select hunks to record - [x]=selected **=collapsed  c: confirm  q: abort
  arrow keys: move/expand/collapse  space: select  ?: help

If the terminal is 132-char wide, the text could fit in a single line.
2016-11-28 23:33:02 +00:00
Wagner Bruna
8125fda43a i18n-pt_BR: synchronized with bb96c28331a8 2016-11-25 07:39:02 -02:00
Jun Wu
de6eda0ab8 crecord: make _getstatuslines update numstatuslines
We are going to make the text in the status window dynamically generated,
so its size would be dynamic. Change getstatuslines to update
"numstatuslines" automatically. Fix an issue where "numstatuslines" being 1
makes the chunkpad disappear.
2016-11-23 22:23:15 +00:00
Jun Wu
d59361019f crecord: move status window text calculation to a separate method
We will do some changes there in the next patches. The new method would also
be the "source of truth" of the content of the status window (so if the
status window needs more than 2 lines, it would be calculated from the new
method).

Also, moved "statuswin.refresh" to make the code compact and easier to read.
2016-11-28 23:12:54 +00:00
Cotizo Sima
56dfac3f63 revlog: ensure that flags do not overflow 2 bytes
This patch adds a line that ensures we are not setting by mistake a set of flags
overlfowing the 2 bytes they are allocated. Given the way the data is packed in
the revlog header, overflowing 2 bytes will result in setting a wrong offset.
2016-11-28 04:34:01 -08:00
Augie Fackler
f37a723203 merge with stable 2016-11-27 20:44:52 -05:00
Gregory Szorc
d5c4807106 debugcommands: sort command order
The diff is a bit large but it is straight code moving without any
logical modifications.
2016-11-25 09:59:39 -08:00
Gregory Szorc
7ab5315d89 tests: add test that @commands in debugcommands.py are sorted
I felt like inline Python in test-check-code.t was the most
appropriate place for this, as other linters in contrib/ seem to
be source file agnostic.

The test currently fails.
2016-11-25 09:55:05 -08:00
Simon Farnsworth
3fe60954bc fsmonitor: be robust in the face of bad state
fsmonitor could write out bad state if interrupted part way through, and
would then crash when it tried to read it back in.

Make both sides of the operation more robust - reading state should fail
cleanly, and we can use atomictemp to write out cleanly as the file is
small. Between the two, we shouldn't crash with an IndexError any more.
2016-11-25 07:30:46 -08:00
Mads Kiilerich
a31c060801 merge: use original file extension for temporary files
Some merge tools (like Araxis?) can pick merge mode based on the file
extension. That didn't work well when temporary files were given random
suffixes. It seems to work better when the random part is before the extension.

As usual, when using $output, $local will have the .orig extension. That could
perhaps be the subject of another change another day.
2016-11-23 23:47:38 +01:00
Gregory Szorc
9f87ab8fca ui: use try..finally in configoverride
@contextmanager almost always have their "yield" inside a try..finally
block. This is because if the calling code inside the activated
context manager raises, the code after the "yield" won't get
executed. A "finally" block, however, will get executed in this
scenario.
2016-11-26 09:14:41 -08:00
Gregory Szorc
8a9b1f64ab util: limit output chunk size in zlib decompression
This is essentially a port of 0a1739bca5b8, which was inadvertently
dropped by 8cd7d0fefd30.
2016-11-26 09:07:11 -08:00
Jun Wu
955aa56bff crecord: filter text via i18n
There are some text in the user interface that are not filtered by i18n.
This patch adds the missing "_" call. So the text could be translated.
2016-11-23 18:13:11 +00:00
Jun Wu
c40d1d56d5 revert: pass operation to crecord
So crecord would know what to display
2016-11-23 19:03:24 +00:00
Jun Wu
7363c8226f crecord: add an "operation" field
The field would provide extra information to help us to make the curses UI
text less confusing.
2016-11-23 19:22:36 +00:00
Denis Laxalde
11b3012d89 revert: prompt before removing files in interactive mode
Prior to this change, files to be removed (i.e. files added since the revision
to revert to) were unconditionally removed despite the interactive mode. Now
prompt before actually removing the files, as this is done for other actions
(e.g. forget).
2016-11-25 09:10:30 +01:00
Denis Laxalde
1dc33c0e5e revert: indicate the default choice when prompting to forget files 2016-11-25 09:09:31 +01:00
Denis Laxalde
5b0914afc0 style: avoid an unnecessary line split 2016-11-25 09:09:03 +01:00
Mads Kiilerich
9c5f48e630 shelve: add missing space in help text
The change is trivial and unlikely to have been translated so we update
translation files too.
2016-11-14 22:43:25 +01:00
FUJIWARA Katsunori
367ebf8ba3 scmutil: ignore EPERM at os.utime, which avoids ambiguity at closing
According to POSIX specification, just having group write access to a
file causes EPERM at invocation of os.utime() with an explicit time
information (e.g. working on the repository shared by group access
permission).

To ignore EPERM at closing file object in such case, this patch makes
checkambigatclosing._checkambig() use filestat.avoidambig() introduced
by previous patch.

Some functions below imply this code path at truncation of an existing
(= might be owned by another user) file.

  - strip() in repair.py, introduced by 4d0a08431b6f
  - _playback() in transaction.py, introduced by 48fe04792102

This is a variant of issue5418.
2016-11-13 06:12:22 +09:00
FUJIWARA Katsunori
11742ce806 vfs: ignore EPERM at os.utime, which avoids ambiguity at renaming (issue5418)
According to POSIX specification, just having group write access to a
file causes EPERM at invocation of os.utime() with an explicit time
information (e.g. working on the repository shared by group access
permission).

To ignore EPERM at renaming in such case, this patch makes
vfs.rename() use filestat.avoidambig() introduced by previous patch.
2016-11-13 06:11:56 +09:00
FUJIWARA Katsunori
64644e300c util: add utility function to skip avoiding file stat ambiguity if EPERM
Now, advancing stat.st_mtime by os.utime() is used to avoid file stat
ambiguity. But according to POSIX specification, utime(2) with an
explicit time information is permitted only for a process with:

  - the effective user ID equal to the user ID of the file, or
  - appropriate privileges

  http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html

Therefore, just having group write access to a file causes EPERM at
applying os.utime() on it (e.g. working on the repository shared by
group access permission).

This patch adds class filestat utility function avoidamgig() to avoid
file stat ambiguity but skip it if EPERM.

It is reasonable to always ignore EPERM, because utime(2) causes EPERM
only in the case described above (EACCES is used only for utime(2)
with NULL).
2016-11-13 06:06:23 +09:00
Gregory Szorc
085fa86140 hgweb: cache fctx.parents() in annotate command (issue5414)
43e3fb1c484e introduced a call to fctx.parents() for each line in
annotate output. This function call isn't cheap, as it requires
linkrev adjustment.

Since multiple lines in annotate output tend to belong to the same
file revision, a cache of fctx.parents() lookups for each input
should be effective in the common case. So we implement one.

Since the cache has to precompute parents so an aborted generator
doesn't leave an incomplete cache, we could just return a list.
However, we preserve the generator for backwards compatibility.

The effect of this change when requesting /annotate/96ca0ecdcfa/
browser/locales/en-US/chrome/browser/downloads/downloads.dtd on
the mozilla-aurora repo is significant:

p1(43e3fb1c484e)  5.5s
43e3fb1c484e:    66.3s
this patch:      10.8s

We're still slower than before. But only by ~2x instead of ~12x.

On the tip revisions of layout/base/nsCSSFrameConstructor.cpp file in
the mozilla-unified repo, time went from 12.5s to 14.5s and back to
12.5s. I'm not sure why the mozilla-aurora repo is so slow.

Looking at the code of basefilectx.parents(), there is room for
further improvements. Notably, we still perform redundant calls to
filelog.renamed() and basefilectx._parentfilectx(). And
basefilectx.annotate() also makes similar calls, so there is potential
for object reuse. However, introducing caches here are not appropriate
for the stable branch.
2016-11-05 09:38:07 -07:00
Augie Fackler
95a87ffb9b Added signature for changeset 9506ee30a64d 2016-11-01 14:12:39 -04:00
Kevin Bullock
e51456912a merge with i18n 2016-11-01 13:03:42 -05:00
Nathan Goldbaum
cd41ee4190 tag: clarify warning about making a tag on a branch head
Currently the warning is ambiguous about whether the new tag (possibly specified
via --rev) is being added on a branch head or whether the working directory is
based on a branch head. Clarify the error message to eliminate this ambiguity.
2016-10-31 17:12:32 -05:00
FUJIWARA Katsunori
33379270bf contrib: check reference to old selenic.com domain
Now, all URL in Mercurial source tree should refer mercurial-scm.org
domain instead of selenic.com.

*.po files are ignored in this patch, because they might contain
msgid/msgstr coming from old source files.

This ignorance seems safe enough, because such msgstr should be
ignored at runtime, because:

  - msgid corresponded to it should be invalid, or
  - msgstr itself should be marked as fuzzy at synchronized to recent hg.pot

If any additional examination for *.po files is needed in the future,
let i18n/check-translation.py achieve such examination.

BTW, some binary files (e.g. *.png) are meaningless for checking
reference to old domain in this patch, but aren't ignored like as *.po
files, because excluding multiple suffixes is difficult for regexp
matching.
2016-11-01 20:39:37 +09:00