Commit Graph

969 Commits

Author SHA1 Message Date
Yuya Nishihara
cb89cb49a0 formatter: factor out function to create templater from literal or map file
(tmpl, mapfile) will be packed into a named tuple later.
2017-04-22 15:06:06 +09:00
Yuya Nishihara
8712d0ee3b graphlog: do not look up graphnodetemplate in template paths (BC)
ui.graphnodetemplate config should be a literal template as ui.logtemplate is.
The use of formatter.gettemplater() is valid only for a template string
given by -T/--template option.
2017-04-22 14:53:05 +09:00
Sean Farley
1221c3301c context: inline makememctx (API)
I have always thought it weird that we have a helper method instead of
just using __init__. So, I ripped it out.
2017-06-10 10:24:33 -04:00
Yuya Nishihara
d2ef5f6afb export: map wctx.node() to 'ff...' node id (issue5438) 2017-06-03 19:17:19 +09:00
Yuya Nishihara
32b5726eef scmutil: introduce binnode(ctx) as paired function with intrev(ctx)
It seemed silly to convert ctx.hex() back to binary to use node.hex/short(),
or to use [:12] instead of node.short() because ctx.node() could be None.

Eventually I want to change wctx.rev() and wctx.node() to return wdirrev and
wdirid respectively, but that's quite big API breakage and can't be achieved
without some compatibility wrappers.
2017-06-03 19:12:01 +09:00
Yuya Nishihara
ca7d54c6e1 scmutil: pass ctx object to intrev()
This makes it slightly easier to sort basectx objects by key=scmutil.intrev.
We're most likely to have ctx objects where changectx/workingctx abstraction
is necessary, so this won't increase the abstraction overhead.
2017-06-03 18:57:28 +09:00
Yuya Nishihara
f287cab367 cmdutil: use isstdiofilename() where appropriate 2017-06-01 23:08:23 +09:00
Yuya Nishihara
eff4d5e967 cat: add formatter support
This is an example showing how formatter can handle the --output option.
git subrepo isn't supported for now.
2017-05-25 21:53:44 +09:00
Yuya Nishihara
4980841c12 cat: use with statement to close output file 2017-05-27 17:58:36 +09:00
Yuya Nishihara
de43565bcb cat: stop using makefileobj()
Prepares for porting to the formatter API. We won't be able to utilize the
abstraction provided by makefilename() because formatter must be instantiated
per file.
2017-05-25 21:43:09 +09:00
Yuya Nishihara
1d54e26edc cat: pass filename template as explicit argument
I'll move the handling of the '-' filename to commands.cat().
2017-05-27 18:50:05 +09:00
Yuya Nishihara
3070054965 cmdutil: extract function checking if pattern should be taken as stdin/out
This will be used in commands.cat().
2017-05-25 21:28:08 +09:00
Yuya Nishihara
c171e2c0bc cmdutil: drop deprecated hack to pass file object to makefileobj() (API)
All callers pass a string 'pat' or None.
2017-05-25 21:25:49 +09:00
Augie Fackler
fa101cc823 cmdutil: use sorted(dict) instead of x = dict.keys(); x.sort()
The former both does less work and has the virtue of working on Python 3.
2017-05-28 14:02:14 -04:00
Augie Fackler
b90ae820de cmdutil: avoid redefining write() function in export if possible
Doing less work inside the loop just feels better to me.
2017-05-22 15:05:18 -04:00
Augie Fackler
cab9b6d957 cmdutil: extract closure that performs the actual export formatting
This simplifies things a little by making the actual act of turning a
revision into patch data a single function. After this, adding
formatter support to `hg export` should be much simpler.
2017-05-22 13:34:03 -04:00
Augie Fackler
c84213bcdd cmdutil: use a generator expression instead of a list comprehension 2017-05-22 13:35:22 -04:00
Augie Fackler
414ee4894d cmdutil: rename template param to export to fntemplate
It's actually a template for the filename, not a formatter template.
2017-05-20 20:15:05 -04:00
Augie Fackler
47d21819fe cmdutil: comprehensively document the interface of export
I want to make some improvements here, but in order to make future
patches easier to review I want to document the current state of the
world.
2017-05-20 17:58:04 -04:00
Martin von Zweigbergk
d0f5db29a6 cleanup: reuse existing wctx variables instead of calling repo[None]
Incidentally, this apparently means we load .hgsub one time less as
well, which affects a test case.
2017-05-20 22:27:52 -07:00
Yuya Nishihara
6c2103bc71 commands: move templates of common command options to cmdutil (API)
The goal is to get rid of the debugcommands -> commands dependency.

Since globalopts is the property of the commands, it's kept in the commands
module.
2017-05-14 16:19:47 +09:00
Augie Fackler
b92dbee43c cmdutil: use repo[None].walk instead of repo.walk 2017-05-18 18:00:52 -04:00
Yuya Nishihara
7b77796abc extensions: show deprecation warning for the use of cmdutil.command
Since this is a fundamental API for extensions, we set 1-year period until
actually removing it.
2016-01-09 23:24:52 +09:00
Yuya Nishihara
3e663dde68 registrar: move cmdutil.command to registrar module (API)
cmdutil.command wasn't a member of the registrar framework only for a
historical reason. Let's make that happen. This patch keeps cmdutil.command
as an alias for extension compatibility.
2016-01-09 23:07:20 +09:00
Durham Goode
77dcefda06 obsolete: add operation metadata to rebase/amend/histedit obsmarkers
By recording what operation created the obsmarker, we can show very intuitive
messages to the user in various UIs. For instance, log output could have
messages like "Amended as XXX" to show why a commit is old and has an 'x' on it.

     @  ac28e3  durham
    /   First commit
   |
   | o  d4afe7 durham
   | |  Second commit
   | |
   | x  8e9a5d (Amended as ac28e3)  durham
   |/   First commit
   |
2017-05-09 16:29:31 -07:00
Martin von Zweigbergk
c3406ac3db cleanup: use set literals
We no longer support Python 2.6, so we can now use set literals.
2017-02-10 16:56:29 -08:00
Pulkit Goyal
edb3048605 py3: convert kwargs' keys to str using pycompat.strkwargs 2017-05-04 00:24:21 +05:30
Martin von Zweigbergk
0a45a04c8a forget: access status fields by name, not index 2017-05-04 21:11:40 -07:00
Pulkit Goyal
b69219d4a1 py3: use %d to format integers into bytestrings 2017-05-05 01:41:54 +05:30
Pulkit Goyal
7b5053db1f py3: slice over bytes to prevent getting ascii values 2017-05-05 01:26:13 +05:30
Pulkit Goyal
5e026b2f2b py3: handle opts correctly for hg add
opts in add command were passed again to cmdutil.add() as kwargs so we need
to convert them again to str. Intstead we convert them to bytes when passing
scmutil.match(). Opts handling is also corrected for all the functions which
are called from cmdutil.add().
2017-04-25 01:52:30 +05:30
Pulkit Goyal
deceb69003 py3: convert opts to bytes in cmdutil.dorecord()
commands.commit() calls cmdutil.dorecord() where opts are passed as unicodes
being keyword arguments. This patch converts them back to bytes as they are
required.
2017-04-21 02:20:46 +05:30
Yuya Nishihara
9466c3179f commit: optionally strip quotes from commit template (BC)
For consistency with the other template options.
2017-02-25 19:32:39 +09:00
Yuya Nishihara
5fbb2d3cd5 graphlog: optionally strip quotes from graphnode template (BC)
For consistency with the other template options.
2017-02-25 19:28:16 +09:00
Matt Harbison
6d898e296f serve: add support for Mercurial subrepositories
I've been using `hg serve --web-conf ...` with a simple '/=projects/**' [paths]
configuration for awhile without issue.  Let's ditch the need for the manual
configuration in this case, and limit the repos served to the actual subrepos.

This doesn't attempt to handle the case where a new subrepo appears while the
server is running.  That could probably be handled with a hook if somebody wants
it.  But it's such a rare case, it probably doesn't matter for the temporary
serves.

The main repo is served at '/', just like a repository without subrepos.  I'm
not sure why the duplicate 'adding ...' lines appear on Linux.  They don't
appear on Windows (see 3f4ff1bdf101), so they are optional.

Subrepositories that are configured with '../path' or absolute paths are not
cloneable from the server.  (They aren't cloneable locally either, unless they
also exist at their configured source, perhaps via the share extension.)  They
are still served, so that they can be browsed, or cloned individually.  If we
care about that cloning someday, we can probably just add the extra entries to
the webconf dictionary.  Even if the entries use '../' to escape the root, only
the related subrepositories would end up in the dictionary.
2017-04-15 18:05:40 -04:00
Yuya Nishihara
caee220313 templater: provide loop counter as "index" keyword
This was originally written for JSON templating where we would have to be
careful to not add extra comma, but seems generally useful.

Inner loop started by % operator has its own counter.
2016-04-22 21:46:33 +09:00
Denis Laxalde
2ae8148594 cmdutil: add a "changeset.obsolete" label in changeset_printer
Until now there were no label to highlight obsolete changesets in log output,
only evolution troubles (unstable, bumped, divergent) are supported. We add a
"changeset.obsolete" label on changeset entries produced by changeset_printer
so that obsolete changesets can be highlighted in log output. This is useful
because, unless using a graph log where obsolete changesets have a 'x' marker,
there's no way to identify obsolete changesets. And even in graph mode, when
working directory's parent is obsolete, we get a '@' marker and we do not see
it as obsolete.
2017-03-25 09:39:07 +01:00
Yuya Nishihara
2b0fe29f27 graphlog: pass function arguments without expansion
It's annoying on Python 3 because keys must be unicode type. Let's stop using
**opts expansion when not necessary.
2017-03-14 18:16:13 +09:00
Jun Wu
e7a5a37c7c import: get rid of ui.backupconfig 2017-03-16 14:23:49 -07:00
Yuya Nishihara
02022fc3c5 util: wrap s.encode('string_escape') call for future py3 compatibility 2017-03-15 23:06:50 +09:00
Pierre-Yves David
80b1f7c309 cmdutil: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:09 -08:00
Mads Kiilerich
a936a7f3a7 vfs: use repo.wvfs.unlinkpath 2015-01-14 01:15:26 +01:00
Pierre-Yves David
526ec9867d vfs: use 'vfs' module directly in 'mercurial.cmdutil'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:30:47 +01:00
Pierre-Yves David
e5cb48ac36 vfs: replace 'scmutil.opener' usage with 'scmutil.vfs'
The 'vfs' class is the first class citizen for years. We remove all usages of
the older API. This will let us remove the old API eventually.
2017-03-02 03:52:36 +01:00
Denis Laxalde
de480b0802 revert: always display hunks reversed when reverting to parent
When reverting to the parent of working directory, operation is "discard" so
we want hunks to be presented in the same order as the diff (i.e. "reversed").
So we do not query the experimental.revertalternateinteractivemode option in
this case and always set "reversehunks" to True.
2017-03-06 14:11:21 +01:00
Yuya Nishihara
a69b51cf89 templatekw: move defaulttmpl constant from changeset_templater
These templates are used when rendering inner lists of some template keywords,
so it makes sense to define them in templatekw. This allows us to reuse them
to create a templateformatter knowing changectx.
2017-02-25 16:38:26 +09:00
Yuya Nishihara
e5c5114662 templater: port formatnode filter from changeset_templater
This slightly reduces the difference between changeset_templater and formatter,
and helps extending formatter to support changeset templating.

New formatnode() is not a template filter, but a function since a filter
cannot access to ui. And it's marked as DEPRECATED since I think it exists
only for compatibility reasons.
2017-02-25 16:26:58 +09:00
Martin von Zweigbergk
ee94a5599f revert: move code dealing with deletions closer together 2016-02-24 14:44:14 -08:00
Durham Goode
cfe81cb036 revert: remove set(mf) because it's O(manifest)
The revert code had a 'set(manifest)' line in it, which has a runtime equivalent
to the size of the manifest. With alternative manifest implementations, like
treemanifest, this can be extra expensive. Let's rewrite it to be O(changes)
instead of O(manifest size).
2017-03-01 19:51:05 -08:00
Yuya Nishihara
ea9be23c11 graphlog: restore pager lost at ebae4e1a56fc 2017-02-23 21:20:26 +09:00