Mercurial > hg
annotate mercurial/context.py @ 45739:693da1b928af
backout: leverage cmdutil.check_incompatible_arguments()
Differential Revision: https://phab.mercurial-scm.org/D9216
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 15 Oct 2020 21:44:03 -0700 |
parents | 19590b126764 |
children | e359af6517ce |
rev | line source |
---|---|
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # context.py - changeset and file context objects for mercurial |
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4417
diff
changeset
|
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com> |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
8 from __future__ import absolute_import |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
9 |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
10 import errno |
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
11 import filecmp |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
12 import os |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
13 import stat |
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
14 |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
15 from .i18n import _ |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
16 from .node import ( |
30361
1070df141718
dirstate: change added/modified placeholder hash length to 20 bytes
Durham Goode <durham@fb.com>
parents:
30360
diff
changeset
|
17 addednodeid, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
18 hex, |
30361
1070df141718
dirstate: change added/modified placeholder hash length to 20 bytes
Durham Goode <durham@fb.com>
parents:
30360
diff
changeset
|
19 modifiednodeid, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
20 nullid, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
21 nullrev, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
22 short, |
37448
d7114f883505
node: rename wdirnodes to clarify they are for manifest/filelogs
Yuya Nishihara <yuya@tcha.org>
parents:
37447
diff
changeset
|
23 wdirfilenodeids, |
41967
21cc92fea2aa
context: use wdirhex constant instead of calculating it
Martin von Zweigbergk <martinvonz@google.com>
parents:
41949
diff
changeset
|
24 wdirhex, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
25 ) |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
26 from .pycompat import ( |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
27 getattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
28 open, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
29 ) |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
30 from . import ( |
36917
7affcabf561e
dagop: move annotateline and _annotatepair from context.py
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
31 dagop, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
32 encoding, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
33 error, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
34 fileset, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
35 match as matchmod, |
44857
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
36 mergestate as mergestatemod, |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44934
diff
changeset
|
37 metadata, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
38 obsolete as obsmod, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
39 patch, |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
40 pathutil, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
41 phases, |
31343
ff2f90503d64
context: work around `long` not existing on Python 3
Augie Fackler <augie@google.com>
parents:
31309
diff
changeset
|
42 pycompat, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
43 repoview, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
44 scmutil, |
33353
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
45 sparse, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
46 subrepo, |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35890
diff
changeset
|
47 subrepoutil, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
48 util, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
49 ) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
50 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
51 dateutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
52 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
53 ) |
3122
da85145d4571
filectx: add rename traversal for parents()
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
54 |
8207
dd8d5be57d65
util: take propertycache from context.py
Matt Mackall <mpm@selenic.com>
parents:
8157
diff
changeset
|
55 propertycache = util.propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
56 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
57 |
19537
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
58 class basectx(object): |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
59 """A basectx object represents the common logic for its children: |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
60 changectx: read-only context that is already present in the repo, |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
61 workingctx: a context that represents the working directory and can |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
62 be committed, |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
63 memctx: a context that represents changes in-memory and can also |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
64 be committed.""" |
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
65 |
37175
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
66 def __init__(self, repo): |
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
67 self._repo = repo |
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
68 |
31344
c99371e38e5e
context: implement both __bytes__ and __str__ for Python 3
Augie Fackler <augie@google.com>
parents:
31343
diff
changeset
|
69 def __bytes__(self): |
19540
7b864da00e21
basectx: move __str__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19539
diff
changeset
|
70 return short(self.node()) |
7b864da00e21
basectx: move __str__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19539
diff
changeset
|
71 |
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
72 __str__ = encoding.strmethod(__bytes__) |
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
73 |
19546
a45cf68dd9a2
basectx: move __repr__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19545
diff
changeset
|
74 def __repr__(self): |
43503
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43346
diff
changeset
|
75 return "<%s %s>" % (type(self).__name__, str(self)) |
19546
a45cf68dd9a2
basectx: move __repr__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19545
diff
changeset
|
76 |
19547
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
77 def __eq__(self, other): |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
78 try: |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
79 return type(self) == type(other) and self._rev == other._rev |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
80 except AttributeError: |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
81 return False |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
82 |
19548
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
83 def __ne__(self, other): |
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
84 return not (self == other) |
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
85 |
19550
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
86 def __contains__(self, key): |
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
87 return key in self._manifest |
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
88 |
19551
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
89 def __getitem__(self, key): |
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
90 return self.filectx(key) |
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
91 |
19552
6b76070c4b54
basectx: move __iter__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19551
diff
changeset
|
92 def __iter__(self): |
24227
8ec2df32bd39
context: don't sort manifest entries
Augie Fackler <augie@google.com>
parents:
24213
diff
changeset
|
93 return iter(self._manifest) |
19552
6b76070c4b54
basectx: move __iter__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19551
diff
changeset
|
94 |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
95 def _buildstatusmanifest(self, status): |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
96 """Builds a manifest that includes the given status results, if this is |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
97 a working copy context. For non-working copy contexts, it just returns |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
98 the normal manifest.""" |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
99 return self.manifest() |
21880
e6754f5e4cf7
context: generate filtered manifest efficiently for exact matchers
Siddharth Agarwal <sid0@fb.com>
parents:
21845
diff
changeset
|
100 |
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
101 def _matchstatus(self, other, match): |
33936
c714e82b9ac2
context: always pass a matcher into _matchstatus() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33901
diff
changeset
|
102 """This internal method provides a way for child objects to override the |
21481
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
103 match operator. |
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
104 """ |
33936
c714e82b9ac2
context: always pass a matcher into _matchstatus() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33901
diff
changeset
|
105 return match |
21481
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
106 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
107 def _buildstatus( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
108 self, other, s, match, listignored, listclean, listunknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
109 ): |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
110 """build a status with respect to another context""" |
23257
37c57a7cf160
context.status: explain "caching reasons" more fully
Martin von Zweigbergk <martinvonz@google.com>
parents:
23242
diff
changeset
|
111 # Load earliest manifest first for caching reasons. More specifically, |
37c57a7cf160
context.status: explain "caching reasons" more fully
Martin von Zweigbergk <martinvonz@google.com>
parents:
23242
diff
changeset
|
112 # if you have revisions 1000 and 1001, 1001 is probably stored as a |
37c57a7cf160
context.status: explain "caching reasons" more fully
Martin von Zweigbergk <martinvonz@google.com>
parents:
23242
diff
changeset
|
113 # delta against 1000. Thus, if you read 1000 first, we'll reconstruct |
37c57a7cf160
context.status: explain "caching reasons" more fully
Martin von Zweigbergk <martinvonz@google.com>
parents:
23242
diff
changeset
|
114 # 1000 and cache it so that when you read 1001, we just need to apply a |
37c57a7cf160
context.status: explain "caching reasons" more fully
Martin von Zweigbergk <martinvonz@google.com>
parents:
23242
diff
changeset
|
115 # delta to what's in the cache. So that's one full reconstruction + one |
37c57a7cf160
context.status: explain "caching reasons" more fully
Martin von Zweigbergk <martinvonz@google.com>
parents:
23242
diff
changeset
|
116 # delta application. |
31260
aac054e5389b
context: remove assumptions about manifest creation during _buildstatus
Durham Goode <durham@fb.com>
parents:
31259
diff
changeset
|
117 mf2 = None |
23238
39eb9f78f968
context.status: move manifest caching trick to _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23237
diff
changeset
|
118 if self.rev() is not None and self.rev() < other.rev(): |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
119 mf2 = self._buildstatusmanifest(s) |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
120 mf1 = other._buildstatusmanifest(s) |
31260
aac054e5389b
context: remove assumptions about manifest creation during _buildstatus
Durham Goode <durham@fb.com>
parents:
31259
diff
changeset
|
121 if mf2 is None: |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
122 mf2 = self._buildstatusmanifest(s) |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
123 |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
124 modified, added = [], [] |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
125 removed = [] |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
126 clean = [] |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
127 deleted, unknown, ignored = s.deleted, s.unknown, s.ignored |
23085
e9165c18f8df
status: make 'hg status --rev' faster when there are deleted files
Martin von Zweigbergk <martinvonz@google.com>
parents:
23080
diff
changeset
|
128 deletedset = set(deleted) |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
129 d = mf1.diff(mf2, match=match, clean=listclean) |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
130 for fn, value in pycompat.iteritems(d): |
23731
ccbaa2ed11a4
status: don't list files as both clean and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23730
diff
changeset
|
131 if fn in deletedset: |
ccbaa2ed11a4
status: don't list files as both clean and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23730
diff
changeset
|
132 continue |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
133 if value is None: |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
134 clean.append(fn) |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
135 continue |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
136 (node1, flag1), (node2, flag2) = value |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
137 if node1 is None: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
138 added.append(fn) |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
139 elif node2 is None: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
140 removed.append(fn) |
27749
215b47449e47
context: check for differing flags a little earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
27748
diff
changeset
|
141 elif flag1 != flag2: |
215b47449e47
context: check for differing flags a little earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
27748
diff
changeset
|
142 modified.append(fn) |
37448
d7114f883505
node: rename wdirnodes to clarify they are for manifest/filelogs
Yuya Nishihara <yuya@tcha.org>
parents:
37447
diff
changeset
|
143 elif node2 not in wdirfilenodeids: |
27748
81b391a45264
context: clarify why we don't compare file contents when nodeid differs
Martin von Zweigbergk <martinvonz@google.com>
parents:
27747
diff
changeset
|
144 # When comparing files between two commits, we save time by |
81b391a45264
context: clarify why we don't compare file contents when nodeid differs
Martin von Zweigbergk <martinvonz@google.com>
parents:
27747
diff
changeset
|
145 # not comparing the file contents when the nodeids differ. |
81b391a45264
context: clarify why we don't compare file contents when nodeid differs
Martin von Zweigbergk <martinvonz@google.com>
parents:
27747
diff
changeset
|
146 # Note that this means we incorrectly report a reverted change |
81b391a45264
context: clarify why we don't compare file contents when nodeid differs
Martin von Zweigbergk <martinvonz@google.com>
parents:
27747
diff
changeset
|
147 # to a file as a modification. |
27747
54522bbe1597
status: back out changeset 89f49813526c
Martin von Zweigbergk <martinvonz@google.com>
parents:
27720
diff
changeset
|
148 modified.append(fn) |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
149 elif self[fn].cmp(other[fn]): |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
150 modified.append(fn) |
23731
ccbaa2ed11a4
status: don't list files as both clean and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23730
diff
changeset
|
151 else: |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
152 clean.append(fn) |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
153 |
21971
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
154 if removed: |
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
155 # need to filter files if they are already reported as removed |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
156 unknown = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
157 fn |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
158 for fn in unknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
159 if fn not in mf1 and (not match or match(fn)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
160 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
161 ignored = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
162 fn |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
163 for fn in ignored |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
164 if fn not in mf1 and (not match or match(fn)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
165 ] |
23730
4b56219a5ac2
status: don't list files as both removed and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23712
diff
changeset
|
166 # if they're deleted, don't report them as removed |
4b56219a5ac2
status: don't list files as both removed and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23712
diff
changeset
|
167 removed = [fn for fn in removed if fn not in deletedset] |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
168 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
169 return scmutil.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
170 modified, added, removed, deleted, unknown, ignored, clean |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
171 ) |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
172 |
19549
78155484ae34
basectx: move substate from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19548
diff
changeset
|
173 @propertycache |
78155484ae34
basectx: move substate from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19548
diff
changeset
|
174 def substate(self): |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35890
diff
changeset
|
175 return subrepoutil.state(self, self._repo.ui) |
19549
78155484ae34
basectx: move substate from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19548
diff
changeset
|
176 |
21586
8a2637cf1130
basectx: add subrev method to return the rev of a subrepo given a subpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21482
diff
changeset
|
177 def subrev(self, subpath): |
8a2637cf1130
basectx: add subrev method to return the rev of a subrepo given a subpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21482
diff
changeset
|
178 return self.substate[subpath][1] |
8a2637cf1130
basectx: add subrev method to return the rev of a subrepo given a subpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21482
diff
changeset
|
179 |
19541
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
180 def rev(self): |
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
181 return self._rev |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
182 |
19542
bd95621a2d56
basectx: move node from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19541
diff
changeset
|
183 def node(self): |
bd95621a2d56
basectx: move node from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19541
diff
changeset
|
184 return self._node |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
185 |
19543
18f4951222f4
basectx: move hex from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19542
diff
changeset
|
186 def hex(self): |
19544
74924fa3236d
basectx: change _node to node() in hex
Sean Farley <sean.michael.farley@gmail.com>
parents:
19543
diff
changeset
|
187 return hex(self.node()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
188 |
19553
64a99d972b9e
basectx: move manifest from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19552
diff
changeset
|
189 def manifest(self): |
64a99d972b9e
basectx: move manifest from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19552
diff
changeset
|
190 return self._manifest |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
191 |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
192 def manifestctx(self): |
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
193 return self._manifestctx |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
194 |
24300
a07314472a80
context: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24227
diff
changeset
|
195 def repo(self): |
a07314472a80
context: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24227
diff
changeset
|
196 return self._repo |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
197 |
19554
98f8875f4baa
basectx: move phasestr from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19553
diff
changeset
|
198 def phasestr(self): |
98f8875f4baa
basectx: move phasestr from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19553
diff
changeset
|
199 return phases.phasenames[self.phase()] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
200 |
19555
613b70fedc4e
basectx: move mutable from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19554
diff
changeset
|
201 def mutable(self): |
613b70fedc4e
basectx: move mutable from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19554
diff
changeset
|
202 return self.phase() > phases.public |
19541
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
203 |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
204 def matchfileset(self, cwd, expr, badfn=None): |
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
205 return fileset.match(self, cwd, expr, badfn=badfn) |
20400
f0137d994c83
context: add a getfileset() method so fewer things need fileset directly
Augie Fackler <raf@durin42.com>
parents:
20292
diff
changeset
|
206 |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
207 def obsolete(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
208 """True if the changeset is obsolete""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
209 return self.rev() in obsmod.getrevs(self._repo, b'obsolete') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
210 |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
211 def extinct(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
212 """True if the changeset is extinct""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
213 return self.rev() in obsmod.getrevs(self._repo, b'extinct') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
214 |
33727
f163edb45c47
context: rename unstable into orphan
Boris Feld <boris.feld@octobus.net>
parents:
33726
diff
changeset
|
215 def orphan(self): |
39292
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
216 """True if the changeset is not obsolete, but its ancestor is""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
217 return self.rev() in obsmod.getrevs(self._repo, b'orphan') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
218 |
33729
8413cbeae275
context: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33728
diff
changeset
|
219 def phasedivergent(self): |
39292
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
220 """True if the changeset tries to be a successor of a public changeset |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
221 |
39292
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
222 Only non-public and non-obsolete changesets may be phase-divergent. |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
223 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
224 return self.rev() in obsmod.getrevs(self._repo, b'phasedivergent') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
225 |
33728
8b2d7684407b
context: rename divergent into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents:
33727
diff
changeset
|
226 def contentdivergent(self): |
39292
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
227 """Is a successor of a changeset with multiple possible successor sets |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
228 |
39292
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
229 Only non-public and non-obsolete changesets may be content-divergent. |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
230 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
231 return self.rev() in obsmod.getrevs(self._repo, b'contentdivergent') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
232 |
33730
52c5ff856b49
context: rename troubled into isunstable
Boris Feld <boris.feld@octobus.net>
parents:
33729
diff
changeset
|
233 def isunstable(self): |
39292
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
234 """True if the changeset is either orphan, phase-divergent or |
f6f52841e1ff
context: use new names for unstable changesets in docstrings
Anton Shestakov <av6@dwimlabs.net>
parents:
39197
diff
changeset
|
235 content-divergent""" |
33729
8413cbeae275
context: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33728
diff
changeset
|
236 return self.orphan() or self.phasedivergent() or self.contentdivergent() |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
237 |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
238 def instabilities(self): |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
239 """return the list of instabilities affecting this changeset. |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
240 |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
241 Instabilities are returned as strings. possible values are: |
33667
03039ff3082b
evolution: rename unstable to orphan
Boris Feld <boris.feld@octobus.net>
parents:
33501
diff
changeset
|
242 - orphan, |
33689
9c27a2891b75
evolution: rename bumped to phase-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33688
diff
changeset
|
243 - phase-divergent, |
33688
2194a8723138
evolution: rename divergent to content-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33667
diff
changeset
|
244 - content-divergent. |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
245 """ |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
246 instabilities = [] |
33727
f163edb45c47
context: rename unstable into orphan
Boris Feld <boris.feld@octobus.net>
parents:
33726
diff
changeset
|
247 if self.orphan(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 instabilities.append(b'orphan') |
33729
8413cbeae275
context: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33728
diff
changeset
|
249 if self.phasedivergent(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
250 instabilities.append(b'phase-divergent') |
33728
8b2d7684407b
context: rename divergent into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents:
33727
diff
changeset
|
251 if self.contentdivergent(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 instabilities.append(b'content-divergent') |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
253 return instabilities |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
254 |
19556
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
255 def parents(self): |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
256 """return contexts for each parent changeset""" |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
257 return self._parents |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
258 |
19557
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
259 def p1(self): |
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
260 return self._parents[0] |
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
261 |
19558
d0448e9d4554
basectx: move p2 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19557
diff
changeset
|
262 def p2(self): |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
263 parents = self._parents |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
264 if len(parents) == 2: |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
265 return parents[1] |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
266 return self._repo[nullrev] |
19558
d0448e9d4554
basectx: move p2 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19557
diff
changeset
|
267 |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
268 def _fileinfo(self, path): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
269 if '_manifest' in self.__dict__: |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
270 try: |
44354
2e2cfc3bea0b
context: use manifest.find() instead of two separate calls
Augie Fackler <augie@google.com>
parents:
44263
diff
changeset
|
271 return self._manifest.find(path) |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
272 except KeyError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
273 raise error.ManifestLookupError( |
45489
a108f7ff7778
py3: don't risk passing a None value to error.ManifestLookupError()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45228
diff
changeset
|
274 self._node or b'None', path, _(b'not found in manifest') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
275 ) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
276 if '_manifestdelta' in self.__dict__ or path in self.files(): |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
277 if path in self._manifestdelta: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
278 return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
279 self._manifestdelta[path], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
280 self._manifestdelta.flags(path), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
281 ) |
30340
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
282 mfl = self._repo.manifestlog |
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
283 try: |
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
284 node, flag = mfl[self._changeset.manifest].find(path) |
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
285 except KeyError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
286 raise error.ManifestLookupError( |
45489
a108f7ff7778
py3: don't risk passing a None value to error.ManifestLookupError()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45228
diff
changeset
|
287 self._node or b'None', path, _(b'not found in manifest') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
288 ) |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
289 |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
290 return node, flag |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
291 |
19560
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
292 def filenode(self, path): |
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
293 return self._fileinfo(path)[0] |
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
294 |
19561
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
295 def flags(self, path): |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
296 try: |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
297 return self._fileinfo(path)[1] |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
298 except error.LookupError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
299 return b'' |
19561
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
300 |
42291
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
301 @propertycache |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
302 def _copies(self): |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44934
diff
changeset
|
303 return metadata.computechangesetcopies(self) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
304 |
42291
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
305 def p1copies(self): |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
306 return self._copies[0] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
307 |
42291
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
308 def p2copies(self): |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
309 return self._copies[1] |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
310 |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28488
diff
changeset
|
311 def sub(self, path, allowcreate=True): |
25600
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
312 '''return a subrepo for the stored revision of path, never wdir()''' |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28488
diff
changeset
|
313 return subrepo.subrepo(self, path, allowcreate=allowcreate) |
19562
389d7767630d
basectx: move sub from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19561
diff
changeset
|
314 |
25417
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
315 def nullsub(self, path, pctx): |
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
316 return subrepo.nullsubrepo(self, path, pctx) |
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
317 |
25600
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
318 def workingsub(self, path): |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
319 '''return a subrepo for the stored revision, or wdir if this is a wdir |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
320 context. |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
321 ''' |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
322 return subrepo.subrepo(self, path, allowwdir=True) |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
323 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
324 def match( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
325 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
326 pats=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
327 include=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
328 exclude=None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
329 default=b'glob', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
330 listsubrepos=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
331 badfn=None, |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
332 cwd=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
333 ): |
19563
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
334 r = self._repo |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
335 if not cwd: |
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
336 cwd = r.getcwd() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
337 return matchmod.match( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
338 r.root, |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
339 cwd, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
340 pats, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
341 include, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
342 exclude, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
343 default, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
344 auditor=r.nofsauditor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
345 ctx=self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
346 listsubrepos=listsubrepos, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
347 badfn=badfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
348 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
349 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
350 def diff( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
351 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
352 ctx2=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
353 match=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
354 changes=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
355 opts=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
356 losedatafn=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
357 pathfn=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
358 copy=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
359 copysourcematch=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
360 hunksfilterfn=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
361 ): |
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
362 """Returns a diff generator for the given contexts and matcher""" |
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
363 if ctx2 is None: |
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
364 ctx2 = self.p1() |
19568
f58235d85d6b
basectx: remove unnecessary check of instance
Sean Farley <sean.michael.farley@gmail.com>
parents:
19567
diff
changeset
|
365 if ctx2 is not None: |
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
366 ctx2 = self._repo[ctx2] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
367 return patch.diff( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
368 self._repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
369 ctx2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
370 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
371 match=match, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
372 changes=changes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
373 opts=opts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
374 losedatafn=losedatafn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
375 pathfn=pathfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
376 copy=copy, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
377 copysourcematch=copysourcematch, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
378 hunksfilterfn=hunksfilterfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
379 ) |
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
380 |
24323
4c7c6beade1a
manifest: have context's dirs() call its manifest's dirs()
Drew Gottlieb <drgott@google.com>
parents:
24306
diff
changeset
|
381 def dirs(self): |
4c7c6beade1a
manifest: have context's dirs() call its manifest's dirs()
Drew Gottlieb <drgott@google.com>
parents:
24306
diff
changeset
|
382 return self._manifest.dirs() |
19565
bd1580a9c133
basectx: move _dirs from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19564
diff
changeset
|
383 |
24325
79d9c51488ca
manifest: add hasdir() to context
Drew Gottlieb <drgott@google.com>
parents:
24323
diff
changeset
|
384 def hasdir(self, dir): |
79d9c51488ca
manifest: add hasdir() to context
Drew Gottlieb <drgott@google.com>
parents:
24323
diff
changeset
|
385 return self._manifest.hasdir(dir) |
19566
54817c774d38
basectx: move dirs from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19565
diff
changeset
|
386 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
387 def status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
388 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
389 other=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
390 match=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
391 listignored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
392 listclean=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
393 listunknown=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
394 listsubrepos=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
395 ): |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
396 """return status of files between two nodes or node and working |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
397 directory. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
398 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
399 If other is None, compare this node with working directory. |
21722
ee29b0bb1619
status: document the content of the returned tuple in the docstring
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21718
diff
changeset
|
400 |
ee29b0bb1619
status: document the content of the returned tuple in the docstring
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21718
diff
changeset
|
401 returns (modified, added, removed, deleted, unknown, ignored, clean) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
402 """ |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
403 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
404 ctx1 = self |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
405 ctx2 = self._repo[other] |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
406 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
407 # This next code block is, admittedly, fragile logic that tests for |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
408 # reversing the contexts and wouldn't need to exist if it weren't for |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
409 # the fast (and common) code path of comparing the working directory |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
410 # with its first parent. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
411 # |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
412 # What we're aiming for here is the ability to call: |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
413 # |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
414 # workingctx.status(parentctx) |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
415 # |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
416 # If we always built the manifest for each context and compared those, |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
417 # then we'd be done. But the special case of the above call means we |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
418 # just copy the manifest of the parent. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
419 reversed = False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
420 if not isinstance(ctx1, changectx) and isinstance(ctx2, changectx): |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
421 reversed = True |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
422 ctx1, ctx2 = ctx2, ctx1 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
423 |
40083
48a0ce67d67a
status: intersect matcher with narrow matcher instead of filtering afterwards
Martin von Zweigbergk <martinvonz@google.com>
parents:
40062
diff
changeset
|
424 match = self._repo.narrowmatch(match) |
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
425 match = ctx2._matchstatus(ctx1, match) |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
426 r = scmutil.status([], [], [], [], [], [], []) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
427 r = ctx2._buildstatus( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
428 ctx1, r, match, listignored, listclean, listunknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
429 ) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
430 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
431 if reversed: |
23301
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
432 # Reverse added and removed. Clear deleted, unknown and ignored as |
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
433 # these make no sense to reverse. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
434 r = scmutil.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
435 r.modified, r.removed, r.added, [], [], [], r.clean |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
436 ) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
437 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
438 if listsubrepos: |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
439 for subpath, sub in scmutil.itersubrepos(ctx1, ctx2): |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
440 try: |
27183
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
441 rev2 = ctx2.subrev(subpath) |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
442 except KeyError: |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
443 # A subrepo that existed in node1 was deleted between |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
444 # node1 and node2 (inclusive). Thus, ctx2's substate |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
445 # won't contain that subpath. The best we can do ignore it. |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
446 rev2 = None |
28017
d3f1b7ee5e70
match: rename "narrowmatcher" to "subdirmatcher" (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27983
diff
changeset
|
447 submatch = matchmod.subdirmatcher(subpath, match) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
448 s = sub.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
449 rev2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
450 match=submatch, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
451 ignored=listignored, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
452 clean=listclean, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
453 unknown=listunknown, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
454 listsubrepos=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
455 ) |
43647
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
456 for k in ( |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
457 'modified', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
458 'added', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
459 'removed', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
460 'deleted', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
461 'unknown', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
462 'ignored', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
463 'clean', |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
464 ): |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
465 rfiles, sfiles = getattr(r, k), getattr(s, k) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
466 rfiles.extend(b"%s/%s" % (subpath, f) for f in sfiles) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
467 |
43647
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
468 r.modified.sort() |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
469 r.added.sort() |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
470 r.removed.sort() |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
471 r.deleted.sort() |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
472 r.unknown.sort() |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
473 r.ignored.sort() |
e035a8f71d52
context: use field names instead of field numbers on scmutil.status
Augie Fackler <augie@google.com>
parents:
43633
diff
changeset
|
474 r.clean.sort() |
21616
0a8e7f81e8ae
context: explicitly return a tuple
Sean Farley <sean.michael.farley@gmail.com>
parents:
21595
diff
changeset
|
475 |
23301
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
476 return r |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
477 |
44857
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
478 def mergestate(self, clean=False): |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
479 """Get a mergestate object for this context.""" |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
480 raise NotImplementedError( |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
481 '%s does not implement mergestate()' % self.__class__ |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
482 ) |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
483 |
45088
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
484 def isempty(self): |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
485 return not ( |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
486 len(self.parents()) > 1 |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
487 or self.branch() != self.p1().branch() |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
488 or self.closesbranch() |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
489 or self.files() |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
490 ) |
3e40abe0a170
commit: factor out empty commit check to `basectx.isempty()`
Manuel Jacob <me@manueljacob.de>
parents:
45087
diff
changeset
|
491 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
492 |
19537
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
493 class changectx(basectx): |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
494 """A changecontext object makes access to data related to a particular |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
19902
diff
changeset
|
495 changeset convenient. It represents a read-only context already present in |
19537
6e3e8575276d
basectx: add an empty class that will be used as a parent of all contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19314
diff
changeset
|
496 the repo.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
497 |
43760
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
498 def __init__(self, repo, rev, node, maybe_filtered=True): |
37175
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
499 super(changectx, self).__init__(repo) |
39958
3d35304bd09b
context: move logic from changectx.__init__ to localrepo.__getitem__ (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
39957
diff
changeset
|
500 self._rev = rev |
3d35304bd09b
context: move logic from changectx.__init__ to localrepo.__getitem__ (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
39957
diff
changeset
|
501 self._node = node |
43760
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
502 # When maybe_filtered is True, the revision might be affected by |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
503 # changelog filtering and operation through the filtered changelog must be used. |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
504 # |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
505 # When maybe_filtered is False, the revision has already been checked |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
506 # against filtering and is not filtered. Operation through the |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
507 # unfiltered changelog might be used in some case. |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
508 self._maybe_filtered = maybe_filtered |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
509 |
6469
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
510 def __hash__(self): |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
511 try: |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
512 return hash(self._rev) |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
513 except AttributeError: |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
514 return id(self) |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
515 |
3168
05c588e1803d
context: add __nonzero__ methods
Matt Mackall <mpm@selenic.com>
parents:
3166
diff
changeset
|
516 def __nonzero__(self): |
3578
3b4e00cba57a
Define and use nullrev (revision of nullid) instead of -1.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3454
diff
changeset
|
517 return self._rev != nullrev |
3168
05c588e1803d
context: add __nonzero__ methods
Matt Mackall <mpm@selenic.com>
parents:
3166
diff
changeset
|
518 |
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
519 __bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
520 |
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
521 @propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
522 def _changeset(self): |
43760
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
523 if self._maybe_filtered: |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
524 repo = self._repo |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
525 else: |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
526 repo = self._repo.unfiltered() |
1e87851dba63
changectx: add a "maybe filtered" filtered attribute
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43647
diff
changeset
|
527 return repo.changelog.changelogrevision(self.rev()) |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
528 |
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
529 @propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
530 def _manifest(self): |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
531 return self._manifestctx.read() |
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
532 |
32519 | 533 @property |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
534 def _manifestctx(self): |
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
535 return self._repo.manifestlog[self._changeset.manifest] |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
536 |
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
537 @propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
538 def _manifestdelta(self): |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
539 return self._manifestctx.readdelta() |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
540 |
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
541 @propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
542 def _parents(self): |
27063
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
543 repo = self._repo |
43764
f9068413bd0c
changectx: use unfiltered changelog to access parents of unfiltered revs
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43760
diff
changeset
|
544 if self._maybe_filtered: |
f9068413bd0c
changectx: use unfiltered changelog to access parents of unfiltered revs
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43760
diff
changeset
|
545 cl = repo.changelog |
f9068413bd0c
changectx: use unfiltered changelog to access parents of unfiltered revs
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43760
diff
changeset
|
546 else: |
f9068413bd0c
changectx: use unfiltered changelog to access parents of unfiltered revs
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43760
diff
changeset
|
547 cl = repo.unfiltered().changelog |
f9068413bd0c
changectx: use unfiltered changelog to access parents of unfiltered revs
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43760
diff
changeset
|
548 |
f9068413bd0c
changectx: use unfiltered changelog to access parents of unfiltered revs
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43760
diff
changeset
|
549 p1, p2 = cl.parentrevs(self._rev) |
27063
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
550 if p2 == nullrev: |
44109
98349eddceef
changectx: mark parent of changesets as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44108
diff
changeset
|
551 return [changectx(repo, p1, cl.node(p1), maybe_filtered=False)] |
98349eddceef
changectx: mark parent of changesets as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44108
diff
changeset
|
552 return [ |
98349eddceef
changectx: mark parent of changesets as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44108
diff
changeset
|
553 changectx(repo, p1, cl.node(p1), maybe_filtered=False), |
98349eddceef
changectx: mark parent of changesets as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44108
diff
changeset
|
554 changectx(repo, p2, cl.node(p2), maybe_filtered=False), |
98349eddceef
changectx: mark parent of changesets as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44108
diff
changeset
|
555 ] |
3215
931288cf58a7
contexts: use __getattr__ rather than try/except in changectx
Matt Mackall <mpm@selenic.com>
parents:
3214
diff
changeset
|
556 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
557 def changeset(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
558 c = self._changeset |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
559 return ( |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
560 c.manifest, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
561 c.user, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
562 c.date, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
563 c.files, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
564 c.description, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
565 c.extra, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
566 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
567 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
568 def manifestnode(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
569 return self._changeset.manifest |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
570 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
571 def user(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
572 return self._changeset.user |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
573 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
574 def date(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
575 return self._changeset.date |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
576 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
577 def files(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
578 return self._changeset.files |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
579 |
42374
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
580 def filesmodified(self): |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
581 modified = set(self.files()) |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
582 modified.difference_update(self.filesadded()) |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
583 modified.difference_update(self.filesremoved()) |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
584 return sorted(modified) |
43021
008e74b34fb7
context: clarify the various mode in the filesadded method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42859
diff
changeset
|
585 |
42374
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
586 def filesadded(self): |
43021
008e74b34fb7
context: clarify the various mode in the filesadded method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42859
diff
changeset
|
587 filesadded = self._changeset.filesadded |
43146
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
588 compute_on_none = True |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
589 if self._repo.filecopiesmode == b'changeset-sidedata': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
590 compute_on_none = False |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
591 else: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
592 source = self._repo.ui.config(b'experimental', b'copies.read-from') |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
593 if source == b'changeset-only': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
594 compute_on_none = False |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
595 elif source != b'compatibility': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
596 # filelog mode, ignore any changelog content |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
597 filesadded = None |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
598 if filesadded is None: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
599 if compute_on_none: |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44934
diff
changeset
|
600 filesadded = metadata.computechangesetfilesadded(self) |
43146
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
601 else: |
43021
008e74b34fb7
context: clarify the various mode in the filesadded method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42859
diff
changeset
|
602 filesadded = [] |
008e74b34fb7
context: clarify the various mode in the filesadded method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42859
diff
changeset
|
603 return filesadded |
008e74b34fb7
context: clarify the various mode in the filesadded method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42859
diff
changeset
|
604 |
42374
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
605 def filesremoved(self): |
43022
15badd621825
context: clarify the various mode in the filesremoved method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43021
diff
changeset
|
606 filesremoved = self._changeset.filesremoved |
43146
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
607 compute_on_none = True |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
608 if self._repo.filecopiesmode == b'changeset-sidedata': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
609 compute_on_none = False |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
610 else: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
611 source = self._repo.ui.config(b'experimental', b'copies.read-from') |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
612 if source == b'changeset-only': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
613 compute_on_none = False |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
614 elif source != b'compatibility': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
615 # filelog mode, ignore any changelog content |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
616 filesremoved = None |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
617 if filesremoved is None: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
618 if compute_on_none: |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44934
diff
changeset
|
619 filesremoved = metadata.computechangesetfilesremoved(self) |
43146
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
620 else: |
43022
15badd621825
context: clarify the various mode in the filesremoved method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43021
diff
changeset
|
621 filesremoved = [] |
15badd621825
context: clarify the various mode in the filesremoved method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43021
diff
changeset
|
622 return filesremoved |
42374
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
623 |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
624 @propertycache |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
625 def _copies(self): |
42142
5382d8f8530b
changelog: parse copy metadata if available in extras
Martin von Zweigbergk <martinvonz@google.com>
parents:
42102
diff
changeset
|
626 p1copies = self._changeset.p1copies |
5382d8f8530b
changelog: parse copy metadata if available in extras
Martin von Zweigbergk <martinvonz@google.com>
parents:
42102
diff
changeset
|
627 p2copies = self._changeset.p2copies |
43146
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
628 compute_on_none = True |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
629 if self._repo.filecopiesmode == b'changeset-sidedata': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
630 compute_on_none = False |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
631 else: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
632 source = self._repo.ui.config(b'experimental', b'copies.read-from') |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
633 # If config says to get copy metadata only from changeset, then |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
634 # return that, defaulting to {} if there was no copy metadata. In |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
635 # compatibility mode, we return copy data from the changeset if it |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
636 # was recorded there, and otherwise we fall back to getting it from |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
637 # the filelogs (below). |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
638 # |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
639 # If we are in compatiblity mode and there is not data in the |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
640 # changeset), we get the copy metadata from the filelogs. |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
641 # |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
642 # otherwise, when config said to read only from filelog, we get the |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
643 # copy metadata from the filelogs. |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
644 if source == b'changeset-only': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
645 compute_on_none = False |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
646 elif source != b'compatibility': |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
647 # filelog mode, ignore any changelog content |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
648 p1copies = p2copies = None |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
649 if p1copies is None: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
650 if compute_on_none: |
43023
8af909893188
context: clarify the various mode in the _copies property cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43022
diff
changeset
|
651 p1copies, p2copies = super(changectx, self)._copies |
43146
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
652 else: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
653 if p1copies is None: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
654 p1copies = {} |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
655 if p2copies is None: |
0171483b082f
sidedatacopies: read rename information from sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
656 p2copies = {} |
43023
8af909893188
context: clarify the various mode in the _copies property cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43022
diff
changeset
|
657 return p1copies, p2copies |
8af909893188
context: clarify the various mode in the _copies property cache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43022
diff
changeset
|
658 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
659 def description(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
660 return self._changeset.description |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
661 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
662 def branch(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
663 return encoding.tolocal(self._changeset.extra.get(b"branch")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
664 |
16720
e825a89de5d7
context: add changectx.closesbranch() method
Brodie Rao <brodie@sf.io>
parents:
16719
diff
changeset
|
665 def closesbranch(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
666 return b'close' in self._changeset.extra |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
667 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
668 def extra(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
669 """Return a dict of extra information.""" |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
670 return self._changeset.extra |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
671 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
672 def tags(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
673 """Return a list of byte tag names""" |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
674 return self._repo.nodetags(self._node) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
675 |
13384
caa561759538
context: add method to return all bookmarks pointing to a node
David Soria Parra <dsp@php.net>
parents:
13235
diff
changeset
|
676 def bookmarks(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
677 """Return a list of byte bookmark names.""" |
13384
caa561759538
context: add method to return all bookmarks pointing to a node
David Soria Parra <dsp@php.net>
parents:
13235
diff
changeset
|
678 return self._repo.nodebookmarks(self._node) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
679 |
15421
405ca90df2b1
phases: add a phase method to context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15337
diff
changeset
|
680 def phase(self): |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16610
diff
changeset
|
681 return self._repo._phasecache.phase(self._repo, self._rev) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
682 |
14644
f3a40fd7008c
hidden: Add ``hidden`` method for context
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
14528
diff
changeset
|
683 def hidden(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
684 return self._rev in repoview.filterrevs(self._repo, b'visible') |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
685 |
34681
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
686 def isinmemory(self): |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
687 return False |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
688 |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
689 def children(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
690 """return list of changectx contexts for each child changeset. |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
691 |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
692 This returns only the immediate child changesets. Use descendants() to |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
693 recursively walk children. |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
694 """ |
2627
b779319a532b
context.py: self.repo is not defined, change to self._repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2566
diff
changeset
|
695 c = self._repo.changelog.children(self._node) |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
696 return [self._repo[x] for x in c] |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
697 |
6876 | 698 def ancestors(self): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16761
diff
changeset
|
699 for a in self._repo.changelog.ancestors([self._rev]): |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
700 yield self._repo[a] |
6876 | 701 |
702 def descendants(self): | |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
703 """Recursively yield all children of the changeset. |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
704 |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
705 For just the immediate children, use children() |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
706 """ |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16866
diff
changeset
|
707 for d in self._repo.changelog.descendants([self._rev]): |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
708 yield self._repo[d] |
6876 | 709 |
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
710 def filectx(self, path, fileid=None, filelog=None): |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
711 """get a file context from this changeset""" |
2628
9999a796d389
context.py: filectxs was using a keyword arg, add it to filectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2627
diff
changeset
|
712 if fileid is None: |
9999a796d389
context.py: filectxs was using a keyword arg, add it to filectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2627
diff
changeset
|
713 fileid = self.filenode(path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
714 return filectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
715 self._repo, path, fileid=fileid, changectx=self, filelog=filelog |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
716 ) |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
717 |
21203
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
718 def ancestor(self, c2, warn=False): |
22389
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
719 """return the "best" ancestor context of self and c2 |
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
720 |
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
721 If there are multiple candidates, it will show a message and check |
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
722 merge.preferancestor configuration before falling back to the |
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
723 revlog ancestor.""" |
9843
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
724 # deal with workingctxs |
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
725 n2 = c2._node |
13031
3da456d0c885
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents:
13001
diff
changeset
|
726 if n2 is None: |
9843
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
727 n2 = c2._parents[0]._node |
21125
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
728 cahs = self._repo.changelog.commonancestorsheads(self._node, n2) |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
729 if not cahs: |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
730 anc = nullid |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
731 elif len(cahs) == 1: |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
732 anc = cahs[0] |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
733 else: |
25844
18541e9510c5
merge: make merge.preferancestor type and default consistent
Matt Mackall <mpm@selenic.com>
parents:
25757
diff
changeset
|
734 # experimental config: merge.preferancestor |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
735 for r in self._repo.ui.configlist(b'merge', b'preferancestor'): |
22671
5220c12c43fd
changectx: skip all invalid merge.preferancestor values
Mads Kiilerich <madski@unity3d.com>
parents:
22405
diff
changeset
|
736 try: |
37354
a6014392837e
context: use revsymbol() in "merge.preferancestor" code
Martin von Zweigbergk <martinvonz@google.com>
parents:
37267
diff
changeset
|
737 ctx = scmutil.revsymbol(self._repo, r) |
22671
5220c12c43fd
changectx: skip all invalid merge.preferancestor values
Mads Kiilerich <madski@unity3d.com>
parents:
22405
diff
changeset
|
738 except error.RepoLookupError: |
22180
17011b36aac7
changectx: ancestor should only prefer merge.preferancestor if it is a revision
Mads Kiilerich <madski@unity3d.com>
parents:
21990
diff
changeset
|
739 continue |
21126
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
740 anc = ctx.node() |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
741 if anc in cahs: |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
742 break |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
743 else: |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
744 anc = self._repo.changelog.ancestor(self._node, n2) |
21203
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
745 if warn: |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
746 self._repo.ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
747 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
748 _(b"note: using %s as ancestor of %s and %s\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
749 % (short(anc), short(self._node), short(n2)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
750 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
751 + b''.join( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
752 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
753 b" alternatively, use --config " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
754 b"merge.preferancestor=%s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
755 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
756 % short(n) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
757 for n in sorted(cahs) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
758 if n != anc |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
759 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
760 ) |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
761 return self._repo[anc] |
3125
02b22fefc01f
changectx: add ancestor function
Matt Mackall <mpm@selenic.com>
parents:
3124
diff
changeset
|
762 |
38670
fbec9c0b32d3
context: rename descendant() to isancestorof()
Martin von Zweigbergk <martinvonz@google.com>
parents:
38668
diff
changeset
|
763 def isancestorof(self, other): |
fbec9c0b32d3
context: rename descendant() to isancestorof()
Martin von Zweigbergk <martinvonz@google.com>
parents:
38668
diff
changeset
|
764 """True if this changeset is an ancestor of other""" |
38668
21846c94e605
revlog: delete isdescendantrev() in favor of isancestorrev()
Martin von Zweigbergk <martinvonz@google.com>
parents:
38664
diff
changeset
|
765 return self._repo.changelog.isancestorrev(self._rev, other._rev) |
17626
3a524b647897
context: add "descendant()" to changectx for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17469
diff
changeset
|
766 |
6764 | 767 def walk(self, match): |
24646
5693c834bcb4
manifest: move changectx.walk() to manifests
Drew Gottlieb <drgott@google.com>
parents:
24633
diff
changeset
|
768 '''Generates matching file names.''' |
20292
8dc254198a8f
changectx: increase perf of walk function
Durham Goode <durham@fb.com>
parents:
20236
diff
changeset
|
769 |
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
770 # Wrap match.bad method to have message with nodeid |
24646
5693c834bcb4
manifest: move changectx.walk() to manifests
Drew Gottlieb <drgott@google.com>
parents:
24633
diff
changeset
|
771 def bad(fn, msg): |
25193
ccb1623266eb
context: don't complain about a matcher's subrepo paths in changectx.walk()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24862
diff
changeset
|
772 # The manifest doesn't know about subrepos, so don't complain about |
ccb1623266eb
context: don't complain about a matcher's subrepo paths in changectx.walk()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24862
diff
changeset
|
773 # paths into valid subrepos. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
774 if any(fn == s or fn.startswith(s + b'/') for s in self.substate): |
25193
ccb1623266eb
context: don't complain about a matcher's subrepo paths in changectx.walk()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24862
diff
changeset
|
775 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
776 match.bad(fn, _(b'no such file in rev %s') % self) |
20292
8dc254198a8f
changectx: increase perf of walk function
Durham Goode <durham@fb.com>
parents:
20236
diff
changeset
|
777 |
40084
2cf18f46a1ce
narrow: only walk files within narrowspec also for committed revisions
Martin von Zweigbergk <martinvonz@google.com>
parents:
40083
diff
changeset
|
778 m = matchmod.badmatch(self._repo.narrowmatch(match), bad) |
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
779 return self._manifest.walk(m) |
6764 | 780 |
21985
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
781 def matches(self, match): |
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
782 return self.walk(match) |
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
783 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
784 |
19572
c19f46b904b9
basefilectx: add an empty class that will be used as a parent of file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19571
diff
changeset
|
785 class basefilectx(object): |
c19f46b904b9
basefilectx: add an empty class that will be used as a parent of file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19571
diff
changeset
|
786 """A filecontext object represents the common logic for its children: |
c19f46b904b9
basefilectx: add an empty class that will be used as a parent of file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19571
diff
changeset
|
787 filectx: read-only access to a filerevision that is already present |
c19f46b904b9
basefilectx: add an empty class that will be used as a parent of file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19571
diff
changeset
|
788 in the repo, |
c19f46b904b9
basefilectx: add an empty class that will be used as a parent of file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19571
diff
changeset
|
789 workingfilectx: a filecontext that represents files from the working |
c19f46b904b9
basefilectx: add an empty class that will be used as a parent of file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19571
diff
changeset
|
790 directory, |
32243
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
791 memfilectx: a filecontext that represents files in-memory, |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
792 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
793 |
19573
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
794 @propertycache |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
795 def _filelog(self): |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
796 return self._repo.file(self._path) |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
797 |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
798 @propertycache |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
799 def _changeid(self): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
800 if '_changectx' in self.__dict__: |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
801 return self._changectx.rev() |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
802 elif '_descendantrev' in self.__dict__: |
23983
ff070a53ee74
filectx: if we have a _descendantrev, use it to adjust linkrev
Matt Mackall <mpm@selenic.com>
parents:
23981
diff
changeset
|
803 # this file context was created from a revision with a known |
ff070a53ee74
filectx: if we have a _descendantrev, use it to adjust linkrev
Matt Mackall <mpm@selenic.com>
parents:
23981
diff
changeset
|
804 # descendant, we can (lazily) correct for linkrev aliases |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
805 return self._adjustlinkrev(self._descendantrev) |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
806 else: |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
807 return self._filelog.linkrev(self._filerev) |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
808 |
19575
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
809 @propertycache |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
810 def _filenode(self): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
811 if '_fileid' in self.__dict__: |
19575
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
812 return self._filelog.lookup(self._fileid) |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
813 else: |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
814 return self._changectx.filenode(self._path) |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
815 |
19576
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
816 @propertycache |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
817 def _filerev(self): |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
818 return self._filelog.rev(self._filenode) |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
819 |
19577
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
820 @propertycache |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
821 def _repopath(self): |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
822 return self._path |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
823 |
19578
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
824 def __nonzero__(self): |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
825 try: |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
826 self._filenode |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
827 return True |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
828 except error.LookupError: |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
829 # file is missing |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
830 return False |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
831 |
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
832 __bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
833 |
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
834 def __bytes__(self): |
30270
e25ce44f8447
context: make sure __str__ works, also when there is no _changectx
Mads Kiilerich <mads@kiilerich.com>
parents:
30040
diff
changeset
|
835 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
836 return b"%s@%s" % (self.path(), self._changectx) |
30270
e25ce44f8447
context: make sure __str__ works, also when there is no _changectx
Mads Kiilerich <mads@kiilerich.com>
parents:
30040
diff
changeset
|
837 except error.LookupError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
838 return b"%s@???" % self.path() |
19579
964844d64ef8
basefilectx: move __str__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19578
diff
changeset
|
839 |
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
840 __str__ = encoding.strmethod(__bytes__) |
33019
daccadd75760
py3: define __bytes__ for basefilectx class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32904
diff
changeset
|
841 |
19580
e86a594ab11f
basefilectx: move __repr__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19579
diff
changeset
|
842 def __repr__(self): |
43503
313e3a279828
cleanup: remove pointless r-prefixes on double-quoted strings
Augie Fackler <augie@google.com>
parents:
43346
diff
changeset
|
843 return "<%s %s>" % (type(self).__name__, str(self)) |
19580
e86a594ab11f
basefilectx: move __repr__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19579
diff
changeset
|
844 |
19581
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
845 def __hash__(self): |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
846 try: |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
847 return hash((self._path, self._filenode)) |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
848 except AttributeError: |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
849 return id(self) |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
850 |
19582
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
851 def __eq__(self, other): |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
852 try: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
853 return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
854 type(self) == type(other) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
855 and self._path == other._path |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
856 and self._filenode == other._filenode |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
857 ) |
19582
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
858 except AttributeError: |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
859 return False |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
860 |
19583
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
861 def __ne__(self, other): |
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
862 return not (self == other) |
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
863 |
19584
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
864 def filerev(self): |
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
865 return self._filerev |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
866 |
19585
8e553cd6071e
basefilectx: move filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19584
diff
changeset
|
867 def filenode(self): |
8e553cd6071e
basefilectx: move filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19584
diff
changeset
|
868 return self._filenode |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
869 |
32238
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
870 @propertycache |
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
871 def _flags(self): |
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
872 return self._changectx.flags(self._path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
873 |
19586
43f9ed2f64b1
basefilectx: move flags from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19585
diff
changeset
|
874 def flags(self): |
32238
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
875 return self._flags |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
876 |
19587
b1c344ebd8e4
basefilectx: move filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19586
diff
changeset
|
877 def filelog(self): |
b1c344ebd8e4
basefilectx: move filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19586
diff
changeset
|
878 return self._filelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
879 |
19588
a192fff6c97d
basefilectx: move rev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19587
diff
changeset
|
880 def rev(self): |
a192fff6c97d
basefilectx: move rev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19587
diff
changeset
|
881 return self._changeid |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
882 |
19589
6a9043fa06d0
basefilectx: move linkrev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19588
diff
changeset
|
883 def linkrev(self): |
6a9043fa06d0
basefilectx: move linkrev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19588
diff
changeset
|
884 return self._filelog.linkrev(self._filerev) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
885 |
19590
90994b176bc1
basefilectx: move node from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19589
diff
changeset
|
886 def node(self): |
90994b176bc1
basefilectx: move node from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19589
diff
changeset
|
887 return self._changectx.node() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
888 |
19591
04fbc85f870a
basefilectx: move hex from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19590
diff
changeset
|
889 def hex(self): |
04fbc85f870a
basefilectx: move hex from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19590
diff
changeset
|
890 return self._changectx.hex() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
891 |
19592
1cdb3b3df4df
basefilectx: move user from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19591
diff
changeset
|
892 def user(self): |
1cdb3b3df4df
basefilectx: move user from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19591
diff
changeset
|
893 return self._changectx.user() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
894 |
19593
e3c241c89350
basefilectx: move date from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19592
diff
changeset
|
895 def date(self): |
e3c241c89350
basefilectx: move date from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19592
diff
changeset
|
896 return self._changectx.date() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
897 |
19594
1c030c24e196
basefilectx: move files from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19593
diff
changeset
|
898 def files(self): |
1c030c24e196
basefilectx: move files from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19593
diff
changeset
|
899 return self._changectx.files() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
900 |
19595
bb6fd06975a6
basefilectx: move description from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19594
diff
changeset
|
901 def description(self): |
bb6fd06975a6
basefilectx: move description from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19594
diff
changeset
|
902 return self._changectx.description() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
903 |
19596
9bc3d0dea371
basefilectx: move branch from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19595
diff
changeset
|
904 def branch(self): |
9bc3d0dea371
basefilectx: move branch from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19595
diff
changeset
|
905 return self._changectx.branch() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
906 |
19597
837bc86370f0
basefilectx: move extra from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19596
diff
changeset
|
907 def extra(self): |
837bc86370f0
basefilectx: move extra from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19596
diff
changeset
|
908 return self._changectx.extra() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
909 |
19598
e8ef893a3150
basefilectx: move phase from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19597
diff
changeset
|
910 def phase(self): |
e8ef893a3150
basefilectx: move phase from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19597
diff
changeset
|
911 return self._changectx.phase() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
912 |
19599
66d83efac20a
basefilectx: move phasestr from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19598
diff
changeset
|
913 def phasestr(self): |
66d83efac20a
basefilectx: move phasestr from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19598
diff
changeset
|
914 return self._changectx.phasestr() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
915 |
35088
a9454beb9dd8
context: add obsolete() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
34926
diff
changeset
|
916 def obsolete(self): |
a9454beb9dd8
context: add obsolete() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
34926
diff
changeset
|
917 return self._changectx.obsolete() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
918 |
35093
bd2743936b56
context: add instabilities() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
35088
diff
changeset
|
919 def instabilities(self): |
bd2743936b56
context: add instabilities() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
35088
diff
changeset
|
920 return self._changectx.instabilities() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
921 |
19600
12cdff44fdc4
basefilectx: move manifest from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19599
diff
changeset
|
922 def manifest(self): |
12cdff44fdc4
basefilectx: move manifest from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19599
diff
changeset
|
923 return self._changectx.manifest() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
924 |
19601
f284907631f5
basefilectx: move changectx from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19600
diff
changeset
|
925 def changectx(self): |
f284907631f5
basefilectx: move changectx from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19600
diff
changeset
|
926 return self._changectx |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
927 |
32239
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
928 def renamed(self): |
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
929 return self._copied |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
930 |
41768
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
931 def copysource(self): |
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
932 return self._copied and self._copied[0] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
933 |
24333
5da0eb641881
filectx: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24326
diff
changeset
|
934 def repo(self): |
5da0eb641881
filectx: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24326
diff
changeset
|
935 return self._repo |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
936 |
32240 | 937 def size(self): |
938 return len(self.data()) | |
19584
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
939 |
19602
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
940 def path(self): |
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
941 return self._path |
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
942 |
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
943 def isbinary(self): |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
944 try: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
945 return stringutil.binary(self.data()) |
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
946 except IOError: |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
947 return False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
948 |
22054
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
949 def isexec(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
950 return b'x' in self.flags() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
951 |
22054
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
952 def islink(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
953 return b'l' in self.flags() |
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
954 |
26978
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
955 def isabsent(self): |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
956 """whether this filectx represents a file not in self._changectx |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
957 |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
958 This is mainly for merge code to detect change/delete conflicts. This is |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
959 expected to be True for all subclasses of basectx.""" |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
960 return False |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
961 |
26977
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
962 _customcmp = False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
963 |
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
964 def cmp(self, fctx): |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
965 """compare with other file context |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
966 |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
967 returns True if different than fctx. |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
968 """ |
26977
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
969 if fctx._customcmp: |
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
970 return fctx.cmp(self) |
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
971 |
40991
21ffe6b97a25
context: error out if basefilectx.cmp() is called without self._filenode
Yuya Nishihara <yuya@tcha.org>
parents:
40990
diff
changeset
|
972 if self._filenode is None: |
21ffe6b97a25
context: error out if basefilectx.cmp() is called without self._filenode
Yuya Nishihara <yuya@tcha.org>
parents:
40990
diff
changeset
|
973 raise error.ProgrammingError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
974 b'filectx.cmp() must be reimplemented if not backed by revlog' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
975 ) |
40991
21ffe6b97a25
context: error out if basefilectx.cmp() is called without self._filenode
Yuya Nishihara <yuya@tcha.org>
parents:
40990
diff
changeset
|
976 |
40990
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
977 if fctx._filenode is None: |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
978 if self._repo._encodefilterpats: |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
979 # can't rely on size() because wdir content may be decoded |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
980 return self._filelog.cmp(self._filenode, fctx.data()) |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
981 if self.size() - 4 == fctx.size(): |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
982 # size() can match: |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
983 # if file data starts with '\1\n', empty metadata block is |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
984 # prepended, which adds 4 bytes to filelog.size(). |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
985 return self._filelog.cmp(self._filenode, fctx.data()) |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
986 if self.size() == fctx.size(): |
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
987 # size() matches: need to compare content |
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
988 return self._filelog.cmp(self._filenode, fctx.data()) |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
989 |
40990
39953bcf1f51
context: collapse complex condition to see if filelog have to be compared
Yuya Nishihara <yuya@tcha.org>
parents:
40989
diff
changeset
|
990 # size() differs |
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
991 return True |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
992 |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
993 def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None): |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24050
diff
changeset
|
994 """return the first ancestor of <srcrev> introducing <fnode> |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
995 |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
996 If the linkrev of the file revision does not point to an ancestor of |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
997 srcrev, we'll walk down the ancestors until we find one introducing |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
998 this file revision. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
999 |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1000 :srcrev: the changeset revision we search ancestors from |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1001 :inclusive: if true, the src revision will also be checked |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1002 :stoprev: an optional revision to stop the walk at. If no introduction |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1003 of this file content could be found before this floor |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1004 revision, the function will returns "None" and stops its |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1005 iteration. |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1006 """ |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1007 repo = self._repo |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1008 cl = repo.unfiltered().changelog |
29939
80be4436e4cc
manifest: adds manifestctx.readfast
Durham Goode <durham@fb.com>
parents:
29938
diff
changeset
|
1009 mfl = repo.manifestlog |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1010 # fetch the linkrev |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
1011 lkr = self.linkrev() |
40044
ccf4d808ec4c
context: fast path linkrev adjustement in trivial case
Boris Feld <boris.feld@octobus.net>
parents:
39959
diff
changeset
|
1012 if srcrev == lkr: |
ccf4d808ec4c
context: fast path linkrev adjustement in trivial case
Boris Feld <boris.feld@octobus.net>
parents:
39959
diff
changeset
|
1013 return lkr |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1014 # hack to reuse ancestor computation when searching for renames |
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1015 memberanc = getattr(self, '_ancestrycontext', None) |
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1016 iteranc = None |
24411
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
1017 if srcrev is None: |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
1018 # wctx case, used by workingfilectx during mergecopy |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
1019 revs = [p.rev() for p in self._repo[None].parents()] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1020 inclusive = True # we skipped the real (revless) source |
24411
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
1021 else: |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
1022 revs = [srcrev] |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1023 if memberanc is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1024 memberanc = iteranc = cl.ancestors(revs, lkr, inclusive=inclusive) |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1025 # check if this linkrev is an ancestor of srcrev |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1026 if lkr not in memberanc: |
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1027 if iteranc is None: |
24410
86de531e07e1
adjustlinkrev: prepare source revs for ancestry only once
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24407
diff
changeset
|
1028 iteranc = cl.ancestors(revs, lkr, inclusive=inclusive) |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
1029 fnode = self._filenode |
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
1030 path = self._path |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
1031 for a in iteranc: |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1032 if stoprev is not None and a < stoprev: |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1033 return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1034 ac = cl.read(a) # get changeset data (we avoid object creation) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1035 if path in ac[3]: # checking the 'files' field. |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1036 # The file has been touched, check if the content is |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1037 # similar to the one we search for. |
29939
80be4436e4cc
manifest: adds manifestctx.readfast
Durham Goode <durham@fb.com>
parents:
29938
diff
changeset
|
1038 if fnode == mfl[ac[0]].readfast().get(path): |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1039 return a |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1040 # In theory, we should never get out of that loop without a result. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1041 # But if manifest uses a buggy file revision (not children of the |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1042 # one it replaces) we could. Such a buggy situation will likely |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1043 # result is crash somewhere else at to some point. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1044 return lkr |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
1045 |
40694
8a0136f69027
context: introduce an `isintroducedafter` method and use it in copies
Boris Feld <boris.feld@octobus.net>
parents:
40693
diff
changeset
|
1046 def isintroducedafter(self, changelogrev): |
8a0136f69027
context: introduce an `isintroducedafter` method and use it in copies
Boris Feld <boris.feld@octobus.net>
parents:
40693
diff
changeset
|
1047 """True if a filectx has been introduced after a given floor revision |
8a0136f69027
context: introduce an `isintroducedafter` method and use it in copies
Boris Feld <boris.feld@octobus.net>
parents:
40693
diff
changeset
|
1048 """ |
40696
69206452a2ac
context: small refactoring of `isintroducedafter`
Boris Feld <boris.feld@octobus.net>
parents:
40695
diff
changeset
|
1049 if self.linkrev() >= changelogrev: |
69206452a2ac
context: small refactoring of `isintroducedafter`
Boris Feld <boris.feld@octobus.net>
parents:
40695
diff
changeset
|
1050 return True |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1051 introrev = self._introrev(stoprev=changelogrev) |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1052 if introrev is None: |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1053 return False |
40696
69206452a2ac
context: small refactoring of `isintroducedafter`
Boris Feld <boris.feld@octobus.net>
parents:
40695
diff
changeset
|
1054 return introrev >= changelogrev |
40694
8a0136f69027
context: introduce an `isintroducedafter` method and use it in copies
Boris Feld <boris.feld@octobus.net>
parents:
40693
diff
changeset
|
1055 |
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1056 def introrev(self): |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1057 """return the rev of the changeset which introduced this file revision |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1058 |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1059 This method is different from linkrev because it take into account the |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1060 changeset the filectx was created from. It ensures the returned |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1061 revision is one of its ancestors. This prevents bugs from |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1062 'linkrev-shadowing' when a file revision is used by multiple |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1063 changesets. |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1064 """ |
40695
9fa0d6dd1617
context: split `introrev` logic in a sub function
Boris Feld <boris.feld@octobus.net>
parents:
40694
diff
changeset
|
1065 return self._introrev() |
9fa0d6dd1617
context: split `introrev` logic in a sub function
Boris Feld <boris.feld@octobus.net>
parents:
40694
diff
changeset
|
1066 |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1067 def _introrev(self, stoprev=None): |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1068 """ |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1069 Same as `introrev` but, with an extra argument to limit changelog |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1070 iteration range in some internal usecase. |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1071 |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1072 If `stoprev` is set, the `introrev` will not be searched past that |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1073 `stoprev` revision and "None" might be returned. This is useful to |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1074 limit the iteration range. |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1075 """ |
40692
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1076 toprev = None |
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1077 attrs = vars(self) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1078 if '_changeid' in attrs: |
40692
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1079 # We have a cached value already |
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1080 toprev = self._changeid |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1081 elif '_changectx' in attrs: |
40692
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1082 # We know which changelog entry we are coming from |
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1083 toprev = self._changectx.rev() |
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1084 |
f3f4d8537b11
context: spell out the logic around linkrev adjustement starting point
Boris Feld <boris.feld@octobus.net>
parents:
40671
diff
changeset
|
1085 if toprev is not None: |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1086 return self._adjustlinkrev(toprev, inclusive=True, stoprev=stoprev) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1087 elif '_descendantrev' in attrs: |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1088 introrev = self._adjustlinkrev(self._descendantrev, stoprev=stoprev) |
40693
aee94f0a36cd
context: take advantage of `_descendantrev` in introrev if available
Boris Feld <boris.feld@octobus.net>
parents:
40692
diff
changeset
|
1089 # be nice and cache the result of the computation |
40697
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1090 if introrev is not None: |
d98fb3f42f33
context: floor adjustlinkrev graph walk during copy tracing
Boris Feld <boris.feld@octobus.net>
parents:
40696
diff
changeset
|
1091 self._changeid = introrev |
40693
aee94f0a36cd
context: take advantage of `_descendantrev` in introrev if available
Boris Feld <boris.feld@octobus.net>
parents:
40692
diff
changeset
|
1092 return introrev |
40046
50700a025953
context: reverse conditional branch order in introrev
Boris Feld <boris.feld@octobus.net>
parents:
40045
diff
changeset
|
1093 else: |
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1094 return self.linkrev() |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
1095 |
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1096 def introfilectx(self): |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1097 """Return filectx having identical contents, but pointing to the |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1098 changeset revision where this filectx was introduced""" |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1099 introrev = self.introrev() |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1100 if self.rev() == introrev: |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1101 return self |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1102 return self.filectx(self.filenode(), changeid=introrev) |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1103 |
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1104 def _parentfilectx(self, path, fileid, filelog): |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1105 """create parent filectx keeping ancestry info for _adjustlinkrev()""" |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1106 fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1107 if '_changeid' in vars(self) or '_changectx' in vars(self): |
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1108 # If self is associated with a changeset (probably explicitly |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1109 # fed), ensure the created filectx is associated with a |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1110 # changeset that is an ancestor of self.changectx. |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1111 # This lets us later use _adjustlinkrev to get a correct link. |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1112 fctx._descendantrev = self.rev() |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1113 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1114 elif '_descendantrev' in vars(self): |
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1115 # Otherwise propagate _descendantrev if we have one associated. |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1116 fctx._descendantrev = self._descendantrev |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1117 fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1118 return fctx |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1119 |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
1120 def parents(self): |
22201
269688a398c4
cleanup: fix some list comprehension redefinitions of existing vars
Mads Kiilerich <madski@unity3d.com>
parents:
22192
diff
changeset
|
1121 _path = self._path |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
1122 fl = self._filelog |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1123 parents = self._filelog.parents(self._filenode) |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1124 pl = [(_path, node, fl) for node in parents if node != nullid] |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
1125 |
23702
c48924787eaa
filectx.parents: enforce changeid of parent to be in own changectx ancestors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23701
diff
changeset
|
1126 r = fl.renamed(self._filenode) |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
1127 if r: |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1128 # - In the simple rename case, both parent are nullid, pl is empty. |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1129 # - In case of merge, only one of the parent is null id and should |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1130 # be replaced with the rename information. This parent is -always- |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1131 # the first one. |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1132 # |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24050
diff
changeset
|
1133 # As null id have always been filtered out in the previous list |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1134 # comprehension, inserting to 0 will always result in "replacing |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
1135 # first nullid parent with rename information. |
23699
fe17a6fb220d
filectx.parents: also fetch the filelog of rename source too
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23688
diff
changeset
|
1136 pl.insert(0, (r[0], r[1], self._repo.file(r[0]))) |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
1137 |
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
1138 return [self._parentfilectx(path, fnode, l) for path, fnode, l in pl] |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
1139 |
19606
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
1140 def p1(self): |
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
1141 return self.parents()[0] |
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
1142 |
19607
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
1143 def p2(self): |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
1144 p = self.parents() |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
1145 if len(p) == 2: |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
1146 return p[1] |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
1147 return filectx(self._repo, self._path, fileid=-1, filelog=self._filelog) |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
1148 |
37065
b235bde38a83
annotate: drop linenumber flag from fctx.annotate() (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36918
diff
changeset
|
1149 def annotate(self, follow=False, skiprevs=None, diffopts=None): |
37066
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
1150 """Returns a list of annotateline objects for each line in the file |
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
1151 |
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
1152 - line.fctx is the filectx of the node where that line was last changed |
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
1153 - line.lineno is the line number at the first appearance in the managed |
37065
b235bde38a83
annotate: drop linenumber flag from fctx.annotate() (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36918
diff
changeset
|
1154 file |
37066
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
1155 - line.text is the data on that line (including newline character) |
37065
b235bde38a83
annotate: drop linenumber flag from fctx.annotate() (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36918
diff
changeset
|
1156 """ |
9097
431462bd8478
fix memory usage of revlog caches by limiting cache size [issue1639]
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
1157 getlog = util.lrucachefunc(lambda x: self._repo.file(x)) |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
1158 |
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
1159 def parents(f): |
24862
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
1160 # Cut _descendantrev here to mitigate the penalty of lazy linkrev |
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
1161 # adjustment. Otherwise, p._adjustlinkrev() would walk changelog |
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
1162 # from the topmost introrev (= srcrev) down to p.linkrev() if it |
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
1163 # isn't an ancestor of the srcrev. |
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
1164 f._changeid |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1165 pl = f.parents() |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1166 |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1167 # Don't return renamed parents if we aren't following. |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1168 if not follow: |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1169 pl = [p for p in pl if p.path() == f.path()] |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
1170 |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1171 # renamed filectx won't have a filelog yet, so set it |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1172 # from the cache to save time |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1173 for p in pl: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43503
diff
changeset
|
1174 if not '_filelog' in p.__dict__: |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1175 p._filelog = getlog(p.path()) |
3146
e69a0cbe268e
filectx.annotate: return filectx for each line instead of rev
Brendan Cully <brendan@kublai.com>
parents:
3144
diff
changeset
|
1176 |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
1177 return pl |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1178 |
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
1179 # use linkrev to find the first changeset where self appeared |
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1180 base = self.introfilectx() |
24818
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
1181 if getattr(base, '_ancestrycontext', None) is None: |
44108
c472970339d2
changectx: use unfiltered changelog to walk ancestors in annotate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44104
diff
changeset
|
1182 # it is safe to use an unfiltered repository here because we are |
c472970339d2
changectx: use unfiltered changelog to walk ancestors in annotate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44104
diff
changeset
|
1183 # walking ancestors only. |
c472970339d2
changectx: use unfiltered changelog to walk ancestors in annotate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44104
diff
changeset
|
1184 cl = self._repo.unfiltered().changelog |
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1185 if base.rev() is None: |
24818
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
1186 # wctx is not inclusive, but works because _ancestrycontext |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
1187 # is used to test filelog revisions |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1188 ac = cl.ancestors( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1189 [p.rev() for p in base.parents()], inclusive=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1190 ) |
24818
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
1191 else: |
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
1192 ac = cl.ancestors([base.rev()], inclusive=True) |
24407
dd01834a696f
annotate: reuse ancestry context when adjusting linkrev (issue4532)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23984
diff
changeset
|
1193 base._ancestrycontext = ac |
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
1194 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1195 return dagop.annotate( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1196 base, parents, skiprevs=skiprevs, diffopts=diffopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1197 ) |
3124
4d021b91cb26
filectx: allow passing filelog in init to avoid opening new filelogs
Matt Mackall <mpm@selenic.com>
parents:
3123
diff
changeset
|
1198 |
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1199 def ancestors(self, followfirst=False): |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1200 visit = {} |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1201 c = self |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1202 if followfirst: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1203 cut = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1204 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1205 cut = None |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1206 |
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1207 while True: |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1208 for parent in c.parents()[:cut]: |
23981
24b57c3899f8
filectx: use linkrev to sort ancestors
Matt Mackall <mpm@selenic.com>
parents:
23980
diff
changeset
|
1209 visit[(parent.linkrev(), parent.filenode())] = parent |
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1210 if not visit: |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1211 break |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1212 c = visit.pop(max(visit)) |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1213 yield c |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1214 |
33901
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1215 def decodeddata(self): |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1216 """Returns `data()` after running repository decoding filters. |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1217 |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1218 This is often equivalent to how the data would be expressed on disk. |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1219 """ |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1220 return self._repo.wwritedata(self.path(), self.data()) |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
1221 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1222 |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1223 class filectx(basefilectx): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1224 """A filecontext object makes access to data related to a particular |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1225 filerevision convenient.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1226 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1227 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1228 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1229 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1230 path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1231 changeid=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1232 fileid=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1233 filelog=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1234 changectx=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1235 ): |
40062
b6c2543e1dd8
filectx: correct docstring about "changeid"
Martin von Zweigbergk <martinvonz@google.com>
parents:
40061
diff
changeset
|
1236 """changeid must be a revision number, if specified. |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1237 fileid can be a file revision or node.""" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1238 self._repo = repo |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1239 self._path = path |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1240 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1241 assert ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1242 changeid is not None or fileid is not None or changectx is not None |
43346
6ada8a274b9c
formatting: run black version 19.10b0 on the codebase
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43147
diff
changeset
|
1243 ), ( |
6ada8a274b9c
formatting: run black version 19.10b0 on the codebase
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43147
diff
changeset
|
1244 b"bad args: changeid=%r, fileid=%r, changectx=%r" |
6ada8a274b9c
formatting: run black version 19.10b0 on the codebase
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43147
diff
changeset
|
1245 % (changeid, fileid, changectx,) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1246 ) |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1247 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1248 if filelog is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1249 self._filelog = filelog |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1250 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1251 if changeid is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1252 self._changeid = changeid |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1253 if changectx is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1254 self._changectx = changectx |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1255 if fileid is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1256 self._fileid = fileid |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1257 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1258 @propertycache |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1259 def _changectx(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1260 try: |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
1261 return self._repo[self._changeid] |
23687
8f32dcfbc338
context: catch FilteredRepoLookupError instead of RepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23616
diff
changeset
|
1262 except error.FilteredRepoLookupError: |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1263 # Linkrev may point to any revision in the repository. When the |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1264 # repository is filtered this may lead to `filectx` trying to build |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1265 # `changectx` for filtered revision. In such case we fallback to |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1266 # creating `changectx` on the unfiltered version of the reposition. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1267 # This fallback should not be an issue because `changectx` from |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1268 # `filectx` are not used in complex operations that care about |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1269 # filtering. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1270 # |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1271 # This fallback is a cheap and dirty fix that prevent several |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1272 # crashes. It does not ensure the behavior is correct. However the |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1273 # behavior was not correct before filtering either and "incorrect |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1274 # behavior" is seen as better as "crash" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1275 # |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1276 # Linkrevs have several serious troubles with filtering that are |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1277 # complicated to solve. Proper handling of the issue here should be |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1278 # considered when solving linkrev issue are on the table. |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
1279 return self._repo.unfiltered()[self._changeid] |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1280 |
23770
50f0096a7346
filectx: fix annotate to not directly instantiate filectx
Durham Goode <durham@fb.com>
parents:
23757
diff
changeset
|
1281 def filectx(self, fileid, changeid=None): |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1282 '''opens an arbitrary revision of the file without |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1283 opening a new filelog''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1284 return filectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1285 self._repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1286 self._path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1287 fileid=fileid, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1288 filelog=self._filelog, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1289 changeid=changeid, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1290 ) |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1291 |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30718
diff
changeset
|
1292 def rawdata(self): |
42769
e75981b7ce84
rawdata: update callers in context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42711
diff
changeset
|
1293 return self._filelog.rawdata(self._filenode) |
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30718
diff
changeset
|
1294 |
32241 | 1295 def rawflags(self): |
1296 """low-level revlog flags""" | |
1297 return self._filelog.flags(self._filerev) | |
1298 | |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1299 def data(self): |
22932
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1300 try: |
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1301 return self._filelog.read(self._filenode) |
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1302 except error.CensoredNodeError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1303 if self._repo.ui.config(b"censor", b"policy") == b"ignore": |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1304 return b"" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1305 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1306 _(b"censored node: %s") % short(self._filenode), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1307 hint=_(b"set censor.policy to ignore errors"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1308 ) |
22932
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1309 |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1310 def size(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1311 return self._filelog.size(self._filerev) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1312 |
32239
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
1313 @propertycache |
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
1314 def _copied(self): |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1315 """check if file was actually renamed in this changeset revision |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1316 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1317 If rename logged in file revision, we report copy for changeset only |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1318 if file revisions linkrev points back to the changeset in question |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1319 or both changeset parents contain different file revisions. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1320 """ |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1321 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1322 renamed = self._filelog.renamed(self._filenode) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1323 if not renamed: |
39710
7375a9ab0149
filectx: fix return of renamed
Sean Farley <sean@farley.io>
parents:
39576
diff
changeset
|
1324 return None |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1325 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1326 if self.rev() == self.linkrev(): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1327 return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1328 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1329 name = self.path() |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1330 fnode = self._filenode |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1331 for p in self._changectx.parents(): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1332 try: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1333 if fnode == p.filenode(name): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1334 return None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1335 except error.LookupError: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1336 pass |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1337 return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1338 |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1339 def children(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1340 # hard for renames |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1341 c = self._filelog.children(self._filenode) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1342 return [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1343 filectx(self._repo, self._path, fileid=x, filelog=self._filelog) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1344 for x in c |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1345 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1346 |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1347 |
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1348 class committablectx(basectx): |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1349 """A committablectx object provides common functionality for a context that |
19664
61dcb2aa7378
commitablectx: add a class that will be used as a parent of mutable contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19663
diff
changeset
|
1350 wants the ability to commit, e.g. workingctx or memctx.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1351 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1352 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1353 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1354 repo, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1355 text=b"", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1356 user=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1357 date=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1358 extra=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1359 changes=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1360 branch=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1361 ): |
37175
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
1362 super(committablectx, self).__init__(repo) |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1363 self._rev = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1364 self._node = None |
6709
f84f507c53d3
context: let workingctx.date(), .user() and description() be overriden
Patrick Mezard <pmezard@gmail.com>
parents:
6708
diff
changeset
|
1365 self._text = text |
6718
4386a7706828
Fix commit date (issue1193)
Christian Ebert <blacktrash@gmx.net>
parents:
6715
diff
changeset
|
1366 if date: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
1367 self._date = dateutil.parsedate(date) |
6817 | 1368 if user: |
1369 self._user = user | |
6707
02bad34230a2
localrepo: hide commit() file selection behind workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6705
diff
changeset
|
1370 if changes: |
21592
16f62b4203b1
committablectx: simplify caching the status
Sean Farley <sean.michael.farley@gmail.com>
parents:
21590
diff
changeset
|
1371 self._status = changes |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1372 |
6708
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1373 self._extra = {} |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1374 if extra: |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1375 self._extra = extra.copy() |
42296
df2f22befdc8
context: let caller pass in branch to committablectx.__init__()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42295
diff
changeset
|
1376 if branch is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1377 self._extra[b'branch'] = encoding.fromlocal(branch) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1378 if not self._extra.get(b'branch'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1379 self._extra[b'branch'] = b'default' |
6708
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1380 |
32643
1df98fc923d4
py3: implement __bytes__ for committablectx
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32613
diff
changeset
|
1381 def __bytes__(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1382 return bytes(self._parents[0]) + b"+" |
19666
09459edfb48b
commitablectx: move __str__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19665
diff
changeset
|
1383 |
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
1384 __str__ = encoding.strmethod(__bytes__) |
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
1385 |
19667
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1386 def __nonzero__(self): |
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1387 return True |
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1388 |
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
1389 __bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
1390 |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1391 @propertycache |
19672
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1392 def _status(self): |
21592
16f62b4203b1
committablectx: simplify caching the status
Sean Farley <sean.michael.farley@gmail.com>
parents:
21590
diff
changeset
|
1393 return self._repo.status() |
19672
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1394 |
19674
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1395 @propertycache |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1396 def _user(self): |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1397 return self._repo.ui.username() |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1398 |
19676
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1399 @propertycache |
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1400 def _date(self): |
32409
3e2e179ef031
devel: add a config field to force dates to timestamp 0
Boris Feld <boris.feld@octobus.net>
parents:
32401
diff
changeset
|
1401 ui = self._repo.ui |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1402 date = ui.configdate(b'devel', b'default-date') |
32409
3e2e179ef031
devel: add a config field to force dates to timestamp 0
Boris Feld <boris.feld@octobus.net>
parents:
32401
diff
changeset
|
1403 if date is None: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
1404 date = dateutil.makedate() |
32409
3e2e179ef031
devel: add a config field to force dates to timestamp 0
Boris Feld <boris.feld@octobus.net>
parents:
32401
diff
changeset
|
1405 return date |
19676
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1406 |
21587
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1407 def subrev(self, subpath): |
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1408 return None |
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1409 |
24719
11e8fec00234
committablectx: override manifestnode() to return None
Yuya Nishihara <yuya@tcha.org>
parents:
24646
diff
changeset
|
1410 def manifestnode(self): |
11e8fec00234
committablectx: override manifestnode() to return None
Yuya Nishihara <yuya@tcha.org>
parents:
24646
diff
changeset
|
1411 return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1412 |
19675
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1413 def user(self): |
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1414 return self._user or self._repo.ui.username() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1415 |
19677
e11415510352
commitablectx: move date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19676
diff
changeset
|
1416 def date(self): |
e11415510352
commitablectx: move date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19676
diff
changeset
|
1417 return self._date |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1418 |
19678
897c2dbc0256
commitablectx: move description from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19677
diff
changeset
|
1419 def description(self): |
897c2dbc0256
commitablectx: move description from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19677
diff
changeset
|
1420 return self._text |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1421 |
19679
f21804f1582e
commitablectx: move files from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19678
diff
changeset
|
1422 def files(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1423 return sorted( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1424 self._status.modified + self._status.added + self._status.removed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1425 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1426 |
41789
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1427 def modified(self): |
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1428 return self._status.modified |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1429 |
41789
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1430 def added(self): |
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1431 return self._status.added |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1432 |
41789
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1433 def removed(self): |
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1434 return self._status.removed |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1435 |
41789
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1436 def deleted(self): |
2ba96fca8528
committablectx: move status-related methods closer together
Martin von Zweigbergk <martinvonz@google.com>
parents:
41776
diff
changeset
|
1437 return self._status.deleted |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1438 |
42374
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
1439 filesmodified = modified |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
1440 filesadded = added |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
1441 filesremoved = removed |
65fa61ca20af
context: add ctx.files{modified,added,removed}() methods
Martin von Zweigbergk <martinvonz@google.com>
parents:
42318
diff
changeset
|
1442 |
19687
54b3b4821bfb
commitablectx: move branch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19686
diff
changeset
|
1443 def branch(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1444 return encoding.tolocal(self._extra[b'branch']) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1445 |
19688
21e1068109a7
commitablectx: move closesbranch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19687
diff
changeset
|
1446 def closesbranch(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1447 return b'close' in self._extra |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1448 |
19689
8dbb66f339f3
commitablectx: move extra from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19688
diff
changeset
|
1449 def extra(self): |
8dbb66f339f3
commitablectx: move extra from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19688
diff
changeset
|
1450 return self._extra |
19680
fc33fcfa08f2
commitablectx: move modified from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19679
diff
changeset
|
1451 |
34681
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1452 def isinmemory(self): |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1453 return False |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1454 |
19690
65ff9fd67d8d
commitablectx: move tags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19689
diff
changeset
|
1455 def tags(self): |
25688
24cda1dd45ff
workingctx: don't report the tags for its parents
Matt Harbison <matt_harbison@yahoo.com>
parents:
25660
diff
changeset
|
1456 return [] |
19690
65ff9fd67d8d
commitablectx: move tags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19689
diff
changeset
|
1457 |
19691
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1458 def bookmarks(self): |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1459 b = [] |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1460 for p in self.parents(): |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1461 b.extend(p.bookmarks()) |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1462 return b |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1463 |
19692
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1464 def phase(self): |
43963
bbcf78c4ff90
commitablectx: fix the default phase
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43787
diff
changeset
|
1465 phase = phases.newcommitphase(self._repo.ui) |
19692
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1466 for p in self.parents(): |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1467 phase = max(phase, p.phase()) |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1468 return phase |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1469 |
19693
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1470 def hidden(self): |
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1471 return False |
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1472 |
19694
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1473 def children(self): |
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1474 return [] |
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1475 |
44912
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1476 def flags(self, path): |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1477 if '_manifest' in self.__dict__: |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1478 try: |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1479 return self._manifest.flags(path) |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1480 except KeyError: |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1481 return b'' |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1482 |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1483 try: |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1484 return self._flagfunc(path) |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1485 except OSError: |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1486 return b'' |
4234c9af515d
flags: read flag from dirstate/disk for workingcopyctx (issue5743)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44365
diff
changeset
|
1487 |
19696
210cc42a8ac2
commitablectx: move ancestor from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19695
diff
changeset
|
1488 def ancestor(self, c2): |
22389
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
1489 """return the "best" ancestor context of self and c2""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1490 return self._parents[0].ancestor(c2) # punt on two parents for now |
19696
210cc42a8ac2
commitablectx: move ancestor from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19695
diff
changeset
|
1491 |
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1492 def ancestors(self): |
23616
11a160547d7f
context: return dirstate parents in workingctx.ancestors()
Durham Goode <durham@fb.com>
parents:
23603
diff
changeset
|
1493 for p in self._parents: |
11a160547d7f
context: return dirstate parents in workingctx.ancestors()
Durham Goode <durham@fb.com>
parents:
23603
diff
changeset
|
1494 yield p |
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1495 for a in self._repo.changelog.ancestors( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1496 [p.rev() for p in self._parents] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1497 ): |
39957
e1e3d1b498d3
context: reduce dependence of changectx constructor
Martin von Zweigbergk <martinvonz@google.com>
parents:
39907
diff
changeset
|
1498 yield self._repo[a] |
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1499 |
19699
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1500 def markcommitted(self, node): |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1501 """Perform post-commit cleanup necessary after committing this ctx |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1502 |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1503 Specifically, this updates backing stores this working context |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1504 wraps to reflect the fact that the changes reflected by this |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1505 workingctx have been committed. For example, it marks |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1506 modified and added files as normal in the dirstate. |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1507 |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1508 """ |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1509 |
32610
bf728e72a219
context: move dirty() to committablectx
Sean Farley <sean@farley.io>
parents:
32609
diff
changeset
|
1510 def dirty(self, missing=False, merge=True, branch=True): |
bf728e72a219
context: move dirty() to committablectx
Sean Farley <sean@farley.io>
parents:
32609
diff
changeset
|
1511 return False |
bf728e72a219
context: move dirty() to committablectx
Sean Farley <sean@farley.io>
parents:
32609
diff
changeset
|
1512 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1513 |
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1514 class workingctx(committablectx): |
19671
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1515 """A workingctx object makes access to data related to |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1516 the current working directory convenient. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1517 date - any valid date string or (unixtime, offset), or None. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1518 user - username string, or None. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1519 extra - a dictionary of extra values, or None. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1520 changes - a list of file lists as returned by localrepo.status() |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1521 or None to use the repository status. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1522 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1523 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1524 def __init__( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1525 self, repo, text=b"", user=None, date=None, extra=None, changes=None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1526 ): |
42297
62bb49a1d05d
context: default to using branch from dirstate only in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42296
diff
changeset
|
1527 branch = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1528 if not extra or b'branch' not in extra: |
42297
62bb49a1d05d
context: default to using branch from dirstate only in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42296
diff
changeset
|
1529 try: |
62bb49a1d05d
context: default to using branch from dirstate only in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42296
diff
changeset
|
1530 branch = repo.dirstate.branch() |
62bb49a1d05d
context: default to using branch from dirstate only in workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42296
diff
changeset
|
1531 except UnicodeDecodeError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1532 raise error.Abort(_(b'branch name not in UTF-8!')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1533 super(workingctx, self).__init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1534 repo, text, user, date, extra, changes, branch=branch |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1535 ) |
19671
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1536 |
14129
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1537 def __iter__(self): |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1538 d = self._repo.dirstate |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1539 for f in d: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1540 if d[f] != b'r': |
14129
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1541 yield f |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1542 |
21845
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1543 def __contains__(self, key): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1544 return self._repo.dirstate[key] not in b"?r" |
21845
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1545 |
25590
183965a00c76
context: override workingctx.hex() to avoid a crash
Matt Harbison <matt_harbison@yahoo.com>
parents:
25465
diff
changeset
|
1546 def hex(self): |
41967
21cc92fea2aa
context: use wdirhex constant instead of calculating it
Martin von Zweigbergk <martinvonz@google.com>
parents:
41949
diff
changeset
|
1547 return wdirhex |
25590
183965a00c76
context: override workingctx.hex() to avoid a crash
Matt Harbison <matt_harbison@yahoo.com>
parents:
25465
diff
changeset
|
1548 |
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
1549 @propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1550 def _parents(self): |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1551 p = self._repo.dirstate.parents() |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1552 if p[1] == nullid: |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1553 p = p[:-1] |
39959
43d3b09b3e5a
repo: move unfiltered-repo optimization to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
39958
diff
changeset
|
1554 # use unfiltered repo to delay/avoid loading obsmarkers |
43d3b09b3e5a
repo: move unfiltered-repo optimization to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
39958
diff
changeset
|
1555 unfi = self._repo.unfiltered() |
43767
f3b23d5c15fd
changectx: mark the parents of the working copy as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43764
diff
changeset
|
1556 return [ |
f3b23d5c15fd
changectx: mark the parents of the working copy as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43764
diff
changeset
|
1557 changectx( |
f3b23d5c15fd
changectx: mark the parents of the working copy as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43764
diff
changeset
|
1558 self._repo, unfi.changelog.rev(n), n, maybe_filtered=False |
f3b23d5c15fd
changectx: mark the parents of the working copy as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43764
diff
changeset
|
1559 ) |
f3b23d5c15fd
changectx: mark the parents of the working copy as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43764
diff
changeset
|
1560 for n in p |
f3b23d5c15fd
changectx: mark the parents of the working copy as non filtered
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43764
diff
changeset
|
1561 ] |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1562 |
44052
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1563 def setparents(self, p1node, p2node=nullid): |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1564 dirstate = self._repo.dirstate |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1565 with dirstate.parentchange(): |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1566 copies = dirstate.setparents(p1node, p2node) |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1567 pctx = self._repo[p1node] |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1568 if copies: |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1569 # Adjust copy records, the dirstate cannot do it, it |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1570 # requires access to parents manifests. Preserve them |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1571 # only for entries added to first parent. |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1572 for f in copies: |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1573 if f not in pctx and copies[f] in pctx: |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1574 dirstate.copy(copies[f], f) |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1575 if p2node == nullid: |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1576 for f, s in sorted(dirstate.copies().items()): |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1577 if f not in pctx and s not in pctx: |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1578 dirstate.copy(None, f) |
b74270da5eee
workingctx: move setparents() logic from localrepo to mirror overlayworkingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
44051
diff
changeset
|
1579 |
37447
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1580 def _fileinfo(self, path): |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1581 # populate __dict__['_manifest'] as workingctx has no _manifestdelta |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1582 self._manifest |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1583 return super(workingctx, self)._fileinfo(path) |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1584 |
42292
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1585 def _buildflagfunc(self): |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1586 # Create a fallback function for getting file flags when the |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1587 # filesystem doesn't support them |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1588 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1589 copiesget = self._repo.dirstate.copies().get |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1590 parents = self.parents() |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1591 if len(parents) < 2: |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1592 # when we have one parent, it's easy: copy from parent |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1593 man = parents[0].manifest() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1594 |
42292
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1595 def func(f): |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1596 f = copiesget(f, f) |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1597 return man.flags(f) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1598 |
42292
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1599 else: |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1600 # merges are tricky: we try to reconstruct the unstored |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1601 # result from the merge (issue1802) |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1602 p1, p2 = parents |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1603 pa = p1.ancestor(p2) |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1604 m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest() |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1605 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1606 def func(f): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1607 f = copiesget(f, f) # may be wrong for merges with copies |
42292
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1608 fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f) |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1609 if fl1 == fl2: |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1610 return fl1 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1611 if fl1 == fla: |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1612 return fl2 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1613 if fl2 == fla: |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1614 return fl1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1615 return b'' # punt for conflicts |
42292
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1616 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1617 return func |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1618 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1619 @propertycache |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1620 def _flagfunc(self): |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1621 return self._repo.dirstate.flagfunc(self._buildflagfunc) |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1622 |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1623 def flags(self, path): |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1624 try: |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1625 return self._flagfunc(path) |
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1626 except OSError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1627 return b'' |
42292
491855ea9d62
context: move flags overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42291
diff
changeset
|
1628 |
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
1629 def filectx(self, path, filelog=None): |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1630 """get a file context from the working directory""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1631 return workingfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1632 self._repo, path, workingctx=self, filelog=filelog |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1633 ) |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1634 |
16491
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1635 def dirty(self, missing=False, merge=True, branch=True): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43767
diff
changeset
|
1636 """check whether a working directory is modified""" |
11110
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1637 # check subrepos first |
18364
6252b4f1c4b4
subrepos: process subrepos in sorted order
Mads Kiilerich <mads@kiilerich.com>
parents:
18252
diff
changeset
|
1638 for s in sorted(self.substate): |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
33353
diff
changeset
|
1639 if self.sub(s).dirty(missing=missing): |
11110
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1640 return True |
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1641 # check current working dir |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1642 return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1643 (merge and self.p2()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1644 or (branch and self.branch() != self.p1().branch()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1645 or self.modified() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1646 or self.added() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1647 or self.removed() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1648 or (missing and self.deleted()) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1649 ) |
8717
e8de59577257
context: add a dirty method to detect modified contexts
Matt Mackall <mpm@selenic.com>
parents:
8528
diff
changeset
|
1650 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1651 def add(self, list, prefix=b""): |
27809
37a75d69eb43
with: use context manager for wlock in workingctx.add
Bryan O'Sullivan <bryano@fb.com>
parents:
27749
diff
changeset
|
1652 with self._repo.wlock(): |
37a75d69eb43
with: use context manager for wlock in workingctx.add
Bryan O'Sullivan <bryano@fb.com>
parents:
27749
diff
changeset
|
1653 ui, ds = self._repo.ui, self._repo.dirstate |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1654 uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1655 rejected = [] |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1656 lstat = self._repo.wvfs.lstat |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1657 for f in list: |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1658 # ds.pathto() returns an absolute file when this is invoked from |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1659 # the keyword extension. That gets flagged as non-portable on |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1660 # Windows, since it contains the drive letter and colon. |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1661 scmutil.checkportable(ui, os.path.join(prefix, f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1662 try: |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1663 st = lstat(f) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
13962
diff
changeset
|
1664 except OSError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1665 ui.warn(_(b"%s does not exist!\n") % uipath(f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1666 rejected.append(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1667 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1668 limit = ui.configbytes(b'ui', b'large-file-limit') |
38600
a936d1368fc5
ui: make the large file warning limit fully configurable
Joerg Sonnenberger <joerg@bec.de>
parents:
38589
diff
changeset
|
1669 if limit != 0 and st.st_size > limit: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1670 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1671 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1672 b"%s: up to %d MB of RAM may be required " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1673 b"to manage this file\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1674 b"(use 'hg revert %s' to cancel the " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1675 b"pending addition)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1676 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1677 % (f, 3 * st.st_size // 1000000, uipath(f)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1678 ) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1679 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1680 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1681 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1682 b"%s not added: only files and symlinks " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1683 b"supported currently\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1684 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1685 % uipath(f) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1686 ) |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1687 rejected.append(f) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1688 elif ds[f] in b'amn': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1689 ui.warn(_(b"%s already tracked!\n") % uipath(f)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1690 elif ds[f] == b'r': |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1691 ds.normallookup(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1692 else: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1693 ds.add(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1694 return rejected |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1695 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1696 def forget(self, files, prefix=b""): |
27810
8c81975fe145
with: use context manager for wlock in workingctx.forget
Bryan O'Sullivan <bryano@fb.com>
parents:
27809
diff
changeset
|
1697 with self._repo.wlock(): |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1698 ds = self._repo.dirstate |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1699 uipath = lambda f: ds.pathto(pathutil.join(prefix, f)) |
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1700 rejected = [] |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1701 for f in files: |
41612
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1702 if f not in ds: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1703 self._repo.ui.warn(_(b"%s not tracked!\n") % uipath(f)) |
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1704 rejected.append(f) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1705 elif ds[f] != b'a': |
41612
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1706 ds.remove(f) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1707 else: |
41612
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1708 ds.drop(f) |
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1709 return rejected |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1710 |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1711 def copy(self, source, dest): |
19902
12a8bdd97b4f
context: use "vfs.lstat()" to examine target path instead of "os.path.*"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19901
diff
changeset
|
1712 try: |
12a8bdd97b4f
context: use "vfs.lstat()" to examine target path instead of "os.path.*"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19901
diff
changeset
|
1713 st = self._repo.wvfs.lstat(dest) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25600
diff
changeset
|
1714 except OSError as err: |
19902
12a8bdd97b4f
context: use "vfs.lstat()" to examine target path instead of "os.path.*"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19901
diff
changeset
|
1715 if err.errno != errno.ENOENT: |
12a8bdd97b4f
context: use "vfs.lstat()" to examine target path instead of "os.path.*"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19901
diff
changeset
|
1716 raise |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1717 self._repo.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1718 _(b"%s does not exist!\n") % self._repo.dirstate.pathto(dest) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1719 ) |
19902
12a8bdd97b4f
context: use "vfs.lstat()" to examine target path instead of "os.path.*"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19901
diff
changeset
|
1720 return |
12a8bdd97b4f
context: use "vfs.lstat()" to examine target path instead of "os.path.*"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19901
diff
changeset
|
1721 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1722 self._repo.ui.warn( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1723 _(b"copy failed: %s is not a file or a symbolic link\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1724 % self._repo.dirstate.pathto(dest) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1725 ) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1726 else: |
27812
28d0c0ef327b
with: use context manager for wlock in copy
Bryan O'Sullivan <bryano@fb.com>
parents:
27811
diff
changeset
|
1727 with self._repo.wlock(): |
41612
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1728 ds = self._repo.dirstate |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1729 if ds[dest] in b'?': |
41612
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1730 ds.add(dest) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1731 elif ds[dest] in b'r': |
41612
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1732 ds.normallookup(dest) |
fbd4ce55bcbd
context: replace repeated "self._repo.dirstate" by "ds" variable
Martin von Zweigbergk <martinvonz@google.com>
parents:
41611
diff
changeset
|
1733 ds.copy(source, dest) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1734 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1735 def match( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1736 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1737 pats=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1738 include=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1739 exclude=None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1740 default=b'glob', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1741 listsubrepos=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1742 badfn=None, |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
1743 cwd=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1744 ): |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1745 r = self._repo |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
1746 if not cwd: |
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
1747 cwd = r.getcwd() |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1748 |
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1749 # Only a case insensitive filesystem needs magic to translate user input |
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1750 # to actual case in the filesystem. |
32401
284b18303f61
match: replace icasefsmatch() function by flag to regular match()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32395
diff
changeset
|
1751 icasefs = not util.fscasesensitive(r.root) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1752 return matchmod.match( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1753 r.root, |
44009
e685fac56693
match: resolve filesets against the passed `cwd`, not the current one
Matt Harbison <matt_harbison@yahoo.com>
parents:
43963
diff
changeset
|
1754 cwd, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1755 pats, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1756 include, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1757 exclude, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1758 default, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1759 auditor=r.auditor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1760 ctx=self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1761 listsubrepos=listsubrepos, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1762 badfn=badfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1763 icasefs=icasefs, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1764 ) |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1765 |
21393
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1766 def _filtersuspectsymlink(self, files): |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1767 if not files or self._repo.dirstate._checklink: |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1768 return files |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1769 |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1770 # Symlink placeholders may get non-symlink-like contents |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1771 # via user error or dereferencing by NFS or Samba servers, |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1772 # so we filter out any placeholders that don't look like a |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1773 # symlink |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1774 sane = [] |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1775 for f in files: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1776 if self.flags(f) == b'l': |
21393
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1777 d = self[f].data() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1778 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1779 d == b'' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1780 or len(d) >= 1024 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1781 or b'\n' in d |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1782 or stringutil.binary(d) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1783 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1784 self._repo.ui.debug( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1785 b'ignoring suspect symlink placeholder "%s"\n' % f |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1786 ) |
21393
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1787 continue |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1788 sane.append(f) |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1789 return sane |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1790 |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1791 def _checklookup(self, files): |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1792 # check for any possibly clean files |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1793 if not files: |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1794 return [], [], [] |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1795 |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1796 modified = [] |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1797 deleted = [] |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1798 fixup = [] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1799 pctx = self._parents[0] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1800 # do a full compare of any files that might have changed |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1801 for f in sorted(files): |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1802 try: |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1803 # This will return True for a file that got replaced by a |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1804 # directory in the interim, but fixing that is pretty hard. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1805 if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1806 f not in pctx |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1807 or self.flags(f) != pctx.flags(f) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1808 or pctx[f].cmp(self[f]) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1809 ): |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1810 modified.append(f) |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1811 else: |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1812 fixup.append(f) |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1813 except (IOError, OSError): |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1814 # A file become inaccessible in between? Mark it as deleted, |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1815 # matching dirstate behavior (issue5584). |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1816 # The dirstate has more complex behavior around whether a |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1817 # missing file matches a directory, etc, but we don't need to |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1818 # bother with that: if f has made it to this point, we're sure |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1819 # it's in the dirstate. |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1820 deleted.append(f) |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1821 |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1822 return modified, deleted, fixup |
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1823 |
32813
6d73b7ff8f92
workingctx: also pass status tuple into poststatusfixup
Siddharth Agarwal <sid0@fb.com>
parents:
32812
diff
changeset
|
1824 def _poststatusfixup(self, status, fixup): |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1825 """update dirstate for files that are actually clean""" |
32814
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1826 poststatus = self._repo.postdsstatus() |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1827 if fixup or poststatus: |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1828 try: |
32752
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1829 oldid = self._repo.dirstate.identity() |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1830 |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1831 # updating the dirstate is optional |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1832 # so we don't wait on the lock |
21990
48e32c2c499b
context: call normal on the right object
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
1833 # wlock can invalidate the dirstate, so cache normal _after_ |
48e32c2c499b
context: call normal on the right object
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
1834 # taking the lock |
27813
ff20fe74e5c6
with: use context manager for wlock in checklookup
Bryan O'Sullivan <bryano@fb.com>
parents:
27812
diff
changeset
|
1835 with self._repo.wlock(False): |
32752
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1836 if self._repo.dirstate.identity() == oldid: |
32814
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1837 if fixup: |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1838 normal = self._repo.dirstate.normal |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1839 for f in fixup: |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1840 normal(f) |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1841 # write changes out explicitly, because nesting |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1842 # wlock at runtime may prevent 'wlock.release()' |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1843 # after this block from doing so for subsequent |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1844 # changing files |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1845 tr = self._repo.currenttransaction() |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1846 self._repo.dirstate.write(tr) |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1847 |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1848 if poststatus: |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1849 for ps in poststatus: |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1850 ps(self, status) |
32752
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1851 else: |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1852 # in this case, writing changes out breaks |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1853 # consistency, because .hg/dirstate was |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1854 # already changed simultaneously after last |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1855 # caching (see also issue5584 for detail) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1856 self._repo.ui.debug( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1857 b'skip updating dirstate: identity mismatch\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1858 ) |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1859 except error.LockError: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1860 pass |
32814
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1861 finally: |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1862 # Even if the wlock couldn't be grabbed, clear out the list. |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1863 self._repo.clearpostdsstatus() |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1864 |
33937
e43264525ce5
context: remove unnecessary default values for matchers (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33936
diff
changeset
|
1865 def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1866 '''Gets the status from the dirstate -- internal use only.''' |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1867 subrepos = [] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1868 if b'.hgsub' in self: |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1869 subrepos = sorted(self.substate) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1870 cmp, s = self._repo.dirstate.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1871 match, subrepos, ignored=ignored, clean=clean, unknown=unknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1872 ) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1873 |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1874 # check for any possibly clean files |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1875 fixup = [] |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1876 if cmp: |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1877 modified2, deleted2, fixup = self._checklookup(cmp) |
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1878 s.modified.extend(modified2) |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1879 s.deleted.extend(deleted2) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1880 |
34344
ac0cd81e2f83
dirstate: use keyword arguments to clarify status()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34343
diff
changeset
|
1881 if fixup and clean: |
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1882 s.clean.extend(fixup) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1883 |
32813
6d73b7ff8f92
workingctx: also pass status tuple into poststatusfixup
Siddharth Agarwal <sid0@fb.com>
parents:
32812
diff
changeset
|
1884 self._poststatusfixup(s, fixup) |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1885 |
23776
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1886 if match.always(): |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1887 # cache for performance |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1888 if s.unknown or s.ignored or s.clean: |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1889 # "_status" is cached with list*=False in the normal route |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1890 self._status = scmutil.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1891 s.modified, s.added, s.removed, s.deleted, [], [], [] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1892 ) |
23776
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1893 else: |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1894 self._status = s |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1895 |
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1896 return s |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1897 |
31259
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1898 @propertycache |
42291
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1899 def _copies(self): |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1900 p1copies = {} |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1901 p2copies = {} |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1902 parents = self._repo.dirstate.parents() |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1903 p1manifest = self._repo[parents[0]].manifest() |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1904 p2manifest = self._repo[parents[1]].manifest() |
42859
2b869a515ba6
context: filter out invalid copies from workingctx.p[12]copies()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42769
diff
changeset
|
1905 changedset = set(self.added()) | set(self.modified()) |
42291
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1906 narrowmatch = self._repo.narrowmatch() |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1907 for dst, src in self._repo.dirstate.copies().items(): |
42859
2b869a515ba6
context: filter out invalid copies from workingctx.p[12]copies()
Martin von Zweigbergk <martinvonz@google.com>
parents:
42769
diff
changeset
|
1908 if dst not in changedset or not narrowmatch(dst): |
42291
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1909 continue |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1910 if src in p1manifest: |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1911 p1copies[dst] = src |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1912 elif src in p2manifest: |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1913 p2copies[dst] = src |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1914 return p1copies, p2copies |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1915 |
a13b30555ffb
context: reuse changectx._copies() in all but workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42290
diff
changeset
|
1916 @propertycache |
31259
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1917 def _manifest(self): |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1918 """generate a manifest corresponding to the values in self._status |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1919 |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1920 This reuse the file nodeid from parent, but we use special node |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1921 identifiers for added and modified files. This is used by manifests |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1922 merge to see that files are different and by update logic to avoid |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1923 deleting newly added files. |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1924 """ |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1925 return self._buildstatusmanifest(self._status) |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1926 |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1927 def _buildstatusmanifest(self, status): |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1928 """Builds a manifest that includes the given status results.""" |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1929 parents = self.parents() |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1930 |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1931 man = parents[0].manifest().copy() |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1932 |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1933 ff = self._flagfunc |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1934 for i, l in ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1935 (addednodeid, status.added), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1936 (modifiednodeid, status.modified), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1937 ): |
31259
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1938 for f in l: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1939 man[f] = i |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1940 try: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1941 man.setflag(f, ff(f)) |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1942 except OSError: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1943 pass |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1944 |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1945 for f in status.deleted + status.removed: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1946 if f in man: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1947 del man[f] |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1948 |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1949 return man |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1950 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1951 def _buildstatus( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1952 self, other, s, match, listignored, listclean, listunknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1953 ): |
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1954 """build a status with respect to another context |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1955 |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1956 This includes logic for maintaining the fast path of status when |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1957 comparing the working directory against its parent, which is to skip |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1958 building a new manifest if self (working directory) is not comparing |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1959 against its parent (repo['.']). |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1960 """ |
23239
9fbb50444d55
context.status: call _dirstatestatus() from within _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23238
diff
changeset
|
1961 s = self._dirstatestatus(match, listignored, listclean, listunknown) |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23410
diff
changeset
|
1962 # Filter out symlinks that, in the case of FAT32 and NTFS filesystems, |
23242
18168938e1c1
context.status: only filter suspect symlinks in the dirstate status
Martin von Zweigbergk <martinvonz@google.com>
parents:
23241
diff
changeset
|
1963 # might have accidentally ended up with the entire contents of the file |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23410
diff
changeset
|
1964 # they are supposed to be linking to. |
23302
24f67ad49da7
context.status: make _dirstatestatus() return an status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23301
diff
changeset
|
1965 s.modified[:] = self._filtersuspectsymlink(s.modified) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1966 if other != self._repo[b'.']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1967 s = super(workingctx, self)._buildstatus( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1968 other, s, match, listignored, listclean, listunknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1969 ) |
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1970 return s |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1971 |
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
1972 def _matchstatus(self, other, match): |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1973 """override the match method with a filter for directory patterns |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1974 |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1975 We use inheritance to customize the match.bad method only in cases of |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1976 workingctx since it belongs only to the working directory when |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1977 comparing against the parent changeset. |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1978 |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1979 If we aren't comparing against the working directory's parent, then we |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1980 just use the default match object sent to us. |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1981 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1982 if other != self._repo[b'.']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1983 |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1984 def bad(f, msg): |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1985 # 'f' may be a directory pattern from 'match.files()', |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1986 # so 'f not in ctx1' is not enough |
24326
637da5711122
manifest: have context use self.hasdir()
Drew Gottlieb <drgott@google.com>
parents:
24325
diff
changeset
|
1987 if f not in other and not other.hasdir(f): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1988 self._repo.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1989 b'%s: %s\n' % (self._repo.dirstate.pathto(f), msg) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1990 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1991 |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1992 match.bad = bad |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1993 return match |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1994 |
42293
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
1995 def walk(self, match): |
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
1996 '''Generates matching file names.''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1997 return sorted( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1998 self._repo.dirstate.walk( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
1999 self._repo.narrowmatch(match), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2000 subrepos=sorted(self.substate), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2001 unknown=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2002 ignored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2003 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2004 ) |
42293
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
2005 |
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
2006 def matches(self, match): |
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
2007 match = self._repo.narrowmatch(match) |
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
2008 ds = self._repo.dirstate |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2009 return sorted(f for f in ds.matches(match) if ds[f] != b'r') |
42293
4fbfc893e6b9
context: move walk() and match() overrides from committablectx to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42292
diff
changeset
|
2010 |
33353
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
2011 def markcommitted(self, node): |
42295
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2012 with self._repo.dirstate.parentchange(): |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2013 for f in self.modified() + self.added(): |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2014 self._repo.dirstate.normal(f) |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2015 for f in self.removed(): |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2016 self._repo.dirstate.drop(f) |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2017 self._repo.dirstate.setparents(node) |
44104
85c4cd73996b
localrepo: also fastpath access to working copy parents when possible
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44052
diff
changeset
|
2018 self._repo._quick_access_changeid_invalidate() |
42295
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2019 |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2020 # write changes out explicitly, because nesting wlock at |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2021 # runtime may prevent 'wlock.release()' in 'repo.commit()' |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2022 # from immediately doing so for subsequent changing files |
fdd4d668ceb5
context: move contents of committablectx.markcommitted() to workingctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42293
diff
changeset
|
2023 self._repo.dirstate.write(self._repo.currenttransaction()) |
33353
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
2024 |
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
2025 sparse.aftercommit(self._repo, node) |
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
2026 |
44857
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
2027 def mergestate(self, clean=False): |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
2028 if clean: |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
2029 return mergestatemod.mergestate.clean(self._repo) |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
2030 return mergestatemod.mergestate.read(self._repo) |
e607099d8b93
context: implement mergestate() method
Augie Fackler <augie@google.com>
parents:
44365
diff
changeset
|
2031 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2032 |
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
2033 class committablefilectx(basefilectx): |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
2034 """A committablefilectx provides common functionality for a file context |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
2035 that wants the ability to commit, e.g. workingfilectx or memfilectx.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2036 |
19701
f0f8380ec516
commitablefilectx: add a class that will be used for mutable file contexts
Sean Farley <sean.michael.farley@gmail.com>
parents:
19700
diff
changeset
|
2037 def __init__(self, repo, path, filelog=None, ctx=None): |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2038 self._repo = repo |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2039 self._path = path |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2040 self._changeid = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2041 self._filerev = self._filenode = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2042 |
19149
921b64e1f7b9
filecontext: use 'is not None' to check for filelog existence
Durham Goode <durham@fb.com>
parents:
19061
diff
changeset
|
2043 if filelog is not None: |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2044 self._filelog = filelog |
19702
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
2045 if ctx: |
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
2046 self._changectx = ctx |
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
2047 |
19703
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
2048 def __nonzero__(self): |
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
2049 return True |
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
2050 |
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
2051 __bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
2052 |
24420
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
2053 def linkrev(self): |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
2054 # linked to self._changectx no matter if file is modified or not |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
2055 return self.rev() |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
2056 |
41770
c7a843aa4b42
context: move equivalent renamed() implementations to superclass
Martin von Zweigbergk <martinvonz@google.com>
parents:
41769
diff
changeset
|
2057 def renamed(self): |
c7a843aa4b42
context: move equivalent renamed() implementations to superclass
Martin von Zweigbergk <martinvonz@google.com>
parents:
41769
diff
changeset
|
2058 path = self.copysource() |
c7a843aa4b42
context: move equivalent renamed() implementations to superclass
Martin von Zweigbergk <martinvonz@google.com>
parents:
41769
diff
changeset
|
2059 if not path: |
c7a843aa4b42
context: move equivalent renamed() implementations to superclass
Martin von Zweigbergk <martinvonz@google.com>
parents:
41769
diff
changeset
|
2060 return None |
c7a843aa4b42
context: move equivalent renamed() implementations to superclass
Martin von Zweigbergk <martinvonz@google.com>
parents:
41769
diff
changeset
|
2061 return path, self._changectx._parents[0]._manifest.get(path, nullid) |
c7a843aa4b42
context: move equivalent renamed() implementations to superclass
Martin von Zweigbergk <martinvonz@google.com>
parents:
41769
diff
changeset
|
2062 |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2063 def parents(self): |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2064 '''return parent filectxs, following copies if necessary''' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2065 |
8528
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2066 def filenode(ctx, path): |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2067 return ctx._manifest.get(path, nullid) |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2068 |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2069 path = self._path |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2070 fl = self._filelog |
8528
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2071 pcl = self._changectx._parents |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2072 renamed = self.renamed() |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2073 |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2074 if renamed: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2075 pl = [renamed + (None,)] |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2076 else: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2077 pl = [(path, filenode(pcl[0], path), fl)] |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2078 |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2079 for pc in pcl[1:]: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
2080 pl.append((path, filenode(pc, path), fl)) |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2081 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2082 return [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2083 self._parentfilectx(p, fileid=n, filelog=l) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2084 for p, n, l in pl |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2085 if n != nullid |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2086 ] |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
2087 |
19705
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
2088 def children(self): |
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
2089 return [] |
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
2090 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2091 |
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
2092 class workingfilectx(committablefilectx): |
19704
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2093 """A workingfilectx object makes access to data related to a particular |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2094 file in the working directory convenient.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2095 |
19704
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2096 def __init__(self, repo, path, filelog=None, workingctx=None): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2097 super(workingfilectx, self).__init__(repo, path, filelog, workingctx) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2098 |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2099 @propertycache |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2100 def _changectx(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2101 return workingctx(self._repo) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2102 |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2103 def data(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2104 return self._repo.wread(self._path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2105 |
41768
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
2106 def copysource(self): |
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
2107 return self._repo.dirstate.copied(self._path) |
19704
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
2108 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2109 def size(self): |
19901
4d3ce1646dfc
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19900
diff
changeset
|
2110 return self._repo.wvfs.lstat(self._path).st_size |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2111 |
42456
87a34c767384
merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42407
diff
changeset
|
2112 def lstat(self): |
87a34c767384
merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42407
diff
changeset
|
2113 return self._repo.wvfs.lstat(self._path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2114 |
3962
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
2115 def date(self): |
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
2116 t, tz = self._changectx.date() |
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
2117 try: |
36781
ffa3026d4196
cleanup: use stat_result[stat.ST_MTIME] instead of stat_result.st_mtime
Augie Fackler <augie@google.com>
parents:
36721
diff
changeset
|
2118 return (self._repo.wvfs.lstat(self._path)[stat.ST_MTIME], tz) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25600
diff
changeset
|
2119 except OSError as err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2120 if err.errno != errno.ENOENT: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2121 raise |
3962
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
2122 return (t, tz) |
3310
0e370798eebf
context: add cmp for filectxs
Matt Mackall <mpm@selenic.com>
parents:
3302
diff
changeset
|
2123 |
33283
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
2124 def exists(self): |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
2125 return self._repo.wvfs.exists(self._path) |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
2126 |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
2127 def lexists(self): |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
2128 return self._repo.wvfs.lexists(self._path) |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
2129 |
33086
eb4c49f55f1f
workingfilectx: add audit() as a wrapper for wvfs.audit()
Phil Cohen <phillco@fb.com>
parents:
33085
diff
changeset
|
2130 def audit(self): |
eb4c49f55f1f
workingfilectx: add audit() as a wrapper for wvfs.audit()
Phil Cohen <phillco@fb.com>
parents:
33085
diff
changeset
|
2131 return self._repo.wvfs.audit(self._path) |
eb4c49f55f1f
workingfilectx: add audit() as a wrapper for wvfs.audit()
Phil Cohen <phillco@fb.com>
parents:
33085
diff
changeset
|
2132 |
11702
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
2133 def cmp(self, fctx): |
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
2134 """compare with other file context |
11539
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11538
diff
changeset
|
2135 |
11702
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
2136 returns True if different than fctx. |
11539
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11538
diff
changeset
|
2137 """ |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17424
diff
changeset
|
2138 # fctx should be a filectx (not a workingfilectx) |
11703
55a2af02e45c
context: reuse filecontext.cmp in workingfilecontext.cmp
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11702
diff
changeset
|
2139 # invert comparison to reuse the same code path |
55a2af02e45c
context: reuse filecontext.cmp in workingfilecontext.cmp
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11702
diff
changeset
|
2140 return fctx.cmp(self) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2141 |
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
2142 def remove(self, ignoremissing=False): |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
2143 """wraps unlink for a repo's working directory""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2144 rmdir = self._repo.ui.configbool(b'experimental', b'removeemptydirs') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2145 self._repo.wvfs.unlinkpath( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2146 self._path, ignoremissing=ignoremissing, rmdir=rmdir |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2147 ) |
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
2148 |
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2149 def write(self, data, flags, backgroundclose=False, **kwargs): |
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
2150 """wraps repo.wwrite""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2151 return self._repo.wwrite( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2152 self._path, data, flags, backgroundclose=backgroundclose, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2153 ) |
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
2154 |
34787
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
2155 def markcopied(self, src): |
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
2156 """marks this file a copy of `src`""" |
42318
313812cbf4ca
copies: fix duplicatecopies() with overlay context
Martin von Zweigbergk <martinvonz@google.com>
parents:
42297
diff
changeset
|
2157 self._repo.dirstate.copy(src, self._path) |
34787
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
2158 |
34037
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
2159 def clearunknown(self): |
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
2160 """Removes conflicting items in the working directory so that |
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
2161 ``write()`` can be called successfully. |
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
2162 """ |
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
2163 wvfs = self._repo.wvfs |
34556
7a8a16f8ea22
context: also consider path conflicts when clearing unknown files
Mark Thomas <mbthomas@fb.com>
parents:
34479
diff
changeset
|
2164 f = self._path |
34833
07bbb208a924
context: audit paths before clearing unknown files and dirs
Mark Thomas <mbthomas@fb.com>
parents:
34787
diff
changeset
|
2165 wvfs.audit(f) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2166 if self._repo.ui.configbool( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2167 b'experimental', b'merge.checkpathconflicts' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2168 ): |
39196
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2169 # remove files under the directory as they should already be |
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2170 # warned and backed up |
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2171 if wvfs.isdir(f) and not wvfs.islink(f): |
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2172 wvfs.rmtree(f, forcibly=True) |
43633
0b7733719d21
utils: move finddirs() to pathutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43506
diff
changeset
|
2173 for p in reversed(list(pathutil.finddirs(f))): |
37101
656ac240f392
context: skip path conflicts by default when clearing unknown file (issue5776)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37084
diff
changeset
|
2174 if wvfs.isfileorlink(p): |
656ac240f392
context: skip path conflicts by default when clearing unknown file (issue5776)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37084
diff
changeset
|
2175 wvfs.unlink(p) |
656ac240f392
context: skip path conflicts by default when clearing unknown file (issue5776)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37084
diff
changeset
|
2176 break |
39196
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2177 else: |
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2178 # don't remove files if path conflicts are not processed |
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2179 if wvfs.isdir(f) and not wvfs.islink(f): |
8c6775e812d8
merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents:
38761
diff
changeset
|
2180 wvfs.removedirs(f) |
34037
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
2181 |
33084
873f638fd7db
merge: change repo.wvfs.setflags calls to a new wctx[f].setflags function
Phil Cohen <phillco@fb.com>
parents:
33022
diff
changeset
|
2182 def setflags(self, l, x): |
873f638fd7db
merge: change repo.wvfs.setflags calls to a new wctx[f].setflags function
Phil Cohen <phillco@fb.com>
parents:
33022
diff
changeset
|
2183 self._repo.wvfs.setflags(self._path, l, x) |
873f638fd7db
merge: change repo.wvfs.setflags calls to a new wctx[f].setflags function
Phil Cohen <phillco@fb.com>
parents:
33022
diff
changeset
|
2184 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2185 |
35323
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
2186 class overlayworkingctx(committablectx): |
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
2187 """Wraps another mutable context with a write-back cache that can be |
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
2188 converted into a commit context. |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2189 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2190 self._cache[path] maps to a dict with keys: { |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2191 'exists': bool? |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2192 'date': date? |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2193 'data': str? |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2194 'flags': str? |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2195 'copied': str? (path or None) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2196 } |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2197 If `exists` is True, `flags` must be non-None and 'date' is non-None. If it |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2198 is `False`, the file was deleted. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2199 """ |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2200 |
35289
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
2201 def __init__(self, repo): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2202 super(overlayworkingctx, self).__init__(repo) |
35286
307b1689e3f8
overlayworkingctx: make clean() public
Phil Cohen <phillco@fb.com>
parents:
35285
diff
changeset
|
2203 self.clean() |
35289
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
2204 |
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
2205 def setbase(self, wrappedctx): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2206 self._wrappedctx = wrappedctx |
35289
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
2207 self._parents = [wrappedctx] |
35327
777cb4497d8d
overlayworkingctx: invalidate the manifest cache when changing parents
Phil Cohen <phillco@fb.com>
parents:
35326
diff
changeset
|
2208 # Drop old manifest cache as it is now out of date. |
777cb4497d8d
overlayworkingctx: invalidate the manifest cache when changing parents
Phil Cohen <phillco@fb.com>
parents:
35326
diff
changeset
|
2209 # This is necessary when, e.g., rebasing several nodes with one |
777cb4497d8d
overlayworkingctx: invalidate the manifest cache when changing parents
Phil Cohen <phillco@fb.com>
parents:
35326
diff
changeset
|
2210 # ``overlayworkingctx`` (e.g. with --collapse). |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2211 util.clearcachedproperty(self, b'_manifest') |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2212 |
44051
436d106de670
overlayworkginctx: implement a setparents() to mirror dirstate.setparents()
Martin von Zweigbergk <martinvonz@google.com>
parents:
44050
diff
changeset
|
2213 def setparents(self, p1node, p2node=nullid): |
436d106de670
overlayworkginctx: implement a setparents() to mirror dirstate.setparents()
Martin von Zweigbergk <martinvonz@google.com>
parents:
44050
diff
changeset
|
2214 assert p1node == self._wrappedctx.node() |
436d106de670
overlayworkginctx: implement a setparents() to mirror dirstate.setparents()
Martin von Zweigbergk <martinvonz@google.com>
parents:
44050
diff
changeset
|
2215 self._parents = [self._wrappedctx, self._repo.unfiltered()[p2node]] |
436d106de670
overlayworkginctx: implement a setparents() to mirror dirstate.setparents()
Martin von Zweigbergk <martinvonz@google.com>
parents:
44050
diff
changeset
|
2216 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2217 def data(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2218 if self.isdirty(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2219 if self._cache[path][b'exists']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2220 if self._cache[path][b'data'] is not None: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2221 return self._cache[path][b'data'] |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2222 else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2223 # Must fallback here, too, because we only set flags. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2224 return self._wrappedctx[path].data() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2225 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2226 raise error.ProgrammingError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2227 b"No such file or directory: %s" % path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2228 ) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2229 else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2230 return self._wrappedctx[path].data() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2231 |
35321
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2232 @propertycache |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2233 def _manifest(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2234 parents = self.parents() |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2235 man = parents[0].manifest().copy() |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2236 |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2237 flag = self._flagfunc |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2238 for path in self.added(): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2239 man[path] = addednodeid |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2240 man.setflag(path, flag(path)) |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2241 for path in self.modified(): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2242 man[path] = modifiednodeid |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2243 man.setflag(path, flag(path)) |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2244 for path in self.removed(): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2245 del man[path] |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2246 return man |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2247 |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2248 @propertycache |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2249 def _flagfunc(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2250 def f(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2251 return self._cache[path][b'flags'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2252 |
35321
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2253 return f |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2254 |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2255 def files(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2256 return sorted(self.added() + self.modified() + self.removed()) |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2257 |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2258 def modified(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2259 return [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2260 f |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2261 for f in self._cache.keys() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2262 if self._cache[f][b'exists'] and self._existsinparent(f) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2263 ] |
35321
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2264 |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2265 def added(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2266 return [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2267 f |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2268 for f in self._cache.keys() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2269 if self._cache[f][b'exists'] and not self._existsinparent(f) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2270 ] |
35321
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2271 |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2272 def removed(self): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2273 return [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2274 f |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2275 for f in self._cache.keys() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2276 if not self._cache[f][b'exists'] and self._existsinparent(f) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2277 ] |
35321
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
2278 |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2279 def p1copies(self): |
44039
f652b7ddc1d4
overlwayworkingctx: remove doubly bad reference to wrapped ctx for copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44023
diff
changeset
|
2280 copies = {} |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2281 narrowmatch = self._repo.narrowmatch() |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2282 for f in self._cache.keys(): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2283 if not narrowmatch(f): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2284 continue |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2285 copies.pop(f, None) # delete if it exists |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2286 source = self._cache[f][b'copied'] |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2287 if source: |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2288 copies[f] = source |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2289 return copies |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2290 |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2291 def p2copies(self): |
44039
f652b7ddc1d4
overlwayworkingctx: remove doubly bad reference to wrapped ctx for copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44023
diff
changeset
|
2292 copies = {} |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2293 narrowmatch = self._repo.narrowmatch() |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2294 for f in self._cache.keys(): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2295 if not narrowmatch(f): |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2296 continue |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2297 copies.pop(f, None) # delete if it exists |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2298 source = self._cache[f][b'copied'] |
41755
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2299 if source: |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2300 copies[f] = source |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2301 return copies |
a4358f7345b4
context: introduce p[12]copies() methods and debugp[12]copies commands
Martin von Zweigbergk <martinvonz@google.com>
parents:
41646
diff
changeset
|
2302 |
34681
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
2303 def isinmemory(self): |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
2304 return True |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
2305 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2306 def filedate(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2307 if self.isdirty(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2308 return self._cache[path][b'date'] |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2309 else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2310 return self._wrappedctx[path].date() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2311 |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2312 def markcopied(self, path, origin): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2313 self._markdirty( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2314 path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2315 exists=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2316 date=self.filedate(path), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2317 flags=self.flags(path), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2318 copied=origin, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2319 ) |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2320 |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2321 def copydata(self, path): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2322 if self.isdirty(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2323 return self._cache[path][b'copied'] |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2324 else: |
42288
cdcebc897529
overlaycontext: allow calling copydata() on clean context
Martin von Zweigbergk <martinvonz@google.com>
parents:
42193
diff
changeset
|
2325 return None |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2326 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2327 def flags(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2328 if self.isdirty(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2329 if self._cache[path][b'exists']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2330 return self._cache[path][b'flags'] |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2331 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2332 raise error.ProgrammingError( |
44934
b2e5ec0c596b
context: fix creation of ProgrammingError to not use non-existent field
Martin von Zweigbergk <martinvonz@google.com>
parents:
44916
diff
changeset
|
2333 b"No such file or directory: %s" % path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2334 ) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2335 else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2336 return self._wrappedctx[path].flags() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2337 |
40803
44c2e80db985
rebase: fix dir/file conflict detection when using in-mem merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
40302
diff
changeset
|
2338 def __contains__(self, key): |
44c2e80db985
rebase: fix dir/file conflict detection when using in-mem merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
40302
diff
changeset
|
2339 if key in self._cache: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2340 return self._cache[key][b'exists'] |
40803
44c2e80db985
rebase: fix dir/file conflict detection when using in-mem merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
40302
diff
changeset
|
2341 return key in self.p1() |
44c2e80db985
rebase: fix dir/file conflict detection when using in-mem merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
40302
diff
changeset
|
2342 |
35295
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2343 def _existsinparent(self, path): |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2344 try: |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2345 # ``commitctx` raises a ``ManifestLookupError`` if a path does not |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2346 # exist, unlike ``workingctx``, which returns a ``workingfilectx`` |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2347 # with an ``exists()`` function. |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2348 self._wrappedctx[path] |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2349 return True |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2350 except error.ManifestLookupError: |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2351 return False |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2352 |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2353 def _auditconflicts(self, path): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2354 """Replicates conflict checks done by wvfs.write(). |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2355 |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2356 Since we never write to the filesystem and never call `applyupdates` in |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2357 IMM, we'll never check that a path is actually writable -- e.g., because |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2358 it adds `a/foo`, but `a` is actually a file in the other commit. |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2359 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2360 |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2361 def fail(path, component): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2362 # p1() is the base and we're receiving "writes" for p2()'s |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2363 # files. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2364 if b'l' in self.p1()[component].flags(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2365 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2366 b"error: %s conflicts with symlink %s " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2367 b"in %d." % (path, component, self.p1().rev()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2368 ) |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2369 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2370 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2371 b"error: '%s' conflicts with file '%s' in " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2372 b"%d." % (path, component, self.p1().rev()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2373 ) |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2374 |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2375 # Test that each new directory to be created to write this path from p2 |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2376 # is not a file in p1. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2377 components = path.split(b'/') |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38775
diff
changeset
|
2378 for i in pycompat.xrange(len(components)): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2379 component = b"/".join(components[0:i]) |
40803
44c2e80db985
rebase: fix dir/file conflict detection when using in-mem merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
40302
diff
changeset
|
2380 if component in self: |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2381 fail(path, component) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2382 |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2383 # Test the other direction -- that this path from p2 isn't a directory |
40816
1c8c54cf9725
rebase: fix path auditing to audit path relative to repo root (issue5818)
Martin von Zweigbergk <martinvonz@google.com>
parents:
40803
diff
changeset
|
2384 # in p1 (test that p1 doesn't have any paths matching `path/*`). |
42102
976f069e0ad6
overlayworkingctx: remove misleading trailing slash from directory pattern
Martin von Zweigbergk <martinvonz@google.com>
parents:
42101
diff
changeset
|
2385 match = self.match([path], default=b'path') |
44263
beea86e4d332
context: use manifest.walk() instead of manifest.match() to get file list
Augie Fackler <augie@google.com>
parents:
44109
diff
changeset
|
2386 mfiles = list(self.p1().manifest().walk(match)) |
39576
fa4d16daf1be
context: don't count deleted files as candidates for path conflicts in IMM
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39292
diff
changeset
|
2387 if len(mfiles) > 0: |
fa4d16daf1be
context: don't count deleted files as candidates for path conflicts in IMM
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39292
diff
changeset
|
2388 if len(mfiles) == 1 and mfiles[0] == path: |
fa4d16daf1be
context: don't count deleted files as candidates for path conflicts in IMM
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39292
diff
changeset
|
2389 return |
fa4d16daf1be
context: don't count deleted files as candidates for path conflicts in IMM
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39292
diff
changeset
|
2390 # omit the files which are deleted in current IMM wctx |
40803
44c2e80db985
rebase: fix dir/file conflict detection when using in-mem merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
40302
diff
changeset
|
2391 mfiles = [m for m in mfiles if m in self] |
39576
fa4d16daf1be
context: don't count deleted files as candidates for path conflicts in IMM
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39292
diff
changeset
|
2392 if not mfiles: |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2393 return |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2394 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2395 b"error: file '%s' cannot be written because " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2396 b" '%s/' is a directory in %s (containing %d " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2397 b"entries: %s)" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2398 % (path, path, self.p1(), len(mfiles), b', '.join(mfiles)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2399 ) |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2400 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2401 def write(self, path, data, flags=b'', **kwargs): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2402 if data is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2403 raise error.ProgrammingError(b"data must be non-None") |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
2404 self._auditconflicts(path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2405 self._markdirty( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2406 path, exists=True, data=data, date=dateutil.makedate(), flags=flags |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2407 ) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2408 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2409 def setflags(self, path, l, x): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2410 flag = b'' |
39066
2488dcfa71f8
context: safegaurd from 'lx' being passed as file flag in manifest
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38818
diff
changeset
|
2411 if l: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2412 flag = b'l' |
39066
2488dcfa71f8
context: safegaurd from 'lx' being passed as file flag in manifest
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38818
diff
changeset
|
2413 elif x: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2414 flag = b'x' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2415 self._markdirty(path, exists=True, date=dateutil.makedate(), flags=flag) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2416 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2417 def remove(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2418 self._markdirty(path, exists=False) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2419 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2420 def exists(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2421 """exists behaves like `lexists`, but needs to follow symlinks and |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2422 return False if they are broken. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2423 """ |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2424 if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2425 # If this path exists and is a symlink, "follow" it by calling |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2426 # exists on the destination path. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2427 if ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2428 self._cache[path][b'exists'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2429 and b'l' in self._cache[path][b'flags'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2430 ): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2431 return self.exists(self._cache[path][b'data'].strip()) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2432 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2433 return self._cache[path][b'exists'] |
35295
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2434 |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2435 return self._existsinparent(path) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2436 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2437 def lexists(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2438 """lexists returns True if the path exists""" |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2439 if self.isdirty(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2440 return self._cache[path][b'exists'] |
35295
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2441 |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
2442 return self._existsinparent(path) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2443 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2444 def size(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2445 if self.isdirty(path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2446 if self._cache[path][b'exists']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2447 return len(self._cache[path][b'data']) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2448 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2449 raise error.ProgrammingError( |
44934
b2e5ec0c596b
context: fix creation of ProgrammingError to not use non-existent field
Martin von Zweigbergk <martinvonz@google.com>
parents:
44916
diff
changeset
|
2450 b"No such file or directory: %s" % path |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2451 ) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2452 return self._wrappedctx[path].size() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2453 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2454 def tomemctx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2455 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2456 text, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2457 branch=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2458 extra=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2459 date=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2460 parents=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2461 user=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2462 editor=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2463 ): |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2464 """Converts this ``overlayworkingctx`` into a ``memctx`` ready to be |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2465 committed. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2466 |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2467 ``text`` is the commit message. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2468 ``parents`` (optional) are rev numbers. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2469 """ |
44051
436d106de670
overlayworkginctx: implement a setparents() to mirror dirstate.setparents()
Martin von Zweigbergk <martinvonz@google.com>
parents:
44050
diff
changeset
|
2470 # Default parents to the wrapped context if not passed. |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2471 if parents is None: |
44051
436d106de670
overlayworkginctx: implement a setparents() to mirror dirstate.setparents()
Martin von Zweigbergk <martinvonz@google.com>
parents:
44050
diff
changeset
|
2472 parents = self.parents() |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2473 if len(parents) == 1: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2474 parents = (parents[0], None) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2475 |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2476 # ``parents`` is passed as rev numbers; convert to ``commitctxs``. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2477 if parents[1] is None: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2478 parents = (self._repo[parents[0]], None) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2479 else: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2480 parents = (self._repo[parents[0]], self._repo[parents[1]]) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2481 |
42290
e79aeb518aa1
overlayworkingctx: don't include added-then-deleted files in memctx
Martin von Zweigbergk <martinvonz@google.com>
parents:
42288
diff
changeset
|
2482 files = self.files() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2483 |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2484 def getfile(repo, memctx, path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2485 if self._cache[path][b'exists']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2486 return memfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2487 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2488 memctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2489 path, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2490 self._cache[path][b'data'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2491 b'l' in self._cache[path][b'flags'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2492 b'x' in self._cache[path][b'flags'], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2493 self._cache[path][b'copied'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2494 ) |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2495 else: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2496 # Returning None, but including the path in `files`, is |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2497 # necessary for memctx to register a deletion. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2498 return None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2499 |
44050
2ecbc4ec87d8
overlayworkingctx: default branch to base context's branch
Martin von Zweigbergk <martinvonz@google.com>
parents:
44039
diff
changeset
|
2500 if branch is None: |
2ecbc4ec87d8
overlayworkingctx: default branch to base context's branch
Martin von Zweigbergk <martinvonz@google.com>
parents:
44039
diff
changeset
|
2501 branch = self._wrappedctx.branch() |
2ecbc4ec87d8
overlayworkingctx: default branch to base context's branch
Martin von Zweigbergk <martinvonz@google.com>
parents:
44039
diff
changeset
|
2502 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2503 return memctx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2504 self._repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2505 parents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2506 text, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2507 files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2508 getfile, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2509 date=date, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2510 extra=extra, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2511 user=user, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2512 branch=branch, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2513 editor=editor, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2514 ) |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2515 |
44365
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2516 def tomemctx_for_amend(self, precursor): |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2517 extra = precursor.extra().copy() |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2518 extra[b'amend_source'] = precursor.hex() |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2519 return self.tomemctx( |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2520 text=precursor.description(), |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2521 branch=precursor.branch(), |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2522 extra=extra, |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2523 date=precursor.date(), |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2524 user=precursor.user(), |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2525 ) |
7c4b98a4e536
copy: add experimetal support for unmarking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents:
44354
diff
changeset
|
2526 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2527 def isdirty(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2528 return path in self._cache |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2529 |
35286
307b1689e3f8
overlayworkingctx: make clean() public
Phil Cohen <phillco@fb.com>
parents:
35285
diff
changeset
|
2530 def clean(self): |
45499
19590b126764
merge: use in-memory mergestate when using in-memory context
Martin von Zweigbergk <martinvonz@google.com>
parents:
45489
diff
changeset
|
2531 self._mergestate = None |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2532 self._cache = {} |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2533 |
45228
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2534 def _compact(self): |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2535 """Removes keys from the cache that are actually clean, by comparing |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2536 them with the underlying context. |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2537 |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2538 This can occur during the merge process, e.g. by passing --tool :local |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2539 to resolve a conflict. |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2540 """ |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2541 keys = [] |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2542 # This won't be perfect, but can help performance significantly when |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2543 # using things like remotefilelog. |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2544 scmutil.prefetchfiles( |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2545 self.repo(), |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2546 [ |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2547 ( |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2548 self.p1().rev(), |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2549 scmutil.matchfiles(self.repo(), self._cache.keys()), |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2550 ) |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2551 ], |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2552 ) |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2553 |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2554 for path in self._cache.keys(): |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2555 cache = self._cache[path] |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2556 try: |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2557 underlying = self._wrappedctx[path] |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2558 if ( |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2559 underlying.data() == cache[b'data'] |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2560 and underlying.flags() == cache[b'flags'] |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2561 ): |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2562 keys.append(path) |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2563 except error.ManifestLookupError: |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2564 # Path not in the underlying manifest (created). |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2565 continue |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2566 |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2567 for path in keys: |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2568 del self._cache[path] |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2569 return keys |
1476ec96965f
context: re-add `overlayworkingctx._compact()` removed in 6a5dcd754842
Manuel Jacob <me@manueljacob.de>
parents:
45091
diff
changeset
|
2570 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2571 def _markdirty( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2572 self, path, exists, data=None, date=None, flags=b'', copied=None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2573 ): |
39127
95bd19f60957
overlayworkingctx: fix exception in metadata-only inmemory merges (issue5960)
Kyle Lippincott <spectral@google.com>
parents:
39078
diff
changeset
|
2574 # data not provided, let's see if we already have some; if not, let's |
95bd19f60957
overlayworkingctx: fix exception in metadata-only inmemory merges (issue5960)
Kyle Lippincott <spectral@google.com>
parents:
39078
diff
changeset
|
2575 # grab it from our underlying context, so that we always have data if |
95bd19f60957
overlayworkingctx: fix exception in metadata-only inmemory merges (issue5960)
Kyle Lippincott <spectral@google.com>
parents:
39078
diff
changeset
|
2576 # the file is marked as existing. |
95bd19f60957
overlayworkingctx: fix exception in metadata-only inmemory merges (issue5960)
Kyle Lippincott <spectral@google.com>
parents:
39078
diff
changeset
|
2577 if exists and data is None: |
95bd19f60957
overlayworkingctx: fix exception in metadata-only inmemory merges (issue5960)
Kyle Lippincott <spectral@google.com>
parents:
39078
diff
changeset
|
2578 oldentry = self._cache.get(path) or {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2579 data = oldentry.get(b'data') |
42528
e079e001d536
rebase: fix in-memory rebasing of copy of empty file
Martin von Zweigbergk <martinvonz@google.com>
parents:
42456
diff
changeset
|
2580 if data is None: |
e079e001d536
rebase: fix in-memory rebasing of copy of empty file
Martin von Zweigbergk <martinvonz@google.com>
parents:
42456
diff
changeset
|
2581 data = self._wrappedctx[path].data() |
39127
95bd19f60957
overlayworkingctx: fix exception in metadata-only inmemory merges (issue5960)
Kyle Lippincott <spectral@google.com>
parents:
39078
diff
changeset
|
2582 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2583 self._cache[path] = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2584 b'exists': exists, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2585 b'data': data, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2586 b'date': date, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2587 b'flags': flags, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2588 b'copied': copied, |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2589 } |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2590 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2591 def filectx(self, path, filelog=None): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2592 return overlayworkingfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2593 self._repo, path, parent=self, filelog=filelog |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2594 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2595 |
45499
19590b126764
merge: use in-memory mergestate when using in-memory context
Martin von Zweigbergk <martinvonz@google.com>
parents:
45489
diff
changeset
|
2596 def mergestate(self, clean=False): |
19590b126764
merge: use in-memory mergestate when using in-memory context
Martin von Zweigbergk <martinvonz@google.com>
parents:
45489
diff
changeset
|
2597 if clean or self._mergestate is None: |
19590b126764
merge: use in-memory mergestate when using in-memory context
Martin von Zweigbergk <martinvonz@google.com>
parents:
45489
diff
changeset
|
2598 self._mergestate = mergestatemod.memmergestate(self._repo) |
19590b126764
merge: use in-memory mergestate when using in-memory context
Martin von Zweigbergk <martinvonz@google.com>
parents:
45489
diff
changeset
|
2599 return self._mergestate |
19590b126764
merge: use in-memory mergestate when using in-memory context
Martin von Zweigbergk <martinvonz@google.com>
parents:
45489
diff
changeset
|
2600 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2601 |
35323
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
2602 class overlayworkingfilectx(committablefilectx): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2603 """Wrap a ``workingfilectx`` but intercepts all writes into an in-memory |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2604 cache, which can be flushed through later by calling ``flush()``.""" |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2605 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2606 def __init__(self, repo, path, filelog=None, parent=None): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2607 super(overlayworkingfilectx, self).__init__(repo, path, filelog, parent) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2608 self._repo = repo |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2609 self._parent = parent |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2610 self._path = path |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2611 |
34783
0c812885586b
context: add overlayfilectx.cmp()
Phil Cohen <phillco@fb.com>
parents:
34685
diff
changeset
|
2612 def cmp(self, fctx): |
0c812885586b
context: add overlayfilectx.cmp()
Phil Cohen <phillco@fb.com>
parents:
34685
diff
changeset
|
2613 return self.data() != fctx.data() |
0c812885586b
context: add overlayfilectx.cmp()
Phil Cohen <phillco@fb.com>
parents:
34685
diff
changeset
|
2614 |
35281
010179e21e91
context: switch ctx() use to changectx()
Phil Cohen <phillco@fb.com>
parents:
35271
diff
changeset
|
2615 def changectx(self): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2616 return self._parent |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2617 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2618 def data(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2619 return self._parent.data(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2620 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2621 def date(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2622 return self._parent.filedate(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2623 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2624 def exists(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2625 return self.lexists() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2626 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2627 def lexists(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2628 return self._parent.exists(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2629 |
41768
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
2630 def copysource(self): |
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
2631 return self._parent.copydata(self._path) |
041d829575ed
context: add specialized way of getting copy source file only
Martin von Zweigbergk <martinvonz@google.com>
parents:
41766
diff
changeset
|
2632 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2633 def size(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2634 return self._parent.size(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2635 |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2636 def markcopied(self, origin): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2637 self._parent.markcopied(self._path, origin) |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2638 |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2639 def audit(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2640 pass |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2641 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2642 def flags(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2643 return self._parent.flags(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2644 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2645 def setflags(self, islink, isexec): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2646 return self._parent.setflags(self._path, islink, isexec) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2647 |
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2648 def write(self, data, flags, backgroundclose=False, **kwargs): |
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2649 return self._parent.write(self._path, data, flags, **kwargs) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2650 |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2651 def remove(self, ignoremissing=False): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2652 return self._parent.remove(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2653 |
35322
baf58e621363
overlayworkingctx: add a no-op ``clearunknown()``
Phil Cohen <phillco@fb.com>
parents:
35321
diff
changeset
|
2654 def clearunknown(self): |
baf58e621363
overlayworkingctx: add a no-op ``clearunknown()``
Phil Cohen <phillco@fb.com>
parents:
35321
diff
changeset
|
2655 pass |
baf58e621363
overlayworkingctx: add a no-op ``clearunknown()``
Phil Cohen <phillco@fb.com>
parents:
35321
diff
changeset
|
2656 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2657 |
23710
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2658 class workingcommitctx(workingctx): |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2659 """A workingcommitctx object makes access to data related to |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2660 the revision being committed convenient. |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2661 |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2662 This hides changes in the working directory, if they aren't |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2663 committed in this context. |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2664 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2665 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2666 def __init__( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2667 self, repo, changes, text=b"", user=None, date=None, extra=None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2668 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2669 super(workingcommitctx, self).__init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2670 repo, text, user, date, extra, changes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2671 ) |
23710
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2672 |
33937
e43264525ce5
context: remove unnecessary default values for matchers (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33936
diff
changeset
|
2673 def _dirstatestatus(self, match, ignored=False, clean=False, unknown=False): |
23712
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2674 """Return matched files only in ``self._status`` |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2675 |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2676 Uncommitted files appear "clean" via this context, even if |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2677 they aren't actually so in the working directory. |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2678 """ |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2679 if clean: |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2680 clean = [f for f in self._manifest if f not in self._changedset] |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2681 else: |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2682 clean = [] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2683 return scmutil.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2684 [f for f in self._status.modified if match(f)], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2685 [f for f in self._status.added if match(f)], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2686 [f for f in self._status.removed if match(f)], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2687 [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2688 [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2689 [], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2690 clean, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2691 ) |
23712
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2692 |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2693 @propertycache |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2694 def _changedset(self): |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2695 """Return the set of files changed in this context |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2696 """ |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2697 changed = set(self._status.modified) |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2698 changed.update(self._status.added) |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2699 changed.update(self._status.removed) |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2700 return changed |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2701 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2702 |
27906
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2703 def makecachingfilectxfn(func): |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2704 """Create a filectxfn that caches based on the path. |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2705 |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2706 We can't use util.cachefunc because it uses all arguments as the cache |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2707 key and this creates a cycle since the arguments include the repo and |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2708 memctx. |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2709 """ |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2710 cache = {} |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2711 |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2712 def getfilectx(repo, memctx, path): |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2713 if path not in cache: |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2714 cache[path] = func(repo, memctx, path) |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2715 return cache[path] |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2716 |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2717 return getfilectx |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2718 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2719 |
32763
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2720 def memfilefromctx(ctx): |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2721 """Given a context return a memfilectx for ctx[path] |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2722 |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2723 This is a convenience method for building a memctx based on another |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2724 context. |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2725 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2726 |
32763
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2727 def getfilectx(repo, memctx, path): |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2728 fctx = ctx[path] |
41994
550a172a603b
memctx: rename constructor argument "copied" to "copysource" (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41967
diff
changeset
|
2729 copysource = fctx.copysource() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2730 return memfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2731 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2732 memctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2733 path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2734 fctx.data(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2735 islink=fctx.islink(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2736 isexec=fctx.isexec(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2737 copysource=copysource, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2738 ) |
32763
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2739 |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2740 return getfilectx |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2741 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2742 |
32764
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2743 def memfilefrompatch(patchstore): |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2744 """Given a patch (e.g. patchstore object) return a memfilectx |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2745 |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2746 This is a convenience method for building a memctx based on a patchstore. |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2747 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2748 |
32764
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2749 def getfilectx(repo, memctx, path): |
41994
550a172a603b
memctx: rename constructor argument "copied" to "copysource" (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41967
diff
changeset
|
2750 data, mode, copysource = patchstore.getfile(path) |
32764
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2751 if data is None: |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2752 return None |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2753 islink, isexec = mode |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2754 return memfilectx( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2755 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2756 memctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2757 path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2758 data, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2759 islink=islink, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2760 isexec=isexec, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2761 copysource=copysource, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2762 ) |
32764
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2763 |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2764 return getfilectx |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2765 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2766 |
21665
d2743be1bb06
memctx: inherit from committablectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21664
diff
changeset
|
2767 class memctx(committablectx): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2768 """Use memctx to perform in-memory commits via localrepo.commitctx(). |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2769 |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2770 Revision information is supplied at initialization time while |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2771 related files data and is made available through a callback |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2772 mechanism. 'repo' is the current localrepo, 'parents' is a |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2773 sequence of two parent revisions identifiers (pass None for every |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2774 missing parent), 'text' is the commit message and 'files' lists |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2775 names of files touched by the revision (normalized and relative to |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2776 repository root). |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2777 |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2778 filectxfn(repo, memctx, path) is a callable receiving the |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2779 repository, the current memctx object and the normalized path of |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2780 requested file, relative to repository root. It is fired by the |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2781 commit function for every file in 'files', but calls order is |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2782 undefined. If the file is available in the revision being |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2783 committed (updated or added), filectxfn returns a memfilectx |
31612
c93cdfa131a8
misc: update descriptions about removed file for filectxfn
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31476
diff
changeset
|
2784 object. If the file was removed, filectxfn return None for recent |
c93cdfa131a8
misc: update descriptions about removed file for filectxfn
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31476
diff
changeset
|
2785 Mercurial. Moved files are represented by marking the source file |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2786 removed and the new file added with copy information (see |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2787 memfilectx). |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2788 |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2789 user receives the committer name and defaults to current |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2790 repository username, date is the commit date in any format |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
2791 supported by dateutil.parsedate() and defaults to current date, extra |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2792 is a dictionary of metadata or is left empty. |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2793 """ |
22313
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2794 |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2795 # Mercurial <= 3.1 expects the filectxfn to raise IOError for missing files. |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2796 # Extensions that need to retain compatibility across Mercurial 3.1 can use |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2797 # this field to determine what to do in filectxfn. |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2798 _returnnoneformissingfiles = True |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2799 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2800 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2801 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2802 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2803 parents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2804 text, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2805 files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2806 filectxfn, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2807 user=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2808 date=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2809 extra=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2810 branch=None, |
44023
3216cabffd4a
commit: change default `editor` parameter to None
Matt Harbison <matt_harbison@yahoo.com>
parents:
44009
diff
changeset
|
2811 editor=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2812 ): |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2813 super(memctx, self).__init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2814 repo, text, user, date, extra, branch=branch |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2815 ) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2816 self._rev = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2817 self._node = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2818 parents = [(p or nullid) for p in parents] |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2819 p1, p2 = parents |
37173
05ff1a155a21
memctx: create parent contexts using "repo[p]" syntax
Martin von Zweigbergk <martinvonz@google.com>
parents:
37171
diff
changeset
|
2820 self._parents = [self._repo[p] for p in (p1, p2)] |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
8207
diff
changeset
|
2821 files = sorted(set(files)) |
23587
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2822 self._files = files |
21938
c8411fb5dfef
memctx: substate needs to be {} instead of None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21895
diff
changeset
|
2823 self.substate = {} |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2824 |
32765
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2825 if isinstance(filectxfn, patch.filestore): |
32781
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2826 filectxfn = memfilefrompatch(filectxfn) |
32765
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2827 elif not callable(filectxfn): |
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2828 # if store is not callable, wrap it in a function |
32781
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2829 filectxfn = memfilefromctx(filectxfn) |
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2830 |
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2831 # memoizing increases performance for e.g. vcs convert scenarios. |
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2832 self._filectxfn = makecachingfilectxfn(filectxfn) |
22072
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
2833 |
21238
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
2834 if editor: |
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
2835 self._text = editor(self._repo, self, []) |
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
2836 self._repo.savecommitmessage(self._text) |
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
2837 |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2838 def filectx(self, path, filelog=None): |
22296
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
2839 """get a file context from the working directory |
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
2840 |
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
2841 Returns None if file doesn't exist and should be removed.""" |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2842 return self._filectxfn(self._repo, self, path) |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2843 |
11151
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2844 def commit(self): |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2845 """commit context to the repo""" |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2846 return self._repo.commitctx(self) |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2847 |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2848 @propertycache |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2849 def _manifest(self): |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2850 """generate a manifest based on the return values of filectxfn""" |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2851 |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2852 # keep this simple for now; just worry about p1 |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2853 pctx = self._parents[0] |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2854 man = pctx.manifest().copy() |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2855 |
23603
d74eb8d477d5
memctx: calculate manifest more efficiently
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23602
diff
changeset
|
2856 for f in self._status.modified: |
39713
a5dafefc4a53
memctx: simplify _manifest with new revlog nodeids
Sean Farley <sean@farley.io>
parents:
39712
diff
changeset
|
2857 man[f] = modifiednodeid |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2858 |
23588
87a76cff7147
memctx: calculate manifest including newly added files correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23587
diff
changeset
|
2859 for f in self._status.added: |
39713
a5dafefc4a53
memctx: simplify _manifest with new revlog nodeids
Sean Farley <sean@farley.io>
parents:
39712
diff
changeset
|
2860 man[f] = addednodeid |
23588
87a76cff7147
memctx: calculate manifest including newly added files correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23587
diff
changeset
|
2861 |
23589
200215cdf7aa
memctx: calculate manifest correctly with newly-removed files (issue4470)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23588
diff
changeset
|
2862 for f in self._status.removed: |
200215cdf7aa
memctx: calculate manifest correctly with newly-removed files (issue4470)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23588
diff
changeset
|
2863 if f in man: |
200215cdf7aa
memctx: calculate manifest correctly with newly-removed files (issue4470)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23588
diff
changeset
|
2864 del man[f] |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2865 |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2866 return man |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2867 |
23587
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2868 @propertycache |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2869 def _status(self): |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2870 """Calculate exact status from ``files`` specified at construction |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2871 """ |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2872 man1 = self.p1().manifest() |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2873 p2 = self._parents[1] |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2874 # "1 < len(self._parents)" can't be used for checking |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2875 # existence of the 2nd parent, because "memctx._parents" is |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2876 # explicitly initialized by the list, of which length is 2. |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2877 if p2.node() != nullid: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2878 man2 = p2.manifest() |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2879 managing = lambda f: f in man1 or f in man2 |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2880 else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2881 managing = lambda f: f in man1 |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2882 |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2883 modified, added, removed = [], [], [] |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2884 for f in self._files: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2885 if not managing(f): |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2886 added.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2887 elif self[f]: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2888 modified.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2889 else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2890 removed.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2891 |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2892 return scmutil.status(modified, added, removed, [], [], [], []) |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2893 |
45089
d085fcb11c56
memctx: make `parents()` return list of one element if it’s not a merge
Manuel Jacob <me@manueljacob.de>
parents:
45088
diff
changeset
|
2894 def parents(self): |
d085fcb11c56
memctx: make `parents()` return list of one element if it’s not a merge
Manuel Jacob <me@manueljacob.de>
parents:
45088
diff
changeset
|
2895 if self._parents[1].node() == nullid: |
d085fcb11c56
memctx: make `parents()` return list of one element if it’s not a merge
Manuel Jacob <me@manueljacob.de>
parents:
45088
diff
changeset
|
2896 return [self._parents[0]] |
d085fcb11c56
memctx: make `parents()` return list of one element if it’s not a merge
Manuel Jacob <me@manueljacob.de>
parents:
45088
diff
changeset
|
2897 return self._parents |
d085fcb11c56
memctx: make `parents()` return list of one element if it’s not a merge
Manuel Jacob <me@manueljacob.de>
parents:
45088
diff
changeset
|
2898 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2899 |
21688
cc677803bad4
memfilectx: inherit from committablefilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21687
diff
changeset
|
2900 class memfilectx(committablefilectx): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2901 """memfilectx represents an in-memory file to commit. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2902 |
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23110
diff
changeset
|
2903 See memctx and committablefilectx for more details. |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2904 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2905 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2906 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2907 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2908 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2909 changectx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2910 path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2911 data, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2912 islink=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2913 isexec=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2914 copysource=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2915 ): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2916 """ |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2917 path is the normalized file path relative to repository root. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2918 data is the file content as a string. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2919 islink is True if the file is a symbolic link. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2920 isexec is True if the file is executable. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2921 copied is the source file path if current file was copied in the |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2922 revision being committed, or None.""" |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2923 super(memfilectx, self).__init__(repo, path, None, changectx) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2924 self._data = data |
38761
d558e53cd6b6
context: safegaurd against 'lx' being passed as file flag in manifest
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38755
diff
changeset
|
2925 if islink: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2926 self._flags = b'l' |
38761
d558e53cd6b6
context: safegaurd against 'lx' being passed as file flag in manifest
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38755
diff
changeset
|
2927 elif isexec: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2928 self._flags = b'x' |
38761
d558e53cd6b6
context: safegaurd against 'lx' being passed as file flag in manifest
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38755
diff
changeset
|
2929 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2930 self._flags = b'' |
41995
6fef387af1da
memfilectx: override copysource() instead of using dummy nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
41994
diff
changeset
|
2931 self._copysource = copysource |
6fef387af1da
memfilectx: override copysource() instead of using dummy nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
41994
diff
changeset
|
2932 |
6fef387af1da
memfilectx: override copysource() instead of using dummy nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
41994
diff
changeset
|
2933 def copysource(self): |
6fef387af1da
memfilectx: override copysource() instead of using dummy nodeid
Martin von Zweigbergk <martinvonz@google.com>
parents:
41994
diff
changeset
|
2934 return self._copysource |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2935 |
40986
328557af18eb
context: reimplement memfilectx.cmp()
Yuya Nishihara <yuya@tcha.org>
parents:
40816
diff
changeset
|
2936 def cmp(self, fctx): |
328557af18eb
context: reimplement memfilectx.cmp()
Yuya Nishihara <yuya@tcha.org>
parents:
40816
diff
changeset
|
2937 return self.data() != fctx.data() |
328557af18eb
context: reimplement memfilectx.cmp()
Yuya Nishihara <yuya@tcha.org>
parents:
40816
diff
changeset
|
2938 |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2939 def data(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2940 return self._data |
22074
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2941 |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2942 def remove(self, ignoremissing=False): |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2943 """wraps unlink for a repo's working directory""" |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2944 # need to figure out what to do here |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2945 del self._changectx[self._path] |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2946 |
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2947 def write(self, data, flags, **kwargs): |
22074
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2948 """wraps repo.wwrite""" |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2949 self._data = data |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2950 |
32243
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2951 |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2952 class metadataonlyctx(committablectx): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2953 """Like memctx but it's reusing the manifest of different commit. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2954 Intended to be used by lightweight operations that are creating |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2955 metadata-only changes. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2956 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2957 Revision information is supplied at initialization time. 'repo' is the |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2958 current localrepo, 'ctx' is original revision which manifest we're reuisng |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2959 'parents' is a sequence of two parent revisions identifiers (pass None for |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2960 every missing parent), 'text' is the commit. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2961 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2962 user receives the committer name and defaults to current repository |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2963 username, date is the commit date in any format supported by |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
2964 dateutil.parsedate() and defaults to current date, extra is a dictionary of |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2965 metadata or is left empty. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2966 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2967 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2968 def __init__( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2969 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2970 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2971 originalctx, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2972 parents=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2973 text=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2974 user=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2975 date=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2976 extra=None, |
44023
3216cabffd4a
commit: change default `editor` parameter to None
Matt Harbison <matt_harbison@yahoo.com>
parents:
44009
diff
changeset
|
2977 editor=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2978 ): |
33998
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2979 if text is None: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2980 text = originalctx.description() |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2981 super(metadataonlyctx, self).__init__(repo, text, user, date, extra) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2982 self._rev = None |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2983 self._node = None |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2984 self._originalctx = originalctx |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2985 self._manifestnode = originalctx.manifestnode() |
33998
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2986 if parents is None: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2987 parents = originalctx.parents() |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2988 else: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2989 parents = [repo[p] for p in parents if p is not None] |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2990 parents = parents[:] |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2991 while len(parents) < 2: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2992 parents.append(repo[nullid]) |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2993 p1, p2 = self._parents = parents |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2994 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2995 # sanity check to ensure that the reused manifest parents are |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2996 # manifests of our commit parents |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2997 mp1, mp2 = self.manifestctx().parents |
31840
7973e0a15bd4
metadataonlyctx: replace "changeset()[0]" to "manifestnode()"
Jun Wu <quark@fb.com>
parents:
31663
diff
changeset
|
2998 if p1 != nullid and p1.manifestnode() != mp1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
2999 raise RuntimeError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3000 r"can't reuse the manifest: its p1 " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3001 r"doesn't match the new ctx p1" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3002 ) |
31840
7973e0a15bd4
metadataonlyctx: replace "changeset()[0]" to "manifestnode()"
Jun Wu <quark@fb.com>
parents:
31663
diff
changeset
|
3003 if p2 != nullid and p2.manifestnode() != mp2: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3004 raise RuntimeError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3005 r"can't reuse the manifest: " |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3006 r"its p2 doesn't match the new ctx p2" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3007 ) |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3008 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3009 self._files = originalctx.files() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3010 self.substate = {} |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3011 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3012 if editor: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3013 self._text = editor(self._repo, self, []) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3014 self._repo.savecommitmessage(self._text) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3015 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3016 def manifestnode(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3017 return self._manifestnode |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3018 |
32519 | 3019 @property |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3020 def _manifestctx(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3021 return self._repo.manifestlog[self._manifestnode] |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3022 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3023 def filectx(self, path, filelog=None): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3024 return self._originalctx.filectx(path, filelog=filelog) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3025 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3026 def commit(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3027 """commit context to the repo""" |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3028 return self._repo.commitctx(self) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3029 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3030 @property |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3031 def _manifest(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3032 return self._originalctx.manifest() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3033 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3034 @propertycache |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3035 def _status(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3036 """Calculate exact status from ``files`` specified in the ``origctx`` |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3037 and parents manifests. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3038 """ |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3039 man1 = self.p1().manifest() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3040 p2 = self._parents[1] |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3041 # "1 < len(self._parents)" can't be used for checking |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3042 # existence of the 2nd parent, because "metadataonlyctx._parents" is |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3043 # explicitly initialized by the list, of which length is 2. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3044 if p2.node() != nullid: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3045 man2 = p2.manifest() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3046 managing = lambda f: f in man1 or f in man2 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3047 else: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3048 managing = lambda f: f in man1 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3049 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3050 modified, added, removed = [], [], [] |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3051 for f in self._files: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3052 if not managing(f): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3053 added.append(f) |
33999
be814edf3306
metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
33998
diff
changeset
|
3054 elif f in self: |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3055 modified.append(f) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3056 else: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3057 removed.append(f) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3058 |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
3059 return scmutil.status(modified, added, removed, [], [], [], []) |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3060 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3061 |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3062 class arbitraryfilectx(object): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3063 """Allows you to use filectx-like functions on a file in an arbitrary |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3064 location on disk, possibly not in the working directory. |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3065 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43023
diff
changeset
|
3066 |
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3067 def __init__(self, path, repo=None): |
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3068 # Repo is optional because contrib/simplemerge uses this class. |
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3069 self._repo = repo |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3070 self._path = path |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3071 |
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3072 def cmp(self, fctx): |
34835
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
3073 # filecmp follows symlinks whereas `cmp` should not, so skip the fast |
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
3074 # path if either side is a symlink. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3075 symlinks = b'l' in self.flags() or b'l' in fctx.flags() |
34835
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
3076 if not symlinks and isinstance(fctx, workingfilectx) and self._repo: |
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3077 # Add a fast-path for merge if both sides are disk-backed. |
34835
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
3078 # Note that filecmp uses the opposite return values (True if same) |
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
3079 # from our cmp functions (True if different). |
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3080 return not filecmp.cmp(self.path(), self._repo.wjoin(fctx.path())) |
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
3081 return self.data() != fctx.data() |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3082 |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3083 def path(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3084 return self._path |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3085 |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3086 def flags(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3087 return b'' |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3088 |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3089 def data(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3090 return util.readfile(self._path) |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3091 |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3092 def decodeddata(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3093 with open(self._path, b"rb") as f: |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3094 return f.read() |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3095 |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3096 def remove(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3097 util.unlink(self._path) |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3098 |
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
3099 def write(self, data, flags, **kwargs): |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3100 assert not flags |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
3101 with open(self._path, b"wb") as f: |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
3102 f.write(data) |