Commit Graph

889 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
e269967115 subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
This patch also centralizes composing dirty reason message like
"uncommitted changes in subrepository 'xxxx'".
2015-03-25 13:55:35 +09:00
Matt Harbison
1b58f58b45 revert: evaluate subrepos to revert against the working directory
Reverting to a revision where the subrepo didn't exist will now abort, and
matching subrepos against the working directory is consistent with how filesets
are evaluated since dd1c701aad4d.
2015-03-25 22:20:44 -04:00
Matt Harbison
31c3ab572e revert: handle subrepos missing in the given --rev
The list of subrepos to revert is currently based on the given --rev, so there
is currently no way for this to fail.  Using the --rev context is wrong though,
because if the subrepo doesn't exist in --rev, it is skipped, so it won't be
changed.  This change makes it so that the revert aborts, which is what happens
if a plain file is reverted to -1.  Finding matches based on --rev is also
inconsistent with evaluating files against the working directory (dd1c701aad4d).

This change is made now, so as to not cause breakage when the context is
switched in an upcoming patch.
2015-03-25 21:54:47 -04:00
Sean Farley
a0d78a3107 diff: rename --relative option to --root
The diff output format is unable to express files outside the directory so it
makes sense to name this option --root instead of --relative.
2015-03-25 11:55:15 -07:00
Pierre-Yves David
9d2643c9ed amend: check for directory renames for both merge parents (issue4516)
Before this change, amending a merge would lose the rename information for file
adding in the second parents and implicitly renamed into a new directory.

In case of the merge, we also look for directory rename data from the second
parent. This seems to fix the bug and does not show other issues from the test
suite.
2015-03-02 19:01:00 +00:00
Augie Fackler
69e342baa2 log: fix json-formatted output when file copies are listed (issue4523) 2015-02-02 14:26:47 -05:00
FUJIWARA Katsunori
e42765e252 namespace: introduce logfmt to show l10n-ed messages for hg log correctly
Before this patch, "_()" is used incorrectly for "tag:" and
"bookmark:" fields. "changeset_printer()" looks up keys composed at
runtime, and it prevents "xgettext" command from getting strings to be
translated from source files.

Then, *.po files merged with updated "hg.pot" lose msgids for "tag:"
and "bookmark:".

This patch introduces "logfmt" information into "namespace" to show
l10n-ed messages "hg log" (or "changeset_printer()") correctly.

For similarity to other namespaces, this patch specifies "logfmt" for
"branches" namespace, even though it isn't needed (branch information
is handled in "changeset_printer()" specially).

To find related code paths out easily, this patch adds "i18n: column
positioning ..."  comment to the line composing "logfmt" by default,
even though this line itself doesn't contain any strings to be
translated.
2015-01-28 22:22:59 +09:00
Durham Goode
cb1fb957a4 revert: move prefetch to after the actions logic
The prefetch logic came before the actual population of the actions collection,
so it was always being passed an empty action list. This fixes it by moving it
to after that logic.

The only consumer of this function at the moment is remotefilelog, and I
verified it works with this change.
2015-01-27 19:52:26 -08:00
Yuya Nishihara
4c964d9e78 revert: comment that filesets are always evaluated against workingctx 2015-01-17 14:22:21 +09:00
Martin von Zweigbergk
ce073b0455 revert: take fast path also when not reverting to '.'
This speeds up 'hg revert -r .^ --all --dry-run' on the Mozilla repo
from 4.081s to 0.826s. Note that 'hg revert -r .^ .' does not get any
faster, since '.' does not make match.always() True.

I can't think of a reason it would break anything, and if it does,
it's clearly not covered by tests.
2015-03-24 15:47:57 -07:00
Martin von Zweigbergk
8ef76750bb revert: define 'wctx' a little earlier and use it more 2015-03-24 13:56:51 -07:00
Yuya Nishihara
ed458b9332 log: use rev() to build revset of --follow option from numeric revision
startrev can be -1.
2015-01-10 13:14:00 +09:00
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
Martin von Zweigbergk
5adcba3667 revert: evaluate filesets against working directory (issue4497)
As the failing revert tests in test-fileset-generated.t show,

Revert currently creates one matcher for matching files in the working
copy and another matcher for matching files in the target
revision. The two matchers are created with different contexts, which
means filesets are evaluated differently. Then the union of the sets
of files matching the matchers in the two contexts are reverted. It
doesn't seem to make sense to use two different matchers; only the
context they're applied to should be different.

It seems very likely that the user wants the filesets to be evaluated
against the working directory, which the tests
test-fileset-generated.t also assume, so let's make it so.

I willingly admit that the largefiles code was modified by trial and
error (according to tests).
2015-03-23 23:04:51 -07:00
Siddharth Agarwal
b48f87449f cmdutil.diffordiffstat: add support for diffs relative to a subdirectory
It's possible that some of the match patterns are outside the relative root. We
warn in that case. In upcoming patches we'll add tests for this.
2015-03-17 15:06:40 -07:00
Matt Harbison
8ef259aa86 cmdutil: drop a duplicate import of crecord
It looks like this crept in with 9819929ec97e.
2015-03-20 21:55:11 -04: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 Harbison
3ea5067ed3 subrepo: add basic support to hgsubrepo for the files command
Paths into the subrepo are not yet supported.

The need to use the workingctx in the subrepo will likely be used more in the
future, with the proposed working directory revset symbol.  It is also needed
with archive, if that code is to be reused to support 'extdiff -S'.
Unfortunately, it doesn't seem possible to put the smarts in subrepo.subrepo(),
as it breaks various status and diff tests.

I opted not to pass the desired revision into the subrepo method explicitly,
because the only ones that do pass an explicit revision are methods like status
and diff, which actually operate on two contexts- the subrepo state and the
explicitly passed revision.
2015-03-18 23:03:41 -04:00
Martin von Zweigbergk
5fba048889 walkchangerevs: make followfilter a top-level class
The class only depends on the 'repo' variable in the closure, so let's
move the class out of the function and make it explicit that that (the
repo) is all it needs.
2015-03-19 09:12:21 -07:00
Martin von Zweigbergk
95a9e50c6a walkchangerevs: simplify by using match.always() method
Since "slowpath = match.anypats() or (match.files() and
opts.get('removed'))", we can simplify the condition "not slowpath and
not match.files()" to "not match.anypats() and not match.files()",
which is equivalent to "match.always()".
2014-10-28 22:32:18 -07:00
Durham Goode
724425bff5 obsolete: remove last instance of _enabled
The _enabled bool has been replaced by obsolete.isenabled(...). This removes the
last instance of it so I can remove the _enabled flag entirely shortly.
2015-03-17 14:52:58 -07:00
Yuya Nishihara
53f1e7866c commands: replace "working copy" with "working directory" in help/messages
"working directory" is the standard term, we should use it consistently.

But I didn't touch the hint, "run 'hg update' to get a working copy", because
"get a working directory" sounds a bit odd.
2015-03-17 22:47:08 +09:00
Laurent Charignon
f97eaa8ce4 revert: add flag to make revert interactive 2015-03-16 16:33:59 -07:00
Laurent Charignon
bd121df4b3 record: move ui.write wrapping where it should be
We have to do that for the coloring to work in interactive revert
2015-03-16 15:37:00 -07:00
Laurent Charignon
b53c518d0f record: refactor the filtering code 2015-03-16 15:35:50 -07:00
Laurent Charignon
f58c9907e3 record: consolidate ui.write wrapping in a function 2015-03-16 15:30:33 -07:00
Laurent Charignon
331b4f43db record: minor refactoring of dorecord
It prepares the way for introducing the flag to reverse hunk selection
2015-03-12 17:50:23 -07:00
Laurent Charignon
0502dc3e22 record: enable curses recording logic with experimental flag 2015-03-12 14:24:48 -07:00
Laurent Charignon
62f1f68490 record: change interface of the filtering function
This way filtering functions accept chunks and return chunks
2015-03-12 17:51:37 -07:00
Laurent Charignon
1a368bb039 record: change recording function to work with crecord 2015-03-12 14:20:32 -07:00
Laurent Charignon
8e36c9d449 record: change interface of dorecord to accept new filters
This makes it easier to add different filtering logic (record /crecord ...)
2015-03-11 16:39:38 -07:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Matt Harbison
d26c34fe51 files: replace 'ctx._repo' with 'ctx.repo()' 2015-03-12 22:55:35 -04:00
Matt Harbison
1a03b7a16d files: split reusable implementation into cmdutil for subrepo support 2015-03-08 16:50:57 -04:00
Laurent Charignon
b5de5559b7 record: move dorecord from record to cmdutil
Part of a serie of patches to move record from hgext to core
2015-03-10 17:14:33 -07:00
Siddharth Agarwal
eb2ddaf931 cmdutil.tryimportone: allow importing relative patches with --bypass 2015-03-10 13:06:38 -07:00
Siddharth Agarwal
3f34a651ac cmdutil.tryimportone: allow importing relative patches into the working dir
This makes hg import --prefix dir/ (without bypass) work.
2015-03-09 18:22:24 -07:00
Augie Fackler
dbd43329ce dispatch: offer suggestions of similar-named commands
When suggestions are available, we show those suggestions instead of
showing some help output.
2015-02-10 15:59:12 -05:00
Jordi Gutiérrez Hermoso
91e31472eb log: display closing-branch nodes as "_" (BC)
In plain `hg log` there is no indication that a commit closes a
branch. You can use hg log --debug, but this is too verbose. A simple
idea copied from thg and other graphical viewers is to display the
node for a closing-branch commit as a horizontal line.

I think this technically is a BC if we consider the graphlog to be
part of the stdout API, but I really can't imagine who the hell is
parsing the graphlog to determine information about commits.
2014-11-24 16:42:49 -05:00
Durham Goode
bd91d1c63e workingctx: use normal dirs() instead of dirstate.dirs()
The workingctx class was using dirstate.dirs() as it's implementation. The
sparse extension maintains a pruned down version of the dirstate, so this
resulted in the workingctx reporting an incorrect listing of directories
during merge calculations (it was detecting directory renames when it
shouldn't have).

The fix is to use the default implementation, which uses workingctx._manifest,
which unions the manifest with the dirstate to produce the correct overall
picture. This also produces more accurate output since it will no longer
return directories that have been entirely deleted in the dirstate.

Tests will be added to the sparse extension to detect regressions for this.
2015-03-05 22:16:28 -08:00
Mads Kiilerich
b2b60414f6 spelling: fixes from proofreading of spell checker issues 2015-01-18 02:38:57 +01:00
Matt Mackall
0c7d82b039 merge with stable 2015-03-02 17:32:37 -06:00
Matt Harbison
ee0eea92e1 revert: display full subrepo output with --dry-run
Since the point of --dry-run is to show what will happen, the output with and
without it should agree.  And since revert wasn't being called on subrepos with
--dry-run before, revert in the subrepo had to be defanged in this case.
2015-02-07 21:47:28 -05:00
Yuya Nishihara
ea398a57c8 log: fix --follow null parent not to include revision 0
If p1 is null, ':.' is translated as '0:null'. But rangeset can't handle null,
only revision 0 was visible.  Because 'null' should not be listed implicitly,
"log --follow" (without -r) should be empty if p1 is null.

Test of "hg grep -f" is added for cmdutil.walkchangerevs().
2015-02-06 21:53:39 +09:00
Yuya Nishihara
f61265845b cmdutil: have walkchangerevs utilize common function to build revs 2015-02-06 00:22:20 +09:00
Yuya Nishihara
97ca3a4dd8 log: extract common part from getgraphlogrevs() and getlogrevs() 2015-02-06 00:15:35 +09:00
Yuya Nishihara
bba83cb128 graphlog: remove useless check for empty repo when --follow is specified
This prepares for extracting common part from getgraphlogrevs() and
getlogrevs(). getlogrevs() does not handle empty repo specially.

When it was added at a98e985d1dd1, revs were build by old-style query, '.:0'.
So I think the purpose of "len(repo) > 0" was to handle the case of . = null.
Currently it isn't necessary for 'reverse(:.)', and it does not work if repo
is not empty but p1 is null.

  $ hg up null
  $ hg glog --follow -T '{rev}:{node|short}\n'
  o  0:0a04b987be5a

The subsequent patch will fix this problem, so drops the wrong version for now.
2015-02-06 00:06:47 +09:00
Yuya Nishihara
454ee6ca93 graphlog: move comment and flag denoting revs might be unsorted
This prepares for extracting common part from getgraphlogrevs() and
getlogrevs().  "possiblyunsorted" exists only in getgraphlogrevs().
2015-02-05 23:49:18 +09:00
Yuya Nishihara
f70a0be178 graphlog: remove too early return from getgraphlogrevs() for empty repo
Even if repository is empty, null revision should exist.
2015-02-05 23:14:44 +09: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
Siddharth Agarwal
b112932fc1 cmdutil: rename _makelogfilematcher to _makefollowlogfilematcher
We're going to add a _makenofollowlogfilematcher in an upcoming patch.
2014-08-13 15:15:13 -07:00
Yuya Nishihara
4d834f9237 log: do not use exact matcher for --patch --follow without file (issue4319)
5d9f39626224 is valid only if file argument is specified.  If no pattern
specified, it can simply fall back to the original matcher.
2014-08-01 21:36:56 +09:00
Matt Mackall
f648f507dd templates: re-add template listing support
We used to have --style nosuch to list templates, but --style is now
merged with --template/-T where random strings are acceptable
templates. So we reserve 'list' to allow listing templates.
2014-07-25 15:35:09 -05:00
FUJIWARA Katsunori
f9743bb802 cmdutil: make commit message shown in text editor customizable by template
This patch makes commit message shown in text editor customizable by
template. For example, this can advertise:

  - sample commit messages for routine works,
  - points to call attention before commit,
  - message of the day, and so on

To show commit message correctly even in problematic encoding, this
patch chooses the latter below:

  - replace "buildcommittext" with "buildcommittemplate" completely

  - invoke "buildcommittemplate" only if '[committemplate] changeset'
    is configured explicitly

For example, if multibyte character ending with backslash (0x5c) is
followed by ASCII character 'n' in the customized template, sequence
of backslash and 'n' is treated as line-feed unexpectedly (and
multibyte character is broken, too).

This corruption occurs in 'decode("string-escape")' while parsing
template string.
2014-07-15 23:34:13 +09:00
Matt Mackall
b221e35cf4 commiteditor: refactor default extramsg 2014-07-18 23:15:28 -05:00
Pierre-Yves David
4a068b03fd revert: add a drop action
This prevents the need for a try except in the `_performrevert` code.
2014-08-30 02:25:23 +02:00
Pierre-Yves David
334a6443f4 revert: explicitly track added but deleted file
Added + deleted file are files that need to be untracked from the dirstate but
that are already missing on disk. The current `_performrevert` code is handling
that with exception catching. We will be able to do better with a dedicated set.
2014-08-30 02:23:25 +02:00
Pierre-Yves David
ed9dd646bd revert: have an explicit action for "forget"
The distinction between "remove" and "forget" used to be in special logic
checking for the state of the file in the dirstate. Now that we have dedicated
filtering, we can stop relying on this logic and have two distinct actions.
2014-09-01 12:36:48 +02:00
Pierre-Yves David
5d71ed07e4 revert: split between newly added file and file added in other changeset
These two kinds of files are handled differently. One is deleted and the other
is just forgotten (the file is untracked but left in place). The distinction is
done in the `_performrevert` code itself and we would like to get ride of this.
2014-08-30 18:20:29 +02:00
Matt Mackall
512fbd2843 import: let --exact 'work' with --no-commit (issue4376) 2014-09-19 14:51:58 -05:00
Matt Mackall
7cc7319641 cmdutil: add json style to log-like commands
Sadly, this can't be done with the normal templater like we do with
XML due to JSON's inter-record comma rules.
2014-09-15 13:11:13 -05:00
Durham Goode
a5a69f0001 dirstate: wrap setparent calls with begin/endparentchange (issue4353)
This wraps all the locations of dirstate.setparent with the appropriate
begin/endparentchange calls. This will prevent exceptions during those calls
from causing incoherent dirstates (issue4353).
2014-09-05 11:36:20 -07:00
Pierre-Yves David
0a99f9c4f9 revert: drop lexist check in the backup logic
We are no longer trying to backup files that do not exist on disk. This check
can be safely dropped.
2014-08-30 02:10:29 +02:00
Pierre-Yves David
2a02a27185 revert: distinguish between deleted file and locally modified
Locally modified needs a backup while a deleted file cannot be backed
up because there is no file to backup.
2014-08-30 02:09:53 +02:00
Pierre-Yves David
a6bc441291 revert: detect unknown files in the same path as files marked as removed
Such unknown files may need to be backed up. Having them identified beforehand
will help simplify the backup logic.

We now use different sets with different backup strategies.
2014-08-30 02:00:20 +02:00
Pierre-Yves David
f77e0eb240 revert: cache working context in a variable
During the silicon age, humans on planet Earth discovered the use of
variables. This marvelous invention let them improve both code
readability and performance.
2014-08-30 01:52:08 +02:00
Martin von Zweigbergk
e95a8f8fb9 cmdutil: avoid the confusing name 'patch' for a matcher 2014-08-31 07:45:50 -07:00
Pierre-Yves David
884e556964 revert: drop now useless conditional in the backup check
Now that we removed the (hopeless) attempt to backup file we knew to be
missing in the target changeset, we can stop checking if the file exists in
the target changeset.
2014-08-30 01:51:02 +02:00
Pierre-Yves David
d51e1ac08b revert: no backup for dsadded set
There is only one case where a backup is required in the `dsadded` set, and the
current backup mechanism fails to handle it. So we stop trying to do backups at
all for now. This will help us to simplify the backup code and finally fix
this backup issue.
2014-08-30 01:49:28 +02:00
Pierre-Yves David
5fca88c509 revert: add more padding in the dispatch list
We are going to add more sets and some of them will have longer names. We add
padding in a standalone patch for readbility purposes.
2014-08-30 16:06:09 +02:00
Pierre-Yves David
b34b8413be revert: add documentation in the dispatch table
More sets are coming so documenting the existing ones will help.
2014-08-30 01:48:58 +02:00
Pierre-Yves David
2554c150e4 revert: add a way for external extensions to prefetch file data
This allow extensions that mess with the storage layer (remotefilelog,
largefile) to prefetch any data that will be accessed during the revert
operation.

We are currently fetching more data than theoretically required because the
backup code is a bit stupid. Future patches will improve that.
2014-08-30 02:47:59 +02:00
Matt Mackall
3ce3f9064f merge with stable 2014-08-27 18:35:34 +02:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
FUJIWARA Katsunori
baa5c6430a import: avoid editor invocation when importing with "--exact" for exact-ness
Before this patch, external editor is invoked when imported patch has
no commit message, even if "--exact" is specified. Then, exact-ness is
broken, because empty commit message causes failure of committing.

This patch avoids editor invocation at importing with "--exact" for
exact-ness, because commit message in the patch should be kept as it
is in such case, even if it is empty.
2014-08-23 23:03:50 +09:00
Pierre-Yves David
1119f2b21b debugobsolete: display parents information from markers
Now that we have a new field, we need a way to visualize it.
2014-08-18 17:17:23 -07:00
FUJIWARA Katsunori
6ff720dff7 import: change "editform" to distinguish merge commits from others
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

  - COMMAND: name of command
  - ROUTE: name of route, if there are two or more routes in COMMAND

This patch uses "normal.normal" and "normal.merge" as ROUTE of
"editform" instead of "normal", to distinguish merge commits from
other in "hg import" without "--bypass" case.

This patch assumes "editform" variations for "hg import" below:

    import.normal.normal
    import.normal.merge
    import.bypass.normal
    import.bypass.merge

Unlike other patches in this series, this patch uses "editor.sh"
instead of "checkeditform.sh" for the name of the script to check
"HGEDITFORM", because it has to do more than checking "HGEDITFORM".

To invoke editor forcibly in "test-import-merge.t", this patch creates
the patch not having patch description as "merge.nomsg.diff".
2014-08-16 10:43:59 +09:00
FUJIWARA Katsunori
1d0310bb6c commit: change "editform" to distinguish merge commits from other (--amend)
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

  - COMMAND: name of command
  - ROUTE: name of route, if there are two or more routes in COMMAND

This patch uses "amend.normal" and "amend.merge" as ROUTE of
"editform" instead of "amend", to distinguish merge commits from other
in "hg commit --amend" case.
2014-08-16 10:43:59 +09:00
FUJIWARA Katsunori
df8f4a6663 commit: change "editform" to distinguish merge commits from others
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

  - COMMAND: name of command
  - ROUTE: name of route, if there are two or more routes in COMMAND

This patch uses "normal.normal" and "normal.merge" as ROUTE of
"editform" instead of "normal", to distinguish merge commits from
others in "hg commit" without "--amend" case.

This patch assumes "editform" variations for "hg commit" below:

    commit.normal.normal
    commit.normal.merge
    commit.amend.normal
    commit.amend.merge

"mergeeditform" is factored out for subsequent patches. It takes
"ctxorbool" argument, because context object can't be passed in some
cases.
2014-08-16 10:43:59 +09:00
Pierre-Yves David
6fc35a917d revert: drop dead code for untracked files
Untracked files are handled through status now.
2014-06-25 00:02:17 +01:00
Pierre-Yves David
6f03c922f1 revert: handle unknown files through status
This will allow us to drop the code dedicated to this special case.
2014-06-25 00:01:30 +01:00
Pierre-Yves David
aee89be787 revert: drop more dead code
Now that we detect all clean files, we do not need this clause anymore.
2014-06-24 23:55:43 +01:00
Pierre-Yves David
f409864957 revert: add a message to noop action
This prepares for the arrival of a second "not touching file" action:
revert of an untracked file.
2014-08-02 13:07:01 -07:00
Pierre-Yves David
5dc6cf75e9 revert: simplify loop conditional
The two breaks can be joined into one. The code gains one level of indent.
2014-08-01 11:41:56 -07:00
Pierre-Yves David
84467bf1a9 revert: explode the action tuple in the for loop
noop is about to gain a message.
2014-06-24 18:04:13 +01:00
Pierre-Yves David
110f9a614a revert: use actions[...] in all disptable cases
1. Special cases are not special enough

2. There are two cases where nothing is done and a message is displayed. This
   prepares it.
2014-08-02 12:45:34 -07:00
Pierre-Yves David
5b69082d6e revset: factorize backup decision
The conditional controlling the creation of backup is fairly big. We move config
related decisions outside of the loop.
2014-06-24 17:54:33 +01:00
Pierre-Yves David
8af395dddd revert: use a flat dispatch table
Now that the table is simpler, remove one level of depth from it. This
simplifies its usage in the for loop.
2014-06-24 17:44:31 +01:00
Pierre-Yves David
a3e6a74916 debugobsolete: explicitly display date in the output
As the date is becoming a first-class citizen, we are displaying it in an
explicit field. As a bonus it is now readable by humans.
2014-08-13 23:42:36 -07:00
Pierre-Yves David
b1789db911 obsmarker: add a flags method
We introduce a proper method to access the flag information.
2014-08-15 09:41:30 -07:00
Pierre-Yves David
fbb01f1dde revert: add an XXX about rename tracking
We check for rename information in the dirstate. This is probably not enough to
preserve this behavior when using an explicit target rev.

I just spotted this while working on this code, but this is outside the scope
of my series so I'm just adding a comment to highlight this suspicious
situation.
2014-06-24 16:59:40 +01:00
Pierre-Yves David
429f2742a7 revert: inline a now useless closure
Now that a single call site remains, we can just inline its content.
2014-06-24 17:39:43 +01:00
Pierre-Yves David
6088f7f0d0 revert: remove code killed by the double status
All those checks were here to catch cases where files were not modified in
dirstate but were different in the target revision. This is now properly handled
by calling status on the target node too.
2014-06-24 17:37:24 +01:00
Pierre-Yves David
c1c198f25f revert: drop missingmodified set
There cannot be any elements in this set since:

    dsmodified &= modified
2014-06-24 17:36:49 +01:00
Pierre-Yves David
032cc9974f revert: detect files added during a merge
In case of merge, file that are actually added can be reported as modified. This
is currently handled by special-case code. We detect it beforehand instead. This
will lets use remove the special-case code at some point in the future.
2014-06-24 17:28:20 +01:00
Pierre-Yves David
9f80242186 revert: simplify handling of added files
There are multiple possible cases for added files. But it's all handled by magic
much lower in the stack. We document them, simplify the codes and move on.
2014-08-02 11:32:24 -07:00
FUJIWARA Katsunori
e8856bc78d ui: invoke editor for committing with HGEDITFORM environment variable
At the external editor invocation for committing, the value specified
as "editform" for "cmdutil.getcommiteditor" is in "HGEDITFORM".

This enables external editor to do own customization according to
commit types.
2014-08-15 23:05:53 +09:00
Pierre-Yves David
ff3290bfea revert: use modified information from both statuses
Using status information against the target ensures we are catching all
files with modifications that need reverting.

We still need to distinguish fresh modifications for backup purpose.

test-largefile is affected because it reverted a file that needs no content
change.
2014-06-24 17:27:18 +01:00
Pierre-Yves David
56e34a196a revert: drop special case handling for file unknown in parent
We had a special case for file not caught by any categories. It was
aimed at files missing in wc and wc's parent but existing in the target
revision. This is now properly handled using status information.
2014-06-24 16:57:16 +01:00
Pierre-Yves David
911e895e66 revert: use "remove" information from both statuses
Using status information against the target to make sure we are catching all
files that need to be re-added.

We still need to distinguish fresh removal because they use a different
message.
2014-06-24 16:53:22 +01:00
Pierre-Yves David
2cc3d88c5b revert: process removed files missing in target as clean
If a file does not exist in target and is marked as removed in the dirstate, we
can mark it as clean. There are no changes needed to revert it.
2014-08-01 18:27:47 -07:00
Pierre-Yves David
708550e527 revert: also track clean files
Tracking clean files is the simplest way to be able to reports files that need
no changes. So we explicitly retrieve them.

This fixes a couple of test outputs where the lack of changes was not reported.
2014-07-31 15:52:56 -07:00
Pierre-Yves David
df2c9033ac revert: triage "deleted" files into more appropriate categories
Status can return file as "deleted". This is only a special case
related to working directory state: file is recorded as tracked but no
file exists on disk. This will never be a state obtainable from
manifest comparisons.

"Deleted" files have another working directory status shadowed by the lack of
file. They will -alway- be touched by revert. The "lack of file" can be seen as
a modification. The file will never match the same "content" as in the revert
target. From there we have two options:

1. The file exists in the target and can be seen as "modified".
2. The file does not exist in the target and can be seen as "added".

So now we just dispatch elements from delete into appropriate categories.
2014-08-01 18:57:53 -07:00
Matt Mackall
57de8037d2 merge with stable 2014-08-14 16:25:47 -05:00
Pierre-Yves David
5b7e70a4d0 revert: issue "no changes needed" message for files missing on both side
When a file was marked as removed in the working copy and did not existed in the
target of the revert, we did not issued any message pointing that no change was
needed to the file (implicitly saying that revert had changed the file).

We now properly issue a message in this situation. Tests change in and handful
of case where the message was documented as missing.
2014-07-31 16:03:26 -07:00
Pierre-Yves David
b18e801dd3 revert: call status against revert target too
We now call status against the target (and possibly against the working
directory parent is different). We do not use the information from the two
sources yet, but this is coming soon.

We need the status information aganst the dirstate in all case because we need
to be able to backup local modification.
2014-06-24 15:47:12 +01:00
Pierre-Yves David
b263ff2b09 revert: prefix variable names for dirstate status with "ds"
As we are going to introduce status again other revision we needs to distinguish
between data from dirstate status and the other one. We prefix the existing data
with "ds" to highlight this.
2014-06-24 15:35:43 +01:00
Pierre-Yves David
50ccb74146 revert: move manifest membership condition outside of the loop
Currently, revset is using information from dirstate status and alter its
behavior whenever the file exist in the target manifest or not. This tests are
done a big for loop. We move this member ship testing outside of the loop and
simplifies associates data structure.

This is a step toward a cleaner implementation of revert based on status.
2014-06-24 15:28:22 +01:00
FUJIWARA Katsunori
28e199eab5 cmdutil: use '[committemplate]' section like as map file for style definition
Before this patch, each template definitions for 'changeset*' in
'[committemplate]' section have to be written fully from scratch,
even though many parts of them may be common.

This patch uses '[committemplate]' section like as the map file for
the style definition. All items other than 'changeset' can be referred
from others.

This can reduce total cost of template customization in
 '[committemplate]' section.

When the commit template other than '[committemplate] changeset'
is chosen by 'editform', putting '[committemplate] changeset'
value into the cache of the templater causes unexpected result,
because the templater stores the specified (= chosen) template
definition into own cache as 'changeset' at construction time.

This is the reason why '[committemplate] changeset' can't be referred
from others.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
ec97822d35 cmdutil: look commit template definition up by specified 'editform'
Before this patch, '[committemplate] changeset' definition is shared
between all actions invoking 'commitforceeditor()'.

This prevents template definition from showing action specific
messages: for example, 'hg tag --remove' may need specific
message to call attention, but showing it may be redundant for
other actions.

This patch looks commit template definition up by specified
'editform' introduced by prior patches. 'editform' are
dot-separated list of names, and treated as hierarchical one.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
7b50947677 import: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, 'normal' and 'bypass' are used as ROUTE.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
4de8382c53 commit: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  COMMAND[.ROUTE]

  - ROUTE: name of route, if there are two or more routes in COMMAND

In this patch, 'normal' and 'amend' are used as ROUTE.
2014-08-02 21:46:27 +09:00
FUJIWARA Katsunori
83c808bc5a cmdutil: introduce 'editform' to distinguish the purpose of commit text editing
This information will be used to switch '[committemplate] changeset'
definition according to its purpose in the subsequent patch.

This information also makes it easier to hook commit text editing only
in the specific cases.
2014-08-02 21:46:26 +09:00
Durham Goode
4bf8cd87a5 log: allow patterns with -f
It's not uncommon for a user to want to run log with a pattern or directory name
on the history of their current commit.  Currently we prevent that, but
I can't think of any reason to continue blocking that.

This commit removes the restriction and allows 'hg log -f <dir/pat>'
2014-07-22 22:40:16 -07:00
Siddharth Agarwal
1fe4080620 log: use an exact matcher for --patch --follow
The arguments to log --patch --follow are expected to be exact paths.

This will be used to make manifest filtering for these cases more efficient in
upcoming patches.
2014-07-12 18:31:18 -07:00
Matt Mackall
809fa98620 merge with stable 2014-07-16 17:35:04 -05:00
Siddharth Agarwal
67dffae77b log: make --patch --follow work inside a subdirectory
Previously, the 'patch' code for hg log --patch --follow would try to resolve
patterns relative to the repository root rather than the current working
directory. Fix that by using match.files instead of pats, as done elsewhere
nearby.
2014-07-12 02:23:17 -07:00
Siddharth Agarwal
9d5c80b2c5 log: allow revset for --follow to be lazily evaluated
It is unclear to me why evaluation was forced.

For a repository with over 700,000 commits, 'hg log -f' drops from 1.2 seconds
to 0.2 seconds.
2014-07-12 20:44:00 -07:00
FUJIWARA Katsunori
ccb0dfc103 cmdutil: separate building commit text from 'commitforceeditor'
This separation makes it easier to extend/hook building commit text
from the specified context.

This patch uses 'committext' instead of 'edittext' for names of newly
added variable and function, because the former is more purpose
specific than the latter, even though 'edittext' in 'buildcommittext'
is left as it is to reduce amount of diff.
2014-07-15 00:59:09 +09:00
Augie Fackler
23d3b7a1e7 cmdutil: add copy-filtering support to duplicatecopies
In order to fix issue 4192 we need to be able to skip some copies
while doing duplicatecopies.
2014-06-07 15:14:36 -04:00
Lucas Moscovicz
2794920df6 log: changed implementation to use graphlog code
Now that revsets work in a lazy way, log code can be changed to parse every
option into a revset and then evaluate it lazily.

Now expressions like

  "hg log -b default -b ."

are converted into a revset using the same code as graphlog.
2014-02-28 15:10:56 -08:00
Lucas Moscovicz
783ebe698d cmdutil: changed _makegraphlogrevset to _makelogrevset
This method will now be used to build both graphlog and log revset after this
series of patches.
2014-02-25 10:40:04 -08:00
Matt Mackall
3fd77ddc42 merge with stable 2014-07-02 00:01:13 -05:00
Gregory Szorc
aa3c5a1887 cmdutil: support inferrepo in command decorator 2014-05-04 22:20:00 -07:00
Gregory Szorc
f5b841fd2e cmdutil: add optionalrepo argument to command decorator 2014-05-04 22:12:34 -07:00
Gregory Szorc
a7f200b6b8 commands: add norepo argument to command decorator
Since decorators are evaluated at module load time and since the
@command decorator imports commands, the norepo variable (along with
its friends) may not be declared yet. These variables are now declared
before @command usage to ensure they are present.
2014-05-04 20:58:25 -07:00
Gregory Szorc
db0791767a cmdutil: better document command() 2014-05-04 18:45:04 -07:00
Sean Farley
1002b6c612 memfilectx: call super.__init__ instead of duplicating code
This patch changes the calling signature of memfilectx's __init__ to fall in
line with the other file contexts.

Calling code and tests have been updated accordingly.
2013-08-15 16:49:27 -05:00
Pierre-Yves David
ca87e2a8ca revert: use p2 as parent when reverting against it
revert was always using p1 as parent. This created some minor misbehavior when
reverting against p2. See test change for an example of that.

This is also a useful cleanup for coming refactoring to revert.
2014-05-14 10:38:05 -07:00
Pierre-Yves David
f11f5d8bf7 revert: explicitly get status against the parent
This makes absolutely no functional changes. The default value for
node1 is already the same as the current value of parent. But to be
able to properly use the second parent in merge context, we have to
start to be a bit more explicit about what we compute the status
against.
2014-05-14 10:37:25 -07:00
Pierre-Yves David
ffa305346b revert: group related data in tuple in the dispatch table
The dispatch table used to be:

- action if in target manifest
- action if not in target manifest
- make backup if in target manifest
- make backup if not in target manifest

We turn this into two (action, make backup) tuples.

This helps both readability of the dispatch table and handling of each case.

This also prepares a refactoring where the different actions we performs, whether
"file is in target manifest" or not, are determined before reaching this loop.
2014-05-13 17:28:19 -07:00
Pierre-Yves David
e48f0c2bb9 revert: group action into a single dictionary
We had 4 different variables to hold the list of the 4 possibles
actions. I'm grouping them in a single dictionary for a few reasons.
First, it makes it clearer they are all related and meant to be the
final actions performed by revert. Second this simplifies the parameter
of the _performrevert function. Finally the two elements in each entry
(list and message) have a different consumers in different functions,
this change will make it easier to split them in a later commit.
2014-05-13 16:42:31 -07:00
Pierre-Yves David
04aa6b354e revert: add some inline comments
I spend some time understanding how this part of the revert code is
working. I'm adding some comments to help the code readability. I
expect most of them to disappear in a coming refactoring. But the
refactoring should be easier to follow with the comment.
2014-05-13 16:29:42 -07:00
Pierre-Yves David
2b188dd25a revert: cosmetic align of the dispatch table
This changeset make a minimal cosmetic change to help readability of the value
in this table.
2014-05-13 16:29:20 -07:00
Pierre-Yves David
b7c330c46d import: add --partial flag to create a changeset despite failed hunks
The `hg import` command gains a `--partial` flag. When specified, a commit will
always be created from a patch import. Any hunk that fails to apply will
create .rej file, same as what `hg qimport` would do. This change is mainly
aimed at preserving changeset metadata when applying a patch, something very
important for reviewers.

In case of failure with `--partial`, `hg import` returns 1 and the following
message is displayed:

    patch applied partially
    (fix the .rej files and run `hg commit --amend`)

When multiple patches are imported, we stop at the first one with failed hunks.

In the future, someone may feel brave enough to tackle a --continue flag to
import.
2014-05-08 17:08:17 -07:00
FUJIWARA Katsunori
63865524f1 outgoing: introduce "outgoinghooks" to avoid redundant outgoing check
This patch introduces "outgoinghooks" to avoid redundant outgoing
check for "hg outgoing" in other than "commands.outgoing" (or utility
functions used by it).
2014-04-16 00:37:24 +09:00
FUJIWARA Katsunori
090a597dc7 summary: introduce "summaryremotehooks" to avoid redundant incoming/outgoing check
This patch introduces "summaryremotehooks" to avoid redundant
incoming/outgoing check for "hg summary" in other than
"commands.summary".

Only if "--remote" is not specified for "hg summary", hooks registered
in "summaryremotehooks" are invoked with "None" as "changes" argument
at first, and they should return tuple of two booleans meaning
"whether incomings are needed" and "whether outgoings are needed".

If no hooks return tuple containing "True", "hg summary" does nothing
any more, because incoming/outgoing check is not needed.

Otherwise, hooks are invoked again: at this time, "changes" argument
refers the result of incoming/outgoing check.

This patch also prevents RepoError from being raised if "--remote" is
not specified for "hg summary", because of backward compatibility for
"hg summary --large" without "--remote".
2014-04-16 00:37:24 +09:00
Matt Harbison
615b124547 cat: support cat with explicit paths in subrepos
The cat command with an explicit path into a subrepo is now handled by invoking
cat on the file, from that subrepo.  The previous behavior was to complain that
the file didn't exist in the revision (of the top most repo).  Now when the file
is actually missing, the revision of the subrepo is named instead (though it is
probably desirable to continue naming the top level repo).

The documented output formatters %d and %p reflect the path from the top level
repo, since the purpose of this is to give the illusion of a unified repository.
Support for the undocumented (for cat) formatters %H, %R, %h, %m and %r was
added long ago (I tested back as far as 0.5), but unfortunately these will
reflect the subrepo node instead of the parent context.

The previous implementation was a bit loose with the return value, i.e. it would
return 0 if _any_ file requested was cat'd successfully.  This maintains that
behavior.
2014-03-14 21:32:05 -04:00
Matt Harbison
cb793b21fa cat: move most of the implementation into cmdutils.cat()
This will allow access to the reusable parts from subrepos, similar to add(),
forget(), etc.
2014-03-13 23:45:18 -04:00
FUJIWARA Katsunori
6737a23301 amend: invoke editor forcibly when "--edit" option is specified
1fc59036a99b introduces "--edit" option into "hg commit", but it
doesn't work for "hg commit --amend", because 1fc59036a99b prepares
for editor invocation only around "commitfunc()" internal function,
which is used only for temporary amend commit by "cmdutil.amend()".

Actual commit message editing is executed in "cmdutil.amend()".

This patch invokes editor forcibly when "--edit" option is specified
for "hg commit --amend", even if commit message is specified
explicitly by "--message" or "--logfile".

This patch also removes useless handling for commit message and editor
invocation around "commitfunc()" internal function.
2014-04-16 02:38:11 +09:00
Matt Mackall
ca3a6376d7 debugrevlog: use unfiltered view for changelog 2014-04-14 23:27:31 -04:00
Mads Kiilerich
0e8795ccd6 spelling: fixes from spell checker 2014-04-13 19:01:00 +02:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Matt Mackall
ea6ffc9a80 merge with stable 2014-03-18 14:25:28 -05:00
FUJIWARA Katsunori
89fcbff9fc amend: save commit message into ".hg/last-message.txt"
Before this patch, commit message (may be manually edited) for "commit
--amend" is never saved into ".hg/last-message.txt", because it uses
"localrepository.commitctx()" instead of "localrepository.commit()":
saving into ".hg/last-message.txt" is executed only in the latter.

This patch saves commit message for "commit --amend" into
".hg/last-message.txt" just after user editing.

This is the simplest implementation to fix on stable. Editing and
saving commit message for memctx should be centralized into the
framework like "localrepository.commit()" with "editor" argument or so
in the future.
2014-03-19 01:07:41 +09:00
Lucas Moscovicz
0d53c6ae3b cmdutil: changed max method for lazy call
Used the lazy max call instead of the python max implementation to be able to
use lazysets for graphlog.
2014-03-14 13:27:12 -07:00
Lucas Moscovicz
dafb80fa39 getgraphlogrevs: return an empty baseset instead of a empty list
We aims at returning smartset only so that function higher in the stack can use
smartset feature.
2014-03-14 13:26:40 -07:00
Pierre-Yves David
a0ce769bb9 getgraphlogrevs: do not convert smartset to baseset
We are now sure that revs is a smartset. We remove the baseset call that would
defeat any lazyness.
2014-03-14 16:26:50 -07:00
Lucas Moscovicz
a96218c725 cmdutil: changed revset for spanset
Instead of using baseset(repo.changelog) changed it for spanset(repo) which is
much faster.
2014-03-14 08:44:52 -07:00
Lucas Moscovicz
3972cf7390 cmdutil: changed code in _makegraphlogrevset not to use getitem
__getitem__ is a method that is not implemented lazily on many of the new
classes and it can be easily replaced with a structure that takes advantage of
the new lazy implementations instead.
2014-03-14 11:35:17 -07:00
Lucas Moscovicz
9dd89e3285 cmdutil: changed code in getgraphlogrevs not to use getitem
__getitem__ is a method that is not implemented lazily on many of the new
classes and it can be easily replaced with a structure that takes advantage of
the new lazy implementations instead.
2014-03-14 08:43:52 -07:00
FUJIWARA Katsunori
70f9f39f84 commit: create new amend changeset as secret correctly for "--secret" option
Before this patch, "hg commit --amend --secret" doesn't create new
amend changeset as secret, even though the internal function
"commitfunc()" passed to "cmdutil.amend()" make "phases.new-commit"
configuration as "secret" temporarily.

"cmdutil.amend()" uses specified "commitfunc" only for temporary amend
commit, and creates the final amend commit changeset by
"localrepository.commitctx()" directly with memctx.

This patch creates new amend changeset as secret correctly for
"--secret" option, by changing "phases.new-commit" configuration
temporarily before "localrepository.commitctx()".
2014-03-13 19:48:41 +09:00
Matt Mackall
471d2893a7 merge with default 2014-03-13 15:00:34 -05:00
Matt Mackall
b93e6d4112 merge with stable 2014-03-13 12:05:08 -05:00
Lucas Moscovicz
81e72f8395 cmdutil: changed walkchangerevs to use spanset instead of baseset
Using a spanset takes almost no memory at all. A baseset builds the entire
list in memory and is much slower for methods like __contains__.
2014-03-05 18:49:47 -08:00
Matt Mackall
94e268974b templating: make -T much more flexible
It can now accept styles and paths and references to settings in
[templates].
2014-03-08 17:38:50 -06:00
Matt Mackall
694de7920e changeset_templater: remove use_template method 2014-03-08 16:14:08 -06:00
Matt Mackall
b80c07e771 cmdutil: make helper function to process template args 2014-03-08 16:01:58 -06:00
Alexander Drozdov
53f98064f3 cmdutil: make commitforceeditor() to pass revision extras to ui.edit() 2014-02-06 10:15:20 +04:00
Pierre-Yves David
8e74d42689 revert: extract actual revert in its own function
With this small refactoring, the computation of the action to perform and the
actual change to the disk happen in different function. This allows extension to
wrap the later in case of need. The initial motivation is the `remotefilelog`
extension that need to prefetch all the file content to be checked out.
2014-02-26 18:56:27 -08:00
Lucas Moscovicz
2663ae5f88 cmdutil: implemented new lazy increasingwindows
Now log can work in a lazy way and get results as soon as they are processed.

Performance Benchmarking:

$ time hg log -l1 -qr "branch(default)"
0:3a6a38229d41

real  0m2.303s
user  0m2.252s
sys 0m0.048s

$ time ./hg log -l1 -qr "branch(default)"
0:3a6a38229d41

real  0m0.238s
user  0m0.199s
sys 0m0.037s
2014-02-13 14:27:12 -08:00
Pierre-Yves David
aa3270ed1f import: move tryone closure in cmdutil
We extract the `tryone` function into the `cmdutil` module. A lot of the command
context have to be passed to the utility function, but having and explicit
declaration will allow extension to wrap it. This will allows use to make
changeset evolution related experiment in dedicated extension.

Improving the API of this function is noble goal but outside of the scope of
this patches.
2014-02-11 16:52:36 -08:00
Pierre-Yves David
e54cd58994 debugobsolete: extract marker display in a dedicated function
We want to be able to reuse and extend it from other function or
extension while working on markers exchange.

This changeset is pure core movement.
2014-02-11 16:30:23 -08:00
Augie Fackler
8bfe6ea1ed itersubrepos: move to scmutil to break a direct import cycle 2014-02-03 18:36:00 -05:00
FUJIWARA Katsunori
12afa6b0c3 cmdutil: enhance "getcommiteditor()" for specific usages in MQ
This patch introduces "finishdesc" and "extramsg" arguments into
"getcommiteditor()" for specific usages in MQ.

"finishdesc" will be used to treat the commit message as "[mq];
patch-file-name" (default MQ commit message), if it is left as empty,
instead of aborting commit process.

"extramsg" will be used to show the line below:

    HG: Leave message empty to use default message

instead of:

    HG: Leave message empty to abort commit
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
308518c1e9 import: use "getcommiteditor()" instead of explicit editor choice
This patch also enhances "test-import-bypass.t" and "test-import.t",
because "hg import" hasn't been explicitly tested around editor
invocation and "--edit" option.

This patch explicitly tests below:

    - with "--bypass" (regardless of "--edit"):
        - not invoked, if the patch contains the commit message
        - not invoked, if the commit message is explicitly specified
        - invoked, otherwise (just adding comment)

    - without "--bypass":
        - with "--edit":
            - not invoked, if "--no-commit" is not specified
            - invoked, otherwise
        - without "--edit":
            - not invoked, if the patch contains the commit message
            - not invoked, if "--message" or "--logfile" is specified
              (just adding comment)
            - invoked, otherwise
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
5d7a84ff6f amend: use "getcommiteditor()" instead of explicit editor choice
This patch doesn't change any tests like as preceding patches, because
editor invocation is already tested in "test-commit-amend.t".
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
0a6972edad cmdutil: introduce "getcommiteditor()" to simplify code paths to choose editor
"getcommiteditor()" can simplify code paths to choose commit editor
according to '--edit' option as below:

    before:
        editor = cmdutil.commiteditor # or editor = None/False
        if opts.get('edit'):
            editor = cmdutil.commitforceeditor

    after:
        editor = cmdutil.getcommiteditor(**opts)

"getcommiteditor()" accepts option arguments not in "opts" style but
in "**opts" style, because some code paths want to invoke it with just
explicit "edit=True" argument (building dictionary is redundant).
2014-05-11 00:49:35 +09:00
Lucas Moscovicz
ef8bd69f5f revset: added baseset class (still empty) to improve revset performance
This class is going to be used to cache the set that is created from this list
in many cases while evaluating a revset.
2014-01-21 11:39:26 -08:00
Matt Mackall
74cf3d4bf4 merge with stable 2013-11-19 11:29:56 -05:00
Matt Mackall
c9a233d77e templater: fix escaping in nested string literals (issue4102)
Before the templater got extended for nested expressions, it made
sense to decode string escapes across the whole string. Now we do it
on a piece by piece basis.
2013-11-18 14:02:26 -05:00
Augie Fackler
213fff305a pathutil: tease out a new library to break an import cycle from canonpath use 2013-11-06 18:19:04 -05:00
Yuya Nishihara
4a2a9b7d3a cmdutil: fix makefileobj not to clobber default modemap dict
Problem occurs if "hg cat -o" is invoked more than once in the same process.
The output of "hg cat" will be appended because of modemap[fn] = 'ab'.
2013-10-22 23:38:58 +09:00
Mads Kiilerich
c47c81f0e5 cmdutil: use None as default value for "function pointer" instead of False
Less type confusion.
2013-10-03 18:01:21 +02:00
Siddharth Agarwal
0b1ce7709c cmdutil.service: move pidfile writing to the parent in daemon mode
There is a potential race here, which I suspect I've spotted in the wild, where
something reads the pid file after the parent exits but before the child has
had a chance to write to it. Moving writing the file to the parent causes this
to no longer be an issue.
2013-10-02 15:20:49 -07:00
Siddharth Agarwal
e4986d8e9e cmdutil.service: move pidfile writing to a local function
An upcoming patch will reuse this code.
2013-10-02 15:17:50 -07:00
Siddharth Agarwal
1addd98f97 cmdutil.bailifchanged: standardize error message for dirty working dir
This affects rebase, graft, histedit, and other similar commands.
2013-09-23 21:31:37 -07:00
Durham Goode
87385443b0 log: make file log slow path usable on large repos
Running "hg log <pattern or directory>" on large repos took a very, very long
time because it first read ctx.files() for every commit before even starting to
process the results.

This change makes the ctx.files() check lazy, which makes the command start
producing results immediately.
2013-09-10 19:49:34 -07:00
Matt Mackall
b2c60c13a2 revert: fix largefiles breakage 2013-07-26 21:03:25 -05:00
Matt Mackall
0bc2bdce17 revert: make backup when unforgetting a file (issue3423)
This skips the backup if it would be a duplicate.
2013-07-26 17:08:05 -05:00
Matt Mackall
6d0d30f28a checkunfinished: accommodate histedit quirk
Turns out histedit actually intends for commits (but not other
operations like update) to be possible during its operation.
2013-07-25 02:17:52 -05:00
Matt Mackall
72d6ff963c update: add tracking of interrupted updates (issue3113)
This takes advantage of the new checkunfinished infrastructure
2013-07-25 00:33:28 -05:00
Matt Mackall
1aa741bd25 cmdutil: core functionality to block during multistep commands (issue3955)
This adds a registration point and check functions that will allow
commands to check if multistep operations like an interrupted graft or
rebase are in progress before proceeding.
2013-07-24 23:27:30 -05:00
Durham Goode
1142072e5b filelog: switch 'not len(filerevlog)' to 'not filerevlog'
A few places in the code use 'if not len(revlog)' to check if the revlog
exists. Replacing this with 'not filerevlog' allows alternative revlog
implementations to override __nonzero__ to handle this case without
implementing __len__.
2013-05-30 18:47:16 -07:00
Durham Goode
6733c33949 log: move log file walk to its own function
This moves the logic that determines which changesets to process during a
'hg log foo.txt' command. Putting it in its own function allows extensions
to modify how the file log is traversed. For instance, the current
implementation uses filelog revs heavily. Other implementations may not have
filelog revs available.

The function throws an exception if the traversal is not possible via the
filelog, so the parent function can do things the slow way if necessary
(by walking the entire commit history).

Aside from the exception throwing, no logic is changed.
2013-05-30 19:25:55 -07:00
Bryan O'Sullivan
5acd0ede31 summary: augment output with info from extensions 2013-05-14 11:23:15 -07:00
Bryan O'Sullivan
c787225d04 revert: ensure that copies and renames are honored (issue3920)
Previously, we restored the states of files, but not the additional
information the dirstate uses to track copies and renames.
2013-05-03 12:40:17 -07:00
Mads Kiilerich
bd4ae8e1a6 amend: fix unlocking order - first lock then wlock 2013-04-17 03:41:08 +02:00
Alexander Plavin
829cf92d16 log: fix behavior with empty repositories (issue3497)
Make output in this special case consistent with general case one.
2013-04-17 00:29:54 +04:00
Brodie Rao
3d16726725 amend: support amending merge changesets (issue3778) 2013-02-08 21:08:34 +00:00
Siddharth Agarwal
b97fabd2e4 duplicatecopies: do not mark items not in the dirstate as copies
Consider the following repo:

  0 -- 1 (renames a to b)
    \
     - 2

If we're rebasing 2 onto 1, then duplicatecopies is called with arguments (2,
1). copies.pathcopies goes backwards from 1 to 0 and returns the pair dst = a,
src = b. Of course, since we're working on top of 2, at this point a doesn't
exist in the dirstate.

Extra entries in the copymap are currently harmless because the copymap is
only queried for items in the dirstate map. However, if the dirstate.copy
method becomes one of the sources used to determine which files have changed,
this will prove problematic.

Note that we can't avoid going backwards in general -- consider this repo:

  0 -- 1 (renames a to b)
    \
     - 2 (renames a to c)

Rebasing 2 onto 1 should produce a rename from b to c.
2013-03-28 18:27:19 -07:00
Siddharth Agarwal
218624d093 duplicatecopies: fix arg name and docstring
While most callers do indeed use duplicatecopies with a rev and its parent,
rebase doesn't.
2013-03-28 00:14:27 -07:00
Bryan O'Sullivan
e37e16da0f cmdutil: use a small initial window with --limit
In a large repo, running a command like "log -l1 -p" was expensive because
it would always traverse 8 commits, as 8 was the initial window size.

We now choose the lesser of 8 or the limit, speeding up the "log -l1 -p"
case by a factor of 5.
2013-02-20 11:31:38 -08:00
Kevin Bullock
6f2a9a513a commit: factor out status printing into a helper function
We create a new function commitstatus() in cmdutil that handles printing
the status message(s) after a commit. This will allow other commit-like
commands to use it, and in particular is step 2 towards removing
backout's call to commands.commit.
2013-02-12 16:32:14 +00:00
Mads Kiilerich
ef317883c7 export: show 'Date' header in a format that also is readable for humans
'export' is the official export format and used by patchbomb, but it would only
show date as a timestamp that most humans might find it hard to relate to. It
would be very convenient when reviewing a patch to be able to see what
timestamp the patch will end up with.

Mercurial has always used util.parsedate for parsing these headers. It can
handle 'all' date formats, so we could just as well use a readable one.

'export' will now use the format used by 'log' - which is the format described
as 'Unix date format' in the templating help. We assume that all parsers of '#
HG changeset patch'es can handle that.
2013-02-08 22:54:17 +01:00
Augie Fackler
8671b3e731 export: clobber files with -o (bc) (issue3652)
This violated user expectation. Updated the code to clobber files, but
preserve the behavior of appending multiple patches requested in a
single export. Includes tests.
2013-02-09 15:38:57 -06:00
Antonio Zanardo
a6143a0b42 commit: show active bookmark in commit editor helper text
If there is an active bookmark while committing, the bookmark name
will be visible inside the commit message helper, below the branch
name.

This should make easier for the user to detect a mistaken commit
parent, while working for example with a bookmark centric workflow
like topic branches.

The active bookmark is checked to be in the working directory, as
pointed by Kevin Bullock, because otherwise committing would not
advance it. In other words, this would not show the active
bookmark name if the user changed the working tree parents with
'hg debugsetparents', for example.
2013-02-02 15:37:17 -02:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Mads Kiilerich
5af2faad25 log: make log work even if first parameter doesn't exist
A slowpath optimization kicked in too often because of wrong indentation.
2013-01-15 01:05:12 +01:00
Pierre-Yves David
a1985448ad clfilter: enforce hidden changeset globally
The dispatch code now enables filtering of "hidden" changesets globally. The
filter is installed before command and extension invocation. The `--hidden`
switch is now global and disables this filtering for any command.

Code in log dedicated to changeset exclusion is removed as this global filtering
has the same effect.
2013-01-08 20:37:37 +01:00
Pierre-Yves David
ad252eff44 log: use "hidden" filtering instead of manual check at display time
When log is not given the --hidden option, hidden revision are not shown. We
move the implementation from manual checking at display time to changelog
filtering.

This is the first official usage of the hidden filtering.
2013-01-07 19:24:36 +01:00
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