D6274: copies: document cases in _chain()

2019-05-01 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd1c2688eda80: copies: document cases in _chain() (authored 
by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6274?vs=14969=14981

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -108,26 +108,46 @@
 return min(limit, a, b)
 
 def _chain(src, dst, a, b):
-"""chain two sets of copies a->b"""
+"""chain two sets of copies 'a' and 'b'"""
+
+# When chaining copies in 'a' (from 'src' via some other commit 'mid') with
+# copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
+# following table (not including trivial cases). For example, case 2 is
+# where a file existed in 'src' and remained under that name in 'mid' and
+# then was renamed between 'mid' and 'dst'.
+#
+# case src mid dst result
+#   1   x   y   --
+#   2   x   y   y   x->y
+#   3   x   y   x-
+#   4   x   y   z   x->z
+#   5   -   x   y-
+#   6   x   x   y   x->y
+
+# Initialize result ('t') from 'a'. This catches cases 1 & 2. We'll remove
+# case 1 later. We'll also catch cases 3 & 4 here. Case 4 will be
+# overwritten later, and case 3 will be removed later.
 t = a.copy()
 for k, v in b.iteritems():
 if v in t:
-# found a chain
+# found a chain, i.e. cases 3 & 4.
 if t[v] != k:
-# file wasn't renamed back to itself
+# file wasn't renamed back to itself (i.e. case 4, not 3)
 t[k] = t[v]
 if v not in dst:
 # chain was a rename, not a copy
+# this deletes the copy for 'y' in case 4
 del t[v]
 if v in src:
-# file is a copy of an existing file
+# file is a copy of an existing file, i.e. case 6.
 t[k] = v
 
 for k, v in list(t.items()):
-# remove criss-crossed copies
+# remove criss-crossed copies, i.e. case 3
 if k in src and v in dst:
 del t[k]
-# remove copies to files that were then removed
+# remove copies to files that were then removed, i.e. case 1
+# and file 'y' in cases 3 & 4 (in case of rename)
 elif k not in dst:
 del t[k]
 



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6274: copies: document cases in _chain()

2019-04-29 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 14969.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6274?vs=14948=14969

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -108,26 +108,46 @@
 return min(limit, a, b)
 
 def _chain(src, dst, a, b):
-"""chain two sets of copies a->b"""
+"""chain two sets of copies 'a' and 'b'"""
+
+# When chaining copies in 'a' (from 'src' via some other commit 'mid') with
+# copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
+# following table (not including trivial cases). For example, case 2 is
+# where a file existed in 'src' and remained under that name in 'mid' and
+# then was renamed between 'mid' and 'dst'.
+#
+# case src mid dst result
+#   1   x   y   --
+#   2   x   y   y   x->y
+#   3   x   y   x-
+#   4   x   y   z   x->z
+#   5   -   x   y-
+#   6   x   x   y   x->y
+
+# Initialize result ('t') from 'a'. This catches cases 1 & 2. We'll remove
+# case 1 later. We'll also catch cases 3 & 4 here. Case 4 will be
+# overwritten later, and case 3 will be removed later.
 t = a.copy()
 for k, v in b.iteritems():
 if v in t:
-# found a chain
+# found a chain, i.e. cases 3 & 4.
 if t[v] != k:
-# file wasn't renamed back to itself
+# file wasn't renamed back to itself (i.e. case 4, not 3)
 t[k] = t[v]
 if v not in dst:
 # chain was a rename, not a copy
+# this deletes the copy for 'y' in case 4
 del t[v]
 if v in src:
-# file is a copy of an existing file
+# file is a copy of an existing file, i.e. case 6.
 t[k] = v
 
 for k, v in list(t.items()):
-# remove criss-crossed copies
+# remove criss-crossed copies, i.e. case 3
 if k in src and v in dst:
 del t[k]
-# remove copies to files that were then removed
+# remove copies to files that were then removed, i.e. case 1
+# and file 'y' in cases 3 & 4 (in case of rename)
 elif k not in dst:
 del t[k]
 



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6274: copies: document cases in _chain()

2019-04-28 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 14948.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6274?vs=14846=14948

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -108,26 +108,46 @@
 return min(limit, a, b)
 
 def _chain(src, dst, a, b):
-"""chain two sets of copies a->b"""
+"""chain two sets of copies 'a' and 'b'"""
+
+# When chaining copies in 'a' (from 'src' via some other commit 'mid') with
+# copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
+# following table (not including trivial cases). For example, case 2 is
+# where a file existed in 'src' and remained under that name in 'mid' and
+# then was renamed between 'mid' and 'dst'.
+#
+# case src mid dst result
+#   1   x   y   --
+#   2   x   y   y   x->y
+#   3   x   y   x-
+#   4   x   y   z   x->z
+#   5   -   x   y-
+#   6   x   x   y   x->y
+
+# Initialize result ('t') from 'a'. This catches cases 1 & 2. We'll remove
+# case 1 later. We'll also catch cases 3 & 4 here. Case 4 will be
+# overwritten later, and case 3 will be removed later.
 t = a.copy()
 for k, v in b.iteritems():
 if v in t:
-# found a chain
+# found a chain, i.e. cases 3 & 4.
 if t[v] != k:
-# file wasn't renamed back to itself
+# file wasn't renamed back to itself (i.e. case 4, not 3)
 t[k] = t[v]
 if v not in dst:
 # chain was a rename, not a copy
+# this deletes the copy for 'y' in case 4
 del t[v]
 if v in src:
-# file is a copy of an existing file
+# file is a copy of an existing file, i.e. case 6.
 t[k] = v
 
 for k, v in list(t.items()):
-# remove criss-crossed copies
+# remove criss-crossed copies, i.e. case 3
 if k in src and v in dst:
 del t[k]
-# remove copies to files that were then removed
+# remove copies to files that were then removed, i.e. case 1
+# and file 'y' in cases 3 & 4 (in case of rename)
 elif k not in dst:
 del t[k]
 



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6274: copies: document cases in _chain()

2019-04-24 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  I think the rest of the stack from this patch are independent of the ones 
before, so if reviewers are intimidated by 
https://phab.mercurial-scm.org/D6255, they should still be able to take this 
section of the stack.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6274: copies: document cases in _chain()

2019-04-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 14846.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6274?vs=14843=14846

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -108,26 +108,46 @@
 return min(limit, a, b)
 
 def _chain(src, dst, a, b):
-"""chain two sets of copies a->b"""
+"""chain two sets of copies 'a' and 'b'"""
+
+# When chaining copies in 'a' (from 'src' via some other commit 'mid') with
+# copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
+# following table (not including trivial cases). For example, case 2 is
+# where a file existed in 'src' and remained under that name in 'mid' and
+# then was renamed between 'mid' and 'dst'.
+#
+# case src mid dst result
+#   1   x   y   --
+#   2   x   y   y   x->y
+#   3   x   y   x-
+#   4   x   y   z   x->z
+#   5   -   x   y-
+#   6   x   x   y   x->y
+
+# Initialize result ('t') from 'a'. This catches cases 1 & 2. We'll remove
+# case 1 later. We'll also catch cases 3 & 4 here. Case 4 will be
+# overwritten later, and case 3 will be removed later.
 t = a.copy()
 for k, v in b.iteritems():
 if v in t:
-# found a chain
+# found a chain, i.e. cases 3 & 4.
 if t[v] != k:
-# file wasn't renamed back to itself
+# file wasn't renamed back to itself (i.e. case 4, not 3)
 t[k] = t[v]
 if v not in dst:
 # chain was a rename, not a copy
+# this deletes the copy for 'y' in case 4
 del t[v]
 if v in src:
-# file is a copy of an existing file
+# file is a copy of an existing file, i.e. case 6.
 t[k] = v
 
 for k, v in list(t.items()):
-# remove criss-crossed copies
+# remove criss-crossed copies, i.e. case 3
 if k in src and v in dst:
 del t[k]
-# remove copies to files that were then removed
+# remove copies to files that were then removed, i.e. case 1
+# and file 'y' in cases 3 & 4 (in case of rename)
 elif k not in dst:
 del t[k]
 



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6274: copies: document cases in _chain()

2019-04-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> copies.py:120-125
> +#   1   a   b   --
> +#   2   a   b   b   a->b
> +#   3   a   b   a-
> +#   4   a   b   c   a->c
> +#   5   -   a   b-
> +#   6   a   a   b   a->b

I just realized that using `a`, `b`, `c` as filenames is confusing since `a` 
and `b` are also the names of the copy dicts. I'll rename the files to `x`, 
`y`, `z`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6274: copies: document cases in _chain()

2019-04-18 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6274

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -108,26 +108,46 @@
 return min(limit, a, b)
 
 def _chain(src, dst, a, b):
-"""chain two sets of copies a->b"""
+"""chain two sets of copies 'a' and 'b'"""
+
+# When chaining copies in 'a' (from 'src' via some other commit 'mid') with
+# copies in 'b' (from 'mid' to 'dst'), we can get the different cases in 
the
+# following table (not including trivial cases). For example, case 2 is
+# where a file existed in 'src' and remained under that name in 'mid' and
+# then was renamed between 'mid' and 'dst'.
+#
+# case src mid dst result
+#   1   a   b   --
+#   2   a   b   b   a->b
+#   3   a   b   a-
+#   4   a   b   c   a->c
+#   5   -   a   b-
+#   6   a   a   b   a->b
+
+# Initialize result ('t') from 'a'. This catches cases 1 & 2. We'll remove
+# case 1 later. We'll also catch cases 3 & 4 here. Case 4 will be
+# overwritten later, and case 3 will be removed later.
 t = a.copy()
 for k, v in b.iteritems():
 if v in t:
-# found a chain
+# found a chain, i.e. cases 3 & 4.
 if t[v] != k:
-# file wasn't renamed back to itself
+# file wasn't renamed back to itself (i.e. case 4, not 3)
 t[k] = t[v]
 if v not in dst:
 # chain was a rename, not a copy
+# this deletes the copy for 'b' in case 4
 del t[v]
 if v in src:
-# file is a copy of an existing file
+# file is a copy of an existing file, i.e. case 6.
 t[k] = v
 
 for k, v in list(t.items()):
-# remove criss-crossed copies
+# remove criss-crossed copies, i.e. case 3
 if k in src and v in dst:
 del t[k]
-# remove copies to files that were then removed
+# remove copies to files that were then removed, i.e. case 1
+# and file 'b' in cases 3 & 4 (in case of rename)
 elif k not in dst:
 del t[k]
 



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel