# HG changeset patch # User Idan Kamara # Date 1313272275 -10800 # Node ID f6e1d9a6e0cd91e85046bd3384cd4dce737a524c # Parent d74a5891d9d1e33aa22e8ef3dcdd7e62c2d1a5f1 client: change return value of status() to a list of (code, file path) diff -r d74a5891d9d1 -r f6e1d9a6e0cd hglib/client.py --- a/hglib/client.py Sun Aug 14 00:49:56 2011 +0300 +++ b/hglib/client.py Sun Aug 14 00:51:15 2011 +0300 @@ -521,7 +521,7 @@ ignored=False, copies=False, subrepos=False, include=None, exclude=None): """ - Return a dictionary with the following keys: + Return a list of (code, file path) where code can be: M = modified A = added @@ -531,8 +531,6 @@ ? = untracked I = ignored = origin of the previous file listed as A (added) - - And a list of files to match as values. """ if rev and change: raise ValueError('cannot specify both rev and change') @@ -544,14 +542,13 @@ args.append('-0') out = self.rawcommand(args) - d = dict((c, []) for c in 'MARC!?I') + l = [] for entry in out.split('\0'): if entry: - t, f = entry.split(' ', 1) - d[t].append(f) + l.append(tuple(entry.rsplit(' ', 1))) - return d + return l def tip(self): args = cmdbuilder('tip', template=templates.changeset) diff -r d74a5891d9d1 -r f6e1d9a6e0cd tests/test-copy.py --- a/tests/test-copy.py Sun Aug 14 00:49:56 2011 +0300 +++ b/tests/test-copy.py Sun Aug 14 00:51:15 2011 +0300 @@ -7,10 +7,10 @@ self.client.commit('first', addremove=True) self.assertTrue(self.client.copy('a', 'b')) - self.assertEquals(self.client.status()['A'], ['b']) + self.assertEquals(self.client.status(), [('A', 'b')]) self.append('c', 'a') self.assertTrue(self.client.copy('a', 'c', after=True)) - self.assertEquals(self.client.status()['A'], ['b', 'c']) + self.assertEquals(self.client.status(), [('A', 'b'), ('A', 'c')]) # hg returns 0 even if there were warnings #def test_warnings(self): diff -r d74a5891d9d1 -r f6e1d9a6e0cd tests/test-status.py --- a/tests/test-status.py Sun Aug 14 00:49:56 2011 +0300 +++ b/tests/test-status.py Sun Aug 14 00:51:15 2011 +0300 @@ -2,8 +2,7 @@ class test_status(common.basetest): def test_empty(self): - d = dict((c, []) for c in 'MARC!?I') - self.assertEquals(self.client.status(), d) + self.assertEquals(self.client.status(), []) def test_one_of_each(self): self.append('.hgignore', 'ignored') @@ -12,7 +11,7 @@ self.append('modified', 'a') self.append('removed', 'a') self.append('missing', 'a') - rev0 = self.client.commit('first', addremove=True) + self.client.commit('first', addremove=True) self.append('modified', 'a') self.append('added', 'a') self.client.add(['added']) @@ -20,12 +19,23 @@ self.client.remove(['removed']) self.append('untracked') - d = {'M' : ['modified'], - 'A' : ['added'], - 'R' : ['removed'], - 'C' : ['.hgignore', 'clean'], - '!' : ['missing'], - '?' : ['untracked'], - 'I' : ['ignored']} + l = [('M', 'modified'), + ('A', 'added'), + ('R', 'removed'), + ('C', '.hgignore'), + ('C', 'clean'), + ('!', 'missing'), + ('?', 'untracked'), + ('I', 'ignored')] - self.assertEquals(self.client.status(all=True), d) + st = self.client.status(all=True) + + for i in l: + self.assertTrue(i in st) + + def test_copy(self): + self.append('source', 'a') + self.client.commit('first', addremove=True) + self.client.copy('source', 'dest') + l = [('A', 'dest'), (' ', 'source')] + self.assertEquals(self.client.status(copies=True), l) diff -r d74a5891d9d1 -r f6e1d9a6e0cd tests/test-update.py --- a/tests/test-update.py Sun Aug 14 00:49:56 2011 +0300 +++ b/tests/test-update.py Sun Aug 14 00:51:15 2011 +0300 @@ -24,7 +24,7 @@ self.assertEquals(m, 0) self.assertEquals(r, 0) self.assertEquals(ur, 1) - self.assertEquals(self.client.status()['M'][0], 'a') + self.assertTrue(('M', 'a') in self.client.status()) def test_merge(self): self.append('a', '\n\n\n\nb') @@ -39,7 +39,7 @@ self.assertEquals(m, 1) self.assertEquals(r, 0) self.assertEquals(ur, 0) - self.assertEquals(self.client.status()['M'][0], 'a') + self.assertEquals(self.client.status(), [('M', 'a')]) def test_tip(self): self.client.update(self.rev0)