Commit Graph

31419 Commits

Author SHA1 Message Date
Denis Laxalde
a70f2fcec7 revset: factor out linerange processing into a utility function
Similar processing will be done in hgweb.webutil in forthcoming changeset.
2017-02-24 18:39:08 +01:00
Denis Laxalde
6b9779860f hgweb: add a "patch" query parameter to filelog command
Add support for a "patch" query parameter in filelog web command similar to
--patch option of `hg log` to display the diff of each changeset in the table
of revisions. The diff text is displayed in a dedicated row of the table that
follows the existing one for each entry and spans over all columns. Only
update "paper" template in this patch.
2017-03-13 10:41:13 +01:00
Denis Laxalde
53e1237344 hgweb: handle "parity" internally in webutil.diffs()
There's apparently no reason to have the "parity" of diff blocks that
webutil.diffs() generates coming from outside the function. So have it
internally managed. We thus now pass a "web" object to webutil.diffs() to get
access to both "repo" and "stripecount" attribute.
2017-03-13 10:40:19 +01:00
FUJIWARA Katsunori
3d36ed3225 largefiles: add lfile argument to updatestandin() for efficiency (API)
Before this patch, updatestandin() takes "standin" argument, and
applies splitstandin() on it to pick out a path to largefile (aka
"lfile" or so) from standin.

But in fact, all callers already knows "lfile". In addition to it,
many callers knows both "standin" and "lfile".

Therefore, making updatestandin() take only one of "standin" or
"lfile" is inefficient.
2017-03-27 09:44:36 +09:00
FUJIWARA Katsunori
f21209d88f largefiles: use strip() instead of slicing to get rid of EOL of standin
This slicing prevents from replacing SHA-1 by another (= longer hash
value) in the future.
2017-03-27 09:44:36 +09:00
FUJIWARA Katsunori
f10b10ff74 largefiles: rename local variable appropriately
repo['.'] is called not as "working context" but as "parent context".

In this code path, hash value of current content of file should be
compared against hash value recorded in "parent context".

Therefore, "wctx" may cause misunderstanding in this case.
2017-03-27 09:44:36 +09:00
FUJIWARA Katsunori
3e84715300 largefiles: avoid redundant loop to eliminate None from list
Before this patch, this code path contains two loops for m._files: one
for replacement with standin, and another for elimination of None,
which comes from previous replacement ("standin in wctx or
lfdirstate[f] == 'r'" case in tostandin()).

These two loops can be unified into simple one "for" loop.
2017-03-27 09:44:35 +09:00
FUJIWARA Katsunori
bbdc4d8596 largefiles: avoid meaningless changectx looking up
Logically, "repo[ctx.node()]" should be equal to "ctx".

In addition to it, this redundant code path is repeated
"len(match.m_files)" times.
2017-03-27 09:44:35 +09:00
FUJIWARA Katsunori
fd045393ce largefiles: avoid redundant changectx looking up at each repetitions
These code paths look up changectx at each repetitions, even though
the changectx key isn't changed while loop.
2017-03-27 09:44:35 +09:00
FUJIWARA Katsunori
068a31b4e7 largefiles: omit updating newly added standin at linear merging
Updating standin for newly added largefile is needed, only if same
name largefile exists in destination context at linear merging. In
such case, updated standin is used to detect divergence of largefile
at overridefilemerge().

Otherwise, standin doesn't have any responsibility for its content
(usually, it is empty).
2017-03-27 09:44:34 +09:00
FUJIWARA Katsunori
6fcd56dea5 largefiles: reuse hexsha1() to centralize hash calculation logic into it
This patch also renames argument of hexsha1(), not only for
readability ("data" isn't good name for file-like object), but also
for reviewability (including hexsha1() code helps reviewers to confirm
how these functions are similar).

BTW, copyandhash() has also similar logic, but it can't reuse
hexsha1(), because it writes read-in data into specified fileobj
simultaneously.
2017-03-27 09:44:34 +09:00
Yuya Nishihara
b599e74213 py3: prove second commit works
Finally it works.
2017-03-26 19:11:41 +09:00
Yuya Nishihara
6286308d03 py3: fix manifestdict.fastdelta() to be compatible with memoryview
This doesn't look nice, but a straightforward way to support Python 3.
bytes(m[start:end]) is needed because a memoryview doesn't support ordering
operations. On Python 2, m[start:end] returns a bytes object even if m is
a buffer, so calling bytes() should involve no additional copy.

I'm tired of trying cleaner alternatives, including:

 a. extend memoryview to be compatible with buffer type
    => memoryview is not an acceptable base type
 b. wrap memoryview by buffer-like class
    => zlib complains it isn't bytes-like
2017-03-26 19:06:48 +09:00
Jun Wu
6b0a252616 crecord: use ProgrammingError 2017-03-26 17:00:23 -07:00
Jun Wu
8b5d63a796 transaction: use ProgrammingError 2017-03-26 16:59:30 -07:00
Jun Wu
b99bc99ff6 bundle2: use ProgrammingError 2017-03-26 16:57:25 -07:00
Jun Wu
f331a9612f merge: use ProgrammingError 2017-03-26 16:55:56 -07:00
Jun Wu
809dfffea4 repair: use ProgrammingError 2017-03-26 16:53:28 -07:00
Yuya Nishihara
2a7deb97d4 py3: abuse r'' to preserve str-ness of literals passed to __setattr__() 2017-03-26 16:33:12 +09:00
Yuya Nishihara
5a92909ce0 py3: fix slicing of byte string in revlog.compress()
I tried .startswith('\0'), but data wasn't always a bytes nor a bytearray.
2017-03-26 17:12:06 +09:00
Yuya Nishihara
cb9a6405bb py3: use bytes() to cast to immutable bytes in changelog.appender.write() 2017-03-26 16:31:01 +09:00
Yuya Nishihara
7109431581 py3: use bytes() to cast to immutable bytes in pure.bdiff.bdiff() 2017-03-26 16:16:45 +09:00
Yuya Nishihara
b24f9e13b8 bdiff: drop support for array.array argument from pure.bdiff.bdiff()
Thanks to 54d8e724da64, we no longer pass array.array('c') object to
bdiff().
2017-03-26 16:14:04 +09:00
Pierre-Yves David
7f7216e1a9 histedit: test that an aborted histedit can be rerun (with obsolete)
In the future, this should help catching issue as the one introduced in
33e44341bb82.
2017-03-26 15:55:34 +02:00
Pierre-Yves David
26848e81da histedit: backout changeset 33e44341bb82
Before 33e44341bb82, histedit (like rebase) was only creating markers on final
success from the old-rewritten node to the newly created nodes (as of before
33e44341bb82). In case of abort the aborted attempt were stripped to restore the
repository in its state prior to the attempt.

This use of strip was on purpose. Using markers in this case introduces various
issues. The main one is that keeping the partial result of histedit as obsolete
prevents us to recreates the same nodes in a second attempt. The same operation
will lead to an identical results, using an identical node that already exists
in the repository as obsolete.

To conclude, we cannot and should not switch to obsolescence markers creation on
histedit --abort and we backout 33e44341bb82. A test to catch this class of
issue will be introduced in the next changeset.
2017-03-26 15:46:09 +02:00
Pierre-Yves David
28c534388d histedit: backout changeset bcd3d9060a3a
Its parent is about to be backedout so this one needs to be removed too.
2017-03-26 15:34:39 +02:00
Augie Fackler
653b207160 revsetlang: fix _quote on int on python3
Thanks to Yuya for spotting the need.
2017-03-26 16:48:29 -04:00
Jun Wu
0c169b3296 runtests: unset editor and pager related environment variables
Those environment variables could affect some configuration and future
tests. Drop them to avoid issues.
2017-03-26 20:58:54 -07:00
Jun Wu
fea7f2c74c debugfsinfo: improve case-sensitive testing
Previously the case-sensitive test was for the current directory, and is
fragile with errors, and could remove a real file called ".debugfsinfo".

This patch improves the case-sensitive testing so it test the given path
using a unique temporary file, and does not crash on errors.
2017-03-26 17:59:33 -07:00
Jun Wu
00bc5a1203 debugfsinfo: show fstype for given path 2017-03-26 17:29:37 -07:00
Pulkit Goyal
1f79d54f45 test-check-py3-commands: cleanup tests related to hg status
We were testing hg status on Python 3 at two places in the test. Cleaned up
one of them.
2017-03-26 21:10:25 +05:30
Pulkit Goyal
eb657f47dd diff: use pycompat.{byteskwargs, strkwargs} to switch opts b/w bytes and str 2017-03-26 20:58:21 +05:30
Pulkit Goyal
dbbae871d3 patch: make regular expressions bytes by adding b'' 2017-03-26 20:54:50 +05:30
Pulkit Goyal
dbc47c9005 dispatch: use pycompat.maplist() instead of map() to get a list 2017-03-26 20:49:18 +05:30
Matt Harbison
ca74aac810 color: fix grammar in help text 2017-03-25 13:29:23 -04:00
Jun Wu
dc9779bcfc statfs: detect more filesystems on Linux
Previously, the code only has what manpager says. In <linux/magic.h>, there
are more defined. This patch adds filesystems that appear in the current
Arch Linux's /proc/filesystems (autofs, overlay, securityfs) and f2fs, which
was seen in news.
2017-03-25 12:58:55 -07:00
Matt Harbison
721da7fc07 repair: use context manager for lock management
If repo.lock() raised inside of the try block, 'tr' would have been None in the
finally block where it tries to release().  Modernize the syntax instead of just
winching the lock out of the try block.

I found several other instances of acquiring the lock inside of the 'try', but
those finally blocks handle None references.  I also started switching some
trivial try/finally blocks to context managers, but didn't get them all because
indenting over 3x for lock, wlock and transaction would have spilled over 80
characters.  That got me wondering if there should be a repo.rwlock(), to handle
locking and unlocking in the proper order.

It also looks like py27 supports supports multiple context managers for a single
'with' statement.  Should I hold off on the rest until py26 is dropped?
2017-03-23 23:47:23 -04:00
Gregory Szorc
ee826b7708 gitweb: use monospace font for commit messages
Commit messages often contain vertically aligned text. The default
paper style already uses monospace fonts for rendering commit messages.
And, AFAICT, a number of Git servers also render commit messages
with monospace. It seems like the reasonable thing to do.

This commit converts all instances of the full commit message
in the gitweb style to render with monospace.
2017-03-24 19:52:43 -07:00
Matt Harbison
bbf17f3e32 pager: improve support for various flavors of more on Windows
Hardcoding 'more' -> 'more.com' means that 'more.exe' from MSYS would need to be
configured with its *.exe extension.  This will resolve to either one, as
cmd.exe would have done if the command ran through the shell.

Something that's maybe problematic with this is it comes after 'pageractive' and
various ui configs have been set by the calling method.  But the other early
exits in this method don't undo those changes either.
2017-03-24 22:40:08 -04:00
Jun Wu
43184506ff statfs: avoid static allocation
Previously we have "static struct statfs" to return a string. That is not
multiple-thread safe. This patch moves the allocation to the caller to
address the problem.
2017-03-24 15:05:42 -07:00
Jun Wu
3633e80713 statfs: change Linux feature detection
Previously we check three things: "statfs" function, "linux/magic.h" and
"sys/vfs.h" headers. But we didn't check "struct statfs" or the "f_type"
field. That means if a system has "statfs" but "struct statfs" is not
defined in the two header files we check, or defined without the "f_type"
field, the compilation will fail.

This patch combines the checks (2 headers + 1 function + 1 field) together
and sets "HAVE_LINUX_STATFS". It makes setup.py faster (less checks), and
more reliable (immutable to the issue above).
2017-03-24 14:59:19 -07:00
Martin von Zweigbergk
6a886bd950 rebase: don't require destination if commands.rebase.requiredest=False 2017-03-24 16:20:10 -07:00
Martin von Zweigbergk
1781d7139a tests: add tests with commands.{update,rebase}.requiredest=False
This shows how rebase is currently broken with
commands.rebase.requiredest=False.
2017-03-24 16:20:04 -07:00
Durham Goode
de02ce8716 rebase: move state serialization to use unfiltered repo
Now that rebasestate is serialized as part of the transaction, the repo state it
sees is the version at the end of the transaction, which may have hidden nodes.
Therefore, it's possible parts of the rebase commit set are no longer visible by
the time the transaction is closing, which causes a filtered revision error in
this code. I don't think state serialization should be blocked from accessing
commits it knows exist, especially if all it's trying to do is get the hex of
them, so let's use an unfiltered repo here.

Unfortunately, the only known repro is with the fbamend Facebook extension, so
I'm not sure how to repro it in core Mercurial for a test.
2017-03-12 12:33:35 -07:00
FUJIWARA Katsunori
7f301613fe largefiles: avoid redundant standin() invocations
There are some code paths, which apply standin() on same value
multilpe times instead of using already standin()-ed value.

"fstandin" is common name for "path to standin file" in lfutil.py, to
avoid shadowing "standin()".
2017-03-24 22:29:22 +09:00
FUJIWARA Katsunori
319a3de075 largefiles: replace hashrepofile by hashfile (API)
There is only one user for the former, and repo.wjoin()-ed value is
alread known by that user.
2017-03-24 22:29:22 +09:00
FUJIWARA Katsunori
b0cce9d114 largefiles: call readstandin() with changectx itself instead of rev or node
readstandin() takes "node" argument to get changectx by "repo[node]".

There are some readstandin() invocations, which use ctx.node(),
ctx.rev(), or '.' as "node" argument above, even though corresponded
changectx object is already looked up on caller side.

This patch calls readstandin() with already known changectx itself, to
avoid meaningless re-construction of changectx (indirect case via
copytostore() is also included).

BTW, copytostore() uses "rev" argument only for readstandin()
invocation. Therefore, this patch also renames it to "revorctx" to
indicate that it can take not only revision ID or so but also
changectx, for readability.
2017-03-24 22:26:34 +09:00
FUJIWARA Katsunori
0813b4a24f largefiles: omit redundant splitstandin() invocations
There are 3 splitstandin() invocations in updatestandin() for same
"standin" value.
2017-03-24 22:24:59 +09:00
FUJIWARA Katsunori
9222f27b6b largefiles: replace splitstandin() by isstandin() to omit str creation
If splitstandin()-ed str itself isn't used, isstandin() should be
used instead of it, to omit meaningless str creation.
2017-03-24 22:24:59 +09:00
FUJIWARA Katsunori
53a96c883c largefiles: omit redundant isstandin() before splitstandin()
There are many isstandin() invocations before splitstandin().

The former examines whether specified path starts with ".hglf/". The
latter returns after ".hglf/" of specified path if it starts with that
prefix, or returns None otherwise.

Therefore, value returned by splitstandin() can be used for
replacement of preceding isstandin(), and this replacement can omit
redundant string comparison after isstandin().
2017-03-24 22:24:58 +09:00