Commit Graph

910 Commits

Author SHA1 Message Date
Sean Farley
52b92c45af cmdutil: add special string that ignores rest of text
Similar to git, we add a special string:

  HG: ------------------------ >8 ------------------------

that means anything below it is ignored in a commit message.

This is helpful for integrating with third-party tools that display the
2016-12-31 15:36:36 -06:00
Denis Laxalde
37fb9b1045 cmdutil: add support for evolution "troubles" display in changeset_printer
Add a "trouble" line in changeset header along with a couple of labels on
"log.changeset" line to indicate whether a changeset is troubled or not and
which kind trouble occurs.
2016-10-10 12:06:58 +02:00
Denis Laxalde
1f19429796 cmdutil: extract a _changesetlabels function out of changeset_printer._show()
There is a common logic in changeset_printer and in the summary command for
labelling a changeset.

This prepares extension of changeset's labels with evolution "troubles"
information that would show up in both log and summary outputs. Ultimately,
both would use this function.
2017-01-03 10:56:41 +01:00
Pulkit Goyal
5629f71f5b py3: replace os.sep with pycompat.ossep (part 3 of 4) 2016-12-17 20:14:24 +05:30
Jun Wu
c40d1d56d5 revert: pass operation to crecord
So crecord would know what to display
2016-11-23 19:03:24 +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
Pulkit Goyal
97f340e354 py3: use pycompat.getcwd() instead of os.getcwd()
We have pycompat.getcwd() which returns bytes path on Python 3. This patch
changes most of the occurences of the os.getcwd() with pycompat one.
2016-11-23 00:03:11 +05:30
Yuya Nishihara
dce6c5ba27 server: move cmdutil.service() to new module (API)
And call it runservice() because I'll soon add createservice().

The main reason I'm going to introduce the 'server' module is to solve
future dependency cycle between chgserver.py and commandserver.py.

The 'server' module sits at the same layer as the cmdutil. I believe it's
generally good to get rid of things from the big cmdutil module.
2016-10-15 13:47:43 +09:00
Augie Fackler
01092270e8 cmdutil: turn forward of checkunresolved into a deprecation warning
As with dirstateguard, I really doubt anyone outside core was using
this, as my grep over the repositories I keep locally suggests nobody
was using this. If others are comfortable with it, let's drop the
forward entirely.
2016-11-21 21:36:46 -05:00
Augie Fackler
a8b9b1e400 checkunresolved: move to new package to help avoid import cycles
This will allow localrepo to stop using cmdutil, which should avoid
some future import cycles. There's room for an adventurous soul to
delve deeper into merge.py and figure out how to disentangle more of
it - it appears to be a nexus of cycle problems. Some of it might be
able to move into this new mergeutil package.
2016-11-21 21:31:45 -05:00
Augie Fackler
d85602ec67 cmdutil: mark dirstateguard as deprecated
I sincerely doubt this is used in external code, as grepping the
extensions I keep locally (including Facebook's hgexperimental and
evolve) indicate nobody outside of core uses this. As such, I'd also
welcome just dropping this name forward entirely.
2016-11-21 21:16:54 -05:00
Augie Fackler
b866e41f24 dirstateguard: move to new module so I can break some layering violations
Recently in a review I noticed that localrepo almost has no reason to
import cmdutil anymore. Also, cmdutil is a little on the enormous
side, so breaking this class out strikes me as a win.
2016-11-21 21:29:32 -05:00
Yuya Nishihara
47f9c8b52e py3: bulk replace sys.stdin/out/err by util's
Almost all sys.stdin/out/err in hgext/ and mercurial/ are replaced by util's.
There are a few exceptions:

 - lsprof.py and statprof.py are untouched since they are a kind of vendor
   code and they never import mercurial modules right now.
 - ui._readline() needs to replace sys.stdin and stdout to pass them to
   raw_input(). We'll need another workaround here.
2016-10-20 23:53:36 +09:00
Henning Schild
9ed7d6b8f2 patch: remove unused git parameter from patch.diffstat()
Since 5997ebdd67f0 the parameter is not used anymore.
2016-11-12 13:36:17 +01:00
Durham Goode
52b8095f37 manifest: remove last uses of repo.manifest
Now that all the functionality has been moved to manifestlog/manifestrevlog/etc,
we can finally change all the uses of repo.manifest to use the new versions. A
future diff will then delete repo.manifest.

One additional change in this commit is to change repo.manifestlog to be a
@storecache property instead of @property. This is required by some uses of
repo.manifest require that it be settable (contrib/perf.py and the static http
server). We can't do this in a prior change because we can't use @storecache on
this until repo.manifest is no longer used anywhere.
2016-11-10 02:13:19 -08:00
Durham Goode
f980c11277 manifest: delete unused dirlog and _newmanifest functions
As part of migrating all manifest functionality out of manifest.manifest, let's
migrate a couple spots off of manifest.dirlog() to use the revlog specific
accessor. Then we can delete manifest.dirlog() and other unused functions.
2016-11-10 02:13:19 -08:00
Durham Goode
59f421f2ce manifest: remove manifest.find
As part of removing dependencies on manifest, this drops the find function and
fixes up the two existing callers to use the equivalent apis on manifestctx.
2016-11-08 08:03:43 -08:00
Mads Kiilerich
38cb771268 spelling: fixes of non-dictionary words 2016-10-17 23:16:55 +02:00
timeless
05cf1812b9 cmdutil: refactor checkunresolved
localrepo.commit had code to check for unresolved merge conflicts,
it would be helpful for at least rebase to be able to use that
code without calling commit().
2016-11-02 18:45:53 +00:00
Mads Kiilerich
4ebd936629 cmdutil: satisfy expections in dirstateguard.__del__, even if __init__ fails
Python "delstructors" are terrible - this one because it assumed that __init__
had completed before it was called. That would not necessarily be the case if
the repository was read only or broken and saving the dirstate thus failed in
unexpected ways. That could give confusing warnings about missing '_active'
after failures.

To fix that, make sure all member variables are "declared" before doing
anything that possibly could fail. [Famous last words.]
2016-10-14 01:53:15 +02:00
Augie Fackler
530be6f190 copy: distinguish "file exists" cases and add a hint (BC)
Users that want to add a copy record to an existing commit with 'hg
commit --amend' should be guided towards this workflow, rather than
reaching for some sort of uncommit-recommit flow. As part of this,
distinguish in the top-line error message whether the file merely
already exists (untracked) on disk or the file already exists in
history.

The full list of copy and rename cases and how they interact with
flags are listed below:

target exists  --after  --force  |  action
      n            n      *    |  copy
      n            y      *    |  (1)
  untracked        n      n    |  (4) NEWHINT
  untracked        n      y    |  (3)
  untracked        y      *    |  (2)
      y            n      n    |  (4) NEWHINT
      y            n      y    |  (3)
      y            y      n    |  (2)
      y            y      y    |  (3)
   deleted         n      n    |  copy
   deleted         n      y    |  (3)
   deleted         y      n    |  (1)
   deleted         y      y    |  (1)

* = don't care
(1) <src>: not recording move - <target> does not exist
(2) preserve target contents
(3) replace target contents
(4) <target>: not overwriting - file {exists,already committed}

Credit to Kevin for wholly rewriting my table to cover more cases we
discovered at the sprint.

I think this change gets the hints correct in all cases, but I'd
appreciate close inspection of the test cases to make sure I haven't
gotten turned around in here.
2016-09-19 17:15:39 -04:00
Mads Kiilerich
7afa73604d largefiles: use context for file closing
Make the code slightly smaller and safer (and more deeply indented).
2016-10-08 00:59:41 +02:00
Yuya Nishihara
16b1b93d3f log: copy the way of ancestor traversal to --follow matcher (issue5376)
We can't use fctx.linkrev() because follow() revset tries hard to simulate
the traversal of changelog DAG, not filelog DAG. This patch fixes
_makefollowlogfilematcher() to walk file ancestors in the same way as
revset._follow().

I'll factor out a common function in future patches.
2016-09-24 19:58:23 +09:00
Yuya Nishihara
3dd315fd93 log: unroll loop that populates file paths for --patch --follow matcher
We can't handle the first fctx in the same manner as its ancestors. Also,
I think the original code was too tricky.
2016-09-24 19:52:02 +09:00
Yuya Nishihara
d5da3be9a3 log: drop outdated optimization to walk revisions in reverse order
Since revset is computed lazily, there would be no (or little) benefit to
reverse 'revs' temporarily.
2016-09-22 20:59:24 +09:00
Yuya Nishihara
03a45f600c graphlog: preserve topo sort even if additional filter options specified
Use ordered=revset.followorder instead. This change is logically the same
as 0a4ba6171d17.
2016-09-22 20:53:53 +09:00
timeless
9b9d2357c6 remove: specify hg in added warning 2016-09-02 21:46:00 +00:00
Yuya Nishihara
961a93ff5b log: drop hack to fix order of revset (issue5100)
Specify ordered=revset.followorder instead.

This patch effectively backs out 54ac550f0fd6. revs.sort(reverse=True)
is replaced by revs.reverse() because the matcher should no longer reorder
revisions.
2016-05-03 14:24:00 +09:00
Hannes Oldenburg
03a02bd11b cmdutil: extract samefile function from amend() 2016-08-21 08:00:18 +00:00
Hannes Oldenburg
38a18d3489 subrepo: cleanup of subrepo filematcher logic
Previously in the worst case we iterated the files in matcher twice and
had a method only for this, which reimplemented logic in subdirmatchers
constructor. So we replaced the method with a subdirmatcher.files() call.
2016-08-16 08:15:12 +00:00
Yuya Nishihara
7105924c83 debugobsolete: add formatter support (issue5134)
It appears that computing index isn't cheap if --rev is specified. That's
why "index" field is available only if --index is specified.

I've named marker.flags() as "flag" because "flags" implies a list or dict
in template world.

Thanks to Piotr Listkiewicz for the initial implementation of this patch.
2016-08-15 16:07:55 +09:00
Hannes Oldenburg
007f92d569 match: added matchessubrepo method to matcher
Previously there were three local implementations of this
function in cmdutil.files, cmdutil.remove and scmutil.addremove.
2016-08-09 09:02:51 +00:00
Hannes Oldenburg
475307efcd cmdutil: remove duplicated badmatch call in cat()
Subrepo logic is handled in ctx.walk().
2016-08-07 14:06:20 +00:00
Augie Fackler
b5edcbb2f6 cmdutil: open dirlogs via manifest property, not via repo
This was a convenience method that was rarely used, so let's get rid of it.
2016-08-05 13:00:33 -04:00
Hannes Oldenburg
723f5d01de cmdutil: warnings not issued in cat if subrepopath overlaps
Previously a subrepository "sub" would cause no warnings to
be issued for a file "subnot/a", if it's not present in the
corresponding changeset when calling:

hg cat subnot/a
2016-07-27 08:38:54 +00:00
Hannes Oldenburg
d5c4fdb0dc cmdutil: warnings not issued in remove if subrepopath overlaps
Previously a subrepository "sub" would cause no warnings to be issued
for a file "subnot/a" if it is not removed when calling:

hg remove -S "subnot/a"
2016-07-22 11:29:42 +00:00
skarlage
643208895a revert: don't backup if no files reverted in interactive mode (issue4793)
When reverting interactively, we always backup files before prompting the user
to find out if they actually want to revert them. This can create spurious
*.orig files if a user enters an interactive revert session and then doesn't
revert any files. Instead, we should only backup files that are actually being
touched.
2016-06-30 08:38:19 -07:00
Martin von Zweigbergk
5dcec73439 debug: make debug{revlog,index,data} --dir not just a flag
The directory argument (for tree manifests) should belong to to the
--dir argument. I had mistakenly made --dir a flag. One effect of this
was that I had meant for "-m" to be optional, but instead it changed
the behavior of --dir, so with "hg debugdata -m --dir dir1 0", the -m
took over and the "dir1" got treated as a revision in the root
manifest log.
2016-06-24 11:12:41 -07:00
FUJIWARA Katsunori
f46b49a0e3 check-code: detect "missing _() in ui message" more exactly
Before this patch, "missing _() in ui message" rule overlooks
translatable message, which starts with other than alphabet.

To detect "missing _() in ui message" more exactly, this patch
improves the regexp with assumptions below.

  - sequence consisting of below might precede "translatable message"
    in same string token

    - formatting string, which starts with '%'
    - escaped character, which starts with 'b' (as replacement of '\\'), or
    - characters other than '%', 'b' and 'x' (as replacement of alphabet)

  - any string tokens might precede a string token, which contains
    "translatable message"

This patch builds an input file, which is used to examine "missing _()
in ui message" detection, before '"$check_code" stringjoin.py' in
test-contrib-check-code.t, because this reduces amount of change churn
in subsequent patch.

This patch also applies "()" instead of "_()" on messages below to
hide false-positives:

  - messages for ui.debug() or debug commands/tools
    - contrib/debugshell.py
    - hgext/win32mbcs.py (ui.write() is used, though)
    - mercurial/commands.py
      - _debugchangegroup
      - debugindex
      - debuglocks
      - debugrevlog
      - debugrevspec
      - debugtemplate

  - untranslatable messages
    - doc/gendoc.py (ReST specific text)
    - hgext/hgk.py (permission string)
    - hgext/keyword.py (text written into configuration file)
    - mercurial/cmdutil.py (formatting strings for JSON)
2016-06-21 00:50:39 +09:00
Martijn Pieters
ffccd3fc81 revset: record if a set is in topographical order
A later revision adds actual topographical sorting. Recording if a set is in
this order allows hg log -G to avoid re-sorting the revset.
2016-06-14 11:05:36 +01:00
Martijn Pieters
747bfe58fe graphmod: avoid sorting when already sorted
This is somewhat redundant now, but allows us to add a toposort that should not
be re-sorted either.
2016-06-08 16:18:43 +01:00
Denis Laxalde
e785df5b6d crecord: drop unused "operation" parameter from filterpatch function 2016-06-07 11:57:11 +02:00
Denis Laxalde
259dd53d72 patch: define full messages for interactive record/revert
Followup 814eb5a11da4 to provide complete context for proper localization.

Also update cmdutil.recordfilter docstring to remove recommendation that
"operation" argument should be translated. Indeed, for record/revert, we
either go to patch.filterpatch or crecord.filterpatch (in curses mode) ; the
former now build the full ui message from the operation parameter and the
latter does not use this parameter (removing in a followup patch). For shelve,
operation is not specified and this thus falls back to "record".
2016-06-07 10:37:19 +02:00
Denis Laxalde
ae2b66dbed revert: use "discard"/"revert" verb when reverting interactively (issue5143)
Instead of "record this change to 'FILE'?" now prompt with:

* "discard this change to 'FILE'?" when reverting to the parent of working
  directory, and,
* "revert this change to 'FILE'?" otherwise.
2016-06-03 15:55:07 +02:00
timeless
a1cb3173a2 py3: convert to next() function
next(..) was introduced in py2.6 and .next() is not available in py3

https://docs.python.org/2/library/functions.html#next
2016-05-16 21:30:53 +00:00
Mateusz Kwapich
fc3f152c3e dirstate: make backup methods public
They are called from outside of dirstate anyway and I want the localrepo to
use them too.
2016-05-05 17:06:54 -07:00
Augie Fackler
1ed59ab50e cmdutil: typo fix in comment 2016-05-06 14:22:17 -04:00
Martijn Pieters
4b822b7401 graphmod: disable graph styling when HGPLAIN is set (issue5212)
Produce stable output for tools to rely on by hardcoding all edge styles to
"|". This ensures that any tool parsing the output of hg log -G still gets the
same behaviour as pre-3.8 releases.
2016-04-20 16:33:13 +01:00