Mercurial > python-hglib
changeset 33:d74a5891d9d1
client: add missing options to status
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Sun, 14 Aug 2011 00:49:56 +0300 |
parents | a2fc0a7f648e |
children | f6e1d9a6e0cd |
files | hglib/client.py tests/test-status.py |
diffstat | 2 files changed, 58 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Sun Aug 14 00:49:28 2011 +0300 +++ b/hglib/client.py Sun Aug 14 00:49:56 2011 +0300 @@ -516,9 +516,34 @@ def root(self): return self.rawcommand(['root']).rstrip() - def status(self): - out = self.rawcommand(['status', '-0']) + def status(self, rev=None, change=None, all=False, modified=False, added=False, + removed=False, deleted=False, clean=False, unknown=False, + ignored=False, copies=False, subrepos=False, include=None, + exclude=None): + """ + Return a dictionary with the following keys: + M = modified + A = added + R = removed + C = clean + ! = missing (deleted by non-hg command, but still tracked) + ? = 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') + + args = cmdbuilder('status', rev=rev, change=change, A=all, m=modified, + a=added, r=removed, d=deleted, c=clean, u=unknown, + i=ignored, C=copies, S=subrepos, I=include, X=exclude) + + args.append('-0') + + out = self.rawcommand(args) d = dict((c, []) for c in 'MARC!?I') for entry in out.split('\0'):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-status.py Sun Aug 14 00:49:56 2011 +0300 @@ -0,0 +1,31 @@ +import common, os + +class test_status(common.basetest): + def test_empty(self): + d = dict((c, []) for c in 'MARC!?I') + self.assertEquals(self.client.status(), d) + + def test_one_of_each(self): + self.append('.hgignore', 'ignored') + self.append('ignored', 'a') + self.append('clean', 'a') + self.append('modified', 'a') + self.append('removed', 'a') + self.append('missing', 'a') + rev0 = self.client.commit('first', addremove=True) + self.append('modified', 'a') + self.append('added', 'a') + self.client.add(['added']) + os.remove('missing') + self.client.remove(['removed']) + self.append('untracked') + + d = {'M' : ['modified'], + 'A' : ['added'], + 'R' : ['removed'], + 'C' : ['.hgignore', 'clean'], + '!' : ['missing'], + '?' : ['untracked'], + 'I' : ['ignored']} + + self.assertEquals(self.client.status(all=True), d)