author | Yuya Nishihara <yuya@tcha.org> |
Sun, 25 Mar 2018 18:31:22 +0900 | |
changeset 37448 | d7114f883505 |
parent 37447 | 067e8d1178a2 |
child 37504 | 901e749ca0e1 |
permissions | -rw-r--r-- |
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 |
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
13 |
import re |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
14 |
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
|
15 |
|
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
16 |
from .i18n import _ |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
17 |
from .node import ( |
30361
1070df141718
dirstate: change added/modified placeholder hash length to 20 bytes
Durham Goode <durham@fb.com>
parents:
30360
diff
changeset
|
18 |
addednodeid, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
19 |
bin, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
20 |
hex, |
30361
1070df141718
dirstate: change added/modified placeholder hash length to 20 bytes
Durham Goode <durham@fb.com>
parents:
30360
diff
changeset
|
21 |
modifiednodeid, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
22 |
nullid, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
23 |
nullrev, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
24 |
short, |
37448
d7114f883505
node: rename wdirnodes to clarify they are for manifest/filelogs
Yuya Nishihara <yuya@tcha.org>
parents:
37447
diff
changeset
|
25 |
wdirfilenodeids, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
26 |
wdirid, |
32660
a722c8e17363
localrepo: map integer and hex wdir identifiers to workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
32652
diff
changeset
|
27 |
wdirrev, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
28 |
) |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
29 |
from . import ( |
36917
7affcabf561e
dagop: move annotateline and _annotatepair from context.py
Yuya Nishihara <yuya@tcha.org>
parents:
36781
diff
changeset
|
30 |
dagop, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
31 |
encoding, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
32 |
error, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
33 |
fileset, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
34 |
match as matchmod, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
35 |
obsolete as obsmod, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
36 |
patch, |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
37 |
pathutil, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
38 |
phases, |
31343
ff2f90503d64
context: work around `long` not existing on Python 3
Augie Fackler <augie@google.com>
parents:
31309
diff
changeset
|
39 |
pycompat, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
40 |
repoview, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
41 |
revlog, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
42 |
scmutil, |
33353
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
43 |
sparse, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
44 |
subrepo, |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35890
diff
changeset
|
45 |
subrepoutil, |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
46 |
util, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
47 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
48 |
from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
49 |
dateutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
50 |
stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
51 |
) |
3122
da85145d4571
filectx: add rename traversal for parents()
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
52 |
|
8207
dd8d5be57d65
util: take propertycache from context.py
Matt Mackall <mpm@selenic.com>
parents:
8157
diff
changeset
|
53 |
propertycache = util.propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
54 |
|
36704
470df8c5b781
py3: make sure regular expressions are bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36690
diff
changeset
|
55 |
nonascii = re.compile(br'[^\x21-\x7f]').search |
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
56 |
|
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
|
57 |
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
|
58 |
"""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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
|
37175
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
65 |
def __init__(self, repo): |
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
66 |
self._repo = repo |
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
67 |
|
31344
c99371e38e5e
context: implement both __bytes__ and __str__ for Python 3
Augie Fackler <augie@google.com>
parents:
31343
diff
changeset
|
68 |
def __bytes__(self): |
19540
7b864da00e21
basectx: move __str__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19539
diff
changeset
|
69 |
return short(self.node()) |
7b864da00e21
basectx: move __str__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19539
diff
changeset
|
70 |
|
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
71 |
__str__ = encoding.strmethod(__bytes__) |
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
72 |
|
19546
a45cf68dd9a2
basectx: move __repr__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19545
diff
changeset
|
73 |
def __repr__(self): |
32613
e7eb7494e98d
py3: make sure we return strings from __str__ and __repr__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32610
diff
changeset
|
74 |
return r"<%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
|
75 |
|
19547
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
76 |
def __eq__(self, other): |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
77 |
try: |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
78 |
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
|
79 |
except AttributeError: |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
80 |
return False |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
81 |
|
19548
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
82 |
def __ne__(self, other): |
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
83 |
return not (self == other) |
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
84 |
|
19550
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
85 |
def __contains__(self, key): |
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
86 |
return key in self._manifest |
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
87 |
|
19551
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
88 |
def __getitem__(self, key): |
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
89 |
return self.filectx(key) |
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
90 |
|
19552
6b76070c4b54
basectx: move __iter__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19551
diff
changeset
|
91 |
def __iter__(self): |
24227
8ec2df32bd39
context: don't sort manifest entries
Augie Fackler <augie@google.com>
parents:
24213
diff
changeset
|
92 |
return iter(self._manifest) |
19552
6b76070c4b54
basectx: move __iter__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19551
diff
changeset
|
93 |
|
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
94 |
def _buildstatusmanifest(self, status): |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
95 |
"""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
|
96 |
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
|
97 |
the normal manifest.""" |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
98 |
return self.manifest() |
21880
e6754f5e4cf7
context: generate filtered manifest efficiently for exact matchers
Siddharth Agarwal <sid0@fb.com>
parents:
21845
diff
changeset
|
99 |
|
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
100 |
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
|
101 |
"""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
|
102 |
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
|
103 |
""" |
33936
c714e82b9ac2
context: always pass a matcher into _matchstatus() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33901
diff
changeset
|
104 |
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
|
105 |
|
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
106 |
def _buildstatus(self, other, s, match, listignored, listclean, |
21663
8d9449eaaeff
context: fix wrong indentation from renaming method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21616
diff
changeset
|
107 |
listunknown): |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
108 |
"""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
|
109 |
# 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
|
110 |
# 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
|
111 |
# 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
|
112 |
# 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
|
113 |
# 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
|
114 |
# delta application. |
31260
aac054e5389b
context: remove assumptions about manifest creation during _buildstatus
Durham Goode <durham@fb.com>
parents:
31259
diff
changeset
|
115 |
mf2 = None |
23238
39eb9f78f968
context.status: move manifest caching trick to _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23237
diff
changeset
|
116 |
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
|
117 |
mf2 = self._buildstatusmanifest(s) |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
118 |
mf1 = other._buildstatusmanifest(s) |
31260
aac054e5389b
context: remove assumptions about manifest creation during _buildstatus
Durham Goode <durham@fb.com>
parents:
31259
diff
changeset
|
119 |
if mf2 is None: |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
120 |
mf2 = self._buildstatusmanifest(s) |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
121 |
|
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
122 |
modified, added = [], [] |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
123 |
removed = [] |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
124 |
clean = [] |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
125 |
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
|
126 |
deletedset = set(deleted) |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
127 |
d = mf1.diff(mf2, match=match, clean=listclean) |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
128 |
for fn, value in d.iteritems(): |
23731
ccbaa2ed11a4
status: don't list files as both clean and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23730
diff
changeset
|
129 |
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
|
130 |
continue |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
131 |
if value is None: |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
132 |
clean.append(fn) |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
133 |
continue |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
134 |
(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
|
135 |
if node1 is None: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
136 |
added.append(fn) |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
137 |
elif node2 is None: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
138 |
removed.append(fn) |
27749
215b47449e47
context: check for differing flags a little earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
27748
diff
changeset
|
139 |
elif flag1 != flag2: |
215b47449e47
context: check for differing flags a little earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
27748
diff
changeset
|
140 |
modified.append(fn) |
37448
d7114f883505
node: rename wdirnodes to clarify they are for manifest/filelogs
Yuya Nishihara <yuya@tcha.org>
parents:
37447
diff
changeset
|
141 |
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
|
142 |
# 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
|
143 |
# 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
|
144 |
# 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
|
145 |
# to a file as a modification. |
27747
54522bbe1597
status: back out changeset 89f49813526c
Martin von Zweigbergk <martinvonz@google.com>
parents:
27720
diff
changeset
|
146 |
modified.append(fn) |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
else: |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
150 |
clean.append(fn) |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
151 |
|
21971
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
152 |
if removed: |
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
153 |
# need to filter files if they are already reported as removed |
31261
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
154 |
unknown = [fn for fn in unknown if fn not in mf1 and |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
155 |
(not match or match(fn))] |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
156 |
ignored = [fn for fn in ignored if fn not in mf1 and |
bd884ef2ee46
context: remove uses of manifest.matches
Durham Goode <durham@fb.com>
parents:
31260
diff
changeset
|
157 |
(not match or match(fn))] |
23730
4b56219a5ac2
status: don't list files as both removed and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23712
diff
changeset
|
158 |
# 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
|
159 |
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
|
160 |
|
23302
24f67ad49da7
context.status: make _dirstatestatus() return an status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23301
diff
changeset
|
161 |
return scmutil.status(modified, added, removed, deleted, unknown, |
24f67ad49da7
context.status: make _dirstatestatus() return an status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23301
diff
changeset
|
162 |
ignored, clean) |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
163 |
|
19549
78155484ae34
basectx: move substate from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19548
diff
changeset
|
164 |
@propertycache |
78155484ae34
basectx: move substate from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19548
diff
changeset
|
165 |
def substate(self): |
36009
55e8efa2451a
subrepo: split non-core functions to new module
Yuya Nishihara <yuya@tcha.org>
parents:
35890
diff
changeset
|
166 |
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
|
167 |
|
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
|
168 |
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
|
169 |
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
|
170 |
|
19541
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
171 |
def rev(self): |
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
172 |
return self._rev |
19542
bd95621a2d56
basectx: move node from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19541
diff
changeset
|
173 |
def node(self): |
bd95621a2d56
basectx: move node from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19541
diff
changeset
|
174 |
return self._node |
19543
18f4951222f4
basectx: move hex from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19542
diff
changeset
|
175 |
def hex(self): |
19544
74924fa3236d
basectx: change _node to node() in hex
Sean Farley <sean.michael.farley@gmail.com>
parents:
19543
diff
changeset
|
176 |
return hex(self.node()) |
19553
64a99d972b9e
basectx: move manifest from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19552
diff
changeset
|
177 |
def manifest(self): |
64a99d972b9e
basectx: move manifest from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19552
diff
changeset
|
178 |
return self._manifest |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
179 |
def manifestctx(self): |
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
180 |
return self._manifestctx |
24300
a07314472a80
context: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24227
diff
changeset
|
181 |
def repo(self): |
a07314472a80
context: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24227
diff
changeset
|
182 |
return self._repo |
19554
98f8875f4baa
basectx: move phasestr from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19553
diff
changeset
|
183 |
def phasestr(self): |
98f8875f4baa
basectx: move phasestr from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19553
diff
changeset
|
184 |
return phases.phasenames[self.phase()] |
19555
613b70fedc4e
basectx: move mutable from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19554
diff
changeset
|
185 |
def mutable(self): |
613b70fedc4e
basectx: move mutable from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19554
diff
changeset
|
186 |
return self.phase() > phases.public |
19541
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
187 |
|
20400
f0137d994c83
context: add a getfileset() method so fewer things need fileset directly
Augie Fackler <raf@durin42.com>
parents:
20292
diff
changeset
|
188 |
def getfileset(self, expr): |
f0137d994c83
context: add a getfileset() method so fewer things need fileset directly
Augie Fackler <raf@durin42.com>
parents:
20292
diff
changeset
|
189 |
return fileset.getfileset(self, expr) |
f0137d994c83
context: add a getfileset() method so fewer things need fileset directly
Augie Fackler <raf@durin42.com>
parents:
20292
diff
changeset
|
190 |
|
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
191 |
def obsolete(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
192 |
"""True if the changeset is obsolete""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
193 |
return self.rev() in obsmod.getrevs(self._repo, 'obsolete') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
194 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
195 |
def extinct(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
196 |
"""True if the changeset is extinct""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
197 |
return self.rev() in obsmod.getrevs(self._repo, 'extinct') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
198 |
|
33727
f163edb45c47
context: rename unstable into orphan
Boris Feld <boris.feld@octobus.net>
parents:
33726
diff
changeset
|
199 |
def orphan(self): |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
200 |
"""True if the changeset is not obsolete but it's ancestor are""" |
33777
d4b7496f7d0b
obsolete: rename unstable volatile set into orphan volatile set
Boris Feld <boris.feld@octobus.net>
parents:
33730
diff
changeset
|
201 |
return self.rev() in obsmod.getrevs(self._repo, 'orphan') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
202 |
|
33729
8413cbeae275
context: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33728
diff
changeset
|
203 |
def phasedivergent(self): |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
204 |
"""True if the changeset try to be a successor of a public changeset |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
205 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
206 |
Only non-public and non-obsolete changesets may be bumped. |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
207 |
""" |
33779
9fa874fb34e1
obsolete: rename bumped volatile set into phasedivergent volatile set
Boris Feld <boris.feld@octobus.net>
parents:
33778
diff
changeset
|
208 |
return self.rev() in obsmod.getrevs(self._repo, 'phasedivergent') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
209 |
|
33728
8b2d7684407b
context: rename divergent into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents:
33727
diff
changeset
|
210 |
def contentdivergent(self): |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
211 |
"""Is a successors of a changeset with multiple possible successors set |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
212 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
213 |
Only non-public and non-obsolete changesets may be divergent. |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
214 |
""" |
33778
f3f06c260e9e
obsolete: rename divergent volatile set into contentdivergent volatile set
Boris Feld <boris.feld@octobus.net>
parents:
33777
diff
changeset
|
215 |
return self.rev() in obsmod.getrevs(self._repo, 'contentdivergent') |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
216 |
|
33730
52c5ff856b49
context: rename troubled into isunstable
Boris Feld <boris.feld@octobus.net>
parents:
33729
diff
changeset
|
217 |
def isunstable(self): |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
218 |
"""True if the changeset is either unstable, bumped or divergent""" |
33729
8413cbeae275
context: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33728
diff
changeset
|
219 |
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
|
220 |
|
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
221 |
def instabilities(self): |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
222 |
"""return the list of instabilities affecting this changeset. |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
223 |
|
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
224 |
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
|
225 |
- orphan, |
33689
9c27a2891b75
evolution: rename bumped to phase-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33688
diff
changeset
|
226 |
- phase-divergent, |
33688
2194a8723138
evolution: rename divergent to content-divergent
Boris Feld <boris.feld@octobus.net>
parents:
33667
diff
changeset
|
227 |
- content-divergent. |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
228 |
""" |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
229 |
instabilities = [] |
33727
f163edb45c47
context: rename unstable into orphan
Boris Feld <boris.feld@octobus.net>
parents:
33726
diff
changeset
|
230 |
if self.orphan(): |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
231 |
instabilities.append('orphan') |
33729
8413cbeae275
context: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33728
diff
changeset
|
232 |
if self.phasedivergent(): |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
233 |
instabilities.append('phase-divergent') |
33728
8b2d7684407b
context: rename divergent into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents:
33727
diff
changeset
|
234 |
if self.contentdivergent(): |
33726
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
235 |
instabilities.append('content-divergent') |
ab0c55c2ad9a
context: rename troubles into instabilities
Boris Feld <boris.feld@octobus.net>
parents:
33689
diff
changeset
|
236 |
return instabilities |
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
237 |
|
19556
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
238 |
def parents(self): |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
239 |
"""return contexts for each parent changeset""" |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
240 |
return self._parents |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
241 |
|
19557
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
242 |
def p1(self): |
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
243 |
return self._parents[0] |
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
244 |
|
19558
d0448e9d4554
basectx: move p2 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19557
diff
changeset
|
245 |
def p2(self): |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
246 |
parents = self._parents |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
247 |
if len(parents) == 2: |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
248 |
return parents[1] |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
249 |
return changectx(self._repo, nullrev) |
19558
d0448e9d4554
basectx: move p2 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19557
diff
changeset
|
250 |
|
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
251 |
def _fileinfo(self, path): |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
252 |
if r'_manifest' in self.__dict__: |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
253 |
try: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
254 |
return self._manifest[path], self._manifest.flags(path) |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
255 |
except KeyError: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
256 |
raise error.ManifestLookupError(self._node, path, |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
257 |
_('not found in manifest')) |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
258 |
if r'_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
|
259 |
if path in self._manifestdelta: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
260 |
return (self._manifestdelta[path], |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
261 |
self._manifestdelta.flags(path)) |
30340
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
262 |
mfl = self._repo.manifestlog |
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
263 |
try: |
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
264 |
node, flag = mfl[self._changeset.manifest].find(path) |
608ba935e041
manifest: remove manifest.find
Durham Goode <durham@fb.com>
parents:
30275
diff
changeset
|
265 |
except KeyError: |
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
266 |
raise error.ManifestLookupError(self._node, path, |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
267 |
_('not found in manifest')) |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
268 |
|
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
269 |
return node, flag |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
270 |
|
19560
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
271 |
def filenode(self, path): |
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
272 |
return self._fileinfo(path)[0] |
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
273 |
|
19561
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
274 |
def flags(self, path): |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
275 |
try: |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
276 |
return self._fileinfo(path)[1] |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
277 |
except error.LookupError: |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
278 |
return '' |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
279 |
|
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28488
diff
changeset
|
280 |
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
|
281 |
'''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
|
282 |
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
|
283 |
|
25417
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
284 |
def nullsub(self, path, pctx): |
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
285 |
return subrepo.nullsubrepo(self, path, pctx) |
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
286 |
|
25600
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
287 |
def workingsub(self, path): |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
288 |
'''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
|
289 |
context. |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
290 |
''' |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
291 |
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
|
292 |
|
31388
9e57033fec0c
context: don't use mutable default argument value
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31351
diff
changeset
|
293 |
def match(self, pats=None, include=None, exclude=None, default='glob', |
25465
f472228a9e5e
context: add an optional constructor parameter for a match.bad() override
Matt Harbison <matt_harbison@yahoo.com>
parents:
25435
diff
changeset
|
294 |
listsubrepos=False, badfn=None): |
19563
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
295 |
r = self._repo |
31437
084050d76e4f
context: explicitly tests for None
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31388
diff
changeset
|
296 |
return matchmod.match(r.root, r.getcwd(), pats, |
19563
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
297 |
include, exclude, default, |
27234
15c6eb0a51bd
context: use a the nofsauditor when matching file in history (issue4749)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27183
diff
changeset
|
298 |
auditor=r.nofsauditor, ctx=self, |
25465
f472228a9e5e
context: add an optional constructor parameter for a match.bad() override
Matt Harbison <matt_harbison@yahoo.com>
parents:
25435
diff
changeset
|
299 |
listsubrepos=listsubrepos, badfn=badfn) |
19563
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
300 |
|
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
301 |
def diff(self, ctx2=None, match=None, **opts): |
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
302 |
"""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
|
303 |
if ctx2 is None: |
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
304 |
ctx2 = self.p1() |
19568
f58235d85d6b
basectx: remove unnecessary check of instance
Sean Farley <sean.michael.farley@gmail.com>
parents:
19567
diff
changeset
|
305 |
if ctx2 is not None: |
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
306 |
ctx2 = self._repo[ctx2] |
35353
8384553b1684
py3: handle keyword arguments correctly in context.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35327
diff
changeset
|
307 |
diffopts = patch.diffopts(self._repo.ui, pycompat.byteskwargs(opts)) |
21834
e4d35aa9056c
basectx: pass raw context objects to patch.diff
Sean Farley <sean.michael.farley@gmail.com>
parents:
21722
diff
changeset
|
308 |
return patch.diff(self._repo, ctx2, self, match=match, opts=diffopts) |
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
309 |
|
24323
4c7c6beade1a
manifest: have context's dirs() call its manifest's dirs()
Drew Gottlieb <drgott@google.com>
parents:
24306
diff
changeset
|
310 |
def dirs(self): |
4c7c6beade1a
manifest: have context's dirs() call its manifest's dirs()
Drew Gottlieb <drgott@google.com>
parents:
24306
diff
changeset
|
311 |
return self._manifest.dirs() |
19565
bd1580a9c133
basectx: move _dirs from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19564
diff
changeset
|
312 |
|
24325
79d9c51488ca
manifest: add hasdir() to context
Drew Gottlieb <drgott@google.com>
parents:
24323
diff
changeset
|
313 |
def hasdir(self, dir): |
79d9c51488ca
manifest: add hasdir() to context
Drew Gottlieb <drgott@google.com>
parents:
24323
diff
changeset
|
314 |
return self._manifest.hasdir(dir) |
19566
54817c774d38
basectx: move dirs from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19565
diff
changeset
|
315 |
|
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
316 |
def status(self, other=None, match=None, listignored=False, |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
317 |
listclean=False, listunknown=False, listsubrepos=False): |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
318 |
"""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
|
319 |
directory. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
320 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
321 |
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
|
322 |
|
ee29b0bb1619
status: document the content of the returned tuple in the docstring
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21718
diff
changeset
|
323 |
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
|
324 |
""" |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
325 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
326 |
ctx1 = self |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
327 |
ctx2 = self._repo[other] |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
328 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
329 |
# 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
|
330 |
# 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
|
331 |
# 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
|
332 |
# with its first parent. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
333 |
# |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
334 |
# 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
|
335 |
# |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
336 |
# workingctx.status(parentctx) |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
337 |
# |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
338 |
# 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
|
339 |
# 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
|
340 |
# just copy the manifest of the parent. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
341 |
reversed = False |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
342 |
if (not isinstance(ctx1, changectx) |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
343 |
and isinstance(ctx2, changectx)): |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
344 |
reversed = True |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
345 |
ctx1, ctx2 = ctx2, ctx1 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
346 |
|
33936
c714e82b9ac2
context: always pass a matcher into _matchstatus() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33901
diff
changeset
|
347 |
match = match or matchmod.always(self._repo.root, self._repo.getcwd()) |
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
348 |
match = ctx2._matchstatus(ctx1, match) |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
349 |
r = scmutil.status([], [], [], [], [], [], []) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
350 |
r = ctx2._buildstatus(ctx1, r, match, listignored, listclean, |
21663
8d9449eaaeff
context: fix wrong indentation from renaming method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21616
diff
changeset
|
351 |
listunknown) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
352 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
353 |
if reversed: |
23301
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
354 |
# 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
|
355 |
# these make no sense to reverse. |
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
356 |
r = scmutil.status(r.modified, r.removed, r.added, [], [], [], |
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
357 |
r.clean) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
358 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
359 |
if listsubrepos: |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
360 |
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
|
361 |
try: |
27183
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
362 |
rev2 = ctx2.subrev(subpath) |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
363 |
except KeyError: |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
364 |
# 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
|
365 |
# 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
|
366 |
# 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
|
367 |
rev2 = None |
28017
d3f1b7ee5e70
match: rename "narrowmatcher" to "subdirmatcher" (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27983
diff
changeset
|
368 |
submatch = matchmod.subdirmatcher(subpath, match) |
27183
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
369 |
s = sub.status(rev2, match=submatch, ignored=listignored, |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
370 |
clean=listclean, unknown=listunknown, |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
371 |
listsubrepos=True) |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
372 |
for rfiles, sfiles in zip(r, s): |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
373 |
rfiles.extend("%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
|
374 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
375 |
for l in r: |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
376 |
l.sort() |
21616
0a8e7f81e8ae
context: explicitly return a tuple
Sean Farley <sean.michael.farley@gmail.com>
parents:
21595
diff
changeset
|
377 |
|
23301
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
378 |
return r |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
379 |
|
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
|
380 |
class changectx(basectx): |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
381 |
"""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
|
382 |
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
|
383 |
the repo.""" |
37151
05c13e5aa9ec
context: change default changeid from old form '' to '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
37101
diff
changeset
|
384 |
def __init__(self, repo, changeid='.'): |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
385 |
"""changeid is a revision number, node, or tag""" |
37175
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
386 |
super(changectx, self).__init__(repo) |
19539
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
387 |
|
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
388 |
try: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
389 |
if isinstance(changeid, int): |
23013
b50ed6b9b513
changectx: move `IndexError` handling in the top level try except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23012
diff
changeset
|
390 |
self._node = repo.changelog.node(changeid) |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
391 |
self._rev = changeid |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
392 |
return |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
393 |
if changeid == 'null': |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
394 |
self._node = nullid |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
395 |
self._rev = nullrev |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
396 |
return |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
397 |
if changeid == 'tip': |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
398 |
self._node = repo.changelog.tip() |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
399 |
self._rev = repo.changelog.rev(self._node) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
400 |
return |
34926
f7e4d6c20095
statichttprepo: prevent loading dirstate over HTTP on node lookup (issue5717)
Yuya Nishihara <yuya@tcha.org>
parents:
34835
diff
changeset
|
401 |
if (changeid == '.' |
f7e4d6c20095
statichttprepo: prevent loading dirstate over HTTP on node lookup (issue5717)
Yuya Nishihara <yuya@tcha.org>
parents:
34835
diff
changeset
|
402 |
or repo.local() and changeid == repo.dirstate.p1()): |
24050
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
403 |
# this is a hack to delay/avoid loading obsmarkers |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
404 |
# when we know that '.' won't be hidden |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
405 |
self._node = repo.dirstate.p1() |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
406 |
self._rev = repo.unfiltered().changelog.rev(self._node) |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
407 |
return |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
408 |
if len(changeid) == 20: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
409 |
try: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
410 |
self._node = changeid |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
411 |
self._rev = repo.changelog.rev(changeid) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
412 |
return |
37386
167b22a906f3
context: make repo[<filtered binary nodeid>] match node
Martin von Zweigbergk <martinvonz@google.com>
parents:
37385
diff
changeset
|
413 |
except error.FilteredLookupError: |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
414 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
415 |
except LookupError: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
416 |
pass |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
417 |
|
18084
ee3b5fb648c7
clfilter: ensure context raise RepoLookupError when the revision is filtered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18072
diff
changeset
|
418 |
try: |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
419 |
r = int(changeid) |
31351
5da0c7888dc4
context: use portable construction to verify int parsing
Augie Fackler <augie@google.com>
parents:
31344
diff
changeset
|
420 |
if '%d' % r != changeid: |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
421 |
raise ValueError |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
422 |
l = len(repo.changelog) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
423 |
if r < 0: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
424 |
r += l |
32660
a722c8e17363
localrepo: map integer and hex wdir identifiers to workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
32652
diff
changeset
|
425 |
if r < 0 or r >= l and r != wdirrev: |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
426 |
raise ValueError |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
427 |
self._rev = r |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
428 |
self._node = repo.changelog.node(r) |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
429 |
return |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
430 |
except error.FilteredIndexError: |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
431 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
432 |
except (ValueError, OverflowError, IndexError): |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
433 |
pass |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
434 |
|
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
435 |
if len(changeid) == 40: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
436 |
try: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
437 |
self._node = bin(changeid) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
438 |
self._rev = repo.changelog.rev(self._node) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
439 |
return |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
440 |
except error.FilteredLookupError: |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
441 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
442 |
except (TypeError, LookupError): |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
443 |
pass |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
444 |
|
23560
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
445 |
# lookup bookmarks through the name interface |
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
446 |
try: |
23561
3c2419e07df5
namespaces: remove weakref; always pass in repo
Ryan McElroy <rmcelroy@fb.com>
parents:
23560
diff
changeset
|
447 |
self._node = repo.names.singlenode(repo, changeid) |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
448 |
self._rev = repo.changelog.rev(self._node) |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
449 |
return |
23560
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
450 |
except KeyError: |
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
451 |
pass |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
452 |
|
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
453 |
self._node = repo.unfiltered().changelog._partialmatch(changeid) |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
454 |
if self._node is not None: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
455 |
self._rev = repo.changelog.rev(self._node) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
456 |
return |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
457 |
|
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
458 |
# lookup failed |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
459 |
# check if it might have come from damaged dirstate |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
460 |
# |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
461 |
# XXX we could avoid the unfiltered if we had a recognizable |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
462 |
# exception for filtered changeset access |
34926
f7e4d6c20095
statichttprepo: prevent loading dirstate over HTTP on node lookup (issue5717)
Yuya Nishihara <yuya@tcha.org>
parents:
34835
diff
changeset
|
463 |
if (repo.local() |
f7e4d6c20095
statichttprepo: prevent loading dirstate over HTTP on node lookup (issue5717)
Yuya Nishihara <yuya@tcha.org>
parents:
34835
diff
changeset
|
464 |
and changeid in repo.unfiltered().dirstate.parents()): |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
465 |
msg = _("working directory has unknown parent '%s'!") |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
466 |
raise error.Abort(msg % short(changeid)) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
467 |
try: |
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
468 |
if len(changeid) == 20 and nonascii(changeid): |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
469 |
changeid = hex(changeid) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
470 |
except TypeError: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
471 |
pass |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
472 |
except (error.FilteredIndexError, error.FilteredLookupError, |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
473 |
error.FilteredRepoLookupError): |
37385
ecd3f6909184
context: move handling of filtering error to revsymbol() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
37354
diff
changeset
|
474 |
raise |
23013
b50ed6b9b513
changectx: move `IndexError` handling in the top level try except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23012
diff
changeset
|
475 |
except IndexError: |
b50ed6b9b513
changectx: move `IndexError` handling in the top level try except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23012
diff
changeset
|
476 |
pass |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
477 |
raise error.RepoLookupError( |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
478 |
_("unknown revision '%s'") % changeid) |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
479 |
|
6469
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
480 |
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
|
481 |
try: |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
482 |
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
|
483 |
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
|
484 |
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
|
485 |
|
3168
05c588e1803d
context: add __nonzero__ methods
Matt Mackall <mpm@selenic.com>
parents:
3166
diff
changeset
|
486 |
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
|
487 |
return self._rev != nullrev |
3168
05c588e1803d
context: add __nonzero__ methods
Matt Mackall <mpm@selenic.com>
parents:
3166
diff
changeset
|
488 |
|
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
489 |
__bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
490 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
491 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
492 |
def _changeset(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
493 |
return self._repo.changelog.changelogrevision(self.rev()) |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
494 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
495 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
496 |
def _manifest(self): |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
497 |
return self._manifestctx.read() |
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
498 |
|
32519 | 499 |
@property |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
500 |
def _manifestctx(self): |
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
501 |
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
|
502 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
503 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
504 |
def _manifestdelta(self): |
30344
362f6f651b2e
context: add manifestctx property on changectx
Durham Goode <durham@fb.com>
parents:
30340
diff
changeset
|
505 |
return self._manifestctx.readdelta() |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
506 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
507 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
508 |
def _parents(self): |
27063
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
509 |
repo = self._repo |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
510 |
p1, p2 = repo.changelog.parentrevs(self._rev) |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
511 |
if p2 == nullrev: |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
512 |
return [changectx(repo, p1)] |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
513 |
return [changectx(repo, p1), changectx(repo, p2)] |
3215
931288cf58a7
contexts: use __getattr__ rather than try/except in changectx
Matt Mackall <mpm@selenic.com>
parents:
3214
diff
changeset
|
514 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
515 |
def changeset(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
516 |
c = self._changeset |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
517 |
return ( |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
518 |
c.manifest, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
519 |
c.user, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
520 |
c.date, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
521 |
c.files, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
522 |
c.description, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
523 |
c.extra, |
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
524 |
) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
525 |
def manifestnode(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
526 |
return self._changeset.manifest |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
527 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
528 |
def user(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
529 |
return self._changeset.user |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
530 |
def date(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
531 |
return self._changeset.date |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
532 |
def files(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
533 |
return self._changeset.files |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
534 |
def description(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
535 |
return self._changeset.description |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
536 |
def branch(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
537 |
return encoding.tolocal(self._changeset.extra.get("branch")) |
16720
e825a89de5d7
context: add changectx.closesbranch() method
Brodie Rao <brodie@sf.io>
parents:
16719
diff
changeset
|
538 |
def closesbranch(self): |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
539 |
return 'close' in self._changeset.extra |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
540 |
def extra(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
541 |
"""Return a dict of extra information.""" |
28488
437c32dcec7d
context: use changelogrevision
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28315
diff
changeset
|
542 |
return self._changeset.extra |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
543 |
def tags(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
544 |
"""Return a list of byte tag names""" |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
545 |
return self._repo.nodetags(self._node) |
13384
caa561759538
context: add method to return all bookmarks pointing to a node
David Soria Parra <dsp@php.net>
parents:
13235
diff
changeset
|
546 |
def bookmarks(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
547 |
"""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
|
548 |
return self._repo.nodebookmarks(self._node) |
15421
405ca90df2b1
phases: add a phase method to context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15337
diff
changeset
|
549 |
def phase(self): |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16610
diff
changeset
|
550 |
return self._repo._phasecache.phase(self._repo, self._rev) |
14644
f3a40fd7008c
hidden: Add ``hidden`` method for context
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
14528
diff
changeset
|
551 |
def hidden(self): |
18382
f3b21beb9802
filtering: rename filters to their antonyms
Kevin Bullock <kbullock@ringworld.org>
parents:
18364
diff
changeset
|
552 |
return self._rev in repoview.filterrevs(self._repo, 'visible') |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
553 |
|
34681
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
554 |
def isinmemory(self): |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
555 |
return False |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
556 |
|
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
557 |
def children(self): |
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
558 |
"""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
|
559 |
|
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
560 |
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
|
561 |
recursively walk children. |
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
562 |
""" |
2627
b779319a532b
context.py: self.repo is not defined, change to self._repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2566
diff
changeset
|
563 |
c = self._repo.changelog.children(self._node) |
3673
eb0b4a2d70a9
white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3578
diff
changeset
|
564 |
return [changectx(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
|
565 |
|
6876 | 566 |
def ancestors(self): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16761
diff
changeset
|
567 |
for a in self._repo.changelog.ancestors([self._rev]): |
6876 | 568 |
yield changectx(self._repo, a) |
569 |
||
570 |
def descendants(self): |
|
35107
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
571 |
"""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
|
572 |
|
b22a0d9e0a83
docs: add args/returns docs for some cmdutil, context, and registrar functions
rlevasseur@google.com
parents:
35093
diff
changeset
|
573 |
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
|
574 |
""" |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16866
diff
changeset
|
575 |
for d in self._repo.changelog.descendants([self._rev]): |
6876 | 576 |
yield changectx(self._repo, d) |
577 |
||
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
578 |
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
|
579 |
"""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
|
580 |
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
|
581 |
fileid = self.filenode(path) |
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
582 |
return filectx(self._repo, path, fileid=fileid, |
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
583 |
changectx=self, filelog=filelog) |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
584 |
|
21203
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
585 |
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
|
586 |
"""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
|
587 |
|
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
588 |
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
|
589 |
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
|
590 |
revlog ancestor.""" |
9843
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
591 |
# deal with workingctxs |
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
592 |
n2 = c2._node |
13031
3da456d0c885
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents:
13001
diff
changeset
|
593 |
if n2 is None: |
9843
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
if not cahs: |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
597 |
anc = nullid |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
598 |
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
|
599 |
anc = cahs[0] |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
600 |
else: |
25844
18541e9510c5
merge: make merge.preferancestor type and default consistent
Matt Mackall <mpm@selenic.com>
parents:
25757
diff
changeset
|
601 |
# experimental config: merge.preferancestor |
34479
99c3dee3f6ce
configitems: register the 'merge.preferancestor' config
Boris Feld <boris.feld@octobus.net>
parents:
34433
diff
changeset
|
602 |
for r in self._repo.ui.configlist('merge', 'preferancestor'): |
22671
5220c12c43fd
changectx: skip all invalid merge.preferancestor values
Mads Kiilerich <madski@unity3d.com>
parents:
22405
diff
changeset
|
603 |
try: |
37354
a6014392837e
context: use revsymbol() in "merge.preferancestor" code
Martin von Zweigbergk <martinvonz@google.com>
parents:
37267
diff
changeset
|
604 |
ctx = scmutil.revsymbol(self._repo, r) |
22671
5220c12c43fd
changectx: skip all invalid merge.preferancestor values
Mads Kiilerich <madski@unity3d.com>
parents:
22405
diff
changeset
|
605 |
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
|
606 |
continue |
21126
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
607 |
anc = ctx.node() |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
608 |
if anc in cahs: |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
609 |
break |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
610 |
else: |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
611 |
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
|
612 |
if warn: |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
613 |
self._repo.ui.status( |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
614 |
(_("note: using %s as ancestor of %s and %s\n") % |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
615 |
(short(anc), short(self._node), short(n2))) + |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
616 |
''.join(_(" alternatively, use --config " |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
617 |
"merge.preferancestor=%s\n") % |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
618 |
short(n) for n in sorted(cahs) if n != anc)) |
21125
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
619 |
return changectx(self._repo, anc) |
3125
02b22fefc01f
changectx: add ancestor function
Matt Mackall <mpm@selenic.com>
parents:
3124
diff
changeset
|
620 |
|
17626
3a524b647897
context: add "descendant()" to changectx for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17469
diff
changeset
|
621 |
def descendant(self, other): |
3a524b647897
context: add "descendant()" to changectx for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17469
diff
changeset
|
622 |
"""True if other is descendant of this changeset""" |
3a524b647897
context: add "descendant()" to changectx for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17469
diff
changeset
|
623 |
return self._repo.changelog.descendant(self._rev, other._rev) |
3a524b647897
context: add "descendant()" to changectx for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17469
diff
changeset
|
624 |
|
6764 | 625 |
def walk(self, match): |
24646
5693c834bcb4
manifest: move changectx.walk() to manifests
Drew Gottlieb <drgott@google.com>
parents:
24633
diff
changeset
|
626 |
'''Generates matching file names.''' |
20292
8dc254198a8f
changectx: increase perf of walk function
Durham Goode <durham@fb.com>
parents:
20236
diff
changeset
|
627 |
|
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
628 |
# 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
|
629 |
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
|
630 |
# 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
|
631 |
# paths into valid subrepos. |
25195 | 632 |
if any(fn == s or fn.startswith(s + '/') |
633 |
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
|
634 |
return |
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
635 |
match.bad(fn, _('no such file in rev %s') % self) |
20292
8dc254198a8f
changectx: increase perf of walk function
Durham Goode <durham@fb.com>
parents:
20236
diff
changeset
|
636 |
|
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
637 |
m = matchmod.badmatch(match, bad) |
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
638 |
return self._manifest.walk(m) |
6764 | 639 |
|
21985
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
640 |
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
|
641 |
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
|
642 |
|
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
|
643 |
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
|
644 |
"""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
|
645 |
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
|
646 |
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
|
647 |
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
|
648 |
directory, |
32243
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
649 |
memfilectx: a filecontext that represents files in-memory, |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
650 |
overlayfilectx: duplicate another filecontext with some fields overridden. |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
651 |
""" |
19573
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
652 |
@propertycache |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
653 |
def _filelog(self): |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
654 |
return self._repo.file(self._path) |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
655 |
|
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
656 |
@propertycache |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
657 |
def _changeid(self): |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
658 |
if r'_changeid' in self.__dict__: |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
659 |
return self._changeid |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
660 |
elif r'_changectx' in self.__dict__: |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
661 |
return self._changectx.rev() |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
662 |
elif r'_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
|
663 |
# 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
|
664 |
# descendant, we can (lazily) correct for linkrev aliases |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
665 |
return self._adjustlinkrev(self._descendantrev) |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
666 |
else: |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
667 |
return self._filelog.linkrev(self._filerev) |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
668 |
|
19575
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
669 |
@propertycache |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
670 |
def _filenode(self): |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
671 |
if r'_fileid' in self.__dict__: |
19575
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
672 |
return self._filelog.lookup(self._fileid) |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
673 |
else: |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
674 |
return self._changectx.filenode(self._path) |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
675 |
|
19576
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
676 |
@propertycache |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
677 |
def _filerev(self): |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
678 |
return self._filelog.rev(self._filenode) |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
679 |
|
19577
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
680 |
@propertycache |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
681 |
def _repopath(self): |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
682 |
return self._path |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
683 |
|
19578
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
684 |
def __nonzero__(self): |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
685 |
try: |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
686 |
self._filenode |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
687 |
return True |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
688 |
except error.LookupError: |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
689 |
# file is missing |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
690 |
return False |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
691 |
|
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
692 |
__bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
693 |
|
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
694 |
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
|
695 |
try: |
e25ce44f8447
context: make sure __str__ works, also when there is no _changectx
Mads Kiilerich <mads@kiilerich.com>
parents:
30040
diff
changeset
|
696 |
return "%s@%s" % (self.path(), self._changectx) |
e25ce44f8447
context: make sure __str__ works, also when there is no _changectx
Mads Kiilerich <mads@kiilerich.com>
parents:
30040
diff
changeset
|
697 |
except error.LookupError: |
e25ce44f8447
context: make sure __str__ works, also when there is no _changectx
Mads Kiilerich <mads@kiilerich.com>
parents:
30040
diff
changeset
|
698 |
return "%s@???" % self.path() |
19579
964844d64ef8
basefilectx: move __str__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19578
diff
changeset
|
699 |
|
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
700 |
__str__ = encoding.strmethod(__bytes__) |
33019
daccadd75760
py3: define __bytes__ for basefilectx class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32904
diff
changeset
|
701 |
|
19580
e86a594ab11f
basefilectx: move __repr__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19579
diff
changeset
|
702 |
def __repr__(self): |
36705
c6901665cd5b
py3: make sure __repr__ returns a str
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36704
diff
changeset
|
703 |
return r"<%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
|
704 |
|
19581
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
705 |
def __hash__(self): |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
706 |
try: |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
707 |
return hash((self._path, self._filenode)) |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
708 |
except AttributeError: |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
709 |
return id(self) |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
710 |
|
19582
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
711 |
def __eq__(self, other): |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
712 |
try: |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
713 |
return (type(self) == type(other) and self._path == other._path |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
714 |
and self._filenode == other._filenode) |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
715 |
except AttributeError: |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
716 |
return False |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
717 |
|
19583
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
718 |
def __ne__(self, other): |
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
719 |
return not (self == other) |
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
720 |
|
19584
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
721 |
def filerev(self): |
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
722 |
return self._filerev |
19585
8e553cd6071e
basefilectx: move filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19584
diff
changeset
|
723 |
def filenode(self): |
8e553cd6071e
basefilectx: move filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19584
diff
changeset
|
724 |
return self._filenode |
32238
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
725 |
@propertycache |
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
726 |
def _flags(self): |
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
727 |
return self._changectx.flags(self._path) |
19586
43f9ed2f64b1
basefilectx: move flags from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19585
diff
changeset
|
728 |
def flags(self): |
32238
8a660af9dbe3
filectx: make flags a property cache
Jun Wu <quark@fb.com>
parents:
32148
diff
changeset
|
729 |
return self._flags |
19587
b1c344ebd8e4
basefilectx: move filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19586
diff
changeset
|
730 |
def filelog(self): |
b1c344ebd8e4
basefilectx: move filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19586
diff
changeset
|
731 |
return self._filelog |
19588
a192fff6c97d
basefilectx: move rev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19587
diff
changeset
|
732 |
def rev(self): |
a192fff6c97d
basefilectx: move rev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19587
diff
changeset
|
733 |
return self._changeid |
19589
6a9043fa06d0
basefilectx: move linkrev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19588
diff
changeset
|
734 |
def linkrev(self): |
6a9043fa06d0
basefilectx: move linkrev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19588
diff
changeset
|
735 |
return self._filelog.linkrev(self._filerev) |
19590
90994b176bc1
basefilectx: move node from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19589
diff
changeset
|
736 |
def node(self): |
90994b176bc1
basefilectx: move node from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19589
diff
changeset
|
737 |
return self._changectx.node() |
19591
04fbc85f870a
basefilectx: move hex from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19590
diff
changeset
|
738 |
def hex(self): |
04fbc85f870a
basefilectx: move hex from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19590
diff
changeset
|
739 |
return self._changectx.hex() |
19592
1cdb3b3df4df
basefilectx: move user from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19591
diff
changeset
|
740 |
def user(self): |
1cdb3b3df4df
basefilectx: move user from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19591
diff
changeset
|
741 |
return self._changectx.user() |
19593
e3c241c89350
basefilectx: move date from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19592
diff
changeset
|
742 |
def date(self): |
e3c241c89350
basefilectx: move date from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19592
diff
changeset
|
743 |
return self._changectx.date() |
19594
1c030c24e196
basefilectx: move files from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19593
diff
changeset
|
744 |
def files(self): |
1c030c24e196
basefilectx: move files from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19593
diff
changeset
|
745 |
return self._changectx.files() |
19595
bb6fd06975a6
basefilectx: move description from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19594
diff
changeset
|
746 |
def description(self): |
bb6fd06975a6
basefilectx: move description from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19594
diff
changeset
|
747 |
return self._changectx.description() |
19596
9bc3d0dea371
basefilectx: move branch from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19595
diff
changeset
|
748 |
def branch(self): |
9bc3d0dea371
basefilectx: move branch from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19595
diff
changeset
|
749 |
return self._changectx.branch() |
19597
837bc86370f0
basefilectx: move extra from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19596
diff
changeset
|
750 |
def extra(self): |
837bc86370f0
basefilectx: move extra from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19596
diff
changeset
|
751 |
return self._changectx.extra() |
19598
e8ef893a3150
basefilectx: move phase from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19597
diff
changeset
|
752 |
def phase(self): |
e8ef893a3150
basefilectx: move phase from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19597
diff
changeset
|
753 |
return self._changectx.phase() |
19599
66d83efac20a
basefilectx: move phasestr from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19598
diff
changeset
|
754 |
def phasestr(self): |
66d83efac20a
basefilectx: move phasestr from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19598
diff
changeset
|
755 |
return self._changectx.phasestr() |
35088
a9454beb9dd8
context: add obsolete() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
34926
diff
changeset
|
756 |
def obsolete(self): |
a9454beb9dd8
context: add obsolete() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
34926
diff
changeset
|
757 |
return self._changectx.obsolete() |
35093
bd2743936b56
context: add instabilities() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
35088
diff
changeset
|
758 |
def instabilities(self): |
bd2743936b56
context: add instabilities() method to basefilectx
Anton Shestakov <av6@dwimlabs.net>
parents:
35088
diff
changeset
|
759 |
return self._changectx.instabilities() |
19600
12cdff44fdc4
basefilectx: move manifest from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19599
diff
changeset
|
760 |
def manifest(self): |
12cdff44fdc4
basefilectx: move manifest from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19599
diff
changeset
|
761 |
return self._changectx.manifest() |
19601
f284907631f5
basefilectx: move changectx from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19600
diff
changeset
|
762 |
def changectx(self): |
f284907631f5
basefilectx: move changectx from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19600
diff
changeset
|
763 |
return self._changectx |
32239
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
764 |
def renamed(self): |
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
765 |
return self._copied |
24333
5da0eb641881
filectx: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24326
diff
changeset
|
766 |
def repo(self): |
5da0eb641881
filectx: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24326
diff
changeset
|
767 |
return self._repo |
32240 | 768 |
def size(self): |
769 |
return len(self.data()) |
|
19584
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
770 |
|
19602
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
771 |
def path(self): |
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
772 |
return self._path |
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
773 |
|
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
774 |
def isbinary(self): |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
775 |
try: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
776 |
return stringutil.binary(self.data()) |
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
777 |
except IOError: |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
778 |
return False |
22054
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
779 |
def isexec(self): |
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
780 |
return 'x' in self.flags() |
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
781 |
def islink(self): |
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
782 |
return 'l' in self.flags() |
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
783 |
|
26978
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
784 |
def isabsent(self): |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
785 |
"""whether this filectx represents a file not in self._changectx |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
786 |
|
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
787 |
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
|
788 |
expected to be True for all subclasses of basectx.""" |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
789 |
return False |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
790 |
|
26977
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
791 |
_customcmp = False |
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
792 |
def cmp(self, fctx): |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
793 |
"""compare with other file context |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
794 |
|
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
795 |
returns True if different than fctx. |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
796 |
""" |
26977
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
797 |
if fctx._customcmp: |
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
798 |
return fctx.cmp(self) |
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
799 |
|
28116
ba8257cb53e8
filectx: replace use of _filerev with _filenode
Durham Goode <durham@fb.com>
parents:
28017
diff
changeset
|
800 |
if (fctx._filenode is None |
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
801 |
and (self._repo._encodefilterpats |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
802 |
# if file data starts with '\1\n', empty metadata block is |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
803 |
# prepended, which adds 4 bytes to filelog.size(). |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
804 |
or self.size() - 4 == fctx.size()) |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
805 |
or self.size() == fctx.size()): |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
806 |
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
|
807 |
|
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
808 |
return True |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
809 |
|
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
810 |
def _adjustlinkrev(self, srcrev, inclusive=False): |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24050
diff
changeset
|
811 |
"""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
|
812 |
|
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
813 |
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
|
814 |
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
|
815 |
this file revision. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
816 |
|
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
817 |
: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
|
818 |
:inclusive: if true, the src revision will also be checked |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
819 |
""" |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
820 |
repo = self._repo |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
821 |
cl = repo.unfiltered().changelog |
29939
80be4436e4cc
manifest: adds manifestctx.readfast
Durham Goode <durham@fb.com>
parents:
29938
diff
changeset
|
822 |
mfl = repo.manifestlog |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
823 |
# fetch the linkrev |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
824 |
lkr = self.linkrev() |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
825 |
# 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
|
826 |
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
|
827 |
iteranc = None |
24411
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
828 |
if srcrev is None: |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
829 |
# 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
|
830 |
revs = [p.rev() for p in self._repo[None].parents()] |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
831 |
inclusive = True # we skipped the real (revless) source |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
832 |
else: |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
833 |
revs = [srcrev] |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
834 |
if memberanc is None: |
24411
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
835 |
memberanc = iteranc = cl.ancestors(revs, lkr, |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
836 |
inclusive=inclusive) |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
837 |
# 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
|
838 |
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
|
839 |
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
|
840 |
iteranc = cl.ancestors(revs, lkr, inclusive=inclusive) |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
841 |
fnode = self._filenode |
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
842 |
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
|
843 |
for a in iteranc: |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
844 |
ac = cl.read(a) # get changeset data (we avoid object creation) |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
845 |
if path in ac[3]: # checking the 'files' field. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
846 |
# 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
|
847 |
# similar to the one we search for. |
29939
80be4436e4cc
manifest: adds manifestctx.readfast
Durham Goode <durham@fb.com>
parents:
29938
diff
changeset
|
848 |
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
|
849 |
return a |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
850 |
# 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
|
851 |
# 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
|
852 |
# 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
|
853 |
# 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
|
854 |
return lkr |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
855 |
|
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
856 |
def introrev(self): |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
857 |
"""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
|
858 |
|
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
859 |
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
|
860 |
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
|
861 |
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
|
862 |
'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
|
863 |
changesets. |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
864 |
""" |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
865 |
lkr = self.linkrev() |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
866 |
attrs = vars(self) |
36639
334da951a50b
py3: fix some membership tests on linkrev adjustment
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
867 |
noctx = not (r'_changeid' in attrs or r'_changectx' in attrs) |
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
868 |
if noctx or self.rev() == lkr: |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
869 |
return self.linkrev() |
30275
e81d72b4b0ae
adjustlinkrev: remove unnecessary parameters
Jun Wu <quark@fb.com>
parents:
30270
diff
changeset
|
870 |
return self._adjustlinkrev(self.rev(), inclusive=True) |
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
871 |
|
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
872 |
def introfilectx(self): |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
873 |
"""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
|
874 |
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
|
875 |
introrev = self.introrev() |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
876 |
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
|
877 |
return self |
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
878 |
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
|
879 |
|
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
880 |
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
|
881 |
"""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
|
882 |
fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) |
36639
334da951a50b
py3: fix some membership tests on linkrev adjustment
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
883 |
if r'_changeid' in vars(self) or r'_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
|
884 |
# 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
|
885 |
# 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
|
886 |
# 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
|
887 |
# 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
|
888 |
fctx._descendantrev = self.rev() |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
889 |
fctx._ancestrycontext = getattr(self, '_ancestrycontext', None) |
36639
334da951a50b
py3: fix some membership tests on linkrev adjustment
Yuya Nishihara <yuya@tcha.org>
parents:
36607
diff
changeset
|
890 |
elif r'_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
|
891 |
# 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
|
892 |
fctx._descendantrev = self._descendantrev |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
893 |
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
|
894 |
return fctx |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
895 |
|
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
896 |
def parents(self): |
22201
269688a398c4
cleanup: fix some list comprehension redefinitions of existing vars
Mads Kiilerich <madski@unity3d.com>
parents:
22192
diff
changeset
|
897 |
_path = self._path |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
898 |
fl = self._filelog |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
899 |
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
|
900 |
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
|
901 |
|
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
|
902 |
r = fl.renamed(self._filenode) |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
903 |
if r: |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
904 |
# - 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
|
905 |
# - 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
|
906 |
# 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
|
907 |
# the first one. |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
908 |
# |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24050
diff
changeset
|
909 |
# 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
|
910 |
# 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
|
911 |
# 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
|
912 |
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
|
913 |
|
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
914 |
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
|
915 |
|
19606
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
916 |
def p1(self): |
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
917 |
return self.parents()[0] |
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
918 |
|
19607
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
919 |
def p2(self): |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
920 |
p = self.parents() |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
921 |
if len(p) == 2: |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
922 |
return p[1] |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
923 |
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
|
924 |
|
37065
b235bde38a83
annotate: drop linenumber flag from fctx.annotate() (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36918
diff
changeset
|
925 |
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
|
926 |
"""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
|
927 |
|
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
928 |
- 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
|
929 |
- 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
|
930 |
file |
37066
b33b91ca2ec2
annotate: pack line content into annotateline object (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37065
diff
changeset
|
931 |
- 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
|
932 |
""" |
9097
431462bd8478
fix memory usage of revlog caches by limiting cache size [issue1639]
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
933 |
getlog = util.lrucachefunc(lambda x: self._repo.file(x)) |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
934 |
|
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
935 |
def parents(f): |
24862
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
936 |
# 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
|
937 |
# 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
|
938 |
# 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
|
939 |
# 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
|
940 |
f._changeid |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
941 |
pl = f.parents() |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
942 |
|
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
943 |
# 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
|
944 |
if not follow: |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
945 |
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
|
946 |
|
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
947 |
# 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
|
948 |
# from the cache to save time |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
949 |
for p in pl: |
35834
f61461d2bfd8
context: use native string when peeking in __dict__
Augie Fackler <augie@google.com>
parents:
35725
diff
changeset
|
950 |
if not r'_filelog' in p.__dict__: |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
951 |
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
|
952 |
|
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
953 |
return pl |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
954 |
|
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
955 |
# 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
|
956 |
base = self.introfilectx() |
24818
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
957 |
if getattr(base, '_ancestrycontext', None) is None: |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
958 |
cl = self._repo.changelog |
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
959 |
if base.rev() is None: |
24818
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
960 |
# wctx is not inclusive, but works because _ancestrycontext |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
961 |
# is used to test filelog revisions |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
962 |
ac = cl.ancestors([p.rev() for p in base.parents()], |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
963 |
inclusive=True) |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
964 |
else: |
35271
d90c534099b1
filectx: extract helper method to obtain filectx pointing to its introrev
Yuya Nishihara <yuya@tcha.org>
parents:
35107
diff
changeset
|
965 |
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
|
966 |
base._ancestrycontext = ac |
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
967 |
|
37065
b235bde38a83
annotate: drop linenumber flag from fctx.annotate() (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36918
diff
changeset
|
968 |
return dagop.annotate(base, parents, skiprevs=skiprevs, |
b235bde38a83
annotate: drop linenumber flag from fctx.annotate() (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36918
diff
changeset
|
969 |
diffopts=diffopts) |
3124
4d021b91cb26
filectx: allow passing filelog in init to avoid opening new filelogs
Matt Mackall <mpm@selenic.com>
parents:
3123
diff
changeset
|
970 |
|
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
971 |
def ancestors(self, followfirst=False): |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
972 |
visit = {} |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
973 |
c = self |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
974 |
if followfirst: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
975 |
cut = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
976 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
977 |
cut = None |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
978 |
|
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
979 |
while True: |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
980 |
for parent in c.parents()[:cut]: |
23981
24b57c3899f8
filectx: use linkrev to sort ancestors
Matt Mackall <mpm@selenic.com>
parents:
23980
diff
changeset
|
981 |
visit[(parent.linkrev(), parent.filenode())] = parent |
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
982 |
if not visit: |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
983 |
break |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
984 |
c = visit.pop(max(visit)) |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
985 |
yield c |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
986 |
|
33901
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
987 |
def decodeddata(self): |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
988 |
"""Returns `data()` after running repository decoding filters. |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
989 |
|
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
990 |
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
|
991 |
""" |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
992 |
return self._repo.wwritedata(self.path(), self.data()) |
f488223a87ab
context: add `decodeddata()` to basefilectx
Phil Cohen <phillco@fb.com>
parents:
33797
diff
changeset
|
993 |
|
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
994 |
class filectx(basefilectx): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
995 |
"""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
|
996 |
filerevision convenient.""" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
997 |
def __init__(self, repo, path, changeid=None, fileid=None, |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
998 |
filelog=None, changectx=None): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
999 |
"""changeid can be a changeset revision, node, or tag. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1000 |
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
|
1001 |
self._repo = repo |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1002 |
self._path = path |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1003 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1004 |
assert (changeid is not None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1005 |
or fileid is not None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1006 |
or changectx is not None), \ |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1007 |
("bad args: changeid=%r, fileid=%r, changectx=%r" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1008 |
% (changeid, fileid, changectx)) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1009 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1010 |
if filelog is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1011 |
self._filelog = filelog |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1012 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1013 |
if changeid is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1014 |
self._changeid = changeid |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1015 |
if changectx is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1016 |
self._changectx = changectx |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1017 |
if fileid is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1018 |
self._fileid = fileid |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1019 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1020 |
@propertycache |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1021 |
def _changectx(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1022 |
try: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1023 |
return changectx(self._repo, self._changeid) |
23687
8f32dcfbc338
context: catch FilteredRepoLookupError instead of RepoLookupError
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23616
diff
changeset
|
1024 |
except error.FilteredRepoLookupError: |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1025 |
# 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
|
1026 |
# 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
|
1027 |
# `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
|
1028 |
# 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
|
1029 |
# 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
|
1030 |
# `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
|
1031 |
# filtering. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1032 |
# |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1033 |
# 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
|
1034 |
# 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
|
1035 |
# 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
|
1036 |
# behavior" is seen as better as "crash" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1037 |
# |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1038 |
# 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
|
1039 |
# 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
|
1040 |
# considered when solving linkrev issue are on the table. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1041 |
return changectx(self._repo.unfiltered(), self._changeid) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1042 |
|
23770
50f0096a7346
filectx: fix annotate to not directly instantiate filectx
Durham Goode <durham@fb.com>
parents:
23757
diff
changeset
|
1043 |
def filectx(self, fileid, changeid=None): |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1044 |
'''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
|
1045 |
opening a new filelog''' |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1046 |
return filectx(self._repo, self._path, fileid=fileid, |
23770
50f0096a7346
filectx: fix annotate to not directly instantiate filectx
Durham Goode <durham@fb.com>
parents:
23757
diff
changeset
|
1047 |
filelog=self._filelog, changeid=changeid) |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1048 |
|
30743
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30718
diff
changeset
|
1049 |
def rawdata(self): |
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30718
diff
changeset
|
1050 |
return self._filelog.revision(self._filenode, raw=True) |
2df983125d37
revlog: add 'raw' argument to revision and _addrevision
Remi Chaintron <remi@fb.com>
parents:
30718
diff
changeset
|
1051 |
|
32241 | 1052 |
def rawflags(self): |
1053 |
"""low-level revlog flags""" |
|
1054 |
return self._filelog.flags(self._filerev) |
|
1055 |
||
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1056 |
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
|
1057 |
try: |
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1058 |
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
|
1059 |
except error.CensoredNodeError: |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33364
diff
changeset
|
1060 |
if self._repo.ui.config("censor", "policy") == "ignore": |
22932
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1061 |
return "" |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26492
diff
changeset
|
1062 |
raise error.Abort(_("censored node: %s") % short(self._filenode), |
23110
692bde7f486d
i18n: make hint message of exception translatable
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23085
diff
changeset
|
1063 |
hint=_("set censor.policy to ignore errors")) |
22932
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1064 |
|
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1065 |
def size(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1066 |
return self._filelog.size(self._filerev) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1067 |
|
32239
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
1068 |
@propertycache |
c38c15d4ce48
filectx: make renamed a property cache
Jun Wu <quark@fb.com>
parents:
32238
diff
changeset
|
1069 |
def _copied(self): |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1070 |
"""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
|
1071 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1072 |
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
|
1073 |
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
|
1074 |
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
|
1075 |
""" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1076 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1077 |
renamed = self._filelog.renamed(self._filenode) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1078 |
if not renamed: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1079 |
return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1080 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1081 |
if self.rev() == self.linkrev(): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1082 |
return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1083 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1084 |
name = self.path() |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1085 |
fnode = self._filenode |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1086 |
for p in self._changectx.parents(): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1087 |
try: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1088 |
if fnode == p.filenode(name): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1089 |
return None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1090 |
except error.LookupError: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1091 |
pass |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1092 |
return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1093 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1094 |
def children(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1095 |
# hard for renames |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1096 |
c = self._filelog.children(self._filenode) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1097 |
return [filectx(self._repo, self._path, fileid=x, |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1098 |
filelog=self._filelog) for x in c] |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1099 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1100 |
class committablectx(basectx): |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1101 |
"""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
|
1102 |
wants the ability to commit, e.g. workingctx or memctx.""" |
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
|
1103 |
def __init__(self, repo, text="", user=None, date=None, extra=None, |
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
|
1104 |
changes=None): |
37175
fbe34945220d
context: set repo property in basectx
Martin von Zweigbergk <martinvonz@google.com>
parents:
37174
diff
changeset
|
1105 |
super(committablectx, self).__init__(repo) |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1106 |
self._rev = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1107 |
self._node = None |
6709
f84f507c53d3
context: let workingctx.date(), .user() and description() be overriden
Patrick Mezard <pmezard@gmail.com>
parents:
6708
diff
changeset
|
1108 |
self._text = text |
6718
4386a7706828
Fix commit date (issue1193)
Christian Ebert <blacktrash@gmx.net>
parents:
6715
diff
changeset
|
1109 |
if date: |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
1110 |
self._date = dateutil.parsedate(date) |
6817 | 1111 |
if user: |
1112 |
self._user = user |
|
6707
02bad34230a2
localrepo: hide commit() file selection behind workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6705
diff
changeset
|
1113 |
if changes: |
21592
16f62b4203b1
committablectx: simplify caching the status
Sean Farley <sean.michael.farley@gmail.com>
parents:
21590
diff
changeset
|
1114 |
self._status = changes |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1115 |
|
6708
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1116 |
self._extra = {} |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1117 |
if extra: |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1118 |
self._extra = extra.copy() |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1119 |
if 'branch' not in self._extra: |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1120 |
try: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
1121 |
branch = encoding.fromlocal(self._repo.dirstate.branch()) |
6708
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1122 |
except UnicodeDecodeError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26492
diff
changeset
|
1123 |
raise error.Abort(_('branch name not in UTF-8!')) |
6708
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1124 |
self._extra['branch'] = branch |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1125 |
if self._extra['branch'] == '': |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1126 |
self._extra['branch'] = 'default' |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1127 |
|
32643
1df98fc923d4
py3: implement __bytes__ for committablectx
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32613
diff
changeset
|
1128 |
def __bytes__(self): |
1df98fc923d4
py3: implement __bytes__ for committablectx
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32613
diff
changeset
|
1129 |
return bytes(self._parents[0]) + "+" |
19666
09459edfb48b
commitablectx: move __str__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19665
diff
changeset
|
1130 |
|
33022
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
1131 |
__str__ = encoding.strmethod(__bytes__) |
ce96efec8112
py3: add utility to forward __str__() to __bytes__()
Yuya Nishihara <yuya@tcha.org>
parents:
33019
diff
changeset
|
1132 |
|
19667
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1133 |
def __nonzero__(self): |
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1134 |
return True |
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1135 |
|
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
1136 |
__bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
1137 |
|
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1138 |
def _buildflagfunc(self): |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1139 |
# Create a fallback function for getting file flags when the |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1140 |
# filesystem doesn't support them |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1141 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1142 |
copiesget = self._repo.dirstate.copies().get |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1143 |
parents = self.parents() |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1144 |
if len(parents) < 2: |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1145 |
# when we have one parent, it's easy: copy from parent |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1146 |
man = parents[0].manifest() |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1147 |
def func(f): |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1148 |
f = copiesget(f, f) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1149 |
return man.flags(f) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1150 |
else: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1151 |
# merges are tricky: we try to reconstruct the unstored |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1152 |
# result from the merge (issue1802) |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1153 |
p1, p2 = parents |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1154 |
pa = p1.ancestor(p2) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1155 |
m1, m2, ma = p1.manifest(), p2.manifest(), pa.manifest() |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1156 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1157 |
def func(f): |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1158 |
f = copiesget(f, f) # may be wrong for merges with copies |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1159 |
fl1, fl2, fla = m1.flags(f), m2.flags(f), ma.flags(f) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1160 |
if fl1 == fl2: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1161 |
return fl1 |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1162 |
if fl1 == fla: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1163 |
return fl2 |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1164 |
if fl2 == fla: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1165 |
return fl1 |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1166 |
return '' # punt for conflicts |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1167 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1168 |
return func |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1169 |
|
19670
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1170 |
@propertycache |
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1171 |
def _flagfunc(self): |
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1172 |
return self._repo.dirstate.flagfunc(self._buildflagfunc) |
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1173 |
|
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1174 |
@propertycache |
19672
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1175 |
def _status(self): |
21592
16f62b4203b1
committablectx: simplify caching the status
Sean Farley <sean.michael.farley@gmail.com>
parents:
21590
diff
changeset
|
1176 |
return self._repo.status() |
19672
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1177 |
|
19674
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1178 |
@propertycache |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1179 |
def _user(self): |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1180 |
return self._repo.ui.username() |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1181 |
|
19676
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1182 |
@propertycache |
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1183 |
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
|
1184 |
ui = self._repo.ui |
3e2e179ef031
devel: add a config field to force dates to timestamp 0
Boris Feld <boris.feld@octobus.net>
parents:
32401
diff
changeset
|
1185 |
date = ui.configdate('devel', 'default-date') |
3e2e179ef031
devel: add a config field to force dates to timestamp 0
Boris Feld <boris.feld@octobus.net>
parents:
32401
diff
changeset
|
1186 |
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
|
1187 |
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
|
1188 |
return date |
19676
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1189 |
|
21587
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1190 |
def subrev(self, subpath): |
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1191 |
return None |
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1192 |
|
24719
11e8fec00234
committablectx: override manifestnode() to return None
Yuya Nishihara <yuya@tcha.org>
parents:
24646
diff
changeset
|
1193 |
def manifestnode(self): |
11e8fec00234
committablectx: override manifestnode() to return None
Yuya Nishihara <yuya@tcha.org>
parents:
24646
diff
changeset
|
1194 |
return None |
19675
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1195 |
def user(self): |
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1196 |
return self._user or self._repo.ui.username() |
19677
e11415510352
commitablectx: move date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19676
diff
changeset
|
1197 |
def date(self): |
e11415510352
commitablectx: move date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19676
diff
changeset
|
1198 |
return self._date |
19678
897c2dbc0256
commitablectx: move description from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19677
diff
changeset
|
1199 |
def description(self): |
897c2dbc0256
commitablectx: move description from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19677
diff
changeset
|
1200 |
return self._text |
19679
f21804f1582e
commitablectx: move files from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19678
diff
changeset
|
1201 |
def files(self): |
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1202 |
return sorted(self._status.modified + self._status.added + |
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1203 |
self._status.removed) |
19675
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1204 |
|
19680
fc33fcfa08f2
commitablectx: move modified from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19679
diff
changeset
|
1205 |
def modified(self): |
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1206 |
return self._status.modified |
19681
cfc4ae65023f
commitablectx: move added from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19680
diff
changeset
|
1207 |
def added(self): |
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1208 |
return self._status.added |
19682
42ffc7f31acf
commitablectx: move removed from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19681
diff
changeset
|
1209 |
def removed(self): |
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1210 |
return self._status.removed |
19683
6336f35ed77d
commitablectx: move deleted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19682
diff
changeset
|
1211 |
def deleted(self): |
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1212 |
return self._status.deleted |
19687
54b3b4821bfb
commitablectx: move branch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19686
diff
changeset
|
1213 |
def branch(self): |
54b3b4821bfb
commitablectx: move branch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19686
diff
changeset
|
1214 |
return encoding.tolocal(self._extra['branch']) |
19688
21e1068109a7
commitablectx: move closesbranch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19687
diff
changeset
|
1215 |
def closesbranch(self): |
21e1068109a7
commitablectx: move closesbranch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19687
diff
changeset
|
1216 |
return 'close' in self._extra |
19689
8dbb66f339f3
commitablectx: move extra from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19688
diff
changeset
|
1217 |
def extra(self): |
8dbb66f339f3
commitablectx: move extra from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19688
diff
changeset
|
1218 |
return self._extra |
19680
fc33fcfa08f2
commitablectx: move modified from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19679
diff
changeset
|
1219 |
|
34681
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1220 |
def isinmemory(self): |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1221 |
return False |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1222 |
|
19690
65ff9fd67d8d
commitablectx: move tags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19689
diff
changeset
|
1223 |
def tags(self): |
25688
24cda1dd45ff
workingctx: don't report the tags for its parents
Matt Harbison <matt_harbison@yahoo.com>
parents:
25660
diff
changeset
|
1224 |
return [] |
19690
65ff9fd67d8d
commitablectx: move tags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19689
diff
changeset
|
1225 |
|
19691
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1226 |
def bookmarks(self): |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1227 |
b = [] |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1228 |
for p in self.parents(): |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1229 |
b.extend(p.bookmarks()) |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1230 |
return b |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1231 |
|
19692
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1232 |
def phase(self): |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1233 |
phase = phases.draft # default phase to draft |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1234 |
for p in self.parents(): |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1235 |
phase = max(phase, p.phase()) |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1236 |
return phase |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1237 |
|
19693
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1238 |
def hidden(self): |
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1239 |
return False |
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1240 |
|
19694
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1241 |
def children(self): |
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1242 |
return [] |
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1243 |
|
19695
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1244 |
def flags(self, path): |
32148
2cfdf5241096
py3: use raw strings while accessing class.__dict__
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32069
diff
changeset
|
1245 |
if r'_manifest' in self.__dict__: |
19695
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1246 |
try: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1247 |
return self._manifest.flags(path) |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1248 |
except KeyError: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1249 |
return '' |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1250 |
|
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1251 |
try: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1252 |
return self._flagfunc(path) |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1253 |
except OSError: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1254 |
return '' |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1255 |
|
19696
210cc42a8ac2
commitablectx: move ancestor from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19695
diff
changeset
|
1256 |
def ancestor(self, c2): |
22389
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
1257 |
"""return the "best" ancestor context of self and c2""" |
19696
210cc42a8ac2
commitablectx: move ancestor from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19695
diff
changeset
|
1258 |
return self._parents[0].ancestor(c2) # punt on two parents for now |
210cc42a8ac2
commitablectx: move ancestor from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19695
diff
changeset
|
1259 |
|
19697
8c95e74857c6
commitablectx: move walk from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19696
diff
changeset
|
1260 |
def walk(self, match): |
24646
5693c834bcb4
manifest: move changectx.walk() to manifests
Drew Gottlieb <drgott@google.com>
parents:
24633
diff
changeset
|
1261 |
'''Generates matching file names.''' |
34343
255c761a52db
dirstate: use keyword arguments to clarify walk()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34131
diff
changeset
|
1262 |
return sorted(self._repo.dirstate.walk(match, |
255c761a52db
dirstate: use keyword arguments to clarify walk()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34131
diff
changeset
|
1263 |
subrepos=sorted(self.substate), |
255c761a52db
dirstate: use keyword arguments to clarify walk()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34131
diff
changeset
|
1264 |
unknown=True, ignored=False)) |
19697
8c95e74857c6
commitablectx: move walk from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19696
diff
changeset
|
1265 |
|
21985
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
1266 |
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
|
1267 |
return sorted(self._repo.dirstate.matches(match)) |
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
1268 |
|
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1269 |
def ancestors(self): |
23616
11a160547d7f
context: return dirstate parents in workingctx.ancestors()
Durham Goode <durham@fb.com>
parents:
23603
diff
changeset
|
1270 |
for p in self._parents: |
11a160547d7f
context: return dirstate parents in workingctx.ancestors()
Durham Goode <durham@fb.com>
parents:
23603
diff
changeset
|
1271 |
yield p |
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1272 |
for a in self._repo.changelog.ancestors( |
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1273 |
[p.rev() for p in self._parents]): |
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1274 |
yield changectx(self._repo, a) |
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1275 |
|
19699
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1276 |
def markcommitted(self, node): |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1277 |
"""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
|
1278 |
|
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1279 |
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
|
1280 |
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
|
1281 |
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
|
1282 |
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
|
1283 |
|
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1284 |
""" |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1285 |
|
32349
81936f6462c1
context: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32243
diff
changeset
|
1286 |
with self._repo.dirstate.parentchange(): |
81936f6462c1
context: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32243
diff
changeset
|
1287 |
for f in self.modified() + self.added(): |
81936f6462c1
context: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32243
diff
changeset
|
1288 |
self._repo.dirstate.normal(f) |
81936f6462c1
context: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32243
diff
changeset
|
1289 |
for f in self.removed(): |
81936f6462c1
context: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32243
diff
changeset
|
1290 |
self._repo.dirstate.drop(f) |
81936f6462c1
context: migrate to context manager for changing dirstate parents
Augie Fackler <augie@google.com>
parents:
32243
diff
changeset
|
1291 |
self._repo.dirstate.setparents(node) |
19699
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1292 |
|
25757
4d1382fd96ff
context: write dirstate out explicitly at the end of markcommitted
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25753
diff
changeset
|
1293 |
# write changes out explicitly, because nesting wlock at |
4d1382fd96ff
context: write dirstate out explicitly at the end of markcommitted
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25753
diff
changeset
|
1294 |
# runtime may prevent 'wlock.release()' in 'repo.commit()' |
4d1382fd96ff
context: write dirstate out explicitly at the end of markcommitted
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25753
diff
changeset
|
1295 |
# from immediately doing so for subsequent changing files |
26748
5ba0a99ff27f
dirstate: make dirstate.write() callers pass transaction object to it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26604
diff
changeset
|
1296 |
self._repo.dirstate.write(self._repo.currenttransaction()) |
25757
4d1382fd96ff
context: write dirstate out explicitly at the end of markcommitted
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25753
diff
changeset
|
1297 |
|
32610
bf728e72a219
context: move dirty() to committablectx
Sean Farley <sean@farley.io>
parents:
32609
diff
changeset
|
1298 |
def dirty(self, missing=False, merge=True, branch=True): |
bf728e72a219
context: move dirty() to committablectx
Sean Farley <sean@farley.io>
parents:
32609
diff
changeset
|
1299 |
return False |
bf728e72a219
context: move dirty() to committablectx
Sean Farley <sean@farley.io>
parents:
32609
diff
changeset
|
1300 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1301 |
class workingctx(committablectx): |
19671
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1302 |
"""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
|
1303 |
the current working directory convenient. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1304 |
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
|
1305 |
user - username string, or None. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1306 |
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
|
1307 |
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
|
1308 |
or None to use the repository status. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1309 |
""" |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1310 |
def __init__(self, repo, text="", user=None, date=None, extra=None, |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1311 |
changes=None): |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1312 |
super(workingctx, self).__init__(repo, text, user, date, extra, changes) |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1313 |
|
14129
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1314 |
def __iter__(self): |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1315 |
d = self._repo.dirstate |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1316 |
for f in d: |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1317 |
if d[f] != 'r': |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1318 |
yield f |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1319 |
|
21845
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1320 |
def __contains__(self, key): |
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1321 |
return self._repo.dirstate[key] not in "?r" |
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1322 |
|
25590
183965a00c76
context: override workingctx.hex() to avoid a crash
Matt Harbison <matt_harbison@yahoo.com>
parents:
25465
diff
changeset
|
1323 |
def hex(self): |
25738
04d26a3c96fd
workingctx: use node.wdirid constant
Yuya Nishihara <yuya@tcha.org>
parents:
25688
diff
changeset
|
1324 |
return hex(wdirid) |
25590
183965a00c76
context: override workingctx.hex() to avoid a crash
Matt Harbison <matt_harbison@yahoo.com>
parents:
25465
diff
changeset
|
1325 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
1326 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1327 |
def _parents(self): |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1328 |
p = self._repo.dirstate.parents() |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1329 |
if p[1] == nullid: |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1330 |
p = p[:-1] |
17330
32e9d63d9ba6
context: simplify workingctx._parents
Patrick Mezard <patrick@mezard.eu>
parents:
17207
diff
changeset
|
1331 |
return [changectx(self._repo, x) for x in p] |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1332 |
|
37447
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1333 |
def _fileinfo(self, path): |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1334 |
# 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
|
1335 |
self._manifest |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1336 |
return super(workingctx, self)._fileinfo(path) |
067e8d1178a2
workingctx: build _manifest on filenode() or flags() request
Yuya Nishihara <yuya@tcha.org>
parents:
37391
diff
changeset
|
1337 |
|
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
1338 |
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
|
1339 |
"""get a file context from the working directory""" |
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
1340 |
return workingfilectx(self._repo, path, workingctx=self, |
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
1341 |
filelog=filelog) |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1342 |
|
16491
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1343 |
def dirty(self, missing=False, merge=True, branch=True): |
8717
e8de59577257
context: add a dirty method to detect modified contexts
Matt Mackall <mpm@selenic.com>
parents:
8528
diff
changeset
|
1344 |
"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
|
1345 |
# check subrepos first |
18364
6252b4f1c4b4
subrepos: process subrepos in sorted order
Mads Kiilerich <mads@kiilerich.com>
parents:
18252
diff
changeset
|
1346 |
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
|
1347 |
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
|
1348 |
return True |
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1349 |
# check current working dir |
16491
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1350 |
return ((merge and self.p2()) or |
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1351 |
(branch and self.branch() != self.p1().branch()) or |
8717
e8de59577257
context: add a dirty method to detect modified contexts
Matt Mackall <mpm@selenic.com>
parents:
8528
diff
changeset
|
1352 |
self.modified() or self.added() or self.removed() or |
e8de59577257
context: add a dirty method to detect modified contexts
Matt Mackall <mpm@selenic.com>
parents:
8528
diff
changeset
|
1353 |
(missing and self.deleted())) |
e8de59577257
context: add a dirty method to detect modified contexts
Matt Mackall <mpm@selenic.com>
parents:
8528
diff
changeset
|
1354 |
|
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1355 |
def add(self, list, prefix=""): |
27809
37a75d69eb43
with: use context manager for wlock in workingctx.add
Bryan O'Sullivan <bryano@fb.com>
parents:
27749
diff
changeset
|
1356 |
with self._repo.wlock(): |
37a75d69eb43
with: use context manager for wlock in workingctx.add
Bryan O'Sullivan <bryano@fb.com>
parents:
27749
diff
changeset
|
1357 |
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
|
1358 |
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
|
1359 |
rejected = [] |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1360 |
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
|
1361 |
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
|
1362 |
# 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
|
1363 |
# 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
|
1364 |
# 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
|
1365 |
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
|
1366 |
try: |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1367 |
st = lstat(f) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
13962
diff
changeset
|
1368 |
except OSError: |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1369 |
ui.warn(_("%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
|
1370 |
rejected.append(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1371 |
continue |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1372 |
if st.st_size > 10000000: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1373 |
ui.warn(_("%s: up to %d MB of RAM may be required " |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1374 |
"to manage this file\n" |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1375 |
"(use 'hg revert %s' to cancel the " |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1376 |
"pending addition)\n") |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1377 |
% (f, 3 * st.st_size // 1000000, uipath(f))) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1378 |
if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1379 |
ui.warn(_("%s not added: only files and symlinks " |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1380 |
"supported currently\n") % uipath(f)) |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1381 |
rejected.append(f) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1382 |
elif ds[f] in 'amn': |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1383 |
ui.warn(_("%s already tracked!\n") % uipath(f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1384 |
elif ds[f] == 'r': |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1385 |
ds.normallookup(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1386 |
else: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1387 |
ds.add(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1388 |
return rejected |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1389 |
|
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1390 |
def forget(self, files, prefix=""): |
27810
8c81975fe145
with: use context manager for wlock in workingctx.forget
Bryan O'Sullivan <bryano@fb.com>
parents:
27809
diff
changeset
|
1391 |
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
|
1392 |
ds = self._repo.dirstate |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1393 |
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
|
1394 |
rejected = [] |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1395 |
for f in files: |
16111
131d1a09108a
context: make workingctx.forget() really warn about untracked files
Patrick Mezard <patrick@mezard.eu>
parents:
15912
diff
changeset
|
1396 |
if f not in self._repo.dirstate: |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1397 |
self._repo.ui.warn(_("%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
|
1398 |
rejected.append(f) |
16111
131d1a09108a
context: make workingctx.forget() really warn about untracked files
Patrick Mezard <patrick@mezard.eu>
parents:
15912
diff
changeset
|
1399 |
elif self._repo.dirstate[f] != 'a': |
131d1a09108a
context: make workingctx.forget() really warn about untracked files
Patrick Mezard <patrick@mezard.eu>
parents:
15912
diff
changeset
|
1400 |
self._repo.dirstate.remove(f) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1401 |
else: |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14429
diff
changeset
|
1402 |
self._repo.dirstate.drop(f) |
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1403 |
return rejected |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1404 |
|
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1405 |
def undelete(self, list): |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1406 |
pctxs = self.parents() |
27811
09820fb88e14
with: use context manager for wlock in workingctx.undelete
Bryan O'Sullivan <bryano@fb.com>
parents:
27810
diff
changeset
|
1407 |
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
|
1408 |
ds = self._repo.dirstate |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1409 |
for f in list: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1410 |
if self._repo.dirstate[f] != 'r': |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1411 |
self._repo.ui.warn(_("%s not removed!\n") % ds.pathto(f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1412 |
else: |
12360
4ae3e5dffa60
context: fix filectx.undelete() (issue2388)
Patrick Mezard <pmezard@gmail.com>
parents:
12344
diff
changeset
|
1413 |
fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f] |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1414 |
t = fctx.data() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1415 |
self._repo.wwrite(f, t, fctx.flags()) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1416 |
self._repo.dirstate.normal(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1417 |
|
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1418 |
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
|
1419 |
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
|
1420 |
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
|
1421 |
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
|
1422 |
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
|
1423 |
raise |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1424 |
self._repo.ui.warn(_("%s does not exist!\n") |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1425 |
% self._repo.dirstate.pathto(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
|
1426 |
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
|
1427 |
if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)): |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1428 |
self._repo.ui.warn(_("copy failed: %s is not a file or a " |
33501
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1429 |
"symbolic link\n") |
7008f6819002
context: name files relative to cwd in warning messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33499
diff
changeset
|
1430 |
% self._repo.dirstate.pathto(dest)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1431 |
else: |
27812
28d0c0ef327b
with: use context manager for wlock in copy
Bryan O'Sullivan <bryano@fb.com>
parents:
27811
diff
changeset
|
1432 |
with self._repo.wlock(): |
23402
2963d5c9d90b
rename: properly report removed and added file as modified (issue4458)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23401
diff
changeset
|
1433 |
if self._repo.dirstate[dest] in '?': |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1434 |
self._repo.dirstate.add(dest) |
23402
2963d5c9d90b
rename: properly report removed and added file as modified (issue4458)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23401
diff
changeset
|
1435 |
elif self._repo.dirstate[dest] in 'r': |
2963d5c9d90b
rename: properly report removed and added file as modified (issue4458)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23401
diff
changeset
|
1436 |
self._repo.dirstate.normallookup(dest) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1437 |
self._repo.dirstate.copy(source, dest) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1438 |
|
31388
9e57033fec0c
context: don't use mutable default argument value
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31351
diff
changeset
|
1439 |
def match(self, pats=None, include=None, exclude=None, default='glob', |
25465
f472228a9e5e
context: add an optional constructor parameter for a match.bad() override
Matt Harbison <matt_harbison@yahoo.com>
parents:
25435
diff
changeset
|
1440 |
listsubrepos=False, badfn=None): |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1441 |
r = self._repo |
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1442 |
|
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1443 |
# 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
|
1444 |
# 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
|
1445 |
icasefs = not util.fscasesensitive(r.root) |
284b18303f61
match: replace icasefsmatch() function by flag to regular match()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32395
diff
changeset
|
1446 |
return matchmod.match(r.root, r.getcwd(), pats, include, exclude, |
284b18303f61
match: replace icasefsmatch() function by flag to regular match()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32395
diff
changeset
|
1447 |
default, auditor=r.auditor, ctx=self, |
284b18303f61
match: replace icasefsmatch() function by flag to regular match()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32395
diff
changeset
|
1448 |
listsubrepos=listsubrepos, badfn=badfn, |
284b18303f61
match: replace icasefsmatch() function by flag to regular match()
Martin von Zweigbergk <martinvonz@google.com>
parents:
32395
diff
changeset
|
1449 |
icasefs=icasefs) |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1450 |
|
21393
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1451 |
def _filtersuspectsymlink(self, files): |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1452 |
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
|
1453 |
return files |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1454 |
|
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1455 |
# 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
|
1456 |
# 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
|
1457 |
# 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
|
1458 |
# symlink |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1459 |
sane = [] |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1460 |
for f in files: |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1461 |
if self.flags(f) == 'l': |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1462 |
d = self[f].data() |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
1463 |
if (d == '' or len(d) >= 1024 or '\n' in d |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37066
diff
changeset
|
1464 |
or stringutil.binary(d)): |
21393
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1465 |
self._repo.ui.debug('ignoring suspect symlink placeholder' |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1466 |
' "%s"\n' % f) |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1467 |
continue |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1468 |
sane.append(f) |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1469 |
return sane |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1470 |
|
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1471 |
def _checklookup(self, files): |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1472 |
# 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
|
1473 |
if not files: |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1474 |
return [], [], [] |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1475 |
|
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1476 |
modified = [] |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1477 |
deleted = [] |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1478 |
fixup = [] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1479 |
pctx = self._parents[0] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1480 |
# 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
|
1481 |
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
|
1482 |
try: |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1483 |
# 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
|
1484 |
# directory in the interim, but fixing that is pretty hard. |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1485 |
if (f not in pctx or self.flags(f) != pctx.flags(f) |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1486 |
or pctx[f].cmp(self[f])): |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1487 |
modified.append(f) |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1488 |
else: |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1489 |
fixup.append(f) |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1490 |
except (IOError, OSError): |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1491 |
# 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
|
1492 |
# matching dirstate behavior (issue5584). |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1493 |
# 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
|
1494 |
# 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
|
1495 |
# 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
|
1496 |
# it's in the dirstate. |
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1497 |
deleted.append(f) |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1498 |
|
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1499 |
return modified, deleted, fixup |
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1500 |
|
32813
6d73b7ff8f92
workingctx: also pass status tuple into poststatusfixup
Siddharth Agarwal <sid0@fb.com>
parents:
32812
diff
changeset
|
1501 |
def _poststatusfixup(self, status, fixup): |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1502 |
"""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
|
1503 |
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
|
1504 |
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
|
1505 |
try: |
32752
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1506 |
oldid = self._repo.dirstate.identity() |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1507 |
|
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1508 |
# 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
|
1509 |
# 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
|
1510 |
# 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
|
1511 |
# taking the lock |
27813
ff20fe74e5c6
with: use context manager for wlock in checklookup
Bryan O'Sullivan <bryano@fb.com>
parents:
27812
diff
changeset
|
1512 |
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
|
1513 |
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
|
1514 |
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
|
1515 |
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
|
1516 |
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
|
1517 |
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
|
1518 |
# 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
|
1519 |
# 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
|
1520 |
# 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
|
1521 |
# 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
|
1522 |
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
|
1523 |
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
|
1524 |
|
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1525 |
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
|
1526 |
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
|
1527 |
ps(self, status) |
32752
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1528 |
else: |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1529 |
# 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
|
1530 |
# consistency, because .hg/dirstate was |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1531 |
# already changed simultaneously after last |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1532 |
# caching (see also issue5584 for detail) |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1533 |
self._repo.ui.debug('skip updating dirstate: ' |
dc7efa2826e4
context: avoid writing outdated dirstate out (issue5584)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32728
diff
changeset
|
1534 |
'identity mismatch\n') |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1535 |
except error.LockError: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1536 |
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
|
1537 |
finally: |
2083d1643d69
workingctx: add a way for extensions to run code at status fixup time
Siddharth Agarwal <sid0@fb.com>
parents:
32813
diff
changeset
|
1538 |
# 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
|
1539 |
self._repo.clearpostdsstatus() |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1540 |
|
33937
e43264525ce5
context: remove unnecessary default values for matchers (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33936
diff
changeset
|
1541 |
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
|
1542 |
'''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
|
1543 |
subrepos = [] |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1544 |
if '.hgsub' in self: |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1545 |
subrepos = sorted(self.substate) |
34344
ac0cd81e2f83
dirstate: use keyword arguments to clarify status()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34343
diff
changeset
|
1546 |
cmp, s = self._repo.dirstate.status(match, subrepos, ignored=ignored, |
ac0cd81e2f83
dirstate: use keyword arguments to clarify status()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34343
diff
changeset
|
1547 |
clean=clean, unknown=unknown) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1548 |
|
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1549 |
# check for any possibly clean files |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1550 |
fixup = [] |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1551 |
if cmp: |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1552 |
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
|
1553 |
s.modified.extend(modified2) |
32651
c850f0ed54c1
status: don't crash if a lookup file disappears
Siddharth Agarwal <sid0@fb.com>
parents:
32069
diff
changeset
|
1554 |
s.deleted.extend(deleted2) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1555 |
|
34344
ac0cd81e2f83
dirstate: use keyword arguments to clarify status()'s callers
Martin von Zweigbergk <martinvonz@google.com>
parents:
34343
diff
changeset
|
1556 |
if fixup and clean: |
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1557 |
s.clean.extend(fixup) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1558 |
|
32813
6d73b7ff8f92
workingctx: also pass status tuple into poststatusfixup
Siddharth Agarwal <sid0@fb.com>
parents:
32812
diff
changeset
|
1559 |
self._poststatusfixup(s, fixup) |
32812
add613cddcb6
workingctx: factor out post-status dirstate fixup
Siddharth Agarwal <sid0@fb.com>
parents:
32781
diff
changeset
|
1560 |
|
23776
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1561 |
if match.always(): |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1562 |
# cache for performance |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1563 |
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
|
1564 |
# "_status" is cached with list*=False in the normal route |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1565 |
self._status = scmutil.status(s.modified, s.added, s.removed, |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1566 |
s.deleted, [], [], []) |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1567 |
else: |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1568 |
self._status = s |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1569 |
|
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1570 |
return s |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1571 |
|
31259
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1572 |
@propertycache |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1573 |
def _manifest(self): |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1574 |
"""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
|
1575 |
|
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1576 |
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
|
1577 |
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
|
1578 |
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
|
1579 |
deleting newly added files. |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1580 |
""" |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1581 |
return self._buildstatusmanifest(self._status) |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1582 |
|
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1583 |
def _buildstatusmanifest(self, status): |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1584 |
"""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
|
1585 |
parents = self.parents() |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1586 |
|
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1587 |
man = parents[0].manifest().copy() |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1588 |
|
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1589 |
ff = self._flagfunc |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1590 |
for i, l in ((addednodeid, status.added), |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1591 |
(modifiednodeid, status.modified)): |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1592 |
for f in l: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1593 |
man[f] = i |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1594 |
try: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1595 |
man.setflag(f, ff(f)) |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1596 |
except OSError: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1597 |
pass |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1598 |
|
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1599 |
for f in status.deleted + status.removed: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1600 |
if f in man: |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1601 |
del man[f] |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1602 |
|
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1603 |
return man |
6a9d0d24fdb4
context: move _manifest from committablectx to workingctx
Durham Goode <durham@fb.com>
parents:
31258
diff
changeset
|
1604 |
|
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1605 |
def _buildstatus(self, other, s, match, listignored, listclean, |
21663
8d9449eaaeff
context: fix wrong indentation from renaming method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21616
diff
changeset
|
1606 |
listunknown): |
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1607 |
"""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
|
1608 |
|
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1609 |
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
|
1610 |
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
|
1611 |
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
|
1612 |
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
|
1613 |
""" |
23239
9fbb50444d55
context.status: call _dirstatestatus() from within _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23238
diff
changeset
|
1614 |
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
|
1615 |
# 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
|
1616 |
# 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
|
1617 |
# 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
|
1618 |
s.modified[:] = self._filtersuspectsymlink(s.modified) |
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1619 |
if other != self._repo['.']: |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1620 |
s = super(workingctx, self)._buildstatus(other, s, match, |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1621 |
listignored, listclean, |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1622 |
listunknown) |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1623 |
return s |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1624 |
|
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
1625 |
def _matchstatus(self, other, match): |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1626 |
"""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
|
1627 |
|
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1628 |
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
|
1629 |
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
|
1630 |
comparing against the parent changeset. |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1631 |
|
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1632 |
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
|
1633 |
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
|
1634 |
""" |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1635 |
if other != self._repo['.']: |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1636 |
def bad(f, msg): |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1637 |
# '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
|
1638 |
# 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
|
1639 |
if f not in other and not other.hasdir(f): |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1640 |
self._repo.ui.warn('%s: %s\n' % |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1641 |
(self._repo.dirstate.pathto(f), msg)) |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1642 |
match.bad = bad |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1643 |
return match |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1644 |
|
33353
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
1645 |
def markcommitted(self, node): |
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
1646 |
super(workingctx, self).markcommitted(node) |
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
1647 |
|
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
1648 |
sparse.aftercommit(self._repo, node) |
160efb559f67
sparse: move post commit actions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33283
diff
changeset
|
1649 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1650 |
class committablefilectx(basefilectx): |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1651 |
"""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
|
1652 |
that wants the ability to commit, e.g. workingfilectx or memfilectx.""" |
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
|
1653 |
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
|
1654 |
self._repo = repo |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1655 |
self._path = path |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1656 |
self._changeid = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1657 |
self._filerev = self._filenode = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1658 |
|
19149
921b64e1f7b9
filecontext: use 'is not None' to check for filelog existence
Durham Goode <durham@fb.com>
parents:
19061
diff
changeset
|
1659 |
if filelog is not None: |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1660 |
self._filelog = filelog |
19702
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
1661 |
if ctx: |
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
1662 |
self._changectx = ctx |
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
1663 |
|
19703
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
1664 |
def __nonzero__(self): |
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
1665 |
return True |
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
1666 |
|
31476
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
1667 |
__bool__ = __nonzero__ |
413b44003462
py3: add __bool__ to every class defining __nonzero__
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31464
diff
changeset
|
1668 |
|
24420
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
1669 |
def linkrev(self): |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
1670 |
# 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
|
1671 |
return self.rev() |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
1672 |
|
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1673 |
def parents(self): |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1674 |
'''return parent filectxs, following copies if necessary''' |
8528
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1675 |
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
|
1676 |
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
|
1677 |
|
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1678 |
path = self._path |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1679 |
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
|
1680 |
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
|
1681 |
renamed = self.renamed() |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1682 |
|
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1683 |
if renamed: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1684 |
pl = [renamed + (None,)] |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1685 |
else: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1686 |
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
|
1687 |
|
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1688 |
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
|
1689 |
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
|
1690 |
|
24817
0bb98eee531d
committablefilectx: propagate ancestry info to parent to fix annotation
Yuya Nishihara <yuya@tcha.org>
parents:
24816
diff
changeset
|
1691 |
return [self._parentfilectx(p, fileid=n, filelog=l) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1692 |
for p, n, l in pl if n != nullid] |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1693 |
|
19705
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
1694 |
def children(self): |
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
1695 |
return [] |
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
1696 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1697 |
class workingfilectx(committablefilectx): |
19704
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1698 |
"""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
|
1699 |
file in the working directory convenient.""" |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1700 |
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
|
1701 |
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
|
1702 |
|
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1703 |
@propertycache |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1704 |
def _changectx(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1705 |
return workingctx(self._repo) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1706 |
|
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1707 |
def data(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1708 |
return self._repo.wread(self._path) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1709 |
def renamed(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1710 |
rp = self._repo.dirstate.copied(self._path) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1711 |
if not rp: |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1712 |
return None |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1713 |
return rp, self._changectx._parents[0]._manifest.get(rp, nullid) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1714 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1715 |
def size(self): |
19901
4d3ce1646dfc
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19900
diff
changeset
|
1716 |
return self._repo.wvfs.lstat(self._path).st_size |
3962
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1717 |
def date(self): |
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1718 |
t, tz = self._changectx.date() |
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1719 |
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
|
1720 |
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
|
1721 |
except OSError as err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1722 |
if err.errno != errno.ENOENT: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1723 |
raise |
3962
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1724 |
return (t, tz) |
3310
0e370798eebf
context: add cmp for filectxs
Matt Mackall <mpm@selenic.com>
parents:
3302
diff
changeset
|
1725 |
|
33283
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
1726 |
def exists(self): |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
1727 |
return self._repo.wvfs.exists(self._path) |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
1728 |
|
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
1729 |
def lexists(self): |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
1730 |
return self._repo.wvfs.lexists(self._path) |
634b259079c5
workingfilectx: add exists, lexists
Phil Cohen <phillco@fb.com>
parents:
33086
diff
changeset
|
1731 |
|
33086
eb4c49f55f1f
workingfilectx: add audit() as a wrapper for wvfs.audit()
Phil Cohen <phillco@fb.com>
parents:
33085
diff
changeset
|
1732 |
def audit(self): |
eb4c49f55f1f
workingfilectx: add audit() as a wrapper for wvfs.audit()
Phil Cohen <phillco@fb.com>
parents:
33085
diff
changeset
|
1733 |
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
|
1734 |
|
11702
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
1735 |
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
|
1736 |
"""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
|
1737 |
|
11702
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
1738 |
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
|
1739 |
""" |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17424
diff
changeset
|
1740 |
# 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
|
1741 |
# 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
|
1742 |
return fctx.cmp(self) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1743 |
|
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1744 |
def remove(self, ignoremissing=False): |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1745 |
"""wraps unlink for a repo's working directory""" |
31309
8908f985570c
vfs: use repo.wvfs.unlinkpath
Mads Kiilerich <madski@unity3d.com>
parents:
31261
diff
changeset
|
1746 |
self._repo.wvfs.unlinkpath(self._path, ignoremissing=ignoremissing) |
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1747 |
|
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
1748 |
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
|
1749 |
"""wraps repo.wwrite""" |
33085
1e79c66d6b07
workingfilectx: add backgroundclose as a kwarg to write()
Phil Cohen <phillco@fb.com>
parents:
33084
diff
changeset
|
1750 |
self._repo.wwrite(self._path, data, flags, |
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
1751 |
backgroundclose=backgroundclose, |
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
1752 |
**kwargs) |
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1753 |
|
34787
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
1754 |
def markcopied(self, src): |
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
1755 |
"""marks this file a copy of `src`""" |
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
1756 |
if self._repo.dirstate[self._path] in "nma": |
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
1757 |
self._repo.dirstate.copy(src, self._path) |
754b5117622f
context: add workingfilectx.markcopied
Phil Cohen <phillco@fb.com>
parents:
34783
diff
changeset
|
1758 |
|
34037
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
1759 |
def clearunknown(self): |
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
1760 |
"""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
|
1761 |
``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
|
1762 |
""" |
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
1763 |
wvfs = self._repo.wvfs |
34556
7a8a16f8ea22
context: also consider path conflicts when clearing unknown files
Mark Thomas <mbthomas@fb.com>
parents:
34479
diff
changeset
|
1764 |
f = self._path |
34833
07bbb208a924
context: audit paths before clearing unknown files and dirs
Mark Thomas <mbthomas@fb.com>
parents:
34787
diff
changeset
|
1765 |
wvfs.audit(f) |
34556
7a8a16f8ea22
context: also consider path conflicts when clearing unknown files
Mark Thomas <mbthomas@fb.com>
parents:
34479
diff
changeset
|
1766 |
if wvfs.isdir(f) and not wvfs.islink(f): |
7a8a16f8ea22
context: also consider path conflicts when clearing unknown files
Mark Thomas <mbthomas@fb.com>
parents:
34479
diff
changeset
|
1767 |
wvfs.rmtree(f, forcibly=True) |
37101
656ac240f392
context: skip path conflicts by default when clearing unknown file (issue5776)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37084
diff
changeset
|
1768 |
if self._repo.ui.configbool('experimental', 'merge.checkpathconflicts'): |
656ac240f392
context: skip path conflicts by default when clearing unknown file (issue5776)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37084
diff
changeset
|
1769 |
for p in reversed(list(util.finddirs(f))): |
656ac240f392
context: skip path conflicts by default when clearing unknown file (issue5776)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37084
diff
changeset
|
1770 |
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
|
1771 |
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
|
1772 |
break |
34037
65ae54582713
merge: move some of the logic in batchget() to workingfilectx
Phil Cohen <phillco@fb.com>
parents:
33999
diff
changeset
|
1773 |
|
33084
873f638fd7db
merge: change repo.wvfs.setflags calls to a new wctx[f].setflags function
Phil Cohen <phillco@fb.com>
parents:
33022
diff
changeset
|
1774 |
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
|
1775 |
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
|
1776 |
|
35323
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
1777 |
class overlayworkingctx(committablectx): |
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
1778 |
"""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
|
1779 |
converted into a commit context. |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1780 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1781 |
self._cache[path] maps to a dict with keys: { |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1782 |
'exists': bool? |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1783 |
'date': date? |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1784 |
'data': str? |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1785 |
'flags': str? |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1786 |
'copied': str? (path or None) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1787 |
} |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1788 |
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
|
1789 |
is `False`, the file was deleted. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1790 |
""" |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1791 |
|
35289
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
1792 |
def __init__(self, repo): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1793 |
super(overlayworkingctx, self).__init__(repo) |
35286
307b1689e3f8
overlayworkingctx: make clean() public
Phil Cohen <phillco@fb.com>
parents:
35285
diff
changeset
|
1794 |
self.clean() |
35289
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
1795 |
|
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
1796 |
def setbase(self, wrappedctx): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1797 |
self._wrappedctx = wrappedctx |
35289
2f8c476c49fe
overlayworkingctx: move _wrappedctx out of the constructor
Phil Cohen <phillco@fb.com>
parents:
35286
diff
changeset
|
1798 |
self._parents = [wrappedctx] |
35327
777cb4497d8d
overlayworkingctx: invalidate the manifest cache when changing parents
Phil Cohen <phillco@fb.com>
parents:
35326
diff
changeset
|
1799 |
# 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
|
1800 |
# 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
|
1801 |
# ``overlayworkingctx`` (e.g. with --collapse). |
777cb4497d8d
overlayworkingctx: invalidate the manifest cache when changing parents
Phil Cohen <phillco@fb.com>
parents:
35326
diff
changeset
|
1802 |
util.clearcachedproperty(self, '_manifest') |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1803 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1804 |
def data(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1805 |
if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1806 |
if self._cache[path]['exists']: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1807 |
if self._cache[path]['data']: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1808 |
return self._cache[path]['data'] |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1809 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1810 |
# Must fallback here, too, because we only set flags. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1811 |
return self._wrappedctx[path].data() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1812 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1813 |
raise error.ProgrammingError("No such file or directory: %s" % |
35294
d4f65050f3c5
overlayworkingctx: fix a bad reference to `self._path`
Phil Cohen <phillco@fb.com>
parents:
35293
diff
changeset
|
1814 |
path) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1815 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1816 |
return self._wrappedctx[path].data() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1817 |
|
35321
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1818 |
@propertycache |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1819 |
def _manifest(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1820 |
parents = self.parents() |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1821 |
man = parents[0].manifest().copy() |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1822 |
|
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1823 |
flag = self._flagfunc |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1824 |
for path in self.added(): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1825 |
man[path] = addednodeid |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1826 |
man.setflag(path, flag(path)) |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1827 |
for path in self.modified(): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1828 |
man[path] = modifiednodeid |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1829 |
man.setflag(path, flag(path)) |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1830 |
for path in self.removed(): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1831 |
del man[path] |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1832 |
return man |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1833 |
|
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1834 |
@propertycache |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1835 |
def _flagfunc(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1836 |
def f(path): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1837 |
return self._cache[path]['flags'] |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1838 |
return f |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1839 |
|
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1840 |
def files(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1841 |
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
|
1842 |
|
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1843 |
def modified(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1844 |
return [f for f in self._cache.keys() if self._cache[f]['exists'] and |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1845 |
self._existsinparent(f)] |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1846 |
|
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1847 |
def added(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1848 |
return [f for f in self._cache.keys() if self._cache[f]['exists'] and |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1849 |
not self._existsinparent(f)] |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1850 |
|
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1851 |
def removed(self): |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1852 |
return [f for f in self._cache.keys() if |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1853 |
not self._cache[f]['exists'] and self._existsinparent(f)] |
2e1c32a9c97b
overlayworkingctx: add _manifest, files(), added(), removed(), modified()
Phil Cohen <phillco@fb.com>
parents:
35319
diff
changeset
|
1854 |
|
34681
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1855 |
def isinmemory(self): |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1856 |
return True |
4dc8a2ee0f4f
context: add is `isinmemory()` to filectx
Phil Cohen <phillco@fb.com>
parents:
34556
diff
changeset
|
1857 |
|
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1858 |
def filedate(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1859 |
if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1860 |
return self._cache[path]['date'] |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1861 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1862 |
return self._wrappedctx[path].date() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1863 |
|
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1864 |
def markcopied(self, path, origin): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1865 |
if self.isdirty(path): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1866 |
self._cache[path]['copied'] = origin |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1867 |
else: |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1868 |
raise error.ProgrammingError('markcopied() called on clean context') |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1869 |
|
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1870 |
def copydata(self, path): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1871 |
if self.isdirty(path): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1872 |
return self._cache[path]['copied'] |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1873 |
else: |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1874 |
raise error.ProgrammingError('copydata() called on clean context') |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
1875 |
|
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1876 |
def flags(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1877 |
if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1878 |
if self._cache[path]['exists']: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1879 |
return self._cache[path]['flags'] |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1880 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1881 |
raise error.ProgrammingError("No such file or directory: %s" % |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1882 |
self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1883 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1884 |
return self._wrappedctx[path].flags() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1885 |
|
35295
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1886 |
def _existsinparent(self, path): |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1887 |
try: |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1888 |
# ``commitctx` raises a ``ManifestLookupError`` if a path does not |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1889 |
# exist, unlike ``workingctx``, which returns a ``workingfilectx`` |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1890 |
# with an ``exists()`` function. |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1891 |
self._wrappedctx[path] |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1892 |
return True |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1893 |
except error.ManifestLookupError: |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1894 |
return False |
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1895 |
|
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1896 |
def _auditconflicts(self, path): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1897 |
"""Replicates conflict checks done by wvfs.write(). |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1898 |
|
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1899 |
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
|
1900 |
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
|
1901 |
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
|
1902 |
""" |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1903 |
def fail(path, component): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1904 |
# 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
|
1905 |
# files. |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1906 |
if 'l' in self.p1()[component].flags(): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1907 |
raise error.Abort("error: %s conflicts with symlink %s " |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1908 |
"in %s." % (path, component, |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1909 |
self.p1().rev())) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1910 |
else: |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1911 |
raise error.Abort("error: '%s' conflicts with file '%s' in " |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1912 |
"%s." % (path, component, |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1913 |
self.p1().rev())) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1914 |
|
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1915 |
# 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
|
1916 |
# is not a file in p1. |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1917 |
components = path.split('/') |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1918 |
for i in xrange(len(components)): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1919 |
component = "/".join(components[0:i]) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1920 |
if component in self.p1(): |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1921 |
fail(path, component) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1922 |
|
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1923 |
# Test the other direction -- that this path from p2 isn't a directory |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1924 |
# in p1 (test that p1 doesn't any paths matching `path/*`). |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1925 |
match = matchmod.match('/', '', [path + '/'], default=b'relpath') |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1926 |
matches = self.p1().manifest().matches(match) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1927 |
if len(matches) > 0: |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1928 |
if len(matches) == 1 and matches.keys()[0] == path: |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1929 |
return |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1930 |
raise error.Abort("error: file '%s' cannot be written because " |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1931 |
" '%s/' is a folder in %s (containing %d " |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1932 |
"entries: %s)" |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1933 |
% (path, path, self.p1(), len(matches), |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1934 |
', '.join(matches.keys()))) |
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1935 |
|
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
1936 |
def write(self, path, data, flags='', **kwargs): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1937 |
if data is None: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1938 |
raise error.ProgrammingError("data must be non-None") |
35324
72fbdd373de8
overlayworkingctx: add _auditconflicts to write()
Phil Cohen <phillco@fb.com>
parents:
35323
diff
changeset
|
1939 |
self._auditconflicts(path) |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
1940 |
self._markdirty(path, exists=True, data=data, date=dateutil.makedate(), |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1941 |
flags=flags) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1942 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1943 |
def setflags(self, path, l, x): |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36411
diff
changeset
|
1944 |
self._markdirty(path, exists=True, date=dateutil.makedate(), |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1945 |
flags=(l and 'l' or '') + (x and 'x' or '')) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1946 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1947 |
def remove(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1948 |
self._markdirty(path, exists=False) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1949 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1950 |
def exists(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1951 |
"""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
|
1952 |
return False if they are broken. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1953 |
""" |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1954 |
if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1955 |
# 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
|
1956 |
# exists on the destination path. |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1957 |
if (self._cache[path]['exists'] and |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1958 |
'l' in self._cache[path]['flags']): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1959 |
return self.exists(self._cache[path]['data'].strip()) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1960 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1961 |
return self._cache[path]['exists'] |
35295
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1962 |
|
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1963 |
return self._existsinparent(path) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1964 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1965 |
def lexists(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1966 |
"""lexists returns True if the path exists""" |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1967 |
if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1968 |
return self._cache[path]['exists'] |
35295
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1969 |
|
bea46aed1e1b
overlayworkingctx: add `_checkexist(path)`
Phil Cohen <phillco@fb.com>
parents:
35294
diff
changeset
|
1970 |
return self._existsinparent(path) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1971 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1972 |
def size(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1973 |
if self.isdirty(path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1974 |
if self._cache[path]['exists']: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1975 |
return len(self._cache[path]['data']) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1976 |
else: |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1977 |
raise error.ProgrammingError("No such file or directory: %s" % |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1978 |
self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1979 |
return self._wrappedctx[path].size() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
1980 |
|
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1981 |
def tomemctx(self, text, branch=None, extra=None, date=None, parents=None, |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1982 |
user=None, editor=None): |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1983 |
"""Converts this ``overlayworkingctx`` into a ``memctx`` ready to be |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1984 |
committed. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1985 |
|
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1986 |
``text`` is the commit message. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1987 |
``parents`` (optional) are rev numbers. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1988 |
""" |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1989 |
# Default parents to the wrapped contexts' if not passed. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1990 |
if parents is None: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1991 |
parents = self._wrappedctx.parents() |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1992 |
if len(parents) == 1: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1993 |
parents = (parents[0], None) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1994 |
|
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1995 |
# ``parents`` is passed as rev numbers; convert to ``commitctxs``. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1996 |
if parents[1] is None: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1997 |
parents = (self._repo[parents[0]], None) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1998 |
else: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
1999 |
parents = (self._repo[parents[0]], self._repo[parents[1]]) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2000 |
|
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2001 |
files = self._cache.keys() |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2002 |
def getfile(repo, memctx, path): |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2003 |
if self._cache[path]['exists']: |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2004 |
return memfilectx(repo, memctx, path, |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2005 |
self._cache[path]['data'], |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2006 |
'l' in self._cache[path]['flags'], |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2007 |
'x' in self._cache[path]['flags'], |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2008 |
self._cache[path]['copied']) |
35325
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2009 |
else: |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2010 |
# Returning None, but including the path in `files`, is |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2011 |
# necessary for memctx to register a deletion. |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2012 |
return None |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2013 |
return memctx(self._repo, parents, text, files, getfile, date=date, |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2014 |
extra=extra, user=user, branch=branch, editor=editor) |
71edd38c4bb4
overlayworkingctx: add ``tomemctx()``
Phil Cohen <phillco@fb.com>
parents:
35324
diff
changeset
|
2015 |
|
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2016 |
def isdirty(self, path): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2017 |
return path in self._cache |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2018 |
|
35319
228916ca12b5
rebase: add concludememorynode(), and call it when rebasing in-memory
Phil Cohen <phillco@fb.com>
parents:
35295
diff
changeset
|
2019 |
def isempty(self): |
228916ca12b5
rebase: add concludememorynode(), and call it when rebasing in-memory
Phil Cohen <phillco@fb.com>
parents:
35295
diff
changeset
|
2020 |
# We need to discard any keys that are actually clean before the empty |
228916ca12b5
rebase: add concludememorynode(), and call it when rebasing in-memory
Phil Cohen <phillco@fb.com>
parents:
35295
diff
changeset
|
2021 |
# commit check. |
228916ca12b5
rebase: add concludememorynode(), and call it when rebasing in-memory
Phil Cohen <phillco@fb.com>
parents:
35295
diff
changeset
|
2022 |
self._compact() |
228916ca12b5
rebase: add concludememorynode(), and call it when rebasing in-memory
Phil Cohen <phillco@fb.com>
parents:
35295
diff
changeset
|
2023 |
return len(self._cache) == 0 |
228916ca12b5
rebase: add concludememorynode(), and call it when rebasing in-memory
Phil Cohen <phillco@fb.com>
parents:
35295
diff
changeset
|
2024 |
|
35286
307b1689e3f8
overlayworkingctx: make clean() public
Phil Cohen <phillco@fb.com>
parents:
35285
diff
changeset
|
2025 |
def clean(self): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2026 |
self._cache = {} |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2027 |
|
35326
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2028 |
def _compact(self): |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2029 |
"""Removes keys from the cache that are actually clean, by comparing |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2030 |
them with the underlying context. |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2031 |
|
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2032 |
This can occur during the merge process, e.g. by passing --tool :local |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2033 |
to resolve a conflict. |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2034 |
""" |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2035 |
keys = [] |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2036 |
for path in self._cache.keys(): |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2037 |
cache = self._cache[path] |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2038 |
try: |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2039 |
underlying = self._wrappedctx[path] |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2040 |
if (underlying.data() == cache['data'] and |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2041 |
underlying.flags() == cache['flags']): |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2042 |
keys.append(path) |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2043 |
except error.ManifestLookupError: |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2044 |
# Path not in the underlying manifest (created). |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2045 |
continue |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2046 |
|
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2047 |
for path in keys: |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2048 |
del self._cache[path] |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2049 |
return keys |
dc9da4f4f363
overlayworkingctx: add `_compact()`
Phil Cohen <phillco@fb.com>
parents:
35325
diff
changeset
|
2050 |
|
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2051 |
def _markdirty(self, path, exists, data=None, date=None, flags=''): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2052 |
self._cache[path] = { |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2053 |
'exists': exists, |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2054 |
'data': data, |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2055 |
'date': date, |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2056 |
'flags': flags, |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2057 |
'copied': None, |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2058 |
} |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2059 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2060 |
def filectx(self, path, filelog=None): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2061 |
return overlayworkingfilectx(self._repo, path, parent=self, |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2062 |
filelog=filelog) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2063 |
|
35323
8e1386b342f7
overlayworkingctx: inherit from committablectx instead of workingctx
Phil Cohen <phillco@fb.com>
parents:
35322
diff
changeset
|
2064 |
class overlayworkingfilectx(committablefilectx): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2065 |
"""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
|
2066 |
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
|
2067 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2068 |
def __init__(self, repo, path, filelog=None, parent=None): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2069 |
super(overlayworkingfilectx, self).__init__(repo, path, filelog, |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2070 |
parent) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2071 |
self._repo = repo |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2072 |
self._parent = parent |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2073 |
self._path = path |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2074 |
|
34783
0c812885586b
context: add overlayfilectx.cmp()
Phil Cohen <phillco@fb.com>
parents:
34685
diff
changeset
|
2075 |
def cmp(self, fctx): |
0c812885586b
context: add overlayfilectx.cmp()
Phil Cohen <phillco@fb.com>
parents:
34685
diff
changeset
|
2076 |
return self.data() != fctx.data() |
0c812885586b
context: add overlayfilectx.cmp()
Phil Cohen <phillco@fb.com>
parents:
34685
diff
changeset
|
2077 |
|
35281
010179e21e91
context: switch ctx() use to changectx()
Phil Cohen <phillco@fb.com>
parents:
35271
diff
changeset
|
2078 |
def changectx(self): |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2079 |
return self._parent |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2080 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2081 |
def data(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2082 |
return self._parent.data(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2083 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2084 |
def date(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2085 |
return self._parent.filedate(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2086 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2087 |
def exists(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2088 |
return self.lexists() |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2089 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2090 |
def lexists(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2091 |
return self._parent.exists(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2092 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2093 |
def renamed(self): |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2094 |
path = self._parent.copydata(self._path) |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2095 |
if not path: |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2096 |
return None |
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2097 |
return path, self._changectx._parents[0]._manifest.get(path, nullid) |
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2098 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2099 |
def size(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2100 |
return self._parent.size(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2101 |
|
35293
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2102 |
def markcopied(self, origin): |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2103 |
self._parent.markcopied(self._path, origin) |
8b3a636bb341
overlayworkingctx: track copy information in the context
Phil Cohen <phillco@fb.com>
parents:
35289
diff
changeset
|
2104 |
|
34104
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2105 |
def audit(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2106 |
pass |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2107 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2108 |
def flags(self): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2109 |
return self._parent.flags(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2110 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2111 |
def setflags(self, islink, isexec): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2112 |
return self._parent.setflags(self._path, islink, isexec) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2113 |
|
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2114 |
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
|
2115 |
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
|
2116 |
|
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2117 |
def remove(self, ignoremissing=False): |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2118 |
return self._parent.remove(self._path) |
f698bb31bdfb
context: add overlayworkingcontext and overlayworkingfilectx
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
2119 |
|
35322
baf58e621363
overlayworkingctx: add a no-op ``clearunknown()``
Phil Cohen <phillco@fb.com>
parents:
35321
diff
changeset
|
2120 |
def clearunknown(self): |
baf58e621363
overlayworkingctx: add a no-op ``clearunknown()``
Phil Cohen <phillco@fb.com>
parents:
35321
diff
changeset
|
2121 |
pass |
baf58e621363
overlayworkingctx: add a no-op ``clearunknown()``
Phil Cohen <phillco@fb.com>
parents:
35321
diff
changeset
|
2122 |
|
23710
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2123 |
class workingcommitctx(workingctx): |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2124 |
"""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
|
2125 |
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
|
2126 |
|
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2127 |
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
|
2128 |
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
|
2129 |
""" |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2130 |
def __init__(self, repo, changes, |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2131 |
text="", user=None, date=None, extra=None): |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2132 |
super(workingctx, self).__init__(repo, text, user, date, extra, |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2133 |
changes) |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
2134 |
|
33937
e43264525ce5
context: remove unnecessary default values for matchers (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
33936
diff
changeset
|
2135 |
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
|
2136 |
"""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
|
2137 |
|
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2138 |
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
|
2139 |
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
|
2140 |
""" |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2141 |
if clean: |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2142 |
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
|
2143 |
else: |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2144 |
clean = [] |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2145 |
return scmutil.status([f for f in self._status.modified if match(f)], |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2146 |
[f for f in self._status.added if match(f)], |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2147 |
[f for f in self._status.removed if match(f)], |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2148 |
[], [], [], clean) |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2149 |
|
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2150 |
@propertycache |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2151 |
def _changedset(self): |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2152 |
"""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
|
2153 |
""" |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2154 |
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
|
2155 |
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
|
2156 |
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
|
2157 |
return changed |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
2158 |
|
27906
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2159 |
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
|
2160 |
"""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
|
2161 |
|
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2162 |
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
|
2163 |
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
|
2164 |
memctx. |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2165 |
""" |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2166 |
cache = {} |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2167 |
|
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2168 |
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
|
2169 |
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
|
2170 |
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
|
2171 |
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
|
2172 |
|
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2173 |
return getfilectx |
c183f7b79541
context: don't use util.cachefunc due to cycle creation (issue5043)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27813
diff
changeset
|
2174 |
|
32763
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2175 |
def memfilefromctx(ctx): |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2176 |
"""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
|
2177 |
|
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2178 |
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
|
2179 |
context. |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2180 |
""" |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2181 |
def getfilectx(repo, memctx, path): |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2182 |
fctx = ctx[path] |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2183 |
# this is weird but apparently we only keep track of one parent |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2184 |
# (why not only store that instead of a tuple?) |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2185 |
copied = fctx.renamed() |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2186 |
if copied: |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2187 |
copied = copied[0] |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2188 |
return memfilectx(repo, memctx, path, fctx.data(), |
32763
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2189 |
islink=fctx.islink(), isexec=fctx.isexec(), |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2190 |
copied=copied) |
32763
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2191 |
|
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2192 |
return getfilectx |
34be21aa2b26
memctx: refactor inline getfilectx into convenience method
Sean Farley <sean@farley.io>
parents:
32752
diff
changeset
|
2193 |
|
32764
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2194 |
def memfilefrompatch(patchstore): |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2195 |
"""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
|
2196 |
|
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2197 |
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
|
2198 |
""" |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2199 |
def getfilectx(repo, memctx, path): |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2200 |
data, mode, copied = patchstore.getfile(path) |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2201 |
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
|
2202 |
return None |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2203 |
islink, isexec = mode |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2204 |
return memfilectx(repo, memctx, path, data, islink=islink, |
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2205 |
isexec=isexec, copied=copied) |
32764
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2206 |
|
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2207 |
return getfilectx |
ec302748edd8
context: add convenience method for returning a memfilectx from a patch
Sean Farley <sean@farley.io>
parents:
32763
diff
changeset
|
2208 |
|
21665
d2743be1bb06
memctx: inherit from committablectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21664
diff
changeset
|
2209 |
class memctx(committablectx): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2210 |
"""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
|
2211 |
|
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2212 |
Revision information is supplied at initialization time while |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2213 |
related files data and is made available through a callback |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2214 |
mechanism. 'repo' is the current localrepo, 'parents' is a |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2215 |
sequence of two parent revisions identifiers (pass None for every |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2216 |
missing parent), 'text' is the commit message and 'files' lists |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2217 |
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
|
2218 |
repository root). |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2219 |
|
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2220 |
filectxfn(repo, memctx, path) is a callable receiving the |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2221 |
repository, the current memctx object and the normalized path of |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2222 |
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
|
2223 |
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
|
2224 |
undefined. If the file is available in the revision being |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2225 |
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
|
2226 |
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
|
2227 |
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
|
2228 |
removed and the new file added with copy information (see |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2229 |
memfilectx). |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2230 |
|
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2231 |
user receives the committer name and defaults to current |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2232 |
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
|
2233 |
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
|
2234 |
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
|
2235 |
""" |
22313
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2236 |
|
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2237 |
# 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
|
2238 |
# 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
|
2239 |
# 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
|
2240 |
_returnnoneformissingfiles = True |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
2241 |
|
6721
521c6c6f3b9b
kill some trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6718
diff
changeset
|
2242 |
def __init__(self, repo, parents, text, files, filectxfn, user=None, |
32765
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2243 |
date=None, extra=None, branch=None, editor=False): |
21666
31bdc51b0f1e
memctx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21665
diff
changeset
|
2244 |
super(memctx, self).__init__(repo, text, user, date, extra) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2245 |
self._rev = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2246 |
self._node = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2247 |
parents = [(p or nullid) for p in parents] |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2248 |
p1, p2 = parents |
37173
05ff1a155a21
memctx: create parent contexts using "repo[p]" syntax
Martin von Zweigbergk <martinvonz@google.com>
parents:
37171
diff
changeset
|
2249 |
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
|
2250 |
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
|
2251 |
self._files = files |
32765
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2252 |
if branch is not None: |
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2253 |
self._extra['branch'] = encoding.fromlocal(branch) |
21938
c8411fb5dfef
memctx: substate needs to be {} instead of None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21895
diff
changeset
|
2254 |
self.substate = {} |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2255 |
|
32765
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2256 |
if isinstance(filectxfn, patch.filestore): |
32781
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2257 |
filectxfn = memfilefrompatch(filectxfn) |
32765
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2258 |
elif not callable(filectxfn): |
041d976b662a
context: inline makememctx (API)
Sean Farley <sean@farley.io>
parents:
32764
diff
changeset
|
2259 |
# 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
|
2260 |
filectxfn = memfilefromctx(filectxfn) |
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2261 |
|
448fc659a430
memctx: always use cache for filectxfn
Sean Farley <sean@farley.io>
parents:
32765
diff
changeset
|
2262 |
# 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
|
2263 |
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
|
2264 |
|
21238
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
2265 |
if editor: |
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
2266 |
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
|
2267 |
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
|
2268 |
|
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2269 |
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
|
2270 |
"""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
|
2271 |
|
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
2272 |
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
|
2273 |
return self._filectxfn(self._repo, self, path) |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2274 |
|
11151
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2275 |
def commit(self): |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2276 |
"""commit context to the repo""" |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2277 |
return self._repo.commitctx(self) |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
2278 |
|
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2279 |
@propertycache |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2280 |
def _manifest(self): |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2281 |
"""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
|
2282 |
|
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2283 |
# 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
|
2284 |
pctx = self._parents[0] |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2285 |
man = pctx.manifest().copy() |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2286 |
|
23603
d74eb8d477d5
memctx: calculate manifest more efficiently
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23602
diff
changeset
|
2287 |
for f in self._status.modified: |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2288 |
p1node = nullid |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2289 |
p2node = nullid |
22075
2f0358275501
memctx: add note about p2
Sean Farley <sean.michael.farley@gmail.com>
parents:
22074
diff
changeset
|
2290 |
p = pctx[f].parents() # if file isn't in pctx, check p2? |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2291 |
if len(p) > 0: |
27983
b7af616ca675
memctx: fix memctx manifest file hashes
Durham Goode <durham@fb.com>
parents:
27941
diff
changeset
|
2292 |
p1node = p[0].filenode() |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2293 |
if len(p) > 1: |
27983
b7af616ca675
memctx: fix memctx manifest file hashes
Durham Goode <durham@fb.com>
parents:
27941
diff
changeset
|
2294 |
p2node = p[1].filenode() |
23603
d74eb8d477d5
memctx: calculate manifest more efficiently
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23602
diff
changeset
|
2295 |
man[f] = revlog.hash(self[f].data(), p1node, p2node) |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2296 |
|
23588
87a76cff7147
memctx: calculate manifest including newly added files correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23587
diff
changeset
|
2297 |
for f in self._status.added: |
87a76cff7147
memctx: calculate manifest including newly added files correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23587
diff
changeset
|
2298 |
man[f] = revlog.hash(self[f].data(), nullid, nullid) |
87a76cff7147
memctx: calculate manifest including newly added files correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23587
diff
changeset
|
2299 |
|
23589
200215cdf7aa
memctx: calculate manifest correctly with newly-removed files (issue4470)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23588
diff
changeset
|
2300 |
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
|
2301 |
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
|
2302 |
del man[f] |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2303 |
|
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2304 |
return man |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
2305 |
|
23587
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2306 |
@propertycache |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2307 |
def _status(self): |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2308 |
"""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
|
2309 |
""" |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2310 |
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
|
2311 |
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
|
2312 |
# "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
|
2313 |
# 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
|
2314 |
# 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
|
2315 |
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
|
2316 |
man2 = p2.manifest() |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2317 |
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
|
2318 |
else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2319 |
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
|
2320 |
|
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2321 |
modified, added, removed = [], [], [] |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2322 |
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
|
2323 |
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
|
2324 |
added.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2325 |
elif self[f]: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2326 |
modified.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2327 |
else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2328 |
removed.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2329 |
|
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
2330 |
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
|
2331 |
|
21688
cc677803bad4
memfilectx: inherit from committablefilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21687
diff
changeset
|
2332 |
class memfilectx(committablefilectx): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2333 |
"""memfilectx represents an in-memory file to commit. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2334 |
|
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23110
diff
changeset
|
2335 |
See memctx and committablefilectx for more details. |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2336 |
""" |
35400
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2337 |
def __init__(self, repo, changectx, path, data, islink=False, |
8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
35353
diff
changeset
|
2338 |
isexec=False, copied=None): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2339 |
""" |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2340 |
path is the normalized file path relative to repository root. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2341 |
data is the file content as a string. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2342 |
islink is True if the file is a symbolic link. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2343 |
isexec is True if the file is executable. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
2344 |
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
|
2345 |
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
|
2346 |
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
|
2347 |
self._data = data |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2348 |
self._flags = (islink and 'l' or '') + (isexec and 'x' or '') |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2349 |
self._copied = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2350 |
if copied: |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2351 |
self._copied = (copied, nullid) |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
2352 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2353 |
def data(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
2354 |
return self._data |
22074
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2355 |
|
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2356 |
def remove(self, ignoremissing=False): |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2357 |
"""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
|
2358 |
# 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
|
2359 |
del self._changectx[self._path] |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2360 |
|
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2361 |
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
|
2362 |
"""wraps repo.wwrite""" |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
2363 |
self._data = data |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2364 |
|
32243
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2365 |
class overlayfilectx(committablefilectx): |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2366 |
"""Like memfilectx but take an original filectx and optional parameters to |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2367 |
override parts of it. This is useful when fctx.data() is expensive (i.e. |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2368 |
flag processor is expensive) and raw data, flags, and filenode could be |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2369 |
reused (ex. rebase or mode-only amend a REVIDX_EXTSTORED file). |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2370 |
""" |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2371 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2372 |
def __init__(self, originalfctx, datafunc=None, path=None, flags=None, |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2373 |
copied=None, ctx=None): |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2374 |
"""originalfctx: filecontext to duplicate |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2375 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2376 |
datafunc: None or a function to override data (file content). It is a |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2377 |
function to be lazy. path, flags, copied, ctx: None or overridden value |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2378 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2379 |
copied could be (path, rev), or False. copied could also be just path, |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2380 |
and will be converted to (path, nullid). This simplifies some callers. |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2381 |
""" |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2382 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2383 |
if path is None: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2384 |
path = originalfctx.path() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2385 |
if ctx is None: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2386 |
ctx = originalfctx.changectx() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2387 |
ctxmatch = lambda: True |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2388 |
else: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2389 |
ctxmatch = lambda: ctx == originalfctx.changectx() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2390 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2391 |
repo = originalfctx.repo() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2392 |
flog = originalfctx.filelog() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2393 |
super(overlayfilectx, self).__init__(repo, path, flog, ctx) |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2394 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2395 |
if copied is None: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2396 |
copied = originalfctx.renamed() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2397 |
copiedmatch = lambda: True |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2398 |
else: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2399 |
if copied and not isinstance(copied, tuple): |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2400 |
# repo._filecommit will recalculate copyrev so nullid is okay |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2401 |
copied = (copied, nullid) |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2402 |
copiedmatch = lambda: copied == originalfctx.renamed() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2403 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2404 |
# When data, copied (could affect data), ctx (could affect filelog |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2405 |
# parents) are not overridden, rawdata, rawflags, and filenode may be |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2406 |
# reused (repo._filecommit should double check filelog parents). |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2407 |
# |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2408 |
# path, flags are not hashed in filelog (but in manifestlog) so they do |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2409 |
# not affect reusable here. |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2410 |
# |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2411 |
# If ctx or copied is overridden to a same value with originalfctx, |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2412 |
# still consider it's reusable. originalfctx.renamed() may be a bit |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2413 |
# expensive so it's not called unless necessary. Assuming datafunc is |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2414 |
# always expensive, do not call it for this "reusable" test. |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2415 |
reusable = datafunc is None and ctxmatch() and copiedmatch() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2416 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2417 |
if datafunc is None: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2418 |
datafunc = originalfctx.data |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2419 |
if flags is None: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2420 |
flags = originalfctx.flags() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2421 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2422 |
self._datafunc = datafunc |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2423 |
self._flags = flags |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2424 |
self._copied = copied |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2425 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2426 |
if reusable: |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2427 |
# copy extra fields from originalfctx |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2428 |
attrs = ['rawdata', 'rawflags', '_filenode', '_filerev'] |
34431
52e9310626a8
context: rename local 'attr' to 'attr_'
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
2429 |
for attr_ in attrs: |
52e9310626a8
context: rename local 'attr' to 'attr_'
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
2430 |
if util.safehasattr(originalfctx, attr_): |
52e9310626a8
context: rename local 'attr' to 'attr_'
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
2431 |
setattr(self, attr_, getattr(originalfctx, attr_)) |
32243
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2432 |
|
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2433 |
def data(self): |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2434 |
return self._datafunc() |
07da778f3b58
filectx: add an overlayfilectx class
Jun Wu <quark@fb.com>
parents:
32242
diff
changeset
|
2435 |
|
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2436 |
class metadataonlyctx(committablectx): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2437 |
"""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
|
2438 |
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
|
2439 |
metadata-only changes. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2440 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2441 |
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
|
2442 |
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
|
2443 |
'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
|
2444 |
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
|
2445 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2446 |
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
|
2447 |
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
|
2448 |
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
|
2449 |
metadata or is left empty. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2450 |
""" |
33998
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2451 |
def __init__(self, repo, originalctx, parents=None, text=None, user=None, |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2452 |
date=None, extra=None, editor=False): |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2453 |
if text is None: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2454 |
text = originalctx.description() |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2455 |
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
|
2456 |
self._rev = None |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2457 |
self._node = None |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2458 |
self._originalctx = originalctx |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2459 |
self._manifestnode = originalctx.manifestnode() |
33998
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2460 |
if parents is None: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2461 |
parents = originalctx.parents() |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2462 |
else: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2463 |
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
|
2464 |
parents = parents[:] |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2465 |
while len(parents) < 2: |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2466 |
parents.append(repo[nullid]) |
becce02036e1
context: make parents and text optional in metadataonlyctx
Jun Wu <quark@fb.com>
parents:
33937
diff
changeset
|
2467 |
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
|
2468 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2469 |
# 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
|
2470 |
# manifests of our commit parents |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2471 |
mp1, mp2 = self.manifestctx().parents |
31840
7973e0a15bd4
metadataonlyctx: replace "changeset()[0]" to "manifestnode()"
Jun Wu <quark@fb.com>
parents:
31663
diff
changeset
|
2472 |
if p1 != nullid and p1.manifestnode() != mp1: |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2473 |
raise RuntimeError('can\'t reuse the manifest: ' |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2474 |
'its p1 doesn\'t match the new ctx p1') |
31840
7973e0a15bd4
metadataonlyctx: replace "changeset()[0]" to "manifestnode()"
Jun Wu <quark@fb.com>
parents:
31663
diff
changeset
|
2475 |
if p2 != nullid and p2.manifestnode() != mp2: |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2476 |
raise RuntimeError('can\'t reuse the manifest: ' |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2477 |
'its p2 doesn\'t match the new ctx p2') |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2478 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2479 |
self._files = originalctx.files() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2480 |
self.substate = {} |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2481 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2482 |
if editor: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2483 |
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
|
2484 |
self._repo.savecommitmessage(self._text) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2485 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2486 |
def manifestnode(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2487 |
return self._manifestnode |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2488 |
|
32519 | 2489 |
@property |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2490 |
def _manifestctx(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2491 |
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
|
2492 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2493 |
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
|
2494 |
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
|
2495 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2496 |
def commit(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2497 |
"""commit context to the repo""" |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2498 |
return self._repo.commitctx(self) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2499 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2500 |
@property |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2501 |
def _manifest(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2502 |
return self._originalctx.manifest() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2503 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2504 |
@propertycache |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2505 |
def _status(self): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2506 |
"""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
|
2507 |
and parents manifests. |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2508 |
""" |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2509 |
man1 = self.p1().manifest() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2510 |
p2 = self._parents[1] |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2511 |
# "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
|
2512 |
# 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
|
2513 |
# 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
|
2514 |
if p2.node() != nullid: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2515 |
man2 = p2.manifest() |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2516 |
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
|
2517 |
else: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2518 |
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
|
2519 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2520 |
modified, added, removed = [], [], [] |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2521 |
for f in self._files: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2522 |
if not managing(f): |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2523 |
added.append(f) |
33999
be814edf3306
metadataonlyctx: don't crash when reusing the manifest with deletions
Jun Wu <quark@fb.com>
parents:
33998
diff
changeset
|
2524 |
elif f in self: |
30567
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2525 |
modified.append(f) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2526 |
else: |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2527 |
removed.append(f) |
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2528 |
|
73ce055b169a
memctx: allow the metadataonlyctx thats reusing the manifest node
Mateusz Kwapich <mitrandir@fb.com>
parents:
30361
diff
changeset
|
2529 |
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
|
2530 |
|
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2531 |
class arbitraryfilectx(object): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2532 |
"""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
|
2533 |
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
|
2534 |
""" |
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
2535 |
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
|
2536 |
# 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
|
2537 |
self._repo = repo |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2538 |
self._path = path |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2539 |
|
34685
6036e6e205ca
context: add a fast-comparision for arbitraryfilectx and workingfilectx
Phil Cohen <phillco@fb.com>
parents:
34681
diff
changeset
|
2540 |
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
|
2541 |
# 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
|
2542 |
# path if either side is a symlink. |
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
2543 |
symlinks = ('l' in self.flags() or 'l' in fctx.flags()) |
14c87708f432
arbitraryfilecontext: skip the cmp fast path if any side is a symlink
Phil Cohen <phillco@fb.com>
parents:
34833
diff
changeset
|
2544 |
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
|
2545 |
# 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
|
2546 |
# 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
|
2547 |
# 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
|
2548 |
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
|
2549 |
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
|
2550 |
|
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2551 |
def path(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2552 |
return self._path |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2553 |
|
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2554 |
def flags(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2555 |
return '' |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2556 |
|
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2557 |
def data(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2558 |
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
|
2559 |
|
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2560 |
def decodeddata(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2561 |
with open(self._path, "rb") as f: |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2562 |
return f.read() |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2563 |
|
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2564 |
def remove(self): |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2565 |
util.unlink(self._path) |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2566 |
|
35725
2a7e777c9eed
write: add the possibility to pass keyword argument from batchget to vfs
Boris Feld <boris.feld@octobus.net>
parents:
35610
diff
changeset
|
2567 |
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
|
2568 |
assert not flags |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2569 |
with open(self._path, "w") as f: |
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34037
diff
changeset
|
2570 |
f.write(data) |