Commit Graph

41 Commits

Author SHA1 Message Date
Martin von Zweigbergk
c3406ac3db cleanup: use set literals
We no longer support Python 2.6, so we can now use set literals.
2017-02-10 16:56:29 -08:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
timeless
86b7c93478 convert: filemap use absolute_import 2016-03-02 09:00:58 +00:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Durham Goode
447360b0c9 convert: implements targetfilebelongstosource for filemap source
This is an implementation of the new targetfilebelongstosource() function for
the filemapper. It simply checks if the given file name is prefixed by any of
the rename destinations.

It is not a perfect implementation since it doesn't account for the filemap
specifying includes or excludes, but that makes the problem much harder, and
this implementation should suffice for most cases.
2015-08-15 13:46:30 -07:00
Durham Goode
e31e5da384 convert: add config option for disabling ancestor parent checks
When converting merge commits, convert checks if any of the parents are
ancestors of any of the other parents. To do this, it builds an ancestor list
for every commit in the repository. On large repos this can take a long time
(30min+). Let's add an option for disabling this check to preserve performance.

The downside of this is that it may create unnecessary parent connections when
enabled (which is unfortunate, but not incorrect).

To verify, I ran the convert tests with the flag enabled, and verified the graph
changes were all just to add new parents that were ancestors of existing
parents.
2015-06-29 13:44:24 -07:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Mads Kiilerich
c8659cbb76 convert: optimize convert of files that are unmodified from p2 in merges
Conversion of a merge starts with p1 and re-adds the files that were changed in
the merge or came unmodified from p2. Files that are unmodified from p1 will
thus not be touched and take no time. Files that are unmodified from p2 would be
retrieved and rehashed. They would end up getting the same hash as in p2 and end
up reusing the filelog entry and look like the p1 case ... but it was slow.

Instead, make getchanges also return 'files that are unmodified from p2' so the
sink can reuse the existing p2 entry instead of calling getfile.

Reuse of filelog entries can make a big difference when files are big and with
long revlong chains so they take time to retrieve and hash, or when using an
expensive custom getfile function (think
http://mercurial.selenic.com/wiki/ConvertExtension#Customization with a code
reformatter).

This in combination with changes to reuse filectx entries in
localrepo._filecommit make 'unchanged from p2' almost as fast as 'unchanged
from p1'.

This is so far only implemented for the combination of hg source and hg sink.

This is a refactoring/optimization. It is covered by existing tests and show no
changes - which is a good thing.
2015-03-19 17:40:19 +01:00
Mads Kiilerich
0df22182cc convert: introduce --full for converting all files
Convert will normally only process files that were changed in a source
revision, apply the filemap, and record it has a change in the target
repository. (If it ends up not really changing anything, nothing changes.)

That means that _if_ the filemap is changed before continuing an incremental
convert, the change will only kick in when the files it affects are modified in
a source revision and thus processed.

With --full, convert will make a full conversion every time and process
all files in the source repo and remove target repo files that shouldn't be
there. Filemap changes will thus kick in on the first converted revision, no
matter what is changed.

This flag should in most cases not make any difference but will make convert
significantly slower.

Other names has been considered for this feature, such as "resync", "sync",
"checkunmodified", "all" or "allfiles", but I found that they were less obvious
and required more explanation than "full" and were harder to describe
consistently.
2014-08-26 22:03:32 +02:00
Mads Kiilerich
b0ab086db9 convert: readability and test of rpairs function 2013-11-17 11:18:39 -05:00
Mads Kiilerich
749d4329a5 convert: update source shamap when using filemap, just as when not using filemap
The reverse mapping was introduced in 51f9f23e6ccc to make roundtrip
conversions possible ... but it did not work when using filemap.

Roundtrips with filemaps will of course only work flawlessly if inverse
mappings are used.

Especially, if a lossy convert mapping is used in one direction, then only
linear lines of development can be converted in the other direction. With this
constraint convert will do the right thing by assuming that excluded files
haven't been changed.)

A test case with general coverage of hg-hg roundtrips with filemap is added.

(There a cases where adding records of converted revisions to the shamap in the
source repository doesn't work - especially when converting the same repo to
several other repos and back. It would arguably be better if convert only
updated the shamaps in the target repo but read shamaps from both the source
and and target repo ... but that is a different story. Making the stuff we have
work consistently is step forward no matter what.)
2013-10-03 18:01:21 +02:00
Mads Kiilerich
15460985a6 convert: fix crash when existing converted revision didn't come from source
This case can happen when converting from multiple repositories with filemap.
2013-10-02 19:46:48 +02:00
Mads Kiilerich
329d4ea1f9 convert: fix crash when filemap filtering is changed 2013-10-02 19:46:47 +02:00
Huayang
2cbf7a996c convert: normalize paths in filemaps (issue3612)
convert doesn't normalise double slashes in paths. Path normalization
is applied when a path is loaded into filemap and when a file lookup
request is issued to filemap.
2012-10-05 16:27:34 -07:00
Patrick Mezard
97e1660f02 convert: remove unused newnames variable in filemap 2012-07-16 15:50:19 +02:00
Matt Mackall
c0bdd10df1 merge with stable 2012-07-15 14:48:50 -05:00
Wagner Bruna
243b1101bd convert: make filemap renames consistently override revision renames
When the source repository had a revision renaming "$new -> $old",
but the filemap a "$old -> $new" rename, the converted revision could
use either $new (deleting the file) or $old (keeping the file) when
getting the file data, depending on the lexicographical order of
those names. So the resulting revision would leave some files
untouched (as expected), but delete others arbitrarely.
2012-07-06 01:14:02 -03:00
Patrick Mezard
e029e6740d convert: keep branch switching merges with ancestors (issue3340)
When running convert with a filemap, merge parents which are ancestors
of other parents are ignored. This is hardly a problem when parents
belong to the same branch, but the result could be confusing when named
branches are involved. With:

  -o-a1-a2-a3...     <- A
    \           \
     b1-b2-b3...-m-  <- B

If all b* revisions are discarded, it is useful to preserve 'm' even if
it is empty after filtering to record the branch switch.

This patch makes filemap preserve "ancestor parents" if there is no
"non-ancestor parent" on the same branch than the merge revision.

Remarks:
- I am not completely convinced by the reasons given above and those
  detailed by Matt in this thread:

http://selenic.com/pipermail/mercurial-devel/2012-May/040627.html

  The properties we try to preserve are not clearly defined. That said,
  I know this patch already helped someone on IRC and the tests output
  look reasonable.

- This is a new version of the original "convert: filemap must preserve
  fast-forward merges" patch. It has exactly the same output for 2
  parents merges, the additional complexity is here to handle more than
  two parents.
2012-06-18 18:19:28 +02:00
Matt Mackall
8fc7c196b4 convert: handle trailing slashes in filemap better (issue3124) 2011-11-23 16:25:44 -06:00
etienne
296f5d2a79 convert: added bookmarks support in filemap
When using the convert extension from a Mercurial rep. to subset it with
filemap, the bookmarks are not copied. I fixed this by calling the
base.get_bookmarks() from the filemap getbookmarks() instead of returning an
empty dictionary. It should work also for other converters that implement
getbookmarks() (like git). I don't see any drawbacks except that the bookmarks
are always copied (not necessarily wanted all the times).
2011-09-15 15:03:54 -04:00
Patrick Mezard
95e7147cd4 convert: make filemap prune useless branch closing revs (issue2774)
A branch closing revision only applies if one of its parents belongs to the
branch being closed. Otherwise the filemap can prune it too.
2011-04-20 23:15:18 +02:00
Mads Kiilerich
2f033d321d convert: warn on superfluous / in paths
shlex is really a bad parser for this line-based format ...
2010-07-20 15:49:28 +02:00
Matt Mackall
3c358f36d4 convert: handle closed branch heads in hg-hg conversion (issue2185) 2010-07-25 17:18:35 -05:00
Patrick Mezard
20f6d4cdf1 convert: merge sources getmode() into getfile() 2010-05-09 21:52:34 +02:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Patrick Mezard
a848b6f227 convert: rewrite tags when converting from hg to hg 2009-06-01 17:12:42 +02:00
Patrick Mezard
e8585b2da9 convert: fail fast if source does not support --sourcesort 2009-06-01 17:12:39 +02:00
Stefan Simek
2b62386017 convert: make filemap favor most specific filtering rule
A filemap like:

exclude "doc"
include "doc/foo.txt"

will now preserve doc/foo.txt and exclude everything else in doc/.
2009-11-10 13:04:03 +01:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Martin Geisler
1deb417a82 util: use built-in set and frozenset
This drops Python 2.3 compatibility.
2009-04-22 00:55:32 +02:00
Peter Arrenbrecht
19591b6a8c cleanup: drop unused assignments 2009-03-23 13:13:06 +01:00
Patrick Mezard
980dbe2c9e Merge with crew-stable 2008-01-04 23:43:49 +01:00
Patrick Mezard
8fdc85530f convert: filemap must call base converter before()/after() actions 2008-01-04 23:23:47 +01:00
Maxim Dounin
bd23432b17 convert: allow repo root to be matched in filemap
For consistency with "rename subdir ." syntax in filemap, also support
"rename . subdir".
2007-12-25 21:14:11 -08:00
Bryan O'Sullivan
314630c85c convert: some tidyups, doc improvements, and test fixes
The various back end options are now documented.
The hg source can now be configured not to hand out a revision ID.
2007-11-27 09:44:09 -08:00
Bryan O'Sullivan
857e67d5db convert: abstract map files into a class 2007-11-07 17:06:02 -08:00
Alexis S. L. Carvalho
856d368557 convert --filemap: reduce memory usage 2007-10-06 15:30:15 -03:00
Alexis S. L. Carvalho
8978438d64 convert: readd --filemap
To handle merges correctly, this revision adds a filemap_source class
that wraps a converter_source and does the work necessary to calculate
the subgraph we're interested in.

The wrapped converter_source must provide a new getchangedfiles method
that, given a revision rev, and an index N, returns the list of files
that are different in rev and its Nth parent.

The implementation depends on the ability to skip some revisions and to
change the parents field of the commit objects that we returned earlier.

To make the conversion restartable, we assume the revisons in the
revmapfile are topologically sorted.
2007-10-04 23:21:37 -03:00
Alexis S. L. Carvalho
ab0d9013c0 convert: move filemapper class to a separate file 2007-10-04 23:21:37 -03:00