Commit Graph

910 Commits

Author SHA1 Message Date
Yuya Nishihara
84a8ba9511 templater: factor out function that creates templater from string template
This function will host loading of template aliases. It is not defined at
templater, but at formatter, since formatter is the module handling ui stuff
in front of templater.
2016-04-10 17:23:09 +09:00
Yuya Nishihara
3f981af86b templater: separate function to create templater from map file (API)
New frommapfile() function will make it clear when template aliases will be
loaded. They should be applied to command arguments and templates in hgrc,
but not to map files. Otherwise, our stock styles and web templates
(i.e map-file templates) could be modified unintentionally.

Future patches will add "aliases" argument to __init__(), but not to
frommapfile().
2016-04-03 23:26:48 +09:00
Nathaniel Manista
9e78f05831 cmdutil: avoid recycling variable name "name" in namespaces code
This just feels like asking for future trouble and confusion.
2016-04-14 15:26:18 -04:00
santiagopim
ab2ab42ccf graphmod: shorten graph
Shorten the graph, cutting the all vertical (not oblique) edges rows.
Activate with 'graphshorten = true' in [experimental] section.

Example graph with deactivated option:

$ hg log --graph --template '{rev} {desc|firstline}' --rev 1035:1015
o    1035 Merge with BOS
|\
| o  1034 Fix help output, and a few broken tests.
| |
| o    1033 Merge with MPM.
| |\
| | o  1032 Get patchbomb working with tip again.
| | |
| | o  1031 Rewrite log command.  New version is faster and more featureful.
| | |
| | o    1030 Merge with MPM.
| | |\
| | | o  1029 Emacs: implement hg-incoming, hg-outgoing and hg-push.
| | | |
| | | o  1028 Add commands.debugconfig.
| | | |
| | | o  1027 Emacs: fix up hg-log and hg-diff to operate more uniformly.
| | | |
| | | o    1026 Merge with MPM.
| | | |\
| | | | o  1025 Merge with MPM.
| | | | |
| | | | ~
| | | o  1024 Sync buffers prior to doing a diff.
| | | |
| | | ~
o | |  1023 Minor tweak to the revgen algorithm
|/ /
o |  1022 Minor hgwebdir tweaks
| |
o |  1021 Add Makefile to the manifest
| |
o |  1020 Add default make rule
| |
o |  1019 Create helper functions for I/O to files in the working directory
| |
o |  1018 Add some aliases
| |
o |  1017 Fix up help for binary options
|/
o  1016 Teach annotate about binary files
|
o  1015 Add automatic binary file detection to diff and export
|
~

Example graph with activated option:

$ hg log --graph --template '{rev} {desc|firstline}' --rev 1035:1015
o    1035 Merge with BOS
|\
| o  1034 Fix help output, and a few broken tests.
| o    1033 Merge with MPM.
| |\
| | o  1032 Get patchbomb working with tip again.
| | o  1031 Rewrite log command.  New version is faster and more featureful.
| | o    1030 Merge with MPM.
| | |\
| | | o  1029 Emacs: implement hg-incoming, hg-outgoing and hg-push.
| | | o  1028 Add commands.debugconfig.
| | | o  1027 Emacs: fix up hg-log and hg-diff to operate more uniformly.
| | | o    1026 Merge with MPM.
| | | |\
| | | | o  1025 Merge with MPM.
| | | | |
| | | | ~
| | | o  1024 Sync buffers prior to doing a diff.
| | | |
| | | ~
o | |  1023 Minor tweak to the revgen algorithm
|/ /
o |  1022 Minor hgwebdir tweaks
o |  1021 Add Makefile to the manifest
o |  1020 Add default make rule
o |  1019 Create helper functions for I/O to files in the working directory
o |  1018 Add some aliases
o |  1017 Fix up help for binary options
|/
o  1016 Teach annotate about binary files
o  1015 Add automatic binary file detection to diff and export
|
~
2016-04-08 16:42:43 +02:00
timeless
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
Yuya Nishihara
72e05b7594 templater: drop deprecated handling of KeyError from changeset_templater
It's been superseded by 50f9d20d4c27 and the previous patch. templater.mapfile
is no longer used and removed.
2016-04-03 11:23:31 +09:00
timeless
372fa02ecc crecord: check for untracked arguments
hg commit tracked untracked -- fails complaining about untracked

prior to this commit,
hg commit -i tracked untracked -- did not fail

This is corrected by calling the refactored localrepo.checkcommitpatterns
2016-04-06 18:19:36 +00:00
Jordi Gutiérrez Hermoso
52cc18f78c crecord: re-enable reviewing a patch before comitting it
The "r" option for this feature was copied into Mercurial from
crecord, but the actual implementation never made it into hg until
now. It's a moderately useful feature that allows the user to edit the
patch in a text editor before comitting it for good.

This requires a test, so we must also enable a corresponding testing
'R' option that skips the confirmation dialogue. In addition, we also
need a help text for the editor when reviewing the final patch.

As for why this is a useful feature if we can already edit hunks in an
editor, I would like to offer the following points:

    * editing hunks does not show the entire patch all at once

      ** furthermore, the hunk "tree" in the TUI has no root that could be
         selected for edition

    * it is helpful to be able to see the entire final patch for
      confirmation

      ** within this view, the unselected hunks are hidden, which is
         visusally cleaner

      ** this works as a final review of the complete result, which is
         a bit more difficult to do conceptually via hunk editing

    * this feature was already in crecord, so it was an oversight to
      not bring it to core

    * it works and is consistent with editing hunks
2016-03-20 21:08:17 -04:00
Yuya Nishihara
634500f64e templater: relax unquotestring() to fall back to bare string
This is convenient for our use case where quotes are optional except in
a map file.
2016-03-26 18:12:12 +09:00
Yuya Nishihara
f0125a308f templater: do not abuse SyntaxError to report errors in template map file
SyntaxError is the class representing syntax errors in Python code. We should
use a dedicated exception class for our needs. With this change, unnecessary
re-wrapping of SyntaxError can be eliminated.
2016-03-26 18:01:04 +09:00
Pierre-Yves David
34ff160b27 graphmod: move the graphstyle options to experimental
I let this slip in the [ui] section during the review, as far as I understand we
don't plan to actually support customisation of the output on we are happy with
our choice.  The option are just here to help people tests various options so we
can decide which one we'll actually use.

I'm moving the config option in the experimental section to make this clearer
and avoid making them part of the public API by mistake.
2016-03-24 00:09:58 -07:00
Kostia Balytskyi
35f0e5c575 debugobsolete: add an option to show marker index
A bigger picture is the ability to be delete an arbitrary marker form the
repo's obsstore. This is a useful debug ability and it needs a way to indentify
the marker one wants to delete. Having a marker's index provides such an
ability.
2016-03-23 10:50:24 -07:00
timeless
9ba351b1ab remove: add progress support 2016-03-17 21:03:22 +00:00
timeless
f5abb39053 remove: queue warnings until after status messages (issue5140) (API)
Before this change, warnings were interspersed with (and easily drowned out by)
status messages.

API:
abstractsubrepo.removefiles has an extra argument warnings,
into which callees should append their warnings.
  Note: Callees should not assume that there will be items in the list,
  today, I'm lazily including any other subrepos warnings, but
  that may change.

cmdutil.remove has an extra optional argument warnings,
into which it will place warnings.
If warnings is omitted, warnings will be reported via ui.warn()
as before this change (albeit, after any status messages).
2016-03-17 18:19:36 +00:00
Martijn Pieters
146cd7366a graphmod: allow edges to end early
Rather than draw an edge all the way to the bottom of the graph, make it
possible to end an edge to parents that are not part of the graph early on.
This results in a far cleaner graph.

Any edge type can be set to end early; set the ui.graphstyle.<edgetype>
parameter to the empty string to enable this.

For example, setting the following configuration:

    [ui]
    graphstyle.grandparent = :
    graphstyle.missing =

would result in a graph like this:

  o    changeset:   32:d06dffa21a31
  |\   parent:      27:886ed638191b
  | :  parent:      31:621d83e11f67
  | :
  o :  changeset:   31:621d83e11f67
  |\:  parent:      21:d42a756af44d
  | :  parent:      30:6e11cd4b648f
  | :
  o :    changeset:   30:6e11cd4b648f
  |\ \   parent:      28:44ecd0b9ae99
  | ~ :  parent:      29:cd9bb2be7593
  |  /
  o :    changeset:   28:44ecd0b9ae99
  |\ \   parent:      1:6db2ef61d156
  | ~ :  parent:      26:7f25b6c2f0b9
  |  /
  o :    changeset:   26:7f25b6c2f0b9
  |\ \   parent:      18:1aa84d96232a
  | | :  parent:      25:91da8ed57247
  | | :
  | o :  changeset:   25:91da8ed57247
  | |\:  parent:      21:d42a756af44d
  | | :  parent:      24:a9c19a3d96b7
  | | :
  | o :    changeset:   24:a9c19a3d96b7
  | |\ \   parent:      0:e6eb3150255d
  | | ~ :  parent:      23:a01cddf0766d
  | |  /
  | o :    changeset:   23:a01cddf0766d
  | |\ \   parent:      1:6db2ef61d156
  | | ~ :  parent:      22:e0d9cccacb5d
  | |  /
  | o :  changeset:   22:e0d9cccacb5d
  |/:/   parent:      18:1aa84d96232a
  | :    parent:      21:d42a756af44d
  | :
  | o    changeset:   21:d42a756af44d
  | |\   parent:      19:31ddc2c1573b
  | | |  parent:      20:d30ed6450e32
  | | |
  +---o  changeset:   20:d30ed6450e32
  | | |  parent:      0:e6eb3150255d
  | | ~  parent:      18:1aa84d96232a
  | |
  | o    changeset:   19:31ddc2c1573b
  | |\   parent:      15:1dda3f72782d
  | ~ ~  parent:      17:44765d7c06e0
  |
  o  changeset:   18:1aa84d96232a
     parent:      1:6db2ef61d156
     parent:      15:1dda3f72782d

The default configuration leaves all 3 types set to |.

This is part of the work towards moving smartlog upstream; currently smartlog
injects extra nodes into the graph to indicate grandparent relationships (nodes
elided).
2016-03-19 16:37:47 -07:00
Martijn Pieters
32562c645b graphmod: allow for different styles for different edge types
Rather than draw all edges as solid lines, allow for using different styles for
different edge types. For example you could use dotted lines for edges that
do not connect to a parent, and dashed lines when connecting to a grandparent
(implying missing nodes in between).

For example, setting the following configuration:

    [ui]
    graphstyle.grandparent = :
    graphstyle.missing = .

would result in a graph like this:

  o    changeset:   32:d06dffa21a31
  |\   parent:      27:886ed638191b
  | :  parent:      31:621d83e11f67
  | :
  o :  changeset:   31:621d83e11f67
  |\:  parent:      21:d42a756af44d
  | :  parent:      30:6e11cd4b648f
  | :
  o :    changeset:   30:6e11cd4b648f
  |\ \   parent:      28:44ecd0b9ae99
  | . :  parent:      29:cd9bb2be7593
  | . :
  o . :    changeset:   28:44ecd0b9ae99
  |\ \ \   parent:      1:6db2ef61d156
  | . . :  parent:      26:7f25b6c2f0b9
  | . . :
  o . . :    changeset:   26:7f25b6c2f0b9
  |\ \ \ \   parent:      18:1aa84d96232a
  | | . . :  parent:      25:91da8ed57247
  | | . . :
  | o-----+  changeset:   25:91da8ed57247
  | | . . :  parent:      21:d42a756af44d
  | | . . :  parent:      24:a9c19a3d96b7
  | | . . :
  | o . . :    changeset:   24:a9c19a3d96b7
  | |\ \ \ \   parent:      0:e6eb3150255d
  | | . . . :  parent:      23:a01cddf0766d
  | | . . . :
  | o---+ . :  changeset:   23:a01cddf0766d
  | | . . . :  parent:      1:6db2ef61d156
  | | . . . :  parent:      22:e0d9cccacb5d
  | | . . . :
  | o-------+  changeset:   22:e0d9cccacb5d
  | . . . . :  parent:      18:1aa84d96232a
  |/ / / / /   parent:      21:d42a756af44d
  | . . . :
  | . . . o    changeset:   21:d42a756af44d
  | . . . |\   parent:      19:31ddc2c1573b
  | . . . | |  parent:      20:d30ed6450e32
  | . . . | |
  +-+-------o  changeset:   20:d30ed6450e32
  | . . . |    parent:      0:e6eb3150255d
  | . . . |    parent:      18:1aa84d96232a
  | . . . |
  | . . . o    changeset:   19:31ddc2c1573b
  | . . . .\   parent:      15:1dda3f72782d
  | . . . . |  parent:      17:44765d7c06e0
  | . . . . |
  o---+---+ |  changeset:   18:1aa84d96232a
    . . . . |  parent:      1:6db2ef61d156
   / / / / /   parent:      15:1dda3f72782d
  . . . . .


Edge styles can be altered by setting the following one-character config options::

    [ui]
    graphstyle.parent = |
    graphstyle.grandparent = :
    graphstyle.missing = .

The default configuration leaves all 3 types set to |, leaving graph styles
unaffected.

This is part of the work towards moving smartlog upstream; currently smartlog
injects extra nodes into the graph to indicate grandparent relationships (nodes
elided).
2016-03-19 16:46:15 -07:00
Jordi Gutiérrez Hermoso
bc2e698d24 crecord: rewrite a comment about filtering patches
I couldn't parse the previous version. I think the rewrite better
expresses the intent of that comment.
2016-03-18 16:14:57 -04:00
Jun Wu
df2c932cf1 serve: add chdir command for --daemon-postexec
For chgserver, it probably needs a chdir to /. This patch adds chdir command
support for --daemon-postexec so chg client can make use of it.
2016-03-09 01:17:02 +00:00
Jun Wu
704e54e1c7 serve: accept multiple values for --daemon-postexec
The next patch will add another postexec command: chdir, which can be used
together with unlink. This patch changes the option type of --daemon-postexec
from string to list to accept multiple commands. The error message of invalid
--daemon-postexec value is also changed to include the actual invalid value.
2016-03-09 02:07:40 +00:00
Matt Mackall
6d2484af42 merge with stable 2016-03-11 15:24:27 -06:00
Matt Harbison
3fb00b6ab7 files: don't recurse into subrepos without a path or -S (issue5127)
The 'm.always()' check was needed for when a path to 'sub1' is given, and 'sub1'
contains a subrepo itself.  But that also caused the automatic recursion when no
path was given.  Instead, force -S when printing a subrepo if the subpath is an
exact match (which will unconditionally recurse once in the nested subrepo).
2016-03-06 14:30:34 -05:00
Yuya Nishihara
5b1b6151af log: fix order of revisions filtered by multiple OR options (issue5100)
This is the simplest workaround for the issue of the ordering of revset, which
is that the expression "x or y" takes over the ordering specified by the input
set (or the left-hand-side expression.) For example, the following expression

  A & (x | y)

will be evaluated as if

  (A & x) | (A & y)

That's wrong because revset has ordering. I'm going to fix this problem in
the revset module, but that wouldn't fit to stable. So, this patch just works
around the common log cases.

Since this change might have some impact on performance, it is enabled only
if the expression built from log options has ' or ' operation.
2016-02-15 22:46:07 +09:00
Pierre-Yves David
afc2550500 revert: properly revert to ancestor of p2 during merge (issue5052)
During merge, added (from one perspective) file can be reported as "modified".
To work around that, revert was testing if modified file were present in the
parent manifest and marking them as "added" in this case. However, we should be
checking against the target revision manifest instead. Otherwise see file as
"newly added" even if they exist in the target revision.

That revert behavior regressed in 3657ae7519b7.
2016-02-23 11:41:47 +01:00
Siddharth Agarwal
c8ebb66630 amend: don't preserve most extra fields
This backs out changeset fd794e885a9e9.

There are some extra fields that absolutely should not be preserved, like the
convert_revision field introduced by the convert and hgsubversion extensions.
The problem with extensions blacklisting certain extra fields is that they
might not be enabled at the time the amend is performed.

In the long run we probably want separately marked transferable and
non-transferable extra fields, but for now restore the old Mercurial 3.6
behavior.
2016-02-03 08:59:46 -08:00
Matt Harbison
87e191502b commit: factor the post commit status check into a cmdutil method
The largefiles extension needs to set lfstatus for this status call.  Otherwise,
if a missing largefile is explicitly named, a confusing message is issued that
says the largefile wasn't found, followed by another that says nothing changed.
2016-01-23 23:24:30 -05:00
Yuya Nishihara
3e3e4eca75 graphlog: bring back color to node symbol template
Follows up 64cf8f39aac2. A ui object is required to render labels.
2016-03-09 23:57:15 +09:00
Kostia Balytskyi
e31d7d20ae formatter: make labels work with templated output
To describe the bug this fix is addressing, one can do
   ``$ hg status -T "{label('red', path)}\n" --color=debug``
and observe that the label is not applied before my fix and applied with it.
2016-03-08 04:08:33 -08:00
Martijn Pieters
a973afd498 graphmod: refactor state handling
Move ASCII graph state to a dictionary, to clarify what is being tracked. Move
the 'seen' state (tracking currently active edges) into this structure.
2016-03-04 14:44:32 +00:00
Bryan O'Sullivan
c72a4fb771 with: use context manager in amend 2016-01-15 13:14:50 -08:00
Bryan O'Sullivan
61f7160c5a with: use context manager for wlock in revert 2016-01-15 13:14:46 -08:00
Bryan O'Sullivan
7b94af6911 with: use context manager for wlock in remove 2016-01-15 13:14:45 -08:00
Bryan O'Sullivan
9fd07f61b7 with: use context manager for wlock in recordinwlock 2016-01-15 13:14:45 -08:00
Augie Fackler
a7381bb9d3 bmstore: add handling of the active bookmark
This further centralizes the handling of bookmark storage, and will
help get some lingering bookmarks business out of localrepo. Right
now, this change implies reading of the active bookmark to also imply
reading all bookmarks from disk - for users with many many bookmarks
this may be a measurable performance hit. In that case, we should
migrate bmstore to be able to lazy-read its properties from disk
rather than having to eagerly read them, but I decided to avoid doing
that to try and avoid some potentially complicated filecache decorator
issues.

This doesn't move the logic for writing the active bookmark into a
transaction, though that is probably the correct next step. Since the
API probably needs to morph a little more, I didn't bother marking
bookmarks.{activate,deactivate} as deprecated yet.
2015-11-11 21:18:02 -05:00
Siddharth Agarwal
0efe3372e4 origpath: move from cmdutil to scmutil
This is a lower-level function so it doesn't need to be in cmdutil, and putting
it here avoids a bunch of potential import cycle issues.
2016-01-02 03:02:57 -08:00
timeless
ebb1d48658 cleanup: remove superfluous space after space after equals (python) 2015-12-31 08:16:59 +00:00
timeless
70afd4fdbd graft: hook afterresolvedstates 2015-12-24 20:46:06 +00:00
timeless
ea4a7888cc resolve: suggest the next action
Expose afterresolvedstates to allow graft and similar to
suggest a message when resolving results in no unresolved
files.

If there isn't a matching state in afterresolvedstates,
then if verbose, suggest commiting.
2015-12-24 19:25:44 +00:00
Durham Goode
31ae564415 cmdutil: pass node instead of ctx to diffordiffstat
0f01b8ad724c changed showpatch to use ctx's more, but it accidentally passed
prev as a context and node as a binary string, when both should be passed as
binary strings (since diffordiffstat tries to resolve them via repo[X]).

This affected hggit since the existing ctx belongs to the git overlay, but the
resolved context (from the repo[X] resolution) should belong to the main repo.
This broke a test because it tried to look in the git repo for data that didn't
exist.

This feels like a deeper issue in hggit somewhere, but the fix is here trivial and
obviously more correct
2016-01-04 16:14:04 -08:00
timeless
e8391d2c9e import: refactor nocommit and importbranch handling 2015-12-30 21:07:51 +00:00
timeless
b14a670d15 import: refactor date and user handling 2015-12-30 21:06:31 +00:00
timeless
bb92774f3e import: limit scope of msg in tryimportone 2015-12-30 21:05:42 +00:00
Matt Mackall
798e034a3c merge with stable 2015-12-28 10:11:48 -06:00
Sean Farley
b03ec18822 cmdutil: use crecordmod.checkcurses
Instead of blindly trusting the user's experimental.crecord, we use checkcurses
to abstract that logic so that we can handle the case where python was not
built with curses.
2015-12-15 16:01:45 -08:00
Siddharth Agarwal
7191433ea2 record: don't dereference symlinks while copying over stat data
Previously, we could be calling os.utime or os.chflags (via shutil.copystat) on
a symlink. These functions dereference symlinks, so this would have caused the
timestamp of the target to be set. On a read-only or similarly weird
filesystem, this might cause an exception to be raised.

This is pretty hard to test because conjuring up a read-only filesystem for
test purposes is non-trivial.
2015-12-12 10:58:05 -08:00
Yuya Nishihara
664cff6605 cmdutil: do not duplicate stdout by makefileobj()
It made output order unpredictable because two separate buffers are flushed
individually. Let's use a thin wrapper that just sends close() to black hole.
2015-12-13 20:07:19 +09:00
Yuya Nishihara
db7707d747 cmdutil: reimplement file wrapper that disables close()
There's no need to dynamically create wrappedfileobj class and define
close() as lambda. Also, __iter__() was missing.
2015-12-13 20:01:11 +09:00
Yuya Nishihara
3a0b98410a export: remove useless comparison between file object and string
It was introduced at fa80944106df, where "template" argument could be a file
object. After that, 426525670e45 added "len(template)", so "template" must be
a string now. Therefore, "fp != template" should always be True.

It seems fa80944106df was intended to work around a bug in TortoiseHg, and
I'm sure I've fixed it completely in TortoiseHg source.

https://selenic.com/pipermail/mercurial-devel/2011-February/028467.html
2015-12-13 19:57:54 +09:00
Yuya Nishihara
00a04ad77b export: do not print '<fdopen>' as an output filename
Because makefileobj() duplicates or wraps stdout, "fp != sys.stdout" didn't
work correctly. Python doc states that special file objects are named in the
form '<...>', and absolute filenames should never start with '<', we can
ignore names start with '<'. We can't test fp.fileno() because fp may be a
command-server channel.

https://docs.python.org/2.7/library/stdtypes.html#file.name

In the test output, "exporting patch:" line is printed after patch content.
This is caused by fdopen() and will be fixed by the subsequent patch.
2015-12-13 19:47:46 +09:00
timeless
1054dbcfef record: turn on showfunc
Always try to give diff context when doing an interactive record
2015-12-17 14:38:22 +00:00
Matt Mackall
e9718e4615 merge with stable 2015-12-16 17:40:01 -06:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
FUJIWARA Katsunori
36207b46bf cmdutil: make in-memory changes visible to external editor (issue4378)
Before this patch, external editor process for the commit log can't
view some in-memory changes (especially, of dirstate), because they
aren't written out until the end of transaction (or wlock).

This causes unexpected output of Mercurial commands spawned from that
editor process.

To make in-memory changes visible to external editor process, this
patch does:

  - write (or schedule to write) in-memory dirstate changes, and
  - set HG_PENDING environment variable, if:
    - a transaction is running, and
    - there are in-memory changes to be visible

"hg diff" spawned from external editor process for "hg qrefresh"
shows:

  - "changes newly imported into the topmost" before ab68b153ce34(*)
  - "all changes recorded in the topmost by refreshing" after this patch

(*) ab68b153ce34 changed steps invoking editor process

Even though backward compatibility may be broken, the latter behavior
looks reasonable, because "hg diff" spawned from the editor process
consistently shows "what changes new revision records" regardless of
invocation context.

In fact, issue4378 itself should be resolved by b46029eb5b29, which
made 'repo.transaction()' write in-memory dirstate changes out
explicitly before starting transaction. It also made "hg qrefresh"
imply 'dirstate.write()' before external editor invocation in call
chain below.

  - mq.queue.refresh
    - strip.strip
      - repair.strip
        - localrepository.transaction
          - dirstate.write
    - localrepository.commit
      - invoke external editor

Though, this patch has '(issue4378)' in own summary line to indicate
that issues like issue4378 should be fixed by this.

BTW, this patch adds '-m' option to a 'hg ci --amend' execution in
'test-commit-amend.t', to avoid invoking external editor process.

In this case, "unsure" states may be changed to "clean" according to
timestamp or so on. These changes should be written into pending file,
if external editor invocation is required,

Then, writing dirstate changes out breaks stability of test, because
it shows "transaction abort!/rollback completed" occasionally.

Aborting after editor process invocation while commands below may
cause similar instability of tests, too (AFAIK, there is no more such
one, at this revision)

  - commit --amend
    - without --message/--logfile

  - import
    - without --message/--logfile,
    - without --no-commit,
    - without --bypass,
    - one of below, and
      - patch has no description text, or
      - with --edit
    - aborting at the 1st patch, which adds or removes file(s)
      - if it only changes existing files, status is checked only for
        changed files by 'scmutil.matchfiles()', and transition from
        "unsure" to "normal" in dirstate doesn't occur (= dirstate
        isn't changed, and written out)
      - aborting at the 2nd or later patch implies other pending
        changes (e.g. changelog), and always causes showing
        "transaction abort!/rollback completed"
2015-10-17 01:15:34 +09:00
FUJIWARA Katsunori
811ef7c75f dirstateguard: remove layering violation around saving/restoring backup
This violation, which passes 'repo' object to dirstate, was introduced
by afd0ae63d624 and c26227275f1e.
2015-10-17 01:15:33 +09:00
Tony Tung
4c1f5709e1 commit: abort when a committemplate is not changed
If a committemplate is provided and no message is provided on the
command line, and no edits are made to the commit template, then abort
the commit.
2015-10-09 21:44:54 -07:00
Augie Fackler
0a19647501 merge: have merge.update use a matcher instead of partial fn
This is relatively rarely used functionality, but migrating this to a
matcher will make future work on narrow clones more feasible.
2015-12-14 18:54:03 -05:00
Yuya Nishihara
10b6f5819b graphlog: make node symbol templatable by ui.graphnodetemplate option
New ui.graphnodetemplate option allows us to colorize a node symbol by phase
or branch,

  [ui]
  graphnodetemplate = {label('graphnode.{phase}', graphnode)}
  [color]
  graphnode.draft = yellow bold

or use a variety of unicode emoji characters, and so on. (You'll need less-481
to display non-BMP unicode character.)

  [ui]
  graphnodetemplate = {ifeq(obsolete, 'stable', graphnode, '\xf0\x9f\x92\xa9')}
2015-11-14 17:25:43 +09:00
Yuya Nishihara
f981890d2b graphlog: extract "graphnode" template keyword that represents node symbol
This provides a default node symbol. Tests will be added later.

"showparents" variable is renamed to "wpnodes" to avoid confusion with the
existing showparents() function.
2015-11-14 16:58:18 +09:00
Yuya Nishihara
78ebbc20b2 graphlog: move creation of workingdir-parent nodes to displaygraph()
Future patches will make a node symbol templatable. Because arguments of a
templatekw function are repo and ctx, "showparents" list will have to be
built from a repo object by that function.
2015-11-14 16:45:15 +09:00
Laurent Charignon
1409af5e69 commit: add a way to return more information from the chunkselector
Before this patch, the chunkselector for record or crecord was used to return
the list of hunks that were selected by the user. The goal of this series is to
reintroduce the toggle amend feature for crecord. To do so, we need to be able
to return more than just the selected hunks from the chunkselector but also
the information: is amend mode toggled. This patch adds a new return value for
chunkselectors that will be used to implement the toggle amend feature in
crecord.
2015-11-30 16:35:21 -08:00
Mike Edgar
8e7be9d666 commit: preserve extra when amending with commit --amend
The new extra propagation needs to be accounted for in cmdutil.amend,
when checking for a no-changes fast-path.
2015-11-28 04:11:57 -05:00
Gregory Szorc
b184853d7f ui: remove labeled argument from popbuffer
It was moved to pushbuffer and currently does nothing.
2015-11-24 11:23:10 -08:00
Gregory Szorc
9a0cab7d0b cmdutil: pass labeled=True to pushbuffer()
This doesn't yet change behavior because labeling is still performed
at popbuffer time.

Surprisingly, this is the only in-tree consumer that passes
labeled=True.
2015-11-22 14:13:25 -08:00
Gregory Szorc
dbea71eee2 cmdutil.changeset_printer: pass context into showpatch()
Before, we passed the node then subsequently performed a lookup on
repo.changelog. We already has the context available, so just pass it
in.

This does result in a small performance win. But I doubt it will show
up anywhere because diff[stat] calculation will dwarf the time spent
to create a changectx. Still, we should be creating fewer changectx
out of principle.
2015-11-14 17:44:01 -08:00
Gregory Szorc
330e05f22b cmdutil: use absolute_import
Now that @command doesn't write back into commands when it is being
executed during the loading of commands.py itself, we are unblocked
from converting cmdutil to absolute_import.
2016-02-27 23:57:07 -08:00
Yuya Nishihara
e4227925aa dispatch: store norepo/optionalrepo/inferrepo attributes in function (API)
This can eliminate import cycles and ugly push/pop of global variables at
_checkshellalias(). Attributes of aliascmd are directly accessible.

Because norepo/optionalrepo/inferrepo lists aren't populated, extensions
examining them no longer work. That's why this patch removes these lists
to signal the API incompatibility.

This breaks 3rd-party extensions that are yet to be ported to @command
decorator.
2016-01-01 22:16:25 +09:00
Matt Mackall
c0ab1b7cbf merge with stable 2016-02-29 17:52:17 -06:00
Matt Mackall
0fcff83b31 merge with stable 2016-02-24 15:55:44 -06:00
Jun Wu
229f5b8884 serve: allow --daemon-postexec to be 'unlink:path' or 'none'
This patch changes the format of value of --daemon-postexec. Now it can be
either to unlink a file, or a no-op. The following patch will make chg to
use the no-op option.
2016-02-22 17:30:02 +00:00
Jun Wu
f5397047b4 serve: rename --daemon-pipefds to --daemon-postexec (BC)
Initially we use --daemon-pipefds to pass file descriptors for synchronization.
Later, in order to support Windows, --daemon-pipefds is changed to accept a
file path to unlink instead. The name is outdated since then.

chg client is designed to use flock, which will be held before starting a
server and until the client actually connects to the server it started. The
unlink synchronization approach is not so helpful in this case.

To address the issues, this patch renames pipefds to postexec and the following
patch will allow the value of --daemon-postexec to be things like
'unlink:/path/to/file' or 'none'.
2016-02-22 16:59:08 +00:00
timeless
35e2ff1d7c cmdutil: provide a way to report how to continue
checkafterresolved allows Mercurial to suggest what command to
use next. If users try to continue the wrong command, there
wasn't a good way for the command to suggest what to do next.

Split checkmdutil into howtocontinue and checkafterresolved.
Introduce wrongtooltocontinue which handles raising an Abort with
the hint from howtocontinue.
2016-02-14 16:16:17 +00:00
timeless
3502e556ef util: enable getpid to be replaced
This will enable tests to write stable process ids.
2016-02-03 09:11:22 +00:00
Martin von Zweigbergk
c84bb33a89 match: rename "narrowmatcher" to "subdirmatcher" (API)
I keep mistaking "narrowmatcher" for narrowhg's
narrowmatcher. "subdirmatcher" seems more to the point anyway.
2016-02-05 21:09:32 -08:00
liscju
70a7e0a4b4 revert: makes interactive mode ask to forget added files (issue4936)
Before this patch revert interactive mode unconditionally forgets
added files. This patch fixes this by asking user if he wants
to forget added file. If user doesn't want to forget given file,
it is added to matcher_opts exclude list, to not reviewing it
later with other modified files.
2016-02-05 15:18:40 +01:00
Gregory Szorc
5e2a52d9ca exchange: move bundle specification parsing from cmdutil
Clone bundles require a well-defined string to specify the type of
bundle that is listed so clients can filter compatible file types. The
`hg bundle` command and cmdutil.parsebundletype() already establish the
beginnings of a bundle specification format.

As part of formalizing this format specification so it can be used by
clone bundles, we move the specification parsing bits verbatim to
exchange.py, which is a more suitable place than cmdutil.py. A
subsequent patch will refactor this code to make it more appropriate as
a general API.
2015-10-13 11:43:21 -07:00
FUJIWARA Katsunori
af664f3cc0 dirstate: move code paths for backup from dirstateguard to dirstate
This can centralize the logic to write in-memory changes out correctly
according to transaction activity into dirstate.

Passing 'repo' object to newly added functions is needed to examine
current transaction activity in subsequent patches, because 'dirstate'
itself doesn't have direct reference to it.
2015-10-14 02:49:17 +09:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
FUJIWARA Katsunori
05986aa7a1 cmdutil: stop tryimportone from using dirstateguard (BC)
There is no user of 'cmdutil.tryimportone()' other than
'commands.import_()', which can restore dirstate at failure of
applying patches by transaction or dirstateguard.

Therefore, it is reasonable to stop 'tryimportone()' from using
redundant 'dirstateguard', even though it changes behavior of
'tryimportone()'.

After this patch, 3rd party extensions should use 'dirstateguard' or
so explicitly, if they want to restore dirstate at failure of
importing a patch.
2015-10-09 03:53:46 +09:00
FUJIWARA Katsunori
f2187903e7 dirstate: remove meaningless dirstateguard
Previous patch made dirstate changes in a transaction scope "all or
nothing". Therefore, 'dirstateguard' is meaningless, if its scope is
as same as one of the related transaction.

This patch removes such meaningless 'dirstateguard' usage.
2015-10-09 03:53:46 +09:00
Pierre-Yves David
e5e36f8235 import: allow processing of extra part header after import
As we have a way for extension to add more header, we need a way for them to
actually process them. We add a basic hook point to do extra work after the
import have been committed.
2015-10-07 13:05:25 -07:00
Pierre-Yves David
684d4c614d import: allow processing of extra part header during import
As we have a way for extension to add more header, we need a way for them to
actually process them. We add a basic hook points to alter the changeset
(especially extra) before we commit. There would be more to do for a full
featured hooking, but this currently fit my needs.
2015-10-06 09:51:24 -07:00
Pierre-Yves David
ec1d4cc8b3 patch: move 'extract' return to a dictionnary
The final goal here is to be able to parse, return and process arbitrary data
from patch. This mirror the recently added ability to add arbitrary data to
patch headers.

The first step is to return something more flexible, so we return a dict without
changing any other logic.
2015-10-06 02:01:53 -07:00
Pierre-Yves David
d6432f70b8 export: introduce a generic way to add patch header on export
Extensions currently have no easy way to add data to exported
patch. This is now fixed using a generic mechanism in the same fashion
used by bundle2. Tests are coming in the next changeset with its first
user.
2015-10-05 23:17:01 -07:00
Pierre-Yves David
232a6cb371 bundle: use bundle2 if repository uses general delta
As bundle1 does not support generaldelta, this would mean recomputing delta at
bundle time. This is similar to what we do for strip and shelve and was tracked
as issue4865.
2015-10-01 20:31:43 -07:00
Pierre-Yves David
f1e9601240 parsebundletype: add a comment for future generation 2015-10-01 20:21:16 -07:00
Pierre-Yves David
8f390ad0b6 bundle: extend the format of --type to support version and compression
We had some basic undocumented support for uncompressed bundle2 support. We now
have an official extensible syntax to specify both format type and compression
(eg: bzip2-v2).

In practice, this changeset introduce the 'v1' and 'v2' identifier to make it
possible to combine format and compression. The default format is still 'v1'.
We'll care about picking 'v1' or 'v2' in regard with general delta in the next
changesets.
2015-10-01 19:16:00 -07:00
Pierre-Yves David
63b3b90838 bundle: extract the parsing of the bundle type in a function
We are going to introduce significant extensions of the bundle parsing code to
support creation of bundle2 through the bundle command. As an early step, we
extract the logic in its own function.
2015-10-01 18:01:24 -07:00
Yuya Nishihara
dc974fcbf0 templatekw: port implementation of showparents() from changeset_templater
It isn't cool, but we can peek at ui flag via repo.ui. So, it is possible
to implement showparents() in templatekw, and therefore we can eliminate the
dockeywords hack.
2015-09-26 12:38:02 +09:00
Yuya Nishihara
c09856f19f changeset_printer: move _meaningful_parentrevs() to scmutil
It will be used by templatekw.
2015-09-26 12:29:09 +09:00
timeless@mozdev.org
51da91c959 cmdutil: handle multiline translations of HG: messages safely
Before this, if a localizer/localization included a multiline
message, and didn't prefix the intermediate lines with 'HG: ',
then the line would be a candidate for inclusion in the commit
message -- which isn't ideal.
2015-09-30 12:36:30 -04:00
timeless@mozdev.org
2993615080 cmdutil: remove HG: prefix from translation strings 2015-09-25 03:44:15 -04:00
Pierre-Yves David
124b8948d8 addremove: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 01:58:33 -07:00
Matt Harbison
99ffdaafef extdiff: enable -I/-X with --patch
Not sure how useful this really is, but it's trivial to add and ignoring the
existing arguments supported seems like a bad UI.
2015-09-09 22:27:48 -04:00
Matt Mackall
5b498724ca templater: add new docheader/footer components for XML (issue4135)
The existing header/footer components were templated per-changeset,
and thus couldn't be correctly printed for an empty log
2015-08-26 16:27:14 -05:00
Durham Goode
94ca2e4c06 add: pass full=False to dirstate walk
Previously cmdutil.add would call wctx.walk(), which under the hood calls
dirstate.walk with full=True. This means it returns all of the clean files
(which we don't need when computing the add set), as well as the unclean files.
This results in 1) a lot more work being done and 2) this code path
circumventing the hgwatchman extension, resulting in worse performance in
hgwatchman environments ('hg add .' went from 9s to 1.8s).
2015-09-09 09:07:27 -07:00
timeless@mozdev.org
52eae47139 spelling: behaviour -> behavior 2015-08-28 10:53:55 -04:00
Matt Mackall
ca5b5bbb7b templater: move verbosity-to-template matcher to constructor
We're going to reuse this and it's silly for it to be done per-cset anyway.
2015-08-25 13:38:20 -05:00
Matt Mackall
240305489f templater: remove pseudo-ternary 2015-08-25 12:59:08 -05:00
Matt Mackall
9d8dac9846 templater: fix variable name that shadows built-in 2015-08-25 12:57:21 -05:00
Matt Mackall
c43a857672 templater: minor whitespace tweaks 2015-08-25 09:38:06 -05:00
Christian Delahousse
f5b2078fe3 revert: allow configuring the .orig file location 2015-11-12 17:00:08 -06:00