Patchwork [1,of,7] merge: don't report progress for dr/rd actions

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 10, 2014, 9:08 p.m.
Message ID <53e54ae19ff275421e41.1418245739@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7046/
State Accepted
Commit a1a7c94def6d2db4e9c68c79491bb6d7feb333c9
Headers show

Comments

Martin von Zweigbergk - Dec. 10, 2014, 9:08 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1417824806 28800
#      Fri Dec 05 16:13:26 2014 -0800
# Node ID 53e54ae19ff275421e4103724a28ac2773e5f952
# Parent  3575f42e1b7b174f46f1c69951526d410452abf4
merge: don't report progress for dr/rd actions

It is easier to reason about certain algorithms in terms of a
file->action mapping than the current action->list-of-files. Bid merge
is already written this way (but with a list of actions per file), and
largefiles' overridecalculateupdates() will also benefit. However,
that requires us to have at most one action per file. That requirement
is currently violated by 'dr' (divergent rename) and 'rd' (rename and
delete) actions, which can exist for the same file as some other
action.

These actions are only used for displaying warnings to the user; they
don't change anything in the working copy or the dirstate. In this
way, they are similar to the 'k' (keep) action. However, they are even
less action-like than 'k' is: 'k' at least describes what to do with
the file ("do nothing"), while 'dr' and 'rd' or only annotations for
files for which there may exist other, "real" actions.

As a first step towards separating these acitons out, stop including
them in the progress output, just like we already exclude the 'k'
action.
Matt Mackall - Dec. 10, 2014, 11:17 p.m.
On Wed, 2014-12-10 at 13:08 -0800, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1417824806 28800
> #      Fri Dec 05 16:13:26 2014 -0800
> # Node ID 53e54ae19ff275421e4103724a28ac2773e5f952
> # Parent  3575f42e1b7b174f46f1c69951526d410452abf4
> merge: don't report progress for dr/rd actions

I've queued these for default, thanks.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -742,7 +742,8 @@ 
             audit(f)
             util.unlinkpath(repo.wjoin(f))
 
-    numupdates = sum(len(l) for m, l in actions.items() if m != 'k')
+    numupdates = sum(len(l) for m, l in actions.items()
+                     if m not in ('k', 'dr', 'rd'))
 
     if [a for a in actions['r'] if a[0] == '.hgsubstate']:
         subrepo.submerge(repo, wctx, mctx, wctx, overwrite)
@@ -825,9 +826,6 @@ 
 
     # divergent renames
     for f, args, msg in actions['dr']:
-        repo.ui.debug(" %s: %s -> dr\n" % (f, msg))
-        z += 1
-        progress(_updating, z, item=f, total=numupdates, unit=_files)
         fl, = args
         repo.ui.warn(_("note: possible conflict - %s was renamed "
                        "multiple times to:\n") % f)
@@ -836,9 +834,6 @@ 
 
     # rename and delete
     for f, args, msg in actions['rd']:
-        repo.ui.debug(" %s: %s -> rd\n" % (f, msg))
-        z += 1
-        progress(_updating, z, item=f, total=numupdates, unit=_files)
         fl, = args
         repo.ui.warn(_("note: possible conflict - %s was deleted "
                        "and renamed to:\n") % f)
diff --git a/tests/test-rename-merge1.t b/tests/test-rename-merge1.t
--- a/tests/test-rename-merge1.t
+++ b/tests/test-rename-merge1.t
@@ -40,15 +40,13 @@ 
   removing a
    b2: remote created -> g
   getting b2
-  updating: b2 1/3 files (33.33%)
+  updating: b2 1/2 files (50.00%)
    b: remote moved from a -> m
-  updating: b 2/3 files (66.67%)
+  updating: b 2/2 files (100.00%)
   picked tool 'internal:merge' for b (binary False symlink False)
   merging a and b to b
   my b@044f8520aeeb+ other b@85c198ef2f6c ancestor a@af1939970a1c
    premerge successful
-   a2: divergent renames -> dr
-  updating: a2 3/3 files (100.00%)
   note: possible conflict - a2 was renamed multiple times to:
    c2
    b2
@@ -183,9 +181,7 @@ 
    ancestor: 19d7f95df299, local: 0084274f6b67+, remote: 5d32493049f0
    newfile: remote created -> g
   getting newfile
-  updating: newfile 1/2 files (50.00%)
-   file: rename and delete -> rd
-  updating: file 2/2 files (100.00%)
+  updating: newfile 1/1 files (100.00%)
   note: possible conflict - file was deleted and renamed to:
    newfile
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/tests/test-rename-merge2.t b/tests/test-rename-merge2.t
--- a/tests/test-rename-merge2.t
+++ b/tests/test-rename-merge2.t
@@ -382,14 +382,12 @@ 
    preserving rev for resolve of rev
    c: remote created -> g
   getting c
-  updating: c 1/3 files (33.33%)
+  updating: c 1/2 files (50.00%)
    rev: versions differ -> m
-  updating: rev 2/3 files (66.67%)
+  updating: rev 2/2 files (100.00%)
   picked tool 'python ../merge' for rev (binary False symlink False)
   merging rev
   my rev@02963e448370+ other rev@fe905ef2c33e ancestor rev@924404dff337
-   a: divergent renames -> dr
-  updating: a 3/3 files (100.00%)
   note: possible conflict - a was renamed multiple times to:
    b
    c