comparison mercurial/context.py @ 19673:53a3a8d38301

commitablectx: move status from workingctx
author Sean Farley <sean.michael.farley@gmail.com>
date Wed, 14 Aug 2013 15:55:56 -0500
parents 375986c02539
children ec5b2e2b947f
comparison
equal deleted inserted replaced
19672:375986c02539 19673:53a3a8d38301
935 935
936 @propertycache 936 @propertycache
937 def _status(self): 937 def _status(self):
938 return self._repo.status()[:4] 938 return self._repo.status()[:4]
939 939
940 class workingctx(commitablectx):
941 """A workingctx object makes access to data related to
942 the current working directory convenient.
943 date - any valid date string or (unixtime, offset), or None.
944 user - username string, or None.
945 extra - a dictionary of extra values, or None.
946 changes - a list of file lists as returned by localrepo.status()
947 or None to use the repository status.
948 """
949 def __init__(self, repo, text="", user=None, date=None, extra=None,
950 changes=None):
951 super(workingctx, self).__init__(repo, text, user, date, extra, changes)
952
953 def __iter__(self):
954 d = self._repo.dirstate
955 for f in d:
956 if d[f] != 'r':
957 yield f
958
959 @propertycache
960 def _user(self):
961 return self._repo.ui.username()
962
963 @propertycache
964 def _date(self):
965 return util.makedate()
966
967 @propertycache
968 def _parents(self):
969 p = self._repo.dirstate.parents()
970 if p[1] == nullid:
971 p = p[:-1]
972 return [changectx(self._repo, x) for x in p]
973
974 def status(self, ignored=False, clean=False, unknown=False): 940 def status(self, ignored=False, clean=False, unknown=False):
975 """Explicit status query 941 """Explicit status query
976 Unless this method is used to query the working copy status, the 942 Unless this method is used to query the working copy status, the
977 _status property will implicitly read the status using its default 943 _status property will implicitly read the status using its default
978 arguments.""" 944 arguments."""
984 self._ignored = stat[5] 950 self._ignored = stat[5]
985 if clean: 951 if clean:
986 self._clean = stat[6] 952 self._clean = stat[6]
987 self._status = stat[:4] 953 self._status = stat[:4]
988 return stat 954 return stat
955
956 class workingctx(commitablectx):
957 """A workingctx object makes access to data related to
958 the current working directory convenient.
959 date - any valid date string or (unixtime, offset), or None.
960 user - username string, or None.
961 extra - a dictionary of extra values, or None.
962 changes - a list of file lists as returned by localrepo.status()
963 or None to use the repository status.
964 """
965 def __init__(self, repo, text="", user=None, date=None, extra=None,
966 changes=None):
967 super(workingctx, self).__init__(repo, text, user, date, extra, changes)
968
969 def __iter__(self):
970 d = self._repo.dirstate
971 for f in d:
972 if d[f] != 'r':
973 yield f
974
975 @propertycache
976 def _user(self):
977 return self._repo.ui.username()
978
979 @propertycache
980 def _date(self):
981 return util.makedate()
982
983 @propertycache
984 def _parents(self):
985 p = self._repo.dirstate.parents()
986 if p[1] == nullid:
987 p = p[:-1]
988 return [changectx(self._repo, x) for x in p]
989 989
990 def user(self): 990 def user(self):
991 return self._user or self._repo.ui.username() 991 return self._user or self._repo.ui.username()
992 def date(self): 992 def date(self):
993 return self._date 993 return self._date