Commit Graph

129 Commits

Author SHA1 Message Date
Patrick Mezard
83a4a6c7b9 graphlog: turn getlogrevs() into a generator
This improves the poor "time to first changeset" compared to the
original log command. When running:

  $ hg log -u user

log will enumerate the changelog and display matching revisions when
they are found. But:

  $ hg log -G -u user

will first find all revisions matching the user then start to display
them.

Initially, I considered turning revset.match() into a generator. This is
doable but requires a fair amount of work. Instead,
cmdutil.increasingwindows() is reused to call the revset matcher
repeatedly. This has the nice properties of:
- Let us reorder the windows after filtering, which is necessary as the
  matcher can reorder inputs but is an internal detail not a feature.
- Let us feed the matcher with windows in changelog order, which is good
  for performances.
- Have a generator designed for log-like commands, returning small
  windows at first then batching larger ones.

I feel that calling the matcher multiple times is correct, at least with
the revsets involved in getlogrevs() because they are:
- stateless (no limit())
- respecting f(a|b) = f(a) | f(b), though I have no valid argument about
  that.

Known issues compared to log code:
- Calling the revset matcher multiple times can be slow when revset
  functions have to create expensive data structure for filtering. This
  will be addressed in a followup.
- Predicate combinations like "--user foo --user bar" or "--user foo and
  --branch bar" are inherently slower because all input revision are
  checked against the first condition, then against the second, and so
  forth. log would enumerate the input revisions once and check each of
  them once against all conditions, which is faster. There are solutions
  but nothing cheap to implement.

Some numbers against mozilla repository:

                             first line    total

  * hg log -u rnewman
  /Users/pmezard/bin/hg-2.2      0.148s   7.293s
  /Users/pmezard/bin/hgdev       0.132s   5.747s

  * hg log -u rnewman -u girard
  /Users/pmezard/bin/hg-2.2      0.146s   7.323s
  /Users/pmezard/bin/hgdev       0.136s  11.096s

  * hg log -l 10
  /Users/pmezard/bin/hg-2.2      0.137s   0.153s
  /Users/pmezard/bin/hgdev       0.128s   0.144s

  * hg log -l 10 -u rnewman
  /Users/pmezard/bin/hg-2.2      0.146s   0.265s
  /Users/pmezard/bin/hgdev       0.133s   0.236s

  * hg log -b GECKO193a2_20100228_RELBRANCH
  /Users/pmezard/bin/hg-2.2      2.332s   6.618s
  /Users/pmezard/bin/hgdev       1.972s   5.543s

  * hg log xulrunner
  /Users/pmezard/bin/hg-2.2      5.829s   5.958s
  /Users/pmezard/bin/hgdev       0.194s   6.017s

  * hg log --follow xulrunner/build.mk
  /Users/pmezard/bin/hg-2.2      0.353s   0.438s
  /Users/pmezard/bin/hgdev       0.394s   0.580s

  * hg log -u girard tools
  /Users/pmezard/bin/hg-2.2      5.853s   6.012s
  /Users/pmezard/bin/hgdev       0.195s   6.030s

  * hg log -b COMM2000_20110314_RELBRANCH --copies
  /Users/pmezard/bin/hg-2.2      2.231s   6.653s
  /Users/pmezard/bin/hgdev       1.897s   5.585s

  * hg log --follow
  /Users/pmezard/bin/hg-2.2      0.137s  14.140s
  /Users/pmezard/bin/hgdev       0.381s  44.246s

  * hg log --follow -r 80000:90000
  /Users/pmezard/bin/hg-2.2      0.127s   1.611s
  /Users/pmezard/bin/hgdev       0.147s   1.847s

  * hg log --follow -r 90000:80000
  /Users/pmezard/bin/hg-2.2      0.130s   1.702s
  /Users/pmezard/bin/hgdev       0.368s   6.106s

  * hg log --follow -r 80000:90000 js/src/jsproxy.cpp
  /Users/pmezard/bin/hg-2.2      0.343s   0.388s
  /Users/pmezard/bin/hgdev       0.437s   0.631s

  * hg log --follow -r 90000:80000 js/src/jsproxy.cpp
  /Users/pmezard/bin/hg-2.2      0.342s   0.389s
  /Users/pmezard/bin/hgdev       0.442s   0.628s
2012-05-08 22:43:44 +02:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Patrick Mezard
aa91736f8f graphlog: fix --follow FILE and relative paths
The situation is complicated because filelog() revset uses a match object in
relpath mode while follow() revset interprets the filename as a manifest entry.
2012-04-14 11:27:11 +02:00
Patrick Mezard
97d474a24b graphlog: reduce duplication in --follow code 2012-04-14 11:16:57 +02:00
Patrick Mezard
a0e9bb4632 graphlog: add all log options to glog command
glog and log -G should be equivalent.
2012-04-14 10:44:13 +02:00
Patrick Mezard
923d3cc5c3 graphlog: implement --hidden 2012-04-14 10:30:38 +02:00
Patrick Mezard
38b5c1448f graphlog: cleanup before code move
- Avoid revset module aliasing
- Mark makefilematcher() private
2012-04-11 11:37:13 +02:00
Patrick Mezard
00224d1ac6 graphlog: correctly handle calls in subdirectories 2012-04-11 11:32:00 +02:00
Patrick Mezard
a07861a2e3 graphlog: fix --follow-first --rev combinations
This solves a similar problem than the previous --follow/--rev patch. This time
we need changelog.ancestors()/descendants() filtering on first parent.
Duplicating the code looked better than introducing keyword arguments. Besides,
the ancestors() version was already implemented in follow() revset.
2012-04-11 11:25:34 +02:00
Patrick Mezard
50ca715022 graphlog: fix --follow --rev combinations
The previous behaviour of --follow was really a subset of what is really
happening in log command:
- If --rev is not passed, default to '.:0'
- Resolve --rev into a revision list "revs"
- Set the starting revision to revs[0]
- If revs[1] > revs[0] keep descendants(revs[0]) in revs, otherwise keep
  ancestors.
2012-04-11 11:22:40 +02:00
Patrick Mezard
d269778e3e graphlog: support changeset identifiers in --branch 2012-04-11 11:17:26 +02:00
Patrick Mezard
a87c281f59 graphlog: pass changesets to revset.match() in changelog order
Running:

  $ time hg debugrevspec 'user(mpm)' | wc

on Mercurial repository takes 1.0s with a regular version and 1.8s if
commands.debugrevspec() is patched to pass revisions to revset.match() from tip
to 0.

Depending on what we expect from the revset API and caller wisdom, we might
want to push this change in revset.match() later.
2012-04-11 11:14:07 +02:00
Patrick Mezard
d282c91c89 graphlog: refactor revset() to return revisions
When --follow and --rev are passed, --follow actual behaviour depends on the
input revision sequence defined by --rev. If --rev is not passed, the default
revision sequence depends on the presence of --follow. It means the revision
sequence generation is part of log logic and must be wrapped. The issue
described above is fixed in following patches.
2012-04-11 11:07:30 +02:00
Patrick Mezard
c3cb584665 graphlog: handle old-style --rev values
--rev options cannot be merged into a single revset because we do not know if
they are valid revset or old-style revision specifications, like 'foo-bar'
tags. Instead, a base revision set is generated with scmutil.revrange() then
filtered with the revset built from log options. It also fixes incorrect or
hostile expressions passed in --rev.
2012-03-29 22:42:03 +02:00
Patrick Mezard
4b4652fe4f graphlog: improve --only-branch handling
The previous code was correct for command line as opts always contains the
default empty lists for --branch and --only-branch options. But calling
graphlog.revset() directly with only --only-branch set would leave it
unprocessed.
2012-03-29 16:55:08 +02:00
Patrick Mezard
f3d3c12a18 graphlog: apply file filters --patch/--stat output
When passing --patch/--stat, file filters have to be applied to generate the
correct diff or stat output:
- Without --follow, the static match object can be reused
- With --follow, the files displayed at revision X are the ancestors of
  selected files at parent revision. To do this, we reproduce the ancestry
  calculations done by --follow, lazily.

test-glog.t changes show that --patch output is not satisfying because renames
are reported as copies. This can probably be fixed by:

- Without --follow: compute files to display, look for renames sources and
  extend the matcher to include them.
- With --follow: detect .path() transitions between parent/child filectx,
  filter them using the linked changectx .removed() field and extend fcache
  with them.
2012-02-26 17:12:15 +01:00
Patrick Mezard
24d8a81475 graphlog: fix --removed
"hg log --removed FILE" does not return changesets where FILE was removed, but
ones where FILE was changed and possibly removed. The flag is really here to
disable walkchangerevs() fast path, which cannot see file removals by scanning
filelogs.
2012-02-26 17:10:57 +01:00
Patrick Mezard
14c70f7752 graphlog: evaluate FILE/-I/-X filesets on the working dir
This subtlety is not documented yet but:
- pats/--include/--exclude filesets are evaluated against the working directory
- --rev filesets are reevaluated against every revisions
2012-02-26 17:10:51 +01:00
Patrick Mezard
51f38c7a7c graphlog: implement --copies 2012-02-26 16:56:32 +01:00
Patrick Mezard
38c46923b9 graphlog: implement --follow-first
log --graph --follow-first FILE cannot be compared with the regular version
because it never worked: --follow-first is not taken in account in
walkchangerevs() fast path and is explicitely bypassed in FILE case in
walkchangerevs() nested iterate() function.
2012-02-25 22:11:36 +01:00
Patrick Mezard
7207e784b2 graphlog: implement --follow with file arguments 2012-02-25 22:11:36 +01:00
Patrick Mezard
22a413e426 graphlog: restore FILE glob expansion on Windows
On platforms not supporting shell expansion, scmutil.match() performs glob
expansion on 'pats' arguments. But _matchfiles() revset calls match.match()
directly, bypassing this behaviour. To avoid duplicating scmutil.match(), a
secondary scmutil.matchandpats() is introduced returning both the match object
and the expanded inputs. Note the expanded pats are also needed in the fast
path, and will be used by --follow code path.
2012-02-25 22:11:34 +01:00
Patrick Mezard
4dca114aca graphlog: paths/-I/-X handling requires a new revset
The filtering logic of match objects cannot be reproduced with the existing
revsets as it operates at changeset files level. A changeset touching "a" and
"b" is matched by "-I a -X b" but not by "file(a) and not file(b)".

To solve this, a new internal "_matchfiles(...)" revset is introduced. It works
like "file(x)" but accepts more than one argument and its arguments are
prefixed with "p:", "i:" and "x:" to be used as patterns, include patterns or
exclude patterns respectively.

The _matchfiles revset is kept private for now:
- There are probably smarter ways to pass the arguments in a user-friendly way
- A "rev:" argument is likely appear at some point to emulate log command
  behaviour with regard to filesets: they are evaluated for the parent revision
  and applied everywhere instead of being reevaluated for each revision.
2012-02-23 18:05:20 +01:00
Patrick Mezard
1b972fd9a8 graphlog: imitate log slowpath when inputs are explicit files 2012-02-23 17:55:07 +01:00
Patrick Mezard
bda40c8a55 graphlog: paths arguments must be or'ed 2012-02-23 17:54:42 +01:00
Patrick Mezard
41e01db02e graphlog: rewrite --rev like all other options 2012-02-23 11:21:30 +01:00
Patrick Mezard
ef23be02e3 graphlog: --branch and --only-branch are the same
Handling the aliasing in fancyopts would be cleaner but I do not want to make
this change for stable.
2012-02-23 11:21:04 +01:00
Patrick Mezard
7fa94e616c graphlog: multiple --keyword must be or'ed 2012-02-22 12:30:15 +01:00
Patrick Mezard
5be7a248ec graphlog: multiple --branch must be or'ed 2012-02-22 12:30:15 +01:00
Patrick Mezard
89b24bd8b3 graphlog: multiple --user must be or'ed 2012-02-22 12:30:15 +01:00
Patrick Mezard
a2ea7bb50f graphlog: explicitely join multivalue parameters
This will let use override the "join" value (and/or) depending on the option
considered. The option revset arity is now deduced from the revset and the
option value type, to simplify opt2revset definition.
2012-02-22 12:30:15 +01:00
Matt Mackall
89e1387cb7 graphlog: attempt to fix index overrun (issue2912)
This bug may be caused by file subgraphs have more than two parents
per node. I have no idea if this fix is correct as the graphlog code
is mysterious, but it seems to be fine on the available test case.
2011-08-10 13:25:35 -05:00
Idan Kamara
3d12bdbaa8 graphlog: remove unused arg from _wrapcmd 2011-05-23 23:22:47 +03:00
Matt Mackall
cf07129983 scmutil: move revsingle/pair/range from cmdutil
This allows users at levels below the command layer to avoid import loops.
2011-05-13 14:06:28 -05:00
Adrian Buehlmann
25e3fc2c76 graphlog: use cmdutil.command decorator 2011-05-12 20:27:35 +02:00
timeless
ab34ee7694 remove unused imports 2011-05-01 15:21:57 +02:00
Patrick Mezard
ebc1f0434a graphlog: always sort revisions topologically
The grapher cannot really handled revisions if they are not emitted in
topological order. The previous 'reverse()' revset was not enough to achieve
that and was replaced by an explicit sort call for simplicity. The --limit
option is now also handled as usual with cmdutil.loglimit() instead of a
'limit' revset.
2011-05-01 15:51:52 +02:00
Patrick Mezard
399c49e7c9 graphlog: take the union of --rev specs instead of the intersection 2011-05-01 15:51:48 +02:00
Patrick Mezard
aaafe977fe graphlog: display nodes with more than 2 predecessors
While nodes with more than 2 parents do not exist in revision graphs, they do
appear when you transform them by removing subgraphs while trying to preserve
ancestry links.

This code was borrowed from Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
pbranch extension.
2011-05-01 15:51:20 +02:00
Patrick Mezard
57542c9154 graphlog: log -G --follow file does not work, forbid it
We do not have revsets to follow file history.
2011-04-30 19:42:00 +02:00
Patrick Mezard
f59a4cb18e graphlog: unify log -G revset translation 2011-04-30 19:42:00 +02:00
Patrick Mezard
305ae5565a graphlog: fix log -G --prune
follow() revset really means '::.' while we want something based on the passed
argument. Also, ancestors() revset does not include the parent revisions.
2011-04-30 19:42:00 +02:00
Patrick Mezard
3c82515646 graphlog: escape log -G single value option arguments 2011-04-30 19:42:00 +02:00
Patrick Mezard
eec16f919e graphlog: fix log -G --removed
Current version was mispelled and processed like a valued argument.
2011-04-30 19:42:00 +02:00
Patrick Mezard
caf334a147 graphlog: fix log -G option types when translating to revset
For instance, --keyword is a multiple value option while it was processed as a
single value option.
2011-04-30 19:42:00 +02:00
Alexander Solovyov
f4250e8e9c graphlog: make use of graphmod's revset support 2011-04-23 15:04:15 +02:00
Alexander Solovyov
517dbf068d graphmod: use revsets internally
Thanks for the idea and most of the implementation to Klaus Koch

Backs revisions() and filerevs() with DAG walker which can iterate through
arbitrary list of revisions instead of strict one by one iteration from start to
stop. When a gap occurs in a revisions (i.e. in file log), the next topological
parent within the revset is searched and the connection to it is printed in the
ascii graph.

File graph can draw sometimes more connections than previous version, because
graph is produced according to the revset, not according to a file's filelog.

In case the graph contains several branches where the left parent is null, the
graphs for each are printed sequentially, not in parallel as it was a case
earlier (see for example the graph for README in hg-dev).
2011-03-13 15:53:38 +01:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Markus F.X.J. Oberhumer
17565c031b graphlog: do not swallow all TypeError exceptions (fix fe7058294ec5) 2011-03-16 23:54:55 +01:00
Klaus Koch
b52874b751 graphlog: give meaningful error if more than one file is given 2011-03-13 15:04:13 +01:00