Commit Graph

62 Commits

Author SHA1 Message Date
Mads Kiilerich
3ee1a27c56 diff: search beyond ancestor when detecting renames
This removes an optimization that was introduced in 5a644704d5eb but was too
aggressive - as indicated by how it changed test-mq-merge.t .

We are walking filelogs to find copy sources and we can thus not be sure to hit
the base revision and find the renamed file there - it could also be in the
first ancestor of the base ... in the filelog.

We are walking the filelog and can thus not easily know when we hit the first
ancestor of the base revision and which filename to look for there. Instead, we
use _findlimit like mergecopies do: The lower bound for how far we have to go
is found from the lowest changelog revision that is an ancestor of only one of
the compared revisions. Any filelog ancestor with a revision number lower than
that revision will be the ancestor of both compared revisions, and there is
thus no reason to go further back than that.
2013-11-16 15:46:29 -05:00
Durham Goode
8921ef9d64 copies: refactor checkcopies() into a top level method
This moves checkcopies() out of mergecopies() and makes it a top level
function in the copies module. This allows extensions to override it. For
example, I'm developing a filelog replacement that doesn't have rev numbers
so all the rev number dependent implementation here needs to be replaced
by the extension.

No logic is changed in this commit.
2013-05-01 10:44:21 -07:00
Bryan O'Sullivan
4a4a5dde94 scmutil: use new dirs class in dirstate and context
The multiset-of-directories code was open coded in each of these
modules; this change gets rid of the duplication.
2013-04-10 15:08:26 -07:00
Siddharth Agarwal
563db40b8c copies._forwardcopies: use set operations to find missing files
This is a performance win for a number of reasons:
- We don't iterate over contexts, which avoids a completely unnecessary sorted
  call + the O(number of files) abstraction cost of doing that.
- We don't check membership in a context, which avoids another
  O(number of files) abstraction cost.
- We iterate over the manifests in C instead of Python.

For a large repo with 170,000 files, this improves perfpathcopies from 0.34
seconds to 0.07. Anything that uses pathcopies, such as rebase or diff --git
between two revisions, benefits.
2013-04-04 20:22:29 -07:00
Mads Kiilerich
2e43383c70 copies: report found copies sorted 2012-12-12 02:38:14 +01:00
Mads Kiilerich
ff0cc1a7f9 copies: make the loss in _backwardcopies more stable
A couple of tests shows slightly more correct output. That is pure coincidence.
2013-01-15 02:59:12 +01:00
Siddharth Agarwal
28f04a41d2 copies: do not track backward copies, only renames (issue3739)
The inverse of a rename is a rename, but the inverse of a copy is not a copy.
Presenting it as such -- in particular, stuffing it into the same dict as real
copies -- causes bugs because other code starts believing the inverse copies
are real.

The only test whose output changes is test-mv-cp-st-diff.t. When a backwards
status -C command is run where a copy is involved, the inverse copy (which was
hitherto presented as a real copy) is no longer displayed.

Keeping track of inverse copies is useful in some situations -- composability
of diffs, for example, since adding "a" followed by an inverse copy "b" to "a"
is equivalent to a rename "b" to "a". However, representing them would require
a more complex data structure than the same dict in which real copies are also
stored.
2012-12-26 15:04:07 -08:00
Siddharth Agarwal
76d4a91eed copies: make debug messages more sensible
The -> in debug messages is currently overloaded to mean both source to dest
and dest to source. To fix this, we add explicit labels and make the arrow
direction consistent.
2012-12-26 15:03:58 -08:00
Siddharth Agarwal
8e266eb31f copies: separate moves via directory renames from explicit copies
Currently the "copy" dict contains both explicit copies/moves made by a
context and pending moves that need to happen because the other context moved
the directory the file was in. For explicit copies, the dict stores a
destination to source map, while for pending moves via directory renames, it
stores a source to destination map. The merge code uses this fact in a non-
obvious way to differentiate between these two cases.

We make this explicit by storing these pending moves in a separate dict. The
dict still has a source to destination map, but that is called out in the
docstring.
2012-12-26 14:50:17 -08:00
Matt Mackall
cbbdbdd866 copies: re-include root directory in directory rename detection (issue3511) 2012-06-27 13:41:04 -05:00
Thomas Arendsen Hein
6c60809dcc merge: show renamed on one and deleted on the other side in debug output 2012-05-23 21:34:29 +02:00
Thomas Arendsen Hein
91a8201c52 merge: warn about file deleted in one branch and renamed in other (issue3074)
For divergent renames the following message is printed during merge:
note: possible conflict - file was renamed multiple times to:
 newfile
 file2

When a file is renamed in one branch and deleted in the other, the file still
exists after a merge. With this change a similar message is printed for mv+rm:

note: possible conflict - file was deleted and renamed to:
 newfile
2012-05-23 20:50:16 +02:00
Thomas Arendsen Hein
4735ff24c9 merge: do not warn about copy and rename in the same transaction (issue2113) 2012-05-23 17:25:48 +02:00
Matt Mackall
598d070281 copies: use ctx.dirs() for directory rename detection 2012-02-26 16:45:59 -06:00
Matt Mackall
a5ae14e360 copies: fix mergecopies doc mapping direction 2012-02-26 15:51:56 -06:00
Matt Mackall
26807610cb copies: remove checkdirs options
This removes the undocumented merge.followdirs option, which has
always been true.
2012-02-25 14:22:58 -06:00
Matt Mackall
aaf40ea1d9 copies: add docstring for mergecopies 2012-02-24 18:21:06 -06:00
Matt Mackall
11ed3204e8 copies: remove stray print 2012-01-25 17:14:10 -06:00
Matt Mackall
4b04e60eef copies: eliminate criss-crosses when chaining
Before the copies refactoring, we declared that if a and b were
present in source and destination, we ignored copies between them. The
refactored code could however report b was a copy of a and vice versa
in a situation where we looked for differences between two identical
changesets that copy a to b.

  y
 /
x
 \
  y'
2012-01-24 17:16:29 -06:00
Matt Mackall
48738cad22 copies: rewrite copy detection for non-merge users
The existing copy detection API was designed with merge in mind and
was ill-suited for doing status/diff. The new pathcopies
implementation gives more accurate, easier to use results for
comparing two revisions, and is much simpler to understand.

Test notes:

- test-mv-cp-st.t results finds more renames in the reverse direction now
- test-mq-merge.t was always wrong and duplicated a copy in diff that
  was already present in one of the parent revisions
2012-01-04 17:55:30 -06:00
Matt Mackall
9bfa890ee6 copies: split the copies api for "normal" and merge cases (API) 2012-01-04 15:48:02 -06:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Dan Villiom Podlaski Christiansen
cff327a7f7 copies: don't detect copies as "divergent renames"
(For the purposes of this patch copy is defined as a rename where the
source continues to exist.)
2010-10-10 09:48:37 -05:00
Henrik Stuart
0efc07dca7 copies: properly visit file context ancestors on working file contexts 2010-04-07 21:31:47 +02:00
Brodie Rao
892ba5a830 remove unused imports 2010-02-14 01:52:31 -05:00
Benoit Boissinot
2efacc29bb copies: check if revisions are related (bug found with pylint) 2010-02-02 09:05:20 +01:00
Matt Mackall
3c6c4749ee Merge with stable 2010-01-31 13:43:33 -06:00
Matt Mackall
06bae668d4 copies: revert 1f784cae6615
The behavior of rebase both before and after the fix was actually
incorrect, and this change regressed other parts of copy behavior.
2010-01-31 12:19:52 -06:00
Matt Mackall
1f628d9563 copies: fix issue1994
Unscramble divergence test
2010-01-28 22:45:46 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Matt Mackall
525da95fd6 copies: speed up copy detection
On some large repos, copy detection could spend > 10min using
fctx.ancestor() to determine if file revisions were actually related.
Because ancestor must traverse history to the root to determine the
GCA, it was doing a lot more work than necessary. With this
replacement, same status -r a:b takes ~3 seconds.
2010-01-19 22:20:05 -06:00
Patrick Mezard
62d346efa4 copies: don't report copies with unrelated branch 2010-01-01 13:58:30 +01:00
Matt Mackall
417080c789 Merge with stable 2010-01-28 23:13:10 -06:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Martin Geisler
9f1896c083 do not attempt to translate ui.debug output 2009-09-19 01:15:38 +02:00
Matt Mackall
eb6cba34d7 Merge with stable 2009-07-09 19:49:02 -05:00
Matt Mackall
e3dc8aa6db fix memory usage of revlog caches by limiting cache size [issue1639] 2009-07-09 17:10:07 -05:00
Alejandro Santos
b1c42d384b compat: can't compare two values of unequal datatypes 2009-07-05 11:01:01 +02:00
Martin Geisler
0a365d5ca2 use 'x is None' instead of 'x == None'
The built-in None object is a singleton and it is therefore safe to
compare memory addresses with is. It is also faster, how much depends
on the object being compared. For a simple type like str I get:

            | s = "foo" | s = None
  ----------+-----------+----------
  s == None | 0.25 usec | 0.21 usec
  s is None | 0.17 usec | 0.17 usec
2009-05-20 00:52:46 +02:00
Benoit Boissinot
b23ce9123e copies: use set instead of dict 2009-05-17 04:20:59 +02:00
Martin Geisler
110a176288 copies: don't translate untranslatable string 2009-05-09 14:56:06 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
2f9b02c62d replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
2009-04-26 16:50:44 -05:00
Martin Geisler
e2222d3c43 replace set-like dictionaries with real sets
Many of the dictionaries created by dict.fromkeys were emulating sets.
These can now be replaced with real sets.
2009-04-22 00:57:28 +02:00
Peter Arrenbrecht
bc21361ed2 cleanup: drop unused imports 2009-03-23 13:12:07 +01:00
Dirkjan Ochtman
574603a8c0 use dict.iteritems() rather than dict.items()
This should be faster and more future-proof. Calls where the result is to be
sorted using util.sort() have been left unchanged. Calls to .items() on
configparser objects have been left as-is, too.
2009-01-12 09:16:03 +01:00
Matt Mackall
a65ef7bc5d util: add sort helper 2008-06-27 18:28:45 -05:00
Matt Mackall
bc715be859 add __len__ and __iter__ methods to repo and revlog 2008-06-26 14:35:50 -05:00