changeset 44:2d6c7e0c1b2f

Added newline between successive items output
author Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>
date Sun, 25 Sep 2016 08:38:27 +0200
parents a1fb32ff4532
children 237dd8c4fe78
files mercurial_all_paths.py tests/basic.t tests/duplicates.t tests/facing_problems.t tests/groups-legacy.t
diffstat 4 files changed, 131 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial_all_paths.py	Sat Sep 24 23:31:49 2016 +0200
+++ b/mercurial_all_paths.py	Sun Sep 25 08:38:27 2016 +0200
@@ -13,7 +13,7 @@
 # pylint:disable=invalid-name,broad-except,line-too-long
 
 
-def _iter_over_paths(command, ui, repo, **opts):
+def _iter_over_paths(command, ui, repo, add_sep, **opts):
     """execute given command on multiple paths"""
     # Extract our options and filter them out
     group = opts.pop('group', None) or 'paths'
@@ -26,12 +26,17 @@
 
     # Used to avoid handling duplicate paths twice
     handled = {}
+    # Used to add extra newline between items
+    sep = ''
 
     # Act!
     for alias, path in paths:
         if path in handled:
-            ui.note(_("Skipping %s as path %s was already handled %s\n") % (alias, handled[path]))
+            ui.status(sep + _("Skipping %s as path %s was already handled %s\n") % (alias, handled[path]))
+            sep = '\n' if add_sep else ''
         else:
+            ui.status(sep)
+            sep = '\n' if add_sep else ''
             handled[path] = alias
             try:
                 command(ui, repo, path, **opts)
@@ -39,26 +44,26 @@
                 if not ignore_errors:
                     raise
                 ui.warn(_('error handling %s: %s\n') % (alias, e))
-
+                sep = '\n'
 
 def pushall(ui, repo, **opts):
     """execute push on multiple paths"""
-    _iter_over_paths(mercurial.commands.push, ui, repo, **opts)
+    _iter_over_paths(mercurial.commands.push, ui, repo, True, **opts)
 
 
 def pullall(ui, repo, **opts):
     """execute pull on multiple paths"""
-    _iter_over_paths(mercurial.commands.pull, ui, repo, **opts)
+    _iter_over_paths(mercurial.commands.pull, ui, repo, True, **opts)
 
 
 def incomingall(ui, repo, **opts):
     """execute incoming on multiple paths"""
-    _iter_over_paths(mercurial.commands.incoming, ui, repo, **opts)
+    _iter_over_paths(mercurial.commands.incoming, ui, repo, False, **opts)
 
 
 def outgoingall(ui, repo, **opts):
     """execute outgoing on multiple paths"""
-    _iter_over_paths(mercurial.commands.outgoing, ui, repo, **opts)
+    _iter_over_paths(mercurial.commands.outgoing, ui, repo, False, **opts)
 
 
 def _original_options(cmdname):
--- a/tests/basic.t	Sat Sep 24 23:31:49 2016 +0200
+++ b/tests/basic.t	Sun Sep 25 08:38:27 2016 +0200
@@ -48,19 +48,21 @@
   adding file.txt
   $ hg --cwd $BASE commit -m 'First'
 
-  $ hg --cwd $BASE pushal
+  $ hg --cwd $BASE pushall
   pushing to */rep1 (glob)
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
   pushing to */rep2 (glob)
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
   pushing to */rep3 (glob)
   searching for changes
   adding changesets
@@ -130,6 +132,7 @@
   adding file changes
   added 1 changesets with 1 changes to 1 files
   (run 'hg update' to get a working copy)
+  
   pulling from */rep2 (glob)
   searching for changes
   adding changesets
@@ -137,6 +140,7 @@
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
   (run 'hg heads' to see heads, 'hg merge' to merge)
+  
   pulling from */rep3 (glob)
   searching for changes
   no changes found
@@ -223,12 +227,14 @@
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 1 files (+1 heads)
+  
   pushing to */rep2 (glob)
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
   pushing to */rep3 (glob)
   searching for changes
   adding changesets
--- a/tests/facing_problems.t	Sat Sep 24 23:31:49 2016 +0200
+++ b/tests/facing_problems.t	Sun Sep 25 08:38:27 2016 +0200
@@ -64,6 +64,7 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
   pushing to */unrelated (glob)
   searching for changes
   abort: repository is unrelated
@@ -73,6 +74,44 @@
   0: First
 
   $ hg --cwd $GOOD2 log  -T '{rev}: {desc}\n'
+
+  $ hg --cwd $UNREL log  -T '{rev}: {desc}\n'
+  0: Unrelated
+
+and again, but in non-breaking mode
+
+  $ cat >> $BASE/file.txt << EOF
+  > More text
+  > EOF
+  $ hg --cwd $BASE commit -m 'Second'
+
+  $ hg --cwd $BASE pushall --ignore-errors
+  pushing to */good1 (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  
+  pushing to */unrelated (glob)
+  searching for changes
+  error handling unrel: repository is unrelated
+  
+  error handling missing: repository */missing does not exist (glob)
+  
+  pushing to */good2 (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+
+  $ hg --cwd $GOOD1 log -T '{rev}: {desc}\n'
+  1: Second
+  0: First
+
+  $ hg --cwd $GOOD2 log  -T '{rev}: {desc}\n'
+  1: Second
   0: First
 
   $ hg --cwd $UNREL log  -T '{rev}: {desc}\n'
@@ -90,7 +129,7 @@
   $ hg --cwd $GOOD1 commit -m "In repo1"
 
   $ hg --cwd $UNREL update
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat > $UNREL/unr.txt << EOF
   > Another text
   > EOF
@@ -108,22 +147,85 @@
   $ hg --cwd $GOOD2 commit -m "In good2"
 
   $ hg --cwd $BASE incomingall
-  comparing with */rep1 (glob)
+  comparing with */good1 (glob)
   searching for changes
-  changeset:   1:* (glob)
+  changeset:   2:* (glob)
+  tag:         tip
+  user:        Andy Default <default@nowhere.net>
+  date:        .* (re)
+  summary:     In repo1
+  
+  comparing with */unrelated (glob)
+  searching for changes
+  abort: repository is unrelated
+  [255]
+
+  $ hg --cwd $BASE incomingall --ignore-errors
+  comparing with */good1 (glob)
+  searching for changes
+  changeset:   2:* (glob)
   tag:         tip
   user:        Andy Default <default@nowhere.net>
   date:        .* (re)
   summary:     In repo1
   
-  comparing with */rep2 (glob)
+  comparing with */unrelated (glob)
   searching for changes
-  changeset:   1:* (glob)
+  error handling unrel: repository is unrelated
+  
+  error handling missing: repository */missing not found (glob)
+  
+  comparing with */good2 (glob)
+  searching for changes
+  changeset:   2:* (glob)
   tag:         tip
   user:        Andy Default <default@nowhere.net>
   date:        .* (re)
-  summary:     In repo2
+  summary:     In good2
+  
 
   $ hg --cwd $BASE pullall
+  pulling from */good1 (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  (run 'hg update' to get a working copy)
+  
+  pulling from */unrelated (glob)
+  searching for changes
+  abort: repository is unrelated
+  [255]
  
   $ hg --cwd $BASE log -T '{rev}: {desc}\n'
+  2: In repo1
+  1: Second
+  0: First
+
+  $ hg --cwd $BASE pullall --ignore-errors
+  pulling from */good1 (glob)
+  searching for changes
+  no changes found
+  
+  pulling from */unrelated (glob)
+  searching for changes
+  error handling unrel: repository is unrelated
+  
+  pulling from */missing (glob)
+  error handling missing: repository */missing not found (glob)
+  
+  pulling from */good2 (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 0 changes to 1 files (+1 heads)
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+ 
+  $ hg --cwd $BASE log -T '{rev}: {desc}\n'
+  3: In good2
+  2: In repo1
+  1: Second
+  0: First
+
--- a/tests/groups-legacy.t	Sat Sep 24 23:31:49 2016 +0200
+++ b/tests/groups-legacy.t	Sun Sep 25 08:38:27 2016 +0200
@@ -61,6 +61,7 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
   pushing to */rep3 (glob)
   searching for changes
   adding changesets
@@ -93,6 +94,7 @@
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 1 files
+  
   pushing to */rep4 (glob)
   searching for changes
   adding changesets
@@ -172,6 +174,7 @@
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
   (run 'hg heads' to see heads, 'hg merge' to merge)
+  
   pulling from */rep3 (glob)
   searching for changes
   no changes found
@@ -279,6 +282,7 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
+  
   pushing to */rep3 (glob)
   searching for changes
   adding changesets