Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 19671:367e95bba6e8
commitablectx: move _manifest from workingctx
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Wed, 14 Aug 2013 15:34:18 -0500 |
parents | 6ac735fbea50 |
children | 375986c02539 |
comparison
equal
deleted
inserted
replaced
19670:6ac735fbea50 | 19671:367e95bba6e8 |
---|---|
899 | 899 |
900 @propertycache | 900 @propertycache |
901 def _flagfunc(self): | 901 def _flagfunc(self): |
902 return self._repo.dirstate.flagfunc(self._buildflagfunc) | 902 return self._repo.dirstate.flagfunc(self._buildflagfunc) |
903 | 903 |
904 @propertycache | |
905 def _manifest(self): | |
906 """generate a manifest corresponding to the working directory""" | |
907 | |
908 man = self._parents[0].manifest().copy() | |
909 if len(self._parents) > 1: | |
910 man2 = self.p2().manifest() | |
911 def getman(f): | |
912 if f in man: | |
913 return man | |
914 return man2 | |
915 else: | |
916 getman = lambda f: man | |
917 | |
918 copied = self._repo.dirstate.copies() | |
919 ff = self._flagfunc | |
920 modified, added, removed, deleted = self._status | |
921 for i, l in (("a", added), ("m", modified)): | |
922 for f in l: | |
923 orig = copied.get(f, f) | |
924 man[f] = getman(orig).get(orig, nullid) + i | |
925 try: | |
926 man.set(f, ff(f)) | |
927 except OSError: | |
928 pass | |
929 | |
930 for f in deleted + removed: | |
931 if f in man: | |
932 del man[f] | |
933 | |
934 return man | |
935 | |
904 class workingctx(commitablectx): | 936 class workingctx(commitablectx): |
905 """A workingctx object makes access to data related to | 937 """A workingctx object makes access to data related to |
906 the current working directory convenient. | 938 the current working directory convenient. |
907 date - any valid date string or (unixtime, offset), or None. | 939 date - any valid date string or (unixtime, offset), or None. |
908 user - username string, or None. | 940 user - username string, or None. |
911 or None to use the repository status. | 943 or None to use the repository status. |
912 """ | 944 """ |
913 def __init__(self, repo, text="", user=None, date=None, extra=None, | 945 def __init__(self, repo, text="", user=None, date=None, extra=None, |
914 changes=None): | 946 changes=None): |
915 super(workingctx, self).__init__(repo, text, user, date, extra, changes) | 947 super(workingctx, self).__init__(repo, text, user, date, extra, changes) |
916 | |
917 @propertycache | |
918 def _manifest(self): | |
919 """generate a manifest corresponding to the working directory""" | |
920 | |
921 man = self._parents[0].manifest().copy() | |
922 if len(self._parents) > 1: | |
923 man2 = self.p2().manifest() | |
924 def getman(f): | |
925 if f in man: | |
926 return man | |
927 return man2 | |
928 else: | |
929 getman = lambda f: man | |
930 | |
931 copied = self._repo.dirstate.copies() | |
932 ff = self._flagfunc | |
933 modified, added, removed, deleted = self._status | |
934 for i, l in (("a", added), ("m", modified)): | |
935 for f in l: | |
936 orig = copied.get(f, f) | |
937 man[f] = getman(orig).get(orig, nullid) + i | |
938 try: | |
939 man.set(f, ff(f)) | |
940 except OSError: | |
941 pass | |
942 | |
943 for f in deleted + removed: | |
944 if f in man: | |
945 del man[f] | |
946 | |
947 return man | |
948 | 948 |
949 def __iter__(self): | 949 def __iter__(self): |
950 d = self._repo.dirstate | 950 d = self._repo.dirstate |
951 for f in d: | 951 for f in d: |
952 if d[f] != 'r': | 952 if d[f] != 'r': |