Patchwork client: Be more permissive on the output of update (issue3892)

login
register
mail settings
Submitter Benoit Allard
Date April 23, 2013, 8:25 p.m.
Message ID <9324a89dd84e1562b875.1366748754@Ben-MBP.local>
Download mbox | patch
Permalink /patch/1474/
State Accepted, archived
Headers show

Comments

Benoit Allard - April 23, 2013, 8:25 p.m.
# HG changeset patch
# User Benoit Allard <benoit@aeteurope.nl>
# Date 1366747886 -7200
# Node ID 9324a89dd84e1562b87556a3b2788fdf04ba8179
# Parent  181d1a4115cf7f9ab23f4db2647d3974803aa6db
client: Be more permissive on the output of update (issue3892)

Some extensions can add lines to the output, we now ignore them
Matt Mackall - April 25, 2013, 3:05 p.m.
On Tue, 2013-04-23 at 22:25 +0200, Benoit Allard wrote:
> # HG changeset patch
> # User Benoit Allard <benoit@aeteurope.nl>
> # Date 1366747886 -7200
> # Node ID 9324a89dd84e1562b87556a3b2788fdf04ba8179
> # Parent  181d1a4115cf7f9ab23f4db2647d3974803aa6db
> client: Be more permissive on the output of update (issue3892)
> 
> Some extensions can add lines to the output, we now ignore them

Queued for hglib, thanks.

Patch

diff -r 181d1a4115cf -r 9324a89dd84e hglib/client.py
--- a/hglib/client.py	Tue Apr 02 01:11:47 2013 -0500
+++ b/hglib/client.py	Tue Apr 23 22:11:26 2013 +0200
@@ -1505,11 +1505,8 @@ 
 
         out = self.rawcommand(args, eh=eh)
 
-        # filter out 'merging ...' lines
-        out = util.skiplines(out, 'merging ')
-
-        counters = out.rstrip().split(', ')
-        return tuple(int(s.split(' ', 1)[0]) for s in counters)
+        m = re.search(r'^(\d+).+, (\d+).+, (\d+).+, (\d+)', out, re.MULTILINE)
+        return tuple(map(int,list(m.groups())))
 
     @property
     def version(self):
diff -r 181d1a4115cf -r 9324a89dd84e tests/test-update.py
--- a/tests/test-update.py	Tue Apr 02 01:11:47 2013 -0500
+++ b/tests/test-update.py	Tue Apr 23 22:11:26 2013 +0200
@@ -70,3 +70,19 @@ 
     def test_basic_plain(self):
         open('.hg/hgrc', 'a').write('[defaults]\nupdate=-v\n')
         self.test_basic()
+
+    def test_largefiles(self):
+        import os
+        open('.hg/hgrc', 'a').write('[extensions]\nlargefiles=\n')
+        self.append('b', 'a')
+        self.client.rawcommand(['add', 'b', '--large'])
+        rev2, node2 = self.client.commit('third')
+        # Go back to 0
+        self.client.rawcommand(['update', str(self.rev0)],
+                                # Keep the 'changed' version
+                               prompt=lambda s, d: 'c\n')
+        u, m, r, ur = self.client.update(rev2, clean=True)
+        self.assertEquals(u, 2)
+        self.assertEquals(m, 0)
+        self.assertEquals(r, 0)
+        self.assertEquals(ur, 0)