Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | e359af6517ce |
children | bc3f3b59d0a4 0d055849d5f9 |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
314 | 314 |
315 def nullsub(self, path, pctx): | 315 def nullsub(self, path, pctx): |
316 return subrepo.nullsubrepo(self, path, pctx) | 316 return subrepo.nullsubrepo(self, path, pctx) |
317 | 317 |
318 def workingsub(self, path): | 318 def workingsub(self, path): |
319 '''return a subrepo for the stored revision, or wdir if this is a wdir | 319 """return a subrepo for the stored revision, or wdir if this is a wdir |
320 context. | 320 context. |
321 ''' | 321 """ |
322 return subrepo.subrepo(self, path, allowwdir=True) | 322 return subrepo.subrepo(self, path, allowwdir=True) |
323 | 323 |
324 def match( | 324 def match( |
325 self, | 325 self, |
326 pats=None, | 326 pats=None, |
1052 # one it replaces) we could. Such a buggy situation will likely | 1052 # one it replaces) we could. Such a buggy situation will likely |
1053 # result is crash somewhere else at to some point. | 1053 # result is crash somewhere else at to some point. |
1054 return lkr | 1054 return lkr |
1055 | 1055 |
1056 def isintroducedafter(self, changelogrev): | 1056 def isintroducedafter(self, changelogrev): |
1057 """True if a filectx has been introduced after a given floor revision | 1057 """True if a filectx has been introduced after a given floor revision""" |
1058 """ | |
1059 if self.linkrev() >= changelogrev: | 1058 if self.linkrev() >= changelogrev: |
1060 return True | 1059 return True |
1061 introrev = self._introrev(stoprev=changelogrev) | 1060 introrev = self._introrev(stoprev=changelogrev) |
1062 if introrev is None: | 1061 if introrev is None: |
1063 return False | 1062 return False |
1230 return self._repo.wwritedata(self.path(), self.data()) | 1229 return self._repo.wwritedata(self.path(), self.data()) |
1231 | 1230 |
1232 | 1231 |
1233 class filectx(basefilectx): | 1232 class filectx(basefilectx): |
1234 """A filecontext object makes access to data related to a particular | 1233 """A filecontext object makes access to data related to a particular |
1235 filerevision convenient.""" | 1234 filerevision convenient.""" |
1236 | 1235 |
1237 def __init__( | 1236 def __init__( |
1238 self, | 1237 self, |
1239 repo, | 1238 repo, |
1240 path, | 1239 path, |
1242 fileid=None, | 1241 fileid=None, |
1243 filelog=None, | 1242 filelog=None, |
1244 changectx=None, | 1243 changectx=None, |
1245 ): | 1244 ): |
1246 """changeid must be a revision number, if specified. | 1245 """changeid must be a revision number, if specified. |
1247 fileid can be a file revision or node.""" | 1246 fileid can be a file revision or node.""" |
1248 self._repo = repo | 1247 self._repo = repo |
1249 self._path = path | 1248 self._path = path |
1250 | 1249 |
1251 assert ( | 1250 assert ( |
1252 changeid is not None or fileid is not None or changectx is not None | 1251 changeid is not None or fileid is not None or changectx is not None |
1253 ), ( | 1252 ), b"bad args: changeid=%r, fileid=%r, changectx=%r" % ( |
1254 b"bad args: changeid=%r, fileid=%r, changectx=%r" | 1253 changeid, |
1255 % (changeid, fileid, changectx,) | 1254 fileid, |
1255 changectx, | |
1256 ) | 1256 ) |
1257 | 1257 |
1258 if filelog is not None: | 1258 if filelog is not None: |
1259 self._filelog = filelog | 1259 self._filelog = filelog |
1260 | 1260 |
1287 # complicated to solve. Proper handling of the issue here should be | 1287 # complicated to solve. Proper handling of the issue here should be |
1288 # considered when solving linkrev issue are on the table. | 1288 # considered when solving linkrev issue are on the table. |
1289 return self._repo.unfiltered()[self._changeid] | 1289 return self._repo.unfiltered()[self._changeid] |
1290 | 1290 |
1291 def filectx(self, fileid, changeid=None): | 1291 def filectx(self, fileid, changeid=None): |
1292 '''opens an arbitrary revision of the file without | 1292 """opens an arbitrary revision of the file without |
1293 opening a new filelog''' | 1293 opening a new filelog""" |
1294 return filectx( | 1294 return filectx( |
1295 self._repo, | 1295 self._repo, |
1296 self._path, | 1296 self._path, |
1297 fileid=fileid, | 1297 fileid=fileid, |
1298 filelog=self._filelog, | 1298 filelog=self._filelog, |
2099 return [] | 2099 return [] |
2100 | 2100 |
2101 | 2101 |
2102 class workingfilectx(committablefilectx): | 2102 class workingfilectx(committablefilectx): |
2103 """A workingfilectx object makes access to data related to a particular | 2103 """A workingfilectx object makes access to data related to a particular |
2104 file in the working directory convenient.""" | 2104 file in the working directory convenient.""" |
2105 | 2105 |
2106 def __init__(self, repo, path, filelog=None, workingctx=None): | 2106 def __init__(self, repo, path, filelog=None, workingctx=None): |
2107 super(workingfilectx, self).__init__(repo, path, filelog, workingctx) | 2107 super(workingfilectx, self).__init__(repo, path, filelog, workingctx) |
2108 | 2108 |
2109 @propertycache | 2109 @propertycache |
2700 clean, | 2700 clean, |
2701 ) | 2701 ) |
2702 | 2702 |
2703 @propertycache | 2703 @propertycache |
2704 def _changedset(self): | 2704 def _changedset(self): |
2705 """Return the set of files changed in this context | 2705 """Return the set of files changed in this context""" |
2706 """ | |
2707 changed = set(self._status.modified) | 2706 changed = set(self._status.modified) |
2708 changed.update(self._status.added) | 2707 changed.update(self._status.added) |
2709 changed.update(self._status.removed) | 2708 changed.update(self._status.removed) |
2710 return changed | 2709 return changed |
2711 | 2710 |
2875 | 2874 |
2876 return man | 2875 return man |
2877 | 2876 |
2878 @propertycache | 2877 @propertycache |
2879 def _status(self): | 2878 def _status(self): |
2880 """Calculate exact status from ``files`` specified at construction | 2879 """Calculate exact status from ``files`` specified at construction""" |
2881 """ | |
2882 man1 = self.p1().manifest() | 2880 man1 = self.p1().manifest() |
2883 p2 = self._parents[1] | 2881 p2 = self._parents[1] |
2884 # "1 < len(self._parents)" can't be used for checking | 2882 # "1 < len(self._parents)" can't be used for checking |
2885 # existence of the 2nd parent, because "memctx._parents" is | 2883 # existence of the 2nd parent, because "memctx._parents" is |
2886 # explicitly initialized by the list, of which length is 2. | 2884 # explicitly initialized by the list, of which length is 2. |