Commit Graph

642 Commits

Author SHA1 Message Date
Matt Harbison
8fad1493fa add: pass options via keyword args
The largefiles extensions needs to be able to pass --large, --normal and
--lfsize to subrepos via cmdutil.add() and hgsubrepo.add().  Rather than add
additional special purpose arguments, stop extracting the existing args from the
**opts passed to commands.add() and just pass them along.
2015-01-12 20:59:17 -05:00
Sean Farley
a6610c70d3 log: use namespace logname and colorname
Now that we have the machinary to change the log name and the color label used,
let's use that. Tests have been updated accordingly.
2015-01-14 20:29:47 -08:00
Matt Harbison
85dddfb9c5 forget: don't report rejected files as forgotten as well
It seems like a mistake to report a file as forgotten and rejected.  The
forgotten list doesn't seem to be used by anything in core, so no test changes.
2015-01-11 23:25:23 -05:00
Sean Farley
5c1d1bb100 log: use new namespaces api to display names
The only caveat here is that branches must be displayed first due to backwards
compatibility. The order of namespaces is defined to be the 'update' order
which, unfortunately, is not the same as log output order.

It's worth mentioning that the log output is still translated the same as
before since we are formating our strings the same way:

  # i18n: column positioning for "hg log"
  _("bookmark:    %s\n") % bookmark

becomes

  tname = _(("%s:" % ns.templatename).ljust(13) + "%s\n") % name

when name == 'bookmark'. The ljust(13) keeps the strings and whitespace equal.
Adding a new namespace is even easier now because the log output code doesn't
need to change. A future programmer would just need to add the string to the
corresponding .po file (which is the same as they would have had to do
previously).
2014-10-17 09:26:37 -07:00
Matt Mackall
80c883c82a merge with stable 2015-01-06 18:18:28 -06:00
Gregory Szorc
73fa937531 cmdutil.jsonchangeset: properly compute added and removed files
jsonchangeset._show() was computing the reverse status of the current
changeset. As a result, added files were showing up as removed and
removed files were showing up as adds.

There were existing tests for this code and they were flat out wrong.
2015-01-05 22:18:55 -08:00
Durham Goode
fd373c16b0 log: fix log revset instability
The log/graphlog revset was not producing stable results since it was
iterating over a dict. Now we sort before iterating to guarantee a fixed order.

This fixes some potential flakiness in the tests.
2014-12-08 15:41:54 -08:00
Durham Goode
74a5156e21 log: fix log -f slow path to actually follow history
The revset created when -f was used with a slow path (for patterns and
directories) did not actually contain any logic to enforce follow. Instead it
was depending on the passed in subset to already be limited (which was limited
to :. but not ::.). This fixes it by adding a '& ::.' to any -f log revset.

hg log -f <file> is still broken, in that it can return results that aren't
actually ancestors of the current file, but fixing that has major perf
implications, so we'll deal with it later.
2014-12-05 14:27:32 -08:00
Siddharth Agarwal
34aea9120f cmdutil.changeset_printer: explicitly honor all diffopts
This is used in hg log -p so the output is expected to be the same as that of
hg diff.
2014-11-21 16:01:55 -08:00
Matt Harbison
21ca967140 narrowmatcher: propagate the rel() method
The full path is propagated to the original match object since this is often
used directly for printing a file name to the user.  This is cleaner than
requiring each caller to join the prefix with the file name prior to calling it,
and will lead to not having to pass the prefix around separately.  It is also
consistent with the bad() and abs() methods in terms of the required input.  The
uipath() method now inherits this path building property.

There is no visible change in path style for rel() because it ultimately calls
util.pathto(), which returns an os.sep based path.  (The previous os.path.join()
was violating the documented usage of util.pathto(), that its third parameter be
'/' separated.)  The doctest needed to be normalized to '/' separators to avoid
test differences on Windows, now that a full path is returned for a short
filename.

The test changes are to drop globs that are no longer necessary when printing an
absolute file in a subrepo, as returned from match.uipath().  Previously when
os.path.join() was used to add the prefix, the absolute path to a file in a
subrepo was printed with a mix of '/' and '\'.  The absolute path for a file not
in a subrepo, as returned from match.uipath(), is still purely '/' based.
2014-11-27 10:16:56 -05:00
Matt Harbison
c2203f42d7 remove: use vfs instead of os.path + match.rel() for filesystem checks 2014-12-25 21:50:35 -05:00
Matt Harbison
5632d06d85 forget: use vfs instead of os.path + match.rel() for filesystem checks 2014-12-25 21:43:45 -05:00
Pierre-Yves David
2d599c1c7d revert: look for copy information for all local modifications
Renaming a file over an existing one marks the file as modified. So we
track rename source in modified file too.
2014-11-25 19:40:54 -08:00
Matt Harbison
9b17eabeab subrepo: drop the 'ui' parameter to revert()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in revert is to emit status and warning messages, and to
check the verbose flag prior to printing the action to be performed on a file.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.  Unlike other methods where the matcher is passed along and narrowed, a
new matcher is created in each repo, and therefore the bad() method already used
the local repo's ui.
2014-12-13 19:44:55 -05:00
Matt Harbison
616ad7eb66 subrepo: drop the 'ui' parameter to removefiles()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in remove is to emit status and warning messages, and to
check the verbose flag prior to printing files to be removed.  The bad() method
on the matcher still uses the root repo's ui, because narrowing the matcher
doesn't change the ui object.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.
2014-12-13 19:36:50 -05:00
Matt Harbison
800917e351 subrepo: drop the 'ui' parameter to forget()
This no longer needs to be explicitly passed because the subrepo object tracks
the 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in forget is to emit status and warning messages, and to
check the verbose flag prior to printing files to be forgotten.  The bad()
method on the matcher still uses the root repo's ui, because narrowing the
matcher doesn't change the ui object.

The local repo's ui was already being used to print a warning message in
wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status()
call.
2014-12-13 19:23:30 -05:00
Matt Harbison
418c3ff6d6 subrepo: drop the 'ui' parameter to cat()
This no longer needs to be explicitly passed because the subrepo object tracks
a 'ui' reference since d4e8aa61370d.  See the change to 'archive' for details
about the differences between the output level in the root repo and subrepo 'ui'
object.

The only use for 'ui' in cat is to emit a status message when a subrepo is
missing.  The bad() method on the matcher still uses the root repo's ui, because
narrowing the matcher doesn't change the ui object.
2014-12-13 14:26:38 -05:00
Matt Harbison
3c47e94de7 commit: propagate --addremove to subrepos if -S is specified (issue3759)
The recursive addremove operation occurs completely before the first subrepo is
committed.  Only hg subrepos support the addremove operation at the moment- svn
and git subrepos will warn and abort the commit.
2014-11-24 22:27:49 -05:00
Matt Harbison
44b25f2773 commit: abort if --addremove is specified, but fails
This will be required when subrepo support is added, in order to ensure
consistent commits when a subrepo flavor doesn't support addremove.
2014-11-26 15:16:22 -05:00
Matt Harbison
9e4d7cc2d3 scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns
This will make it easier to support subrepository operations.
2014-11-09 19:57:02 -05:00
Matt Mackall
cabaf089d4 merge with stable 2014-12-09 13:32:19 -06:00
John Coomes
310ded0ea2 add: use lexists so that broken symbolic links are added
This restores the add behavior prior to 83750c0d774f and matches the
behavior of addremove.
2014-12-03 14:33:29 -08:00
Siddharth Agarwal
bf23516938 jsonchangeset: don't honor whitespace and format-changing diffopts
JSON is meant to be parsed by computers, and format changes can break them.
2014-11-18 22:13:05 -08:00
Matt Mackall
4abfc94f18 merge with stable 2014-11-27 12:25:01 -06:00
Matt Harbison
6b20f5bf8e add: check for the existence of a file matched inexactly before adding it
The change in 02ecc94fb657 created a problem on Windows and OS X:

    --- /usr/local/mercurial/tests/test-issue660.t
    +++ /usr/local/mercurial/tests/test-issue660.t.err
    @@ -47,6 +47,8 @@
     Should succeed - shadow removed:

       $ hg add b
    +  adding b/b
    +  b/b does not exist!

Prior to the failing 'hg add', the file 'b/b' was added and committed, then 'b'
was recursively deleted from the filesystem, file 'b' was created and the delete
was recorded with 'hg rm --after'.  This add is attempting to record the
existence of file 'b'.

A filesystem that is not case sensitive prevents dirstate.walk() from skipping
its step 3, and step 3 has the effect of inserting removed files into the walk
list.  The Linux code doesn't run through step 3, and didn't exhibit the
problem.  It's not clear why a non case sensitive filesystem triggers step 3,
given that the path normalization occurs in step 2.

Prior to 02ecc94fb657, part of the check here was 'f not in repo.dirstate'
instead of 'f not in wctx'.  Files in the 'r' state are filtered out of
context.__contains__() but not dirstate.__contains__().  Therefore the removed
file name wasn't added to the list of files to add when checking against
dirstate.  That change was to allow removed files to be readded, but adding a
file that doesn't exist is nonsensical.  If the user specifies a missing file,
it will be an exact match and will still fail.
2014-11-19 22:27:55 -05:00
Martin von Zweigbergk
2916dab85b revert: access status fields by name rather than index
For better readability.
2014-11-19 17:07:27 -08:00
Matt Harbison
8766c8079f remove: avoid a bogus warning about no tracked files when removing '.'
Previously, any files relative to the root of the repo that match the -I
patterns would be deleted, but the command exited with 1 after printing a
warning:

   $ hg remove -S -I 're:.*.txt' .
   removing sub1/sub2/folder/test.txt
   removing sub1/sub2/test.txt
   not removing .: no tracked files
2014-11-16 00:24:23 -05:00
Matt Harbison
c0a7d4f5bc remove: support remove with explicit paths in subrepos 2014-11-12 23:15:20 -05:00
Matt Harbison
17e7835237 remove: recurse into subrepositories with --subrepos/-S flag
Like 'forget', git and svn subrepos are currently not supported.  Unfortunately
the name 'remove' is already used in the subrepo classes, so we break the
convention of naming the subrepo function after the command.
2014-11-15 21:36:19 -05:00
Matt Harbison
7fc45849db remove: move most of the implementation into cmdutils.remove()
This will allow access to the reusable parts from subrepos, similar to add(),
forget(), etc.
2014-11-09 12:31:34 -05:00
Martin von Zweigbergk
42c14b3ed1 add: add back forgotten files even when not matching exactly (BC)
I accidentally did 'hg forget .' and tried to undo the operation with
'hg add .'. I expected the files to be reported as either modified or
clean, but they were still reported as removed. It turns out that
forgotten files are only added back if they are listed explicitly, as
shown by the following two invocations. This makes it hard to recover
from the mistake of forgetting a lot of files.

  $ hg forget README && hg add README && hg status -A README
  C README
  $ hg forget README && hg add . && hg status -A README
  R README

The problem lies in cmdutil.add(). That method checks that the file
isn't already tracked before adding it, but it does so by checking the
dirstate, which does have an entry for forgotten files (state 'r'). We
should instead be checking whether the file exists in the
workingctx. The workingctx is also what we later call add() on, and
that method takes care of transforming the add() into a normallookup()
on the dirstate.

Since we're changing repo.dirstate into wctx, let's also change
repo.walk into wctx.walk for consistency (repo.walk calls wctx.walk,
so we're simply inlining the call).
2014-11-10 14:51:18 -08:00
Mads Kiilerich
523c87c1fe spelling: fixes from proofreading of spell checker issues 2014-04-17 22:47:38 +02:00
Matt Harbison
ebc17dec9c amend: abort early if no username is configured with evolve enabled (issue4211)
Amend will reuse the original username if a new one is not provided
with -U, but obsolete.createmarkers() only considers ui.username() for
the obsolete marker's metadata. Allowing the metadata field to be
spoofed seems to defeat the point of the field in the first place.
This covers 'evolve amend' and 'ci --amend' with evolve enabled.

Without this, the transaction aborts but the parent changeset is set to -1.  The
corresponding test will be added to evolve separately.
2014-10-28 23:05:19 -04:00
Durham Goode
18f3737f3a obsolete: add createmarkers option
The basic obsolete option is allowing the creation of obsolete markers. This
does not enable other features, such as allowing unstable commits or exchanging
obsolete markers.
2014-10-14 13:23:52 -07:00
Matt Mackall
f663e5fc01 duplicatecopies: move from cmdutil to copies
This is in preparation for moving its primary caller into merge.py,
which would be a layering violation in the current location.
2014-10-13 14:33:13 -05:00
Pierre-Yves David
b73c13bbd6 getgraphlogrevs: remove user of baseset.append
A `baseset` has multiple cached results and will get even more in the future.
Making it an object "populated once" like the other smartsets makes it both safer
and simpler. The append method will be removed at some point.
2014-10-07 00:20:00 -07:00
Pierre-Yves David
cac69b710e getlogrevs: remove user of baseset.append
A `baseset` has multiple cached results and will get even more in the future.
Making it an object "populated once" like the other smartsets makes it both safer
and simpler. The append method will be removed at some point.
2014-10-07 00:04:16 -07:00
Jordi Gutiérrez Hermoso
a7cc108c20 log: do not hide the public phase in debug mode (BC)
When 62900f2373fa introduced phases to the `hg log --debug` output, it
also disabled outputting public phase. At the same time, it always
shows phases in the default template, `hg log --debug -T default`.
Those two should produce the same output, but they don't.

I think it makes a lot more sense to always show all phases. There's
already loss of backwards compatibility in this case when using a
newer hg on an old hg repo, since draft commits will show up in the
output of `hg log --debug`.

Finally, I just don't think that any sort of information should be
hidden with --debug. This flag should be about showing as much
information as possible.
2014-10-04 16:28:28 -04:00
Jordi Gutiérrez Hermoso
281cec5b64 templater: set the correct phase for parents
Akin to b5baef1e39f6 which did this for `hg log`, the following sets
the correct phase for the {phase} keyword when the context is a parent
of the current cset. This allows templates such as the following to be
defined,

    parent = '{label("log.parent changeset.{phase}",
                      "parent:      {rev}:{node|formatnode}")}\n'

which when called on a parent (e.g. with the `parents` template
keyword), will produce the correct phase.
2014-10-03 22:03:31 -04:00
Pierre-Yves David
bfd39d13a8 revert: properly back up added files with local modification
These files were previously not backed up because the backup mechanism was not
smart enough. This leads to data lose for the user since uncommitted contents
were discarded.

We now properly move the modified version to <filename>.orig before deleting it.

We have to use a small hack to do a different action if "--no-backup" is
specified. This is needed because the backup process is actually a move (not a
copy) so the file is already missing when we backup. The internet kitten is a
bit disapointed about that, but such is life.

This patch concludes the "lets refactor revert" phases. We can now open the
"Lets find stupid bug with renames and merge" phases.

I'm sure that now that the code is clearer we could do it in another simpler
way, but I consider the current improvement good enough for now.
2014-08-31 13:01:00 +02:00
Pierre-Yves David
985e6cc94b revert: track added files with local modifications
Those files need to be backed up but are currently not. We compute the set of
them to be able to use a different backup strategy in the next changeset.
2014-08-30 02:39:08 +02:00
Pierre-Yves David
4b18de4a6a revert: distinguish between "check" and "backup" strategy
"check" behaves as backup did before. We check if the current file differs
from destination and we create a backup if it does. This is used for untracked
files that will be overwritten by formerly-deleted files. We have to do the manual
check since no status output can provide the content comparison.

"backup" is now doing unconditional backup. This can be used for files seen as
modified compared to both the target and the working directory. In such a case, we
know that the file differs from target without actually comparing any content.

This new "backup" strategy will be especially useful in the case of files added
between the target and the working directory -parent- with additional modifications
in the working directory -itself-. In that case we know we need to back it up, but we
cannot run the content check as the files does not exists in target.
2014-08-30 02:30:24 +02:00
Pierre-Yves David
9c3ba8614b revert: small refactoring in the way backup value are handled
The current backup value may have two different values:

  1. Do not try to do backup
  2. Do backup if applicable

We are about to move to:

  1. Do not try to do backup
  2. Do backup if applicable
  3. Do backup in all cases

So we change the current values to make room for the new one.
2014-08-30 02:28:27 +02:00
Matt Mackall
0602ddc218 merge with stable 2014-09-30 18:22:58 -05:00
Yuya Nishihara
525193c247 templater: fix precedence of --style and --template options
Since 266cfa7de44d, --template option is ignored if --style is specified,
which is wrong according to the doc of show_changeset():

    Display format will be the first non-empty hit of:
    1. option 'template'
    2. option 'style'
    ...
2014-09-30 23:15:56 +09:00
Durham Goode
153b05ace7 revert: special case 'hg revert --all'
On large repos, hg revert --all can take over 13 seconds. This is mainly due to
it walking the tree three times: once to find the list of files in the
dirstate, once to find the list of files in the target, and once to compute the
status from the dirstate to the target.

This optimizes the hg revert --all case to only require the final status. This
speeds it up to 1.3 seconds or so (with hgwatchman enabled).

Further optimizations could be done for the -r NODE and pattern cases, but they
are significantly more complex.
2014-09-19 18:43:53 -07:00
Durham Goode
2b47ffae5c revert: move targetsubs calculation down to its use
A future patch will be reorganizing this section of the code into two paths, and
targetsubs complicates this by existing in the middle of one path, but not the
other. We fix that by moving it 200 lines down, to the only place it's used.
2014-09-19 18:40:39 -07:00
FUJIWARA Katsunori
5c74f6bc14 import: show the warning message for failure of merging
Before this patch, no message is shown for failure of merging at "hg
import".

In such case, merging patch is imported as a normal revision silently,
and it may confuse users.

For simplicity, this patch recommends just using "--exact", even
though importing the merging patch itself is possible without it if:

  - the hash of the 1st parent in the patch is equal to one of the
    patch imported just before (or the parent of the working
    directory, for the 1st patch of the series), and

  - the hash of the 2nd parent in the patch is known in the local
    repository
2014-08-27 23:10:06 +09:00
Sean Farley
a5ff857520 log: use correct phase info for parent field (issue4347)
Previously, there was a copy / paste error with using the current changeset's
phase information. We now look up the parent context explicitly.

The line was too long so it is stored into a variable first.
2014-08-23 17:03:08 -05:00
Siddharth Agarwal
f07a4ceb07 cmdutil: add a hook for making custom non-follow log file matchers
This will be used by largefiles (and basically only by largefiles) in an
upcoming patch.
2014-08-13 15:17:03 -07:00