changeset 19095:5cc71484ee9c stable

merge: increase safety of parallel updating/removing on icasefs "merge.applyupdates()" sorts "actions" in removal first order, and "workeractions" derived from it should be also sorted. If each actions in "workeractions" are executed in serial, this sorting ensures that merging/updating process is collision free, because updating the file in target context is always executed after removing the existing file which causes case-folding collision against the former. In the other hand, if each actions are executed in parallel, updating on a worker process may be executed before removing on another worker process, because "worker.partition()" partitions list of actions regardless of type of each actions. This patch divides "workeractions" into removing and updating, and executes the former first. This patch still scans "actions"/"workeractions" some times for ease of patch review, even though large list may cost much in this way. (total cost should be as same as before) This also changes some tests, because dividing "workeractions" affects progress indication.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 29 Apr 2013 15:58:15 +0900
parents fc1b77db123f
children 0e4af72cbd7f
files mercurial/merge.py tests/test-issue672.t tests/test-rename-dir-merge.t tests/test-rename-merge2.t tests/test-update-reverse.t
diffstat 5 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Tue Apr 30 13:53:49 2013 +0200
+++ b/mercurial/merge.py	Mon Apr 29 15:58:15 2013 +0900
@@ -455,8 +455,10 @@
 
     numupdates = len(actions)
     workeractions = [a for a in actions if a[1] in 'gr']
-    updated = len([a for a in workeractions if a[1] == 'g'])
-    removed = len([a for a in workeractions if a[1] == 'r'])
+    updateactions = [a for a in workeractions if a[1] == 'g']
+    updated = len(updateactions)
+    removeactions = [a for a in workeractions if a[1] == 'r']
+    removed = len(removeactions)
     actions = [a for a in actions if a[1] not in 'gr']
 
     hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate']
@@ -465,7 +467,13 @@
 
     z = 0
     prog = worker.worker(repo.ui, 0.001, getremove, (repo, mctx, overwrite),
-                         workeractions)
+                         removeactions)
+    for i, item in prog:
+        z += i
+        repo.ui.progress(_('updating'), z, item=item, total=numupdates,
+                         unit=_('files'))
+    prog = worker.worker(repo.ui, 0.001, getremove, (repo, mctx, overwrite),
+                         updateactions)
     for i, item in prog:
         z += i
         repo.ui.progress(_('updating'), z, item=item, total=numupdates,
--- a/tests/test-issue672.t	Tue Apr 30 13:53:49 2013 +0200
+++ b/tests/test-issue672.t	Mon Apr 29 15:58:15 2013 +0900
@@ -37,6 +37,7 @@
    1: other deleted -> r
    1a: remote created -> g
   removing 1
+  updating: 1 1/2 files (50.00%)
   getting 1a
   updating: 1a 2/2 files (100.00%)
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
--- a/tests/test-rename-dir-merge.t	Tue Apr 30 13:53:49 2013 +0200
+++ b/tests/test-rename-dir-merge.t	Mon Apr 29 15:58:15 2013 +0900
@@ -46,6 +46,7 @@
    b/b: remote created -> g
   removing a/a
   removing a/b
+  updating: a/b 2/5 files (40.00%)
   getting b/a
   getting b/b
   updating: b/b 4/5 files (80.00%)
--- a/tests/test-rename-merge2.t	Tue Apr 30 13:53:49 2013 +0200
+++ b/tests/test-rename-merge2.t	Mon Apr 29 15:58:15 2013 +0900
@@ -290,6 +290,7 @@
    rev: versions differ -> m
     preserving rev for resolve of rev
   removing a
+  updating: a 1/3 files (33.33%)
   getting b
   updating: b 2/3 files (66.67%)
   updating: rev 3/3 files (100.00%)
--- a/tests/test-update-reverse.t	Tue Apr 30 13:53:49 2013 +0200
+++ b/tests/test-update-reverse.t	Mon Apr 29 15:58:15 2013 +0900
@@ -73,6 +73,7 @@
    main: remote created -> g
   removing side1
   removing side2
+  updating: side2 2/3 files (66.67%)
   getting main
   updating: main 3/3 files (100.00%)
   1 files updated, 0 files merged, 2 files removed, 0 files unresolved