Commit Graph

591 Commits

Author SHA1 Message Date
Pierre-Yves David
d66193718e cmdutil: make options argument optional
There is not reason to force passing of an empty options list.
2013-01-04 13:48:07 +01:00
Matt Mackall
fe2cbf4904 merge with stable 2013-01-02 00:24:28 -06:00
Pierre-Yves David
b6d4017a84 amend: prevent loss of bookmark on failed amend
The active bookmark were moved to the temporary commit. When the transaction
were rollbacked, the bookmark were lost.

We now temporarly disable the bookmark to prevent this effect.
2012-12-30 03:49:15 +01:00
Pierre-Yves David
6a1ec255bb amend: invalidate dirstate in case of failure (issue3670)
The temporary commit created by amend update the dirstate. If the final commit
fails, we need to invalidate the change made to the dirstate, otherwise the
release of the wlock will write the dirstate created after the rollbacked
temporary commit.

This dirstate writing logic should probably be handled in the same object than
the transaction one. However such change are too big for stable.
2012-12-29 18:00:18 +01:00
Siddharth Agarwal
2b9ccce531 cmdutil: make getgraphlogrevs limit-aware
For a repository with over 400,000 changesets, this speeds up graphlog with a
small limit by around 0.05 seconds (~50%).
2012-12-28 16:25:12 -08:00
Siddharth Agarwal
aa52ffdc89 cmdutil: stop pretending we can calculate revs for graphlog lazily
cmdutil.getgraphlogrevs does a ton of work trying to build a graphlog lazily,
and then cmdutil.graphlog comes along and destroys all of that.
graphmod.dagwalker requires that it be given the full list of revs upfront so
that it can perform filtering and tests against known revs.

For a repository with over 400,000 changesets, this speeds up graphlog by
around 0.02 seconds (~20% with a small limit).
2012-12-28 16:25:00 -08:00
Siddharth Agarwal
1e67e6753f cmdutil: store a local ref to repo.hiddenrevs in getgraphlogrevs
On a repository with over 400,000 changesets, this speeds graphlog up by
around 0.03 seconds (~20% with a small limit).
2012-12-28 16:24:36 -08:00
Siddharth Agarwal
9302d9c2b3 cmdutil: make getgraphlogrevs return revs in descending order 2012-12-28 14:46:58 -08:00
FUJIWARA Katsunori
b81a7802fd subrepo: add argument to "diff()" to pass "ui" of caller side (issue3712) (API)
Color extension achieves colorization by overriding the class of
"ui" object just before command execution.

Before this patch, "diff()" of abstractsubrepo and classes
derived from it has no "ui" argument, so "diff()" of hgsubrepo
uses "self._repo.ui" to invoke "cmdutil.diffordiffstat()".

For separation of configuration between repositories, revision
1498948ee815 changed the initialization source of "self._repo.ui"
from "ui"(overridden) to "baseui"(plain) of parent repository.
And this caused break of colorization.

This patch adds "ui" argument to "diff()" of abstractsubrepo and
classes derived from it to pass "ui" object of caller side.
2012-11-30 00:43:55 +09:00
Pierre-Yves David
cc961a38fb amend: force editor only if old message is reused (issue3698)
This regression was added by 435d13b1e757. It triggered the editor even if
--message or --logfile were provided.
2012-11-13 08:41:56 -08:00
Kevin Bullock
e8ece086e3 merge with stable 2012-12-04 11:19:32 -06:00
FUJIWARA Katsunori
ff00b9869d i18n: add "i18n" comment to column positioning messages of "hg log"
This comment makes it easier to distinguish such messages from others
for message translators.
2012-10-31 03:59:27 +09:00
Augie Fackler
167f9d08c6 Merge with crew-stable. 2012-11-13 19:32:53 -06:00
Augie Fackler
9766845689 bookmarks: introduce a bmstore to manage bookmark persistence
Bookmarks persistence still showed a fair amount of its legacy as a
monkeypatching extension. This encapsulates all bookmarks
serialization and parsing in a single class, and offers a single
location where other bookmarks storage engines can be substituted
in. As a result, many files no longer import the bookmarks module,
which strikes me as an encapsulation win.

This doesn't do anything to the current bookmark state yet, but I'm
hoping put that in the bmstore class as well.
2012-11-07 16:21:39 -06:00
Pierre-Yves David
ca37867983 amend: fix incompatibity between logfile and message option (issue3675)
Bug introduced by 435d13b1e757
2012-10-24 15:37:32 +02:00
Pierre-Yves David
5f47fc1c50 amend: do a bare kill of temporary changeset
Before this changeset the temporary changeset created by amend was made a
precursors on the amend result. This add unnecessary complexity to the
obsolescence graph. This temporary commit will probably disappear in the future.
It is an unwanted byproduct of amend that nobody cares about.
2012-10-18 17:54:34 +02:00
Pierre-Yves David
9827da9933 amend: add noise in extra to avoid creating obsolescence cycle (issue3664)
Obsolescence cycle are bad and should be avoided as much as possible. The
current amend implemented touch changeset meta data as few as possible. This
make is easy for amend to result in the same node than a precursors. We add some
deterministic noise in extra to avoid this. In practice, the hex of the amended
changeset is stored in 'amend_source' extra key.
2012-10-18 22:12:15 +02:00
FUJIWARA Katsunori
a34a9f5100 cmdutil: omit redundant "savecommitmessage()" in "tryimportone()"
The preceding patch causes that "makememctx()" with "editor" argument
saves (manually edited) commit message into ".hg/last-message.txt":
saving itself is executed indirectly in "memctx.__init__()".

This makes it redundant to invoke "savecommitmessage()" on caller side
of "makememctx()".

This patch omits such redundant "savecommitmessage()" invocation in
"tryimportone()".

"tryimportone()" uses one of "commiteditor" or "commitforceeditor" as
"editor" argument, and this causes saving commit message always.
2014-05-05 21:26:40 +09:00
FUJIWARA Katsunori
c6286fa71f amend: use "editor" argument for "memctx.__init__" to save commit message
This patch uses "editor" argument of "memctx.__init__" to save commit
message, instead of explicit editor invocation and saving commit
message by "localrepository.savecommitmessage()".

By passing one of "commiteditor" or "commitforceeditor" as "editor",
"memctx.__init__" saves commit message, even when editor invocation is
not needed.
2014-05-05 21:26:40 +09:00
Sean Farley
a5e6af16d7 color: add additional changeset.phase label to log.changeset and log.parent
This allows the user to set different colors for each phase, e.g.

[color]
changeset.public = blue
changeset.draft = green
changeset.secret = red

In addition, this doesn't affect current configuration for custom log.changeset
colors, but rather adds the option for users that want to visually see which
changesets are amendable.
2012-10-16 13:35:58 -05:00
smuralid
d42ff23b07 log: speed up hg log for untracked files (issue1340)
'hg log' on untracked files tends to be fairly slow. The root cause is that we end up using the 'slowpath' when we can't find a revlog for the files listed. This could happen if the file in question is an untracked file, or it is a directory.
This diff tries to speed up 'hg log' (by avoiding the slowpath) for files if we can determine if that file is not (and was never) a directory. We use the previously added store.__contains__ methods to test if the directory exists (or existed) in the store.
To avoid changing any existing semantics, this 'optimization' kicks in only when none of the files listed as arguments to the hg log command exist in the store.
2012-09-13 23:50:45 -07:00
Pierre-Yves David
6a88d239df clfilter: remove any explicit revision number from default cmdutil range
Revision "0" and "-1" may be filtered, we can't use them in any default
revrange.
2012-09-03 14:29:05 +02:00
Pierre-Yves David
df82aab75f clfilter: remove usage of range in favor of iteration over changelog
If we want to apply filtering at changelog level, we need to iterate over it.
See previous changeset description for details.
2012-09-20 19:01:53 +02:00
Pierre-Yves David
e5780b8f05 amend: add obsolete support
If the obsolete feature is enabled, `hg commit --amend` marks a
changeset as obsolete instead of stripping it.
2012-09-11 00:12:07 +02:00
Pierre-Yves David
6675d5b644 amend: use an explicit commit message for temporary amending commit
Before this changeset, the extra commit created during amend had
the same description as the final commit. This was a bit confusing
when trying to understand what that extra commit was about.

This changeset changes the description of such commit to:

    temporary amend commit for <ammend-commit-hash>

The old behaviour was not a big deal, but would become more confusing
once we use obsolescence marker instead of stripping the precursors.

This also helps if the user restores a strip backup.
2012-08-25 16:20:41 +02:00
Pierre-Yves David
d67eeabf85 amend: wrap all commit operations in a single transaction
This allows proper recovery of an interrupted amend process.
No changes are made to the logic besides:

- indent operations into a single try-except clause,
- some comment and code wrapping to 80 chars,
- strip logic should not be contained in the transaction and is extracted from
  the main code.
2012-09-10 23:44:24 +02:00
Pierre-Yves David
c2caef51a8 amend: lock the repository during the whole process
Without this changes another writer can lock the repository in the middle the
amend process. The resulting mess can be pretty ugly.
2012-08-25 15:37:28 +02:00
Patrick Mezard
f64e7c7ee8 Merge with stable 2012-09-09 12:35:06 +02:00
Pierre-Yves David
ef39934b8c amend: preserve phase of amended revision (issue3602)
New commit from the amend process were created without any phase contraint. If
the amended changeset had a different phase from it's parent, the phases data
were lost.

The changeset ensure the new commit are created in the same phase than the
original changeset.
2012-08-30 16:47:08 +02:00
Ankur Dahiya
8c0a7c1aaf color: enabled color support for export command (issue1507)
The export command didn't output the diffs in color, even when color support
was enabled. This patch fixes that by making the export command use the default
ui.write method, instead of directly manipulating the ui.fout file object.
Also added a test case to verify color output to test-export.t.
2012-08-27 09:37:49 -07:00
Ross Lagerwall
661779d660 util: replace util.nulldev with os.devnull
Python since 2.4 has supported os.devnull so having util.nulldev
is unnecessary.
2012-08-04 07:14:40 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Patrick Mezard
33ee7f119d log: make opts entries optional (issue2423) 2012-08-01 15:49:00 +02:00
Pierre-Yves David
edc2b520d9 hidden: move hiddenrevs set on the repository
This set is always accessed through the repo for now. Having this set
carried by the changelog make it complicated to:

- initialize it, computing hidden set may involve revset call
- lazy compute it, (1) only the changelog can detect someone access it,
                   (2) only the repo have enought knowledge to compute it.

In later version I expect he changelog to apply filtering itself and the set to
be carried by changelog again.
2012-07-16 17:44:46 +02:00
Joshua Redstone
30df933365 scmutil: 25% speedup in casecollisionauditor
On a large repository, switching casecollisionauditor to lowercasing all file
names at once rather than one at a time improves hg-add time by 25%.
2012-07-06 13:56:40 -07:00
Patrick Mezard
1bc1374fa9 incoming/outgoing: handle --graph in core 2012-07-11 18:22:07 +02:00
Patrick Mezard
ea80881882 log: support --graph without graphlog extension
The glog command is preserved in the extension for backward compatibility.
2012-07-14 19:09:22 +02:00
Patrick Mezard
2d4a0ad972 graphlog: extract revset/support functions into cmdutil 2012-07-14 18:55:21 +02:00
Matt Mackall
61aa1f42b8 merge with stable 2012-06-29 00:40:52 -05:00
Idan Kamara
bcb7450401 amend: disable hooks when creating intermediate commit (issue3501) 2012-06-23 19:57:29 +03:00
Martin Geisler
50cde07b26 cmdutil: lowercase finddate status message
This message is output by 'hg revert -d DATE' and 'hg update -d DATE'.
2012-06-12 14:18:18 +02:00
Patrick Mezard
eb2318522a cmdutil: extract increasing_windows() from walkchangerevs()
It will be reused in the revset-based version.
2012-05-08 22:43:44 +02:00
Patrick Mezard
2cddd7a828 cmdutil: use filectx.cmp() in amend() 2012-05-13 13:19:46 +02:00
Matt Mackall
05e48d4041 merge with stable 2012-05-13 12:52:24 +02:00
Brodie Rao
92158e04de cleanup: "raise SomeException()" -> "raise SomeException" 2012-05-12 16:00:58 +02:00
Matt Mackall
48471fd098 merge with stable 2012-05-12 00:06:11 +02:00
Idan Kamara
c69934e20c amend: preserve extra dict (issue3430) 2012-05-11 18:33:45 +03:00
Kevin Bullock
cce50f4d35 revert: don't re-create changeset context 2012-05-04 09:20:28 -05:00
Patrick Mezard
bf0d75c9d1 amend: fix copy records handling (issue3410)
Messing with the dirstate before the intermediate commit seems error prone.
Instead, commit and recompute the copies with copies.pathcopies(), then use
that with commitctx().

Since copies.pathcopies() does not support file replacement very well, the
whole .renamed() condition in samefile() is removed and the "file replacement
caused by differing copy source" effect is discarded.

Test shamelessly stolen from Idan Kamara <idankk86@gmail.com>
2012-04-30 20:45:45 +02:00
Patrick Mezard
2c65c226cf localrepo: add setparents() to adjust dirstate copies (issue3407)
The fix introduced in 3509b9cf8f86 was only partially successful. It is correct
to turn dirstate 'm' merge records into normal/dirty ones but copy records are
lost in the process. To adjust them as well, we need to look in the first
parent manifest to know which files were added and preserve only related
records. But the dirstate does not have access to changesets, the logic has to
moved at another level, in localrepo.
2012-04-29 22:25:55 +02:00
Patrick Mezard
68ff0fa6cf dirstate: preserve path components case on renames (issue3402)
The original issue was something like:

  $ hg init repo
  $ cd repo
  $ mkdir D
  $ echo a > D/a
  $ hg ci -Am adda
  adding D/a
  $ mv D temp
  $ mv temp d
  $ echo b > d/b
  $ hg add d/b
  adding D/b
  $ hg ci -m addb
  $ hg mv d/b d/c
  moving D/b to d/c
  $ hg st
  A d/c
  R D/b

Here we expected:

  A D/c
  R D/b

the logic being we try to preserve case of path components already known in the
dirstate. This is fixed by the current patch.

Note the following stories are not still not supported:

Changing directory case
  $ hg mv D d
  moving D/a to D/D/a
  moving D/b to D/D/b
  $ hg st
  A D/D/a
  A D/D/b
  R D/a
  R D/b

or:

  $ hg mv D/* d
  D/a: not overwriting - file exists
  D/b: not overwriting - file exists

And if they were, there are probably similar issues with diffing/patching.
2012-04-28 20:29:21 +02:00
Idan Kamara
66000da94d commit: add option to amend the working dir parent
The --amend flag can be used to amend the parent of the working directory
with a new commit that contains the changes in the parent in addition to
those currently reported by "hg status", if there are any. The old commit
is stored in a backup bundle in ".hg/strip-backup"(see "hg help bundle"
and "hg help unbundle" on how to restore it).

Message, user and date are taken from the amended commit unless specified.
When a message isn't specified on the command line, the editor will open
with the message of the amended commit.

It is not possible to amend public changesets (see "hg help phases") or
changesets that have children.

Behind the scenes, first commit the update (if there is one) as a regular
child of the current parent. Then create a new commit on the parent's
parent with the updated contents. Then change the working copy parent
to this new combined changeset. Finally, strip the amended commit and
update commit created in the beginning.

An alternative (cleaner?) approach of doing this is suggested here:
http://selenic.com/pipermail/mercurial-devel/2012-March/038540.html

It is currently not possible to amend merge commits or recursively,
this can be added at a later time.
2012-04-18 01:20:16 +03:00
Angel Ezquerra
5089e1299f revert: add support for reverting subrepos without --no-backup and/or --all
When a subrepo is reverted but --no-backup is not set, call revert on the
subrepo that is being reverted prior to updating it to the revision specified
in the parent repo's .hgsubstate file.

The --all flag is passed down to the subrepo when it is being reverted. If the
--all flag is not set, all files that are modified on the subrepo will be
reverted.
2012-03-28 11:42:17 +02:00
Angel Ezquerra
3e2b4220e7 revert: add support for reverting subrepos
Reverting a subrepo is done by updating it to the revision that is selected on
the parent repo .hgsubstate file.

* ISSUES/TODO:

- reverting added and removed subrepos is not supported yet.
- reverting subrepos is only supported if the --no-backup flag is used (this
limitation will be removed on another patch).
- The behavior of the --all flag has been changed. It now reverts subrepos as
well. Note that this may lead to data loss if the user has a dirty subrepo.
2012-03-28 11:42:17 +02:00
Matt Mackall
cd32848f59 log: bypass file scan part of fastpath when no files
This avoids loading dirstate parents, looking up p1 rev, and loading
p1 manifest to match against an empty matcher.
2012-04-08 12:38:26 -05:00
Matt Mackall
9b81a301c9 cmdutil: use context instead of lookup 2012-04-08 12:38:24 -05:00
Angel Ezquerra
a67f0ff376 revert: move bulk of revert command from commands to cmdutil
This revision has no functionality change. The code on the original
commands.revert() function has been split. The first part of the
original code, which checks that the command inputs are correct
remains in commands.revert(). The rest of the function, which performs
the actual revert operation has been moved into cmdutil.revert().

The purpose of this change is to make it easier to perform a revert
operation, from other parts of the code. This may be used to implement
reverting of subrepos.
2012-03-28 11:42:17 +02:00
Matt Mackall
6c58e9cb98 rename: handle case-changing (issue1717) 2012-03-23 11:47:27 -05:00
Patrick Mezard
7e644e8129 log: fix --follow FILE ancestry calculation
Currently, --follow FILE looks for a FILE filelog, scans it and collects
linkrevs and renames, then filters them. The problem is the filelog scan does
not start at FILE filenode in parent revision but at the last filelog revision.
So:
- Files not in the parent revision can be followed, the starting node is
  unexpected
- Files in the parent revision can be followed from an incorrect starting
  node.

This patch makes log --follow FILE fail if FILE is not in parent revision, and
computes ancestors of the parent revision FILE filenode.
2012-02-24 20:57:59 +01:00
Matt Mackall
3ec4361714 log: remove caching of all visited revisions (issue3253)
Not only does this eat all available memory for some users, it's slower.
2012-02-10 16:52:32 -06:00
FUJIWARA Katsunori
1b096f8579 forget: show warning messages for forgetting in subrepo correctly
in 'cmdutil.forget()':

   for f in match.files():
       if match.exact(f) or not explicitonly:
           ....

is equal to:

   for f in match.files():
       if True:
           ....

because 'f' from 'match.files()' should 'match.exact(f)':

    - 'match.files()' returns 'self._files'
    - 'match.exact(f)' examines 'f in self._fmap',
    - 'self._fmap' of match is 'set(self._files)'

then, 'explicitonly' wants to suppress warning messges, if it is true
(= 'cmdutil.forget()' is invoked from 'subrepo.forget()').

so, current code should be fixed as:

    if not explicitonly:
        for f in match.files():
           ....
2012-02-06 14:37:49 +09:00
Martin Geisler
1b6b741fb5 templater: handle SyntaxError when parsing ui.logtemplate
Before, Mercurial would crash with a traceback ending with

  SyntaxError: unmatched quotes

if you configured

  [ui]
  logtemplate = {rev}\n

The SyntaxError is now catched and the string is re-parsed without
requiring quotes.
2012-05-12 22:12:54 +02:00
David M. Carr
560a2fff89 forget: fix subrepo recursion for explicit path handling
When support for handling explicit paths in subrepos was added to the forget
command (155b89136ae7), subrepo recursion wasn't taken into account.  This
change fixes that by pulling the majority of the logic of commands.forget into
cmdutil.forget, which can then be called from both there and subrepo.forget.
2012-01-17 19:10:59 -05:00
David M. Carr
375e0ca3cf add: fix subrepo recursion for explicit path handling
When support for handling explicit paths in subrepos was added to the add
command (825c4cefde4b), subrepo recursion wasn't taken into account.  This
change adds an explicitonly argument to cmdutil.add to allow controlling which
levels of recursion should include only explicit paths versus all matched
paths.
2012-01-17 19:10:58 -05:00
Pierre-Yves David
1b001a85f3 changeset_printer: display changeset phase on debug level
Backward compatibility make it hard to display it on higher level
2012-01-17 20:23:23 +01:00
Matt Mackall
dea868ff61 cmdutil: simplify duplicatecopies 2012-01-05 20:35:10 -06:00
Matt Mackall
9bfa890ee6 copies: split the copies api for "normal" and merge cases (API) 2012-01-04 15:48:02 -06:00
Matt Mackall
228f9f6b08 merge with stable 2011-12-21 14:36:08 -06:00
Alistair Bell
8423597fba diff: when diffing a revision with a deleted subrepo, maintain the node context (issue3153) 2011-12-15 16:41:03 -05:00
Renato Cunha
cb456a1751 diff: don't crash when diffing a revision with a deleted subrepo (issue3153)
When a user requested a diff between a revision (r1) that contained a subrepo
and another (r2) that did not, mercurial would crash if r1 was specified before
r2 but would execute the diff otherwise. This fixes this behavior by skipping
the missing subrepo in the diff.
2011-12-14 12:28:00 -02:00
Matt Mackall
720ed4fcd7 alias: shortcut command matching show shadowing works properly (issue3104)
An alias for 'log' was stored in the same command table as
'^log|history'. If the hash function happens to give the latter first,
the alias is effectively ignored when matching 'log'.
2011-12-01 15:51:36 -06:00
Martin Geisler
d6b9b24fa1 merge with stable 2011-12-15 16:26:33 +01:00
Matt Mackall
9e27ec8fc4 merge with stable 2011-12-01 15:57:10 -06:00
David M. Carr
296a0c6305 add: support adding explicit files in subrepos
Change the behavior of the add command such that explicit paths in
subrepos are always added.  This eliminates the previous behavior
where if you called "hg add" for an explicit path in a subrepo
without specifying the -S option, it would be silently ignored.
If you specify patterns, or no arguments at all, the -S option
will still be needed to activate recursion into subrepos.
2011-11-02 01:17:11 -04:00
Eric Roshan Eisner
a6f358182b cmdutil.bailifchanged: abort for dirty subrepos 2011-10-11 18:18:15 -07:00
Matt Mackall
7d65735c38 rebase: move updatedirstate into cmdutil so it can be shared 2011-10-09 16:14:37 -05:00
Andrzej Bieniek
c9cba11d78 export: add %m to file format string (first line of the commit message)
$ hg commit -m "Initial commit"
$ hg export -o %m.patch tip          #It creates Initial_commit.patch file.
2011-07-30 11:08:45 +01:00
Augie Fackler
a5e22d2559 cmdutil: use safehasattr instead of hasattr 2011-07-25 15:32:42 -05:00
Matt Mackall
5ab97592f7 scmutil: switch match users to supplying contexts
The most appropriate context is not always clearly defined. The obvious cases:

For working directory commands, we use None
For commands (eg annotate) with single revs, we use that revision

The less obvious cases:

For commands (eg status, diff) with a pair of revs, we use the second revision
For commands that take a range (like log), we use None
2011-06-18 16:52:51 -05:00
Idan Kamara
14ffa921d6 cmdutil: return a dummy, closable file object if it cannot be duped
If the ui I/O descriptors aren't real descriptors, they cannot be duped.

Instead, we return a wrapper object that behaves the same, and
can be closed (by overriding close and doing nothing).
2011-06-15 23:50:33 +03:00
Idan Kamara
936b803233 cmdutil: use ui descriptors in makefileobj 2011-06-08 14:54:52 +03:00
Idan Kamara
4f72223e4d cmdutil, logmessage: use ui.fin when reading from '-' 2011-06-08 14:54:52 +03:00
Adrian Buehlmann
7062c2db6e workingctx: eliminate remove function
Inlining it into it's last remaining call place in cmdutil.copy.

Note that cmdutil.copy is called with the wlock already held, so no additional
locking is needed to call util.unlinkpath.

We do not need to wrap the util.unlinkpath call into a try block, because
at that point we already know whether abssrc exists or not -- thanks to the
preceding util.copyfile call. Adding a new local 'srcexists' in cmdutil.copy
for that purpose.
2011-06-02 00:33:33 +02:00
Matt Mackall
5f2364be24 cmdutil: make private copies of option lists to avoid sharing monkeypatches 2011-05-26 17:15:35 -05:00
Sune Foldager
9634f23f04 debugindex etc.: add --changelog and --manifest options
These open the changelog and manifest, respectively, directly so you don't
need to specify the path.

The options have been added to debugindex, debugdata and debugrevlog.

The patch also fixes some minor usage-related bugs.
2011-05-14 00:30:32 +02:00
Matt Mackall
0832007f60 scmutil: drop aliases in cmdutil for match functions 2011-05-13 14:58:24 -05:00
Matt Mackall
ae22dd85a2 scmutil: drop some aliases in cmdutil 2011-05-13 14:48:48 -05:00
Matt Mackall
03aaf3756d scmutil: fold in wdutil 2011-05-13 14:07:16 -05:00
Matt Mackall
cf07129983 scmutil: move revsingle/pair/range from cmdutil
This allows users at levels below the command layer to avoid import loops.
2011-05-13 14:06:28 -05:00
Adrian Buehlmann
bd06e02be8 commands: use a decorator to build table incrementally
this allows to define the table entries near the command functions
2011-05-12 08:14:04 +02:00
Matt Mackall
72b9ca1b3b cmdutil: make_file to makefileobj 2011-05-10 16:08:47 -05:00
Matt Mackall
cf2d9729ae cmdutil: make_filename -> makefilename 2011-05-10 16:08:46 -05:00
Matt Mackall
e53ca7b463 cmdutil: bail_if_changed to bailifchanged 2011-05-10 16:08:46 -05:00
Sune Foldager
3889f26501 cmdutil: fix errors reported by pyflakes test 2011-05-08 21:24:30 +02:00
Patrick Mezard
88e958194e patch: move updatedir() from cmdutil into patch
Also, create an artificial wdutil.py to avoid import cycles between patch.py
and cmdutil.py.
2011-05-08 17:48:30 +02:00
Patrick Mezard
2ab321beb7 mq: explicitly updatedir() even if patch() fails
It already works that way in practice, and we intend to merge updatedir() into
patch().
2011-05-08 17:48:29 +02:00
Patrick Mezard
3f102de85d cmdutil: normalize log message eols when reading from file
This will be necessary once util.readfile() operates in binary mode. While
changelog.add() already normalizes the message, doing so in logmessage() is
required as ui.edit() or others expect messages with LF only.
2011-05-07 21:12:33 +02:00
Adrian Buehlmann
c415440828 rename util.set_flags to setflags 2011-05-06 15:22:31 +02:00
Adrian Buehlmann
e981d64ef2 rename path_auditor to pathauditor
The Mercurial 1.9 release is moving a lot of stuff around anyway and we are
already moving path_auditor from util.py to scmutil.py for that release.

So this seems like a good opportunity to do such a rename. It also strengthens
the current project policy to avoid underbars in names.
2011-05-06 09:54:06 +02:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Adrian Buehlmann
c14abef27b scmutil: introduce casecollisionauditor
and cleaning up portability functions
2011-04-30 23:27:00 +02:00
Matt Mackall
2f3e73a448 context: provide an efficient iterator for workingctx
This avoids needing to call status or build a synthetic manifest.
2011-05-01 08:29:50 -05:00
Alexander Solovyov
2f6ab6bf04 revset aliases 2011-04-30 18:30:14 +02:00
Kevin Gessner
e0a808198a add: notify when adding a file that would cause a case-folding collision
On a case-sensitive file system, files can be added with names that differ
only in case (a "case collision"). This would cause an error on case-insensitive
filesystems. A warning or error is now given for such collisions, depending on
the value of ui.portablefilenames ('warn', 'abort', or 'ignore'):

    $ touch file File
    $ hg add --config ui.portablefilenames=abort File
    abort: possible case-folding collision for File
    $ hg add File
    warning: possible case-folding collision for File
2011-04-30 12:39:46 +02:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Idan Kamara
762d333ae9 eliminate various naked except clauses 2011-04-23 00:51:25 +03:00
Adrian Buehlmann
307196b733 move path_auditor from util to scmutil 2011-04-20 22:43:31 +02:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Adrian Buehlmann
fc7e20743c add: introduce a warning message for non-portable filenames (issue2756) (BC)
On POSIX platforms, the 'add', 'addremove', 'copy' and 'rename' commands now
warn if a file has a name that can't be checked out on Windows.

Example:

  $ hg add con.xml
  warning: filename contains 'con', which is reserved on Windows: 'con.xml'
  $ hg status
  A con.xml

The file is added despite the warning.

The warning is ON by default. It can be suppressed by setting the config option
'portablefilenames' in section 'ui' to 'ignore' or 'false':

  $ hg --config ui.portablefilenames=ignore add con.xml
  $ hg sta
  A con.xml

If ui.portablefilenames is set to 'abort', then the command is aborted:

  $ hg --config ui.portablefilenames=abort add con.xml
  abort: filename contains 'con', which is reserved on Windows: 'con.xml'

On Windows, the ui.portablefilenames config setting is irrelevant and the
command is always aborted if a problematic filename is found.
2011-04-19 12:42:53 +02:00
Adrian Buehlmann
53cf962dbf copy: do not copy file if name is disallowed anyway 2011-04-15 16:15:32 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Adrian Buehlmann
87756a5751 cmdutil: fix mode handling in make_file 2011-02-23 23:30:48 +01:00
Matt Mackall
a4d6678bab match: ignore "" patterns
The following command would visit every changeset in repo/ rather than
the last 10:

hg log -l 10 repo/
2011-03-04 19:21:12 -06:00
Waqas Hussain
9981e2f9a8 export: only close files which export itself has opened 2011-02-23 13:21:55 +05:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
David Soria Parra
60c47bdb07 templater: add bookmarks to templates and default output
as bookmarks are not dispalyed as tags anymore, we add a bookmark label
to the changeset printer.
2011-02-11 19:47:39 +01:00
Dan Villiom Podlaski Christiansen
c168860461 make_file: always return a fresh file handle that can be closed
Currently, cmdutil.make_file() will return a freshly made file handle,
except when given a pattern of '-'. If callers would want to close the
handle, they would have to make sure that it's neither sys.stdin or
sys.stdout. Instead, returning a duplicate of either of the two
ensures that make_file() lives up to its name and creates a new
file handle regardless of the input.
2010-12-07 16:08:16 +01:00
Dan Villiom Podlaski Christiansen
811053b2a4 export: flush the file pointer between patches 2010-12-01 21:46:08 +01:00
Matt Mackall
8b31da4540 branch: operate on branch names in local string space where possible
Previously, branch names were ideally manipulated as UTF-8 strings,
because they were stored as UTF-8 in the dirstate and the changelog
and could not be safely converted to the local encoding and back.

However, only about 80% of branch name code was actually using the
right encoding conventions. This patch uses the localstr addition to
allow working on branch names as local strings, which simplifies
handling so that the previously incorrect code becomes correct.
2010-11-24 15:56:32 -06:00
Nicolas Dumazet
1126494b0f merge with stable 2010-11-13 11:58:51 +09:00
Nicolas Dumazet
c2c4887231 log: fix log -rREV FILE when REV isnt the last filerev (issue2492)
Regression from 9f0026001bfd. That previous commit is not supposed
to affect log calls without --follow, so we step out of this
codepath if follow is not True, and it's enough to fix the
regression.

When --follow is given, we fix the issue by taking into account
changesets that have a rev > maxrev to build the filegraph: even if
those files are not included in the final result, it's still needed
to walk correctly the graph from the end of the filelog to minrev, to
track accurately renames.
2010-11-11 02:10:37 +09:00
Nicolas Dumazet
cc0f0d500b cmdutil: move range check outside of filerevgen
Simple refactor, no logic change.
2010-11-11 02:05:02 +09:00
Matt Mackall
72b5ba88f5 commands: add revset support to most commands 2010-11-04 16:21:28 -05:00
Matt Mackall
bc13e3d384 commit: handle missing newline on last commit comment 2010-10-30 12:13:52 -05:00
Patrick Mezard
a3c9b27eda patch: fix copies when patching over uncommitted changed (issue2459) 2010-10-28 21:25:53 +02:00
Wagner Bruna
7ca1d483b2 cmdutil: mark string for i18n 2010-10-20 12:29:41 -02:00
Augie Fackler
42c8b2cf07 termwidth: move to ui.ui from util 2010-10-10 10:06:36 -05:00
Brodie Rao
ff59218cc1 cat: fix cat without -r, broken by 5089d555cee9
The default revision for revsingle() is now '.' instead of None. This
preserves the behavior of cat prior to it using revsingle().
2010-10-08 14:02:23 -05:00
Matt Mackall
9ccbd76ee4 revsets: introduce revsingle helper
revsingle returns a context for the last revision of the supplied revspec
2010-10-07 18:24:29 -05:00
Matt Mackall
223b7c03b1 revsets: make revpair revsets-aware
revpair returns the first and last members of the computed revset(s)
2010-10-07 18:05:04 -05:00
Patrick Mezard
9679c03c21 Restore lexists() changes lost in d8a989380f8b merge 2010-09-20 22:41:10 +02:00
Patrick Mezard
614db673f4 Merge with stable 2010-09-20 22:29:13 +02:00
Patrick Mezard
e043450e1d rename: do not overwrite existing broken symlinks 2010-09-20 21:46:39 +02:00
Martin Geisler
cb93a10b9b add: recurse into subrepositories with --subrepos/-S flag 2010-09-13 13:09:20 +02:00
Martin Geisler
186cdcc54b add: move main part to cmdutil to make it easier to reuse 2010-09-13 13:09:11 +02:00
Martin Geisler
112ea7d5ed patch: break import cycle with cmdutil
The patch module imported cmdutil but used it only in updatedir.
2010-09-13 13:08:09 +02:00
Patrick Mezard
30bd1afde3 subrepos: handle diff nodeids in subrepos, not before
Subversion nodeids are integer revisions.
2010-09-10 22:52:00 +02:00
Martin Geisler
c85f2356e3 subrepos: add function for iterating over ctx subrepos 2010-09-07 16:34:07 +02:00
Martin Geisler
5cb4b1f5eb subrepos: handle modified but uncommitted .hgsub 2010-09-07 16:23:55 +02:00
Martin Geisler
e9c2a20771 diff: recurse into subrepositories with --subrepos/-S flag 2010-09-03 12:58:51 +02:00
Martin Geisler
839c3422d1 cmdutil: use repo.auditor when constructing match object
This gives the repository control over which nested repository paths
that should be allowed via the custom path auditor.

Since paths into subrepositories are now allowed, dirstate.walk must
now filter away more paths than before.
2010-09-03 12:58:51 +02:00
Martin Geisler
80db87965d Consistently import foo as foomod when foo to avoid shadowing
This is in the style of 1aaceccaf1dc.
2010-08-30 14:38:24 +02:00
Martin Geisler
bfea979db3 util: remove lexists, Python 2.4 introduced os.path.lexists 2010-08-25 16:23:32 +02:00
Matt Mackall
76a1c7b90d merge with stable 2010-08-17 17:44:19 -05:00
Alecs King
057134ed97 log: fix the bug 'hg log --stat -p == hg log --stat'
Before:
    hg log --stat -p -r tip # only show stat

After:
    hg log --stat -p -r tip # show stat _and_ diff
2010-08-13 14:29:30 +08:00
Nicolas Dumazet
32ca03310d cmdutil: code simplification 2010-08-15 23:38:00 +09:00
Nicolas Dumazet
252ff032c2 log: do not --follow file that is deleted and recreated later (issue732)
== What ==

issue732 is only one example of a buggy behaviour, but there are in fact many
intricated cases. For example:

( "o" contains an alive version of the tracked file, "x" does not)

tip - o - o - x - o - o - x ...
   \
    o - o - o - o - x ...
     \     /
      o - o

This repository contains at least two instances of the tracked file, but
when calling "hg log -f file" only the latest one (the one alive in tip)
matters to us.

== How ==

We must extract from the filelog the history of the file instance we're
interested in and discard changes related to other instances of that file.

We see that we're only interested in ancestors(node), and that all
other nodes in the filelog should not be considered.
2010-08-15 23:17:53 +09:00
Martin Geisler
4c4fee151a cmdutil: remove unnecessary parenthesis 2010-08-12 18:00:41 +02:00
Nicolas Dumazet
347d6d7320 log: do not redefine cachefunc in walkchangerevs
The same variable is defined a few blocks earlier. The first phases in
walkchangerevs should in fact fill that cache, and allow faster lookups
in the last phase. Redefining and overriding this cached function, (knowing
that it will be called with the same arguments) defeats the caching purpose.
2010-07-20 14:42:05 +09:00
Martin Geisler
608c008186 cmdutils: fix code style 2010-07-21 09:43:45 +02:00
Nicolas Dumazet
48c3dffac9 log: document the different phases in walkchangerevs 2010-07-20 14:32:33 +09:00
Nicolas Dumazet
13f83afe55 log: slowpath: only walk specified revision range during preparation
Even with --removed, it does not make sense to examine changesets outside
of the revision range that was specified by the user: the last phase only
yields a subset of (revs), preparation phase hence only has to examine
(revs) to fill correctly fncache.
2010-07-20 14:13:33 +09:00
Martin Geisler
f3e224e1d7 cmdutil: fix accidental name clash with revrange function
The revrange function was used further up, and when a local variable
is defined with the same name, the earlier call to revrange becomes a
'local variable used before assignment' error.

The clash was introduced in 3544b3baebb0.
2010-07-19 00:41:41 +02:00
Nicolas Dumazet
8b45506535 log: slowpath: do not read the full changelog
When in the slowpath, we are examining _all_ changesets in revs.
We need to order reads so they happen increasingly for I/O performance.

Increasing windows were used to read changelog backwards in a windowed manner,
reading the changelog forward inside each window. But since no revision range
was specified, it was equivalent to reading the full changelog, even if a
single revision was passed to the commandline.

When --removed is used, we _need_ to scan all changesets, but if we're only
looking for file patterns, this is not necessary and we can stick to
the revspec that was given to us.
2010-07-04 18:07:30 +09:00
Nicolas Dumazet
93f72c67e1 log: remove increasing windows usage in fastpath
The purpose of increasing windows is to allow backwards iteration on the
filelog  at a reasonable cost.
But is it needed?
 - if follow is False, we have no reason to iterate backwards.
   We basically just want to walk the complete filelog and yield all revisions
   within the revision range. We can do this forward or
   backwards, as it only reads the index.
 - when follow is True, we need to examine the contents of the filelog, and to
   do this efficiently we need to read the filelog forward.
   And on the other hand, to track ancestors and copies, we need to process
   revisions backwards. But is it necessary to use increasing windows
   for this?
   We can iterate over the complete filelog forward, stack the revisions, and
   read the reversed(pile), it does the same thing with a more readable code.
2010-07-03 18:11:15 +09:00
Nicolas Dumazet
3ac31c1176 log: refactor: test for ranges inside filerevgen 2010-07-03 18:01:54 +09:00
Nicolas Dumazet
c470caa65c log: refactor: compute the value of last outside of filerevgen 2010-07-03 17:58:48 +09:00
Mads Kiilerich
812bb21f4d log: follow filenames through renames (issue647)
In commands.log a displayer was initialized from
cmdutil.show_changeset() with the initial matchfn (which designates
the specified files which only is correct in the highest revision in
the range). prep() is handed the correct list of files, but
displayer.show() didn't use that list but keept using the original
matchfn.

The matchfn argument to cmdutil.show_changeset() wasn't specified in
other places and is only used in .show(), so now we give the matchfn
as an optional parameter to .show().

We do however still have to detect --patch and --stat from opts in
show_changeset() and let it imply a matchall, but that can now be
overruled with the new .show() matchfn parameter.
2010-06-29 12:12:34 +02:00
Simon Howkins
b6970b73cd heads: fix templating of headers again (issue2130)
(tweaks and test by mpm)
2010-06-24 15:18:47 +01:00
Simon Howkins
f313e6ccd4 cmdutil: only output style header once in non-buffered mode (issue2130) 2010-06-24 15:18:47 +01:00
Matt Mackall
5efb5b5080 revrange: fix up empty query again 2010-06-20 14:21:47 -05:00
Matt Mackall
2d126f9f2e revrange: attempt to parse old-style queries as a first pass 2010-06-19 13:00:01 -05:00
Dirkjan Ochtman
af6b696f0f move working dir/dirstate methods from localrepo to workingctx 2010-06-07 20:03:32 +02:00
Matt Mackall
97e2d2bcdb revset: fix test failure with qfinish 2010-06-04 22:54:43 -05:00
Matt Mackall
5de34fa30a walkchangerevs: allow empty query sets 2010-06-03 18:00:15 -05:00
Matt Mackall
959774dfd8 revset: hook into revrange 2010-06-01 11:18:57 -05:00
Matt Mackall
86ebd43d71 remoteui: move from cmdutil to hg 2010-06-01 11:18:57 -05:00
Alexander Solovyov
b4af7f7817 cmdutil: cleanup imports 2010-05-27 22:50:04 +03:00
Peter Arrenbrecht
10bda79606 rename: make --after work if source is already in R state
I routinely want to use `hg addrem` and then fix up missed renames
manually using `hg mv -A`. This patch allows me to record such
renames from a source in state R to a target in state A.
2010-05-26 16:16:47 +02:00
Matt Mackall
a02b5a5fd1 commands: initial audit of exit codes
bisect: clarify None return
bundle: return 1 on no changes
clone: return result code
copy: limit errors to 0/1
commit: return 1 on no changes
forget: return 1 on errors
grep: return 1 if no match found
remove: return 1 on errors
resolve: return 1 if something fails to resolve
rollback: return 1 if no rollback data
2010-05-15 17:48:49 -05:00
Steve Losh
cbd3276a2b cmdutil: Warn when trying to copy/rename --after to a nonexistant file.
Currently running 'hg rename --after foo.txt bar.typo' is a silent no-op.  This patch adds a warning.  It also updates the copy and rename tests.

No actual functionality is changed.

fixes issue 1822
2010-05-01 18:39:40 -04:00
Yuya Nishihara
539b379b8c log: add --stat for diffstat output
log --stat shows diffstat in place of patch output.
2010-04-01 00:35:12 +09:00
David Greenaway
70b803a04d Move 'findrenames' code into its own file.
The next few patches will increase the size of the "findrenames"
functionality. This patch simply moves the function into its own
file to avoid clutter building up in 'cmdutil.py'.
2010-04-03 11:58:16 +11:00
Yuya Nishihara
e1d422d1b5 commands: refactor diff --stat and qdiff --stat
`opts['unified'] = '0'` can be replaced by `diffopts.context = 0`.
2010-04-07 00:45:20 +09:00
Nicolas Dumazet
2e5722b300 log: remove useless condition
for "copied" to be not None, it requires follow=True
2010-04-23 15:24:11 +09:00
Matt Mackall
399ebe1c0f Merge with stable 2010-04-19 17:00:02 -05:00
Yuya Nishihara
b7e5bbb3f3 remoteui: copy http_proxy settings
http_proxy settings of current repo's .hg/hgrc should be available
on remoteui, so that the httprepo can use them when pulling via http.
2010-04-08 00:13:33 +09:00
Martin Geisler
608d0cbf81 cmdutil: do not translate trivial string 2010-04-05 01:00:14 +02:00
Brodie Rao
3a2a2b8869 cmdutil: make use of output labeling in changeset_printer 2010-04-02 15:22:07 -05:00
Matt Mackall
6e515e4e5d progress: drop extra args for pos=None calls (issue2087) 2010-03-17 18:15:16 -05:00
Martin Geisler
652e04c99c progress: use a verb in present participle 2010-03-15 18:40:00 +01:00
Benoit Boissinot
04d99f9fbc patch/diff: move patch.export() to cmdutil.export()
This API change will allow us to break a cycle between patch and cmdutil.
2010-03-08 19:43:24 +01:00
Benoit Boissinot
7c20de57d6 addremove: avoid fetching data again and again 2010-03-08 00:01:12 +01:00
Benoit Boissinot
467b4c41ef addremove: add progress support for similarity search 2010-03-08 00:00:03 +01:00
Benoit Boissinot
fe5ad60ee3 addremove: atomically update the dirstate
In case someone hits ^C during the similarity search, properly rollback
2010-03-07 23:59:28 +01:00
Brodie Rao
892ba5a830 remove unused imports 2010-02-14 01:52:31 -05:00
Brendan Cully
3743c1ee43 mq: make init -Q do what qinit -c did 2010-02-08 10:50:00 +01:00
Brendan Cully
de80ca9367 mq: add -Q option to all commands not in norepo 2010-02-08 10:23:44 +01:00
Patrick Mezard
4b42e59a7a util: make spawndetached() handle subprocess early terminations
The file-based synchronization introduced by 670de588e29e hangs when the child
process fails before terminating the handshake, which the previous pipe-based
version handled correctly. To fix this, the parent polling loop was fixed to
detect premature terminations of the child process.
2010-02-06 16:50:00 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Patrick Mezard
b47d7635f5 templatekw: fix extras, manifest and showlist args (issue1989)
Removing the explicit parameters from keywords signature is easier than copying
and reproducing the original argument list.
2010-01-18 22:59:32 +01:00
Patrick Mezard
965c2821fb Merge with crew-stab le 2010-01-15 10:38:11 +01:00
Patrick Mezard
b5602adbcc cmdutil: expand style paths (issue1948)
Fix suggested by Andrea Riciputi <andrea.riciputi@gmail.com>
2010-01-15 09:50:52 +01:00
Patrick Mezard
052695b2e4 cmdutil: hide child window created by win32 spawndetached()
Hiding the child process window is not strictly necessary but it avoids opening
an empty shell window when running hg serve as well as a task in the task bar.
The window is hidden after the process is already started causing a single
flicker.
2010-01-10 18:13:34 +01:00
Patrick Mezard
48eee05938 Find right hg command for detached process
On Windows, Mercurial can be run from the python script of from a frozen
executable. In the first case, we have to call the python interpreter since the
script is not executable. Frozen executable can be called directly.

Fix 3/3 for issue421
2010-01-06 21:11:58 +01:00
Patrick Mezard
9c0f70e3a8 cmdutil: replace unix pipe handshake with file lock
The pipe handshake cannot be implemented with Windows detached process, which
disables handle inheritance.

Fix 2/3 for issue421
2010-01-06 21:11:58 +01:00
Dirkjan Ochtman
0513f13503 cmdutil: copy auth section in remoteui
This allows me to specify an auth section in a .hg/hgrc instead of just
a global or user-level hgrc.
2009-12-10 12:31:21 +01:00
Nicolas Dumazet
bf5cba2457 cmdutil.service: do not _exit(0) in the parent process
The fact that a parent process spawns a daemon does not necessarily means that
it is the only think it has to do. This was forcing since e8efd88001e7 inotify
processes launched implicitely to exit prematurely:
when no inotify server was running, "hg st" for example would only launch a
inotify server, _exit(0) and thus would not return file statuses.

This changeset adds a test for implicitely launched inotify processes.
Change to output of test-inotify-1208 is correct: it reflects the normal
error message of "hg st" when not dying during "hg inserve" daemon creation.
2009-11-17 15:00:00 +09:00