author | Bryan O'Sullivan <bos@serpentine.com> |
Sun, 27 Dec 2015 23:55:54 +0900 | |
changeset 27524 | f5b6b4e574c1 |
parent 27506 | e6d3dad71e44 |
child 27637 | b502138f5faa |
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 |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
11 |
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
|
12 |
import re |
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
13 |
import stat |
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
14 |
|
27506
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
15 |
from .i18n import _ |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
16 |
from .node import ( |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
17 |
bin, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
18 |
hex, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
19 |
nullid, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
20 |
nullrev, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
21 |
short, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
22 |
wdirid, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
23 |
) |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
24 |
from . import ( |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
25 |
encoding, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
26 |
error, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
27 |
fileset, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
28 |
match as matchmod, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
29 |
mdiff, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
30 |
obsolete as obsmod, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
31 |
patch, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
32 |
phases, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
33 |
repoview, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
34 |
revlog, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
35 |
scmutil, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
36 |
subrepo, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
37 |
util, |
e6d3dad71e44
context: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27234
diff
changeset
|
38 |
) |
3122
da85145d4571
filectx: add rename traversal for parents()
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
39 |
|
8207
dd8d5be57d65
util: take propertycache from context.py
Matt Mackall <mpm@selenic.com>
parents:
8157
diff
changeset
|
40 |
propertycache = util.propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
41 |
|
23593
b1179dabc6de
context: stop setting None for modified or added nodes
Augie Fackler <augie@google.com>
parents:
23402
diff
changeset
|
42 |
# Phony node value to stand-in for new files in some uses of |
b1179dabc6de
context: stop setting None for modified or added nodes
Augie Fackler <augie@google.com>
parents:
23402
diff
changeset
|
43 |
# manifests. Manifests support 21-byte hashes for nodes which are |
b1179dabc6de
context: stop setting None for modified or added nodes
Augie Fackler <augie@google.com>
parents:
23402
diff
changeset
|
44 |
# dirty in the working copy. |
b1179dabc6de
context: stop setting None for modified or added nodes
Augie Fackler <augie@google.com>
parents:
23402
diff
changeset
|
45 |
_newnode = '!' * 21 |
b1179dabc6de
context: stop setting None for modified or added nodes
Augie Fackler <augie@google.com>
parents:
23402
diff
changeset
|
46 |
|
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
47 |
nonascii = re.compile(r'[^\x21-\x7f]').search |
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
48 |
|
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
|
49 |
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
|
50 |
"""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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
def __new__(cls, repo, changeid='', *args, **kwargs): |
19538
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
57 |
if isinstance(changeid, basectx): |
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
58 |
return changeid |
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
59 |
|
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
60 |
o = super(basectx, cls).__new__(cls) |
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
61 |
|
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
62 |
o._repo = repo |
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
63 |
o._rev = nullrev |
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
64 |
o._node = nullid |
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
65 |
|
049d6b5a4a59
basectx: return a copied context if changeid is already a basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19537
diff
changeset
|
66 |
return o |
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
|
67 |
|
19540
7b864da00e21
basectx: move __str__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19539
diff
changeset
|
68 |
def __str__(self): |
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 |
|
19545
5af7045b0b18
basectx: move __int__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19544
diff
changeset
|
71 |
def __int__(self): |
5af7045b0b18
basectx: move __int__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19544
diff
changeset
|
72 |
return self.rev() |
5af7045b0b18
basectx: move __int__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19544
diff
changeset
|
73 |
|
19546
a45cf68dd9a2
basectx: move __repr__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19545
diff
changeset
|
74 |
def __repr__(self): |
a45cf68dd9a2
basectx: move __repr__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19545
diff
changeset
|
75 |
return "<%s %s>" % (type(self).__name__, str(self)) |
a45cf68dd9a2
basectx: move __repr__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19545
diff
changeset
|
76 |
|
19547
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
77 |
def __eq__(self, other): |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
78 |
try: |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
79 |
return type(self) == type(other) and self._rev == other._rev |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
80 |
except AttributeError: |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
81 |
return False |
0537c0cfd87c
basectx: move __eq__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19546
diff
changeset
|
82 |
|
19548
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
83 |
def __ne__(self, other): |
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
84 |
return not (self == other) |
730fdcaa791d
basectx: move __ne__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19547
diff
changeset
|
85 |
|
19550
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
86 |
def __contains__(self, key): |
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
87 |
return key in self._manifest |
0c8ad779eb36
basectx: move __contains__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19549
diff
changeset
|
88 |
|
19551
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
89 |
def __getitem__(self, key): |
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
90 |
return self.filectx(key) |
e07c69145724
basectx: move __getitem__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19550
diff
changeset
|
91 |
|
19552
6b76070c4b54
basectx: move __iter__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19551
diff
changeset
|
92 |
def __iter__(self): |
24227
8ec2df32bd39
context: don't sort manifest entries
Augie Fackler <augie@google.com>
parents:
24213
diff
changeset
|
93 |
return iter(self._manifest) |
19552
6b76070c4b54
basectx: move __iter__ from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19551
diff
changeset
|
94 |
|
21466
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
95 |
def _manifestmatches(self, match, s): |
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
96 |
"""generate a new manifest filtered by the match argument |
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
97 |
|
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
98 |
This method is for internal use only and mainly exists to provide an |
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
99 |
object oriented way for other contexts to customize the manifest |
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
100 |
generation. |
3b1ec3d4ece6
basectx: add _manifestmatches method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21398
diff
changeset
|
101 |
""" |
23305
0cc283f44655
manifest: add matches() method
Martin von Zweigbergk <martinvonz@google.com>
parents:
23304
diff
changeset
|
102 |
return self.manifest().matches(match) |
21880
e6754f5e4cf7
context: generate filtered manifest efficiently for exact matchers
Siddharth Agarwal <sid0@fb.com>
parents:
21845
diff
changeset
|
103 |
|
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
104 |
def _matchstatus(self, other, 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 |
"""return match.always if match is none |
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
106 |
|
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
107 |
This internal method provides a way for child objects to override the |
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
108 |
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
|
109 |
""" |
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
110 |
return match or matchmod.always(self._repo.root, self._repo.getcwd()) |
2f1567ef70ba
basectx: add _matchstatus method for factoring out last of parentworking logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
21480
diff
changeset
|
111 |
|
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
112 |
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
|
113 |
listunknown): |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
114 |
"""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
|
115 |
# 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
|
116 |
# 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
|
117 |
# 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
|
118 |
# 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
|
119 |
# 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
|
120 |
# delta application. |
23238
39eb9f78f968
context.status: move manifest caching trick to _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23237
diff
changeset
|
121 |
if self.rev() is not None and self.rev() < other.rev(): |
39eb9f78f968
context.status: move manifest caching trick to _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23237
diff
changeset
|
122 |
self.manifest() |
21471
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
123 |
mf1 = other._manifestmatches(match, s) |
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
124 |
mf2 = self._manifestmatches(match, s) |
90aff492dc4a
context: add _buildstatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21468
diff
changeset
|
125 |
|
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
126 |
modified, added = [], [] |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
127 |
removed = [] |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
128 |
clean = [] |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
129 |
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
|
130 |
deletedset = set(deleted) |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
131 |
d = mf1.diff(mf2, clean=listclean) |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
132 |
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
|
133 |
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
|
134 |
continue |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
135 |
if value is None: |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
136 |
clean.append(fn) |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
137 |
continue |
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
138 |
(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
|
139 |
if node1 is None: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
140 |
added.append(fn) |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
141 |
elif node2 is None: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
142 |
removed.append(fn) |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
143 |
elif node2 != _newnode: |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
144 |
# The file was not a new file in mf2, so an entry |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
145 |
# from diff is really a difference. |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
146 |
modified.append(fn) |
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 |
# node2 was newnode, but the working file doesn't |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
149 |
# match the one in mf1. |
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
150 |
modified.append(fn) |
23731
ccbaa2ed11a4
status: don't list files as both clean and deleted
Martin von Zweigbergk <martinvonz@google.com>
parents:
23730
diff
changeset
|
151 |
else: |
23757
b5346480a490
context: use new manifest.diff(clean=True) support
Augie Fackler <augie@google.com>
parents:
23755
diff
changeset
|
152 |
clean.append(fn) |
23755
d43948a910a5
context: use manifest.diff() to compute most of status
Augie Fackler <augie@google.com>
parents:
23731
diff
changeset
|
153 |
|
21971
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
154 |
if removed: |
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
155 |
# need to filter files if they are already reported as removed |
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
156 |
unknown = [fn for fn in unknown if fn not in mf1] |
412ac613fd89
status: explicitly exclude removed file from unknown and ignored
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
21938
diff
changeset
|
157 |
ignored = [fn for fn in ignored if fn not in mf1] |
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): |
78155484ae34
basectx: move substate from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19548
diff
changeset
|
166 |
return subrepo.state(self, self._repo.ui) |
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 |
24300
a07314472a80
context: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24227
diff
changeset
|
179 |
def repo(self): |
a07314472a80
context: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24227
diff
changeset
|
180 |
return self._repo |
19554
98f8875f4baa
basectx: move phasestr from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19553
diff
changeset
|
181 |
def phasestr(self): |
98f8875f4baa
basectx: move phasestr from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19553
diff
changeset
|
182 |
return phases.phasenames[self.phase()] |
19555
613b70fedc4e
basectx: move mutable from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19554
diff
changeset
|
183 |
def mutable(self): |
613b70fedc4e
basectx: move mutable from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19554
diff
changeset
|
184 |
return self.phase() > phases.public |
19541
421d49f2f8e2
basectx: move rev from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19540
diff
changeset
|
185 |
|
20400
f0137d994c83
context: add a getfileset() method so fewer things need fileset directly
Augie Fackler <raf@durin42.com>
parents:
20292
diff
changeset
|
186 |
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
|
187 |
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
|
188 |
|
19734
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
189 |
def obsolete(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
190 |
"""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
|
191 |
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
|
192 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
193 |
def extinct(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
194 |
"""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
|
195 |
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
|
196 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
197 |
def unstable(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
198 |
"""True if the changeset is not obsolete but it's ancestor are""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
199 |
return self.rev() in obsmod.getrevs(self._repo, 'unstable') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
200 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
201 |
def bumped(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
202 |
"""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
|
203 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
204 |
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
|
205 |
""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
206 |
return self.rev() in obsmod.getrevs(self._repo, 'bumped') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
207 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
208 |
def divergent(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
209 |
"""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
|
210 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
211 |
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
|
212 |
""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
213 |
return self.rev() in obsmod.getrevs(self._repo, 'divergent') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
214 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
215 |
def troubled(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
216 |
"""True if the changeset is either unstable, bumped or divergent""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
217 |
return self.unstable() or self.bumped() or self.divergent() |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
218 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
219 |
def troubles(self): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
220 |
"""return the list of troubles affecting this changesets. |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
221 |
|
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
222 |
Troubles are returned as strings. possible values are: |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
223 |
- unstable, |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
224 |
- bumped, |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
225 |
- divergent. |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
226 |
""" |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
227 |
troubles = [] |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
228 |
if self.unstable(): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
229 |
troubles.append('unstable') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
230 |
if self.bumped(): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
231 |
troubles.append('bumped') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
232 |
if self.divergent(): |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
233 |
troubles.append('divergent') |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
234 |
return troubles |
e61c6138fa33
context: move evolution functions from changectx to basectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19733
diff
changeset
|
235 |
|
19556
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
236 |
def parents(self): |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
237 |
"""return contexts for each parent changeset""" |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
238 |
return self._parents |
732ee7fff35a
basectx: move parents from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19555
diff
changeset
|
239 |
|
19557
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
240 |
def p1(self): |
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
241 |
return self._parents[0] |
9f57ebf0cce8
basectx: move p1 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19556
diff
changeset
|
242 |
|
19558
d0448e9d4554
basectx: move p2 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19557
diff
changeset
|
243 |
def p2(self): |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
244 |
parents = self._parents |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
245 |
if len(parents) == 2: |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
246 |
return parents[1] |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
247 |
return changectx(self._repo, nullrev) |
19558
d0448e9d4554
basectx: move p2 from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19557
diff
changeset
|
248 |
|
19559
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
249 |
def _fileinfo(self, path): |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
250 |
if '_manifest' in self.__dict__: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
251 |
try: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
252 |
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
|
253 |
except KeyError: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
254 |
raise error.ManifestLookupError(self._node, path, |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
255 |
_('not found in manifest')) |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
256 |
if '_manifestdelta' in self.__dict__ or path in self.files(): |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
257 |
if path in self._manifestdelta: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
258 |
return (self._manifestdelta[path], |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
259 |
self._manifestdelta.flags(path)) |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
260 |
node, flag = self._repo.manifest.find(self._changeset[0], path) |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
261 |
if not node: |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
262 |
raise error.ManifestLookupError(self._node, path, |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
263 |
_('not found in manifest')) |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
264 |
|
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
265 |
return node, flag |
80ad9fe22e18
basectx: move _fileinfo from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19558
diff
changeset
|
266 |
|
19560
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
267 |
def filenode(self, path): |
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
268 |
return self._fileinfo(path)[0] |
f256e1108053
basectx: move filenode from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19559
diff
changeset
|
269 |
|
19561
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
270 |
def flags(self, path): |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
271 |
try: |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
272 |
return self._fileinfo(path)[1] |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
273 |
except error.LookupError: |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
274 |
return '' |
7806e63598b0
basectx: move flags from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19560
diff
changeset
|
275 |
|
19562
389d7767630d
basectx: move sub from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19561
diff
changeset
|
276 |
def sub(self, path): |
25600
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
277 |
'''return a subrepo for the stored revision of path, never wdir()''' |
19562
389d7767630d
basectx: move sub from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19561
diff
changeset
|
278 |
return subrepo.subrepo(self, path) |
389d7767630d
basectx: move sub from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19561
diff
changeset
|
279 |
|
25417
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
280 |
def nullsub(self, path, pctx): |
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
281 |
return subrepo.nullsubrepo(self, path, pctx) |
95c271356a66
context: introduce the nullsub() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25303
diff
changeset
|
282 |
|
25600
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
283 |
def workingsub(self, path): |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
284 |
'''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
|
285 |
context. |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
286 |
''' |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25590
diff
changeset
|
287 |
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
|
288 |
|
25122
755d23a49170
match: resolve filesets in subrepos for commands given the '-S' argument
Matt Harbison <matt_harbison@yahoo.com>
parents:
24922
diff
changeset
|
289 |
def match(self, pats=[], 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
|
290 |
listsubrepos=False, badfn=None): |
19563
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
291 |
r = self._repo |
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
292 |
return matchmod.match(r.root, r.getcwd(), pats, |
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
293 |
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
|
294 |
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
|
295 |
listsubrepos=listsubrepos, badfn=badfn) |
19563
87503cd824fa
basectx: move match from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19562
diff
changeset
|
296 |
|
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
297 |
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
|
298 |
"""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
|
299 |
if ctx2 is None: |
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
300 |
ctx2 = self.p1() |
19568
f58235d85d6b
basectx: remove unnecessary check of instance
Sean Farley <sean.michael.farley@gmail.com>
parents:
19567
diff
changeset
|
301 |
if ctx2 is not None: |
19564
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
302 |
ctx2 = self._repo[ctx2] |
f0ed47b73d37
basectx: move diff from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19563
diff
changeset
|
303 |
diffopts = patch.diffopts(self._repo.ui, opts) |
21834
e4d35aa9056c
basectx: pass raw context objects to patch.diff
Sean Farley <sean.michael.farley@gmail.com>
parents:
21722
diff
changeset
|
304 |
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
|
305 |
|
24323
4c7c6beade1a
manifest: have context's dirs() call its manifest's dirs()
Drew Gottlieb <drgott@google.com>
parents:
24306
diff
changeset
|
306 |
def dirs(self): |
4c7c6beade1a
manifest: have context's dirs() call its manifest's dirs()
Drew Gottlieb <drgott@google.com>
parents:
24306
diff
changeset
|
307 |
return self._manifest.dirs() |
19565
bd1580a9c133
basectx: move _dirs from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19564
diff
changeset
|
308 |
|
24325
79d9c51488ca
manifest: add hasdir() to context
Drew Gottlieb <drgott@google.com>
parents:
24323
diff
changeset
|
309 |
def hasdir(self, dir): |
79d9c51488ca
manifest: add hasdir() to context
Drew Gottlieb <drgott@google.com>
parents:
24323
diff
changeset
|
310 |
return self._manifest.hasdir(dir) |
19566
54817c774d38
basectx: move dirs from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19565
diff
changeset
|
311 |
|
22055
ba5fc3f81f15
basectx: add missing, merge, and branch args to dirty method
Sean Farley <sean.michael.farley@gmail.com>
parents:
22054
diff
changeset
|
312 |
def dirty(self, missing=False, merge=True, branch=True): |
19567
49b128e50e84
basectx: move dirty from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19566
diff
changeset
|
313 |
return False |
49b128e50e84
basectx: move dirty from changectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19566
diff
changeset
|
314 |
|
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
315 |
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
|
316 |
listclean=False, listunknown=False, listsubrepos=False): |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
317 |
"""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
|
318 |
directory. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
319 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
320 |
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
|
321 |
|
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 |
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
|
323 |
""" |
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 |
ctx1 = self |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
326 |
ctx2 = self._repo[other] |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
327 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
328 |
# 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
|
329 |
# 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
|
330 |
# 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
|
331 |
# with its first parent. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
332 |
# |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
333 |
# 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
|
334 |
# |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
335 |
# workingctx.status(parentctx) |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
336 |
# |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
337 |
# 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
|
338 |
# 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
|
339 |
# just copy the manifest of the parent. |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
340 |
reversed = False |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
341 |
if (not isinstance(ctx1, changectx) |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
342 |
and isinstance(ctx2, changectx)): |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
343 |
reversed = True |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
344 |
ctx1, ctx2 = ctx2, ctx1 |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
345 |
|
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
346 |
match = ctx2._matchstatus(ctx1, match) |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
347 |
r = scmutil.status([], [], [], [], [], [], []) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
348 |
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
|
349 |
listunknown) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
350 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
351 |
if reversed: |
23301
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
352 |
# 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
|
353 |
# 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
|
354 |
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
|
355 |
r.clean) |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
356 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
357 |
if listsubrepos: |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
358 |
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
|
359 |
try: |
27183
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
360 |
rev2 = ctx2.subrev(subpath) |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
361 |
except KeyError: |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
362 |
# 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
|
363 |
# 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
|
364 |
# 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
|
365 |
rev2 = None |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
366 |
submatch = matchmod.narrowmatcher(subpath, match) |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
367 |
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
|
368 |
clean=listclean, unknown=listunknown, |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
369 |
listsubrepos=True) |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
370 |
for rfiles, sfiles in zip(r, s): |
0945539a3a6b
extdiff: correctly handle deleted subrepositories (issue3153)
Andrew Zwicky <andrew.zwicky@gmail.com>
parents:
27064
diff
changeset
|
371 |
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
|
372 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
373 |
for l in r: |
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
374 |
l.sort() |
21616
0a8e7f81e8ae
context: explicitly return a tuple
Sean Farley <sean.michael.farley@gmail.com>
parents:
21595
diff
changeset
|
375 |
|
23301
c10dc5568069
context.status: wipe deleted/unknown/ignored fields when reversed
Martin von Zweigbergk <martinvonz@google.com>
parents:
23257
diff
changeset
|
376 |
return r |
21594
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
377 |
|
9e4567829129
basectx: copy localrepo.status method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21593
diff
changeset
|
378 |
|
20035
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
379 |
def makememctx(repo, parents, text, user, date, branch, files, store, |
25303
b7876b8fa063
patch: add 'extra' argument to makememctx
Laurent Charignon <lcharignon@fb.com>
parents:
25195
diff
changeset
|
380 |
editor=None, extra=None): |
20035
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
381 |
def getfilectx(repo, memctx, path): |
22296
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
382 |
data, mode, copied = store.getfile(path) |
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
383 |
if data is None: |
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
384 |
return None |
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
385 |
islink, isexec = mode |
21689
503bb3af70fe
memfilectx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21688
diff
changeset
|
386 |
return memfilectx(repo, path, data, islink=islink, isexec=isexec, |
503bb3af70fe
memfilectx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21688
diff
changeset
|
387 |
copied=copied, memctx=memctx) |
25303
b7876b8fa063
patch: add 'extra' argument to makememctx
Laurent Charignon <lcharignon@fb.com>
parents:
25195
diff
changeset
|
388 |
if extra is None: |
b7876b8fa063
patch: add 'extra' argument to makememctx
Laurent Charignon <lcharignon@fb.com>
parents:
25195
diff
changeset
|
389 |
extra = {} |
20035
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
390 |
if branch: |
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
391 |
extra['branch'] = encoding.fromlocal(branch) |
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
392 |
ctx = memctx(repo, parents, text, files, getfilectx, user, |
21238
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
393 |
date, extra, editor) |
20035
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
394 |
return ctx |
cd79d9ab5e42
makememctx: move from patch to context to break import cycle
Augie Fackler <raf@durin42.com>
parents:
19951
diff
changeset
|
395 |
|
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
|
396 |
class changectx(basectx): |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
397 |
"""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
|
398 |
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
|
399 |
the repo.""" |
6741
5918e2b79859
context: simplify changeid logic
Matt Mackall <mpm@selenic.com>
parents:
6737
diff
changeset
|
400 |
def __init__(self, repo, changeid=''): |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
401 |
"""changeid is a revision number, node, or tag""" |
19539
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
402 |
|
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
403 |
# since basectx.__new__ already took care of copying the object, we |
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
404 |
# don't need to do anything in __init__, so we just exit here |
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
405 |
if isinstance(changeid, basectx): |
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
406 |
return |
79671c46bb46
changectx: if passing a basectx then exit __init__ immediately
Sean Farley <sean.michael.farley@gmail.com>
parents:
19538
diff
changeset
|
407 |
|
6741
5918e2b79859
context: simplify changeid logic
Matt Mackall <mpm@selenic.com>
parents:
6737
diff
changeset
|
408 |
if changeid == '': |
5918e2b79859
context: simplify changeid logic
Matt Mackall <mpm@selenic.com>
parents:
6737
diff
changeset
|
409 |
changeid = '.' |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
410 |
self._repo = repo |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
411 |
|
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
412 |
try: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
413 |
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
|
414 |
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
|
415 |
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
|
416 |
return |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
417 |
if isinstance(changeid, long): |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
418 |
changeid = str(changeid) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
419 |
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
|
420 |
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
|
421 |
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
|
422 |
return |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
return |
24050
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
427 |
if changeid == '.' or changeid == repo.dirstate.p1(): |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
428 |
# 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
|
429 |
# when we know that '.' won't be hidden |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
430 |
self._node = repo.dirstate.p1() |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
431 |
self._rev = repo.unfiltered().changelog.rev(self._node) |
a9b61dbdb827
context: use unfiltered repo for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
23984
diff
changeset
|
432 |
return |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
433 |
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
|
434 |
try: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
435 |
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
|
436 |
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
|
437 |
return |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
438 |
except error.FilteredRepoLookupError: |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
439 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
440 |
except LookupError: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
441 |
pass |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
442 |
|
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
|
443 |
try: |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
444 |
r = int(changeid) |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
445 |
if str(r) != changeid: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
446 |
raise ValueError |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
r += l |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
450 |
if r < 0 or r >= l: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
451 |
raise ValueError |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
452 |
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
|
453 |
self._node = repo.changelog.node(r) |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
454 |
return |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
455 |
except error.FilteredIndexError: |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
456 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
457 |
except (ValueError, OverflowError, IndexError): |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
458 |
pass |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
459 |
|
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
460 |
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
|
461 |
try: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
462 |
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
|
463 |
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
|
464 |
return |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
465 |
except error.FilteredLookupError: |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
466 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
467 |
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
|
468 |
pass |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
469 |
|
23560
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
470 |
# 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
|
471 |
try: |
23561
3c2419e07df5
namespaces: remove weakref; always pass in repo
Ryan McElroy <rmcelroy@fb.com>
parents:
23560
diff
changeset
|
472 |
self._node = repo.names.singlenode(repo, changeid) |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
473 |
self._rev = repo.changelog.rev(self._node) |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
474 |
return |
23560
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
475 |
except KeyError: |
aead63705504
changectx: use names api to simplify and extend node lookup
Sean Farley <sean.michael.farley@gmail.com>
parents:
23543
diff
changeset
|
476 |
pass |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
477 |
except error.FilteredRepoLookupError: |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
478 |
raise |
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
479 |
except error.RepoLookupError: |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
480 |
pass |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
481 |
|
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
482 |
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
|
483 |
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
|
484 |
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
|
485 |
return |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
486 |
|
23012
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
487 |
# lookup failed |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
488 |
# 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
|
489 |
# |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
490 |
# 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
|
491 |
# exception for filtered changeset access |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
492 |
if changeid in repo.unfiltered().dirstate.parents(): |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
493 |
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
|
494 |
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
|
495 |
try: |
26604
a3fcc8e3136b
context: don't hex encode all unknown 20 char revision specs (issue4890)
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
496 |
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
|
497 |
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
|
498 |
except TypeError: |
bdb3349cf7ab
changectx: wrap the `changeid` processing in a try/except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22942
diff
changeset
|
499 |
pass |
23017
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
500 |
except (error.FilteredIndexError, error.FilteredLookupError, |
dc25ed84bee8
changectx: issue a FilteredRepoLookupError when applicable
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23013
diff
changeset
|
501 |
error.FilteredRepoLookupError): |
24922
d9fb88c045a0
context: make warning message for hidden revision extensible
Laurent Charignon <lcharignon@fb.com>
parents:
24862
diff
changeset
|
502 |
if repo.filtername.startswith('visible'): |
23046
c1aede895072
repoview: issue a special message when filtering hidden changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23045
diff
changeset
|
503 |
msg = _("hidden revision '%s'") % changeid |
c1aede895072
repoview: issue a special message when filtering hidden changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23045
diff
changeset
|
504 |
hint = _('use --hidden to access hidden revisions') |
c1aede895072
repoview: issue a special message when filtering hidden changesets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23045
diff
changeset
|
505 |
raise error.FilteredRepoLookupError(msg, hint=hint) |
23045
a4dd270a419c
repoview: include the filter name in filtered revision error messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23017
diff
changeset
|
506 |
msg = _("filtered revision '%s' (not in '%s' subset)") |
a4dd270a419c
repoview: include the filter name in filtered revision error messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23017
diff
changeset
|
507 |
msg %= (changeid, repo.filtername) |
a4dd270a419c
repoview: include the filter name in filtered revision error messages
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23017
diff
changeset
|
508 |
raise error.FilteredRepoLookupError(msg) |
23013
b50ed6b9b513
changectx: move `IndexError` handling in the top level try except
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23012
diff
changeset
|
509 |
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
|
510 |
pass |
16376
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
511 |
raise error.RepoLookupError( |
d3908c911d5e
context: internalize lookup logic
Matt Mackall <mpm@selenic.com>
parents:
16373
diff
changeset
|
512 |
_("unknown revision '%s'") % changeid) |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
513 |
|
6469
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
514 |
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
|
515 |
try: |
fb502719c75c
python 2.6 compatibility: add __hash__ to classes that have __eq__
Paul Moore <p.f.moore@gmail.com>
parents:
6286
diff
changeset
|
516 |
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
|
517 |
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
|
518 |
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
|
519 |
|
3168
05c588e1803d
context: add __nonzero__ methods
Matt Mackall <mpm@selenic.com>
parents:
3166
diff
changeset
|
520 |
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
|
521 |
return self._rev != nullrev |
3168
05c588e1803d
context: add __nonzero__ methods
Matt Mackall <mpm@selenic.com>
parents:
3166
diff
changeset
|
522 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
523 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
524 |
def _changeset(self): |
16377
f8ce254e514f
context: use rev for changelog lookup
Matt Mackall <mpm@selenic.com>
parents:
16376
diff
changeset
|
525 |
return self._repo.changelog.read(self.rev()) |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
526 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
527 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
528 |
def _manifest(self): |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
529 |
return self._repo.manifest.read(self._changeset[0]) |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
530 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
531 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
532 |
def _manifestdelta(self): |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
533 |
return self._repo.manifest.readdelta(self._changeset[0]) |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
534 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
535 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
536 |
def _parents(self): |
27063
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
537 |
repo = self._repo |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
538 |
p1, p2 = repo.changelog.parentrevs(self._rev) |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
539 |
if p2 == nullrev: |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
540 |
return [changectx(repo, p1)] |
37e1fdcb271c
context: optimize _parents()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27016
diff
changeset
|
541 |
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
|
542 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
543 |
def changeset(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
544 |
return self._changeset |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
545 |
def manifestnode(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
546 |
return self._changeset[0] |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
547 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
548 |
def user(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
549 |
return self._changeset[1] |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
550 |
def date(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
551 |
return self._changeset[2] |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
552 |
def files(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
553 |
return self._changeset[3] |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
554 |
def description(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
555 |
return self._changeset[4] |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
556 |
def branch(self): |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
557 |
return encoding.tolocal(self._changeset[5].get("branch")) |
16720
e825a89de5d7
context: add changectx.closesbranch() method
Brodie Rao <brodie@sf.io>
parents:
16719
diff
changeset
|
558 |
def closesbranch(self): |
e825a89de5d7
context: add changectx.closesbranch() method
Brodie Rao <brodie@sf.io>
parents:
16719
diff
changeset
|
559 |
return 'close' in self._changeset[5] |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
560 |
def extra(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
561 |
return self._changeset[5] |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
562 |
def tags(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
563 |
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
|
564 |
def bookmarks(self): |
caa561759538
context: add method to return all bookmarks pointing to a node
David Soria Parra <dsp@php.net>
parents:
13235
diff
changeset
|
565 |
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
|
566 |
def phase(self): |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16610
diff
changeset
|
567 |
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
|
568 |
def hidden(self): |
18382
f3b21beb9802
filtering: rename filters to their antonyms
Kevin Bullock <kbullock@ringworld.org>
parents:
18364
diff
changeset
|
569 |
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
|
570 |
|
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
571 |
def children(self): |
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
572 |
"""return contexts for each child changeset""" |
2627
b779319a532b
context.py: self.repo is not defined, change to self._repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2566
diff
changeset
|
573 |
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
|
574 |
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
|
575 |
|
6876 | 576 |
def ancestors(self): |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16761
diff
changeset
|
577 |
for a in self._repo.changelog.ancestors([self._rev]): |
6876 | 578 |
yield changectx(self._repo, a) |
579 |
||
580 |
def descendants(self): |
|
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16866
diff
changeset
|
581 |
for d in self._repo.changelog.descendants([self._rev]): |
6876 | 582 |
yield changectx(self._repo, d) |
583 |
||
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
584 |
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
|
585 |
"""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
|
586 |
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
|
587 |
fileid = self.filenode(path) |
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
588 |
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
|
589 |
changectx=self, filelog=filelog) |
2563
482c524dd9ab
Add context.py: changeset and file revision contexts
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
590 |
|
21203
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
591 |
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
|
592 |
"""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
|
593 |
|
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
594 |
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
|
595 |
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
|
596 |
revlog ancestor.""" |
9843
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
597 |
# deal with workingctxs |
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
598 |
n2 = c2._node |
13031
3da456d0c885
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents:
13001
diff
changeset
|
599 |
if n2 is None: |
9843
d1043c2ffe6c
merge: fix changectx.ancestor(workingctx) (issue1327)
Matt Mackall <mpm@selenic.com>
parents:
9751
diff
changeset
|
600 |
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
|
601 |
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
|
602 |
if not cahs: |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
603 |
anc = nullid |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
604 |
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
|
605 |
anc = cahs[0] |
e94e90a4526e
context: tell when .ancestor picks one of multiple common ancestors heads
Mads Kiilerich <madski@unity3d.com>
parents:
21114
diff
changeset
|
606 |
else: |
25844
18541e9510c5
merge: make merge.preferancestor type and default consistent
Matt Mackall <mpm@selenic.com>
parents:
25757
diff
changeset
|
607 |
# experimental config: merge.preferancestor |
18541e9510c5
merge: make merge.preferancestor type and default consistent
Matt Mackall <mpm@selenic.com>
parents:
25757
diff
changeset
|
608 |
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
|
609 |
try: |
5220c12c43fd
changectx: skip all invalid merge.preferancestor values
Mads Kiilerich <madski@unity3d.com>
parents:
22405
diff
changeset
|
610 |
ctx = changectx(self._repo, r) |
5220c12c43fd
changectx: skip all invalid merge.preferancestor values
Mads Kiilerich <madski@unity3d.com>
parents:
22405
diff
changeset
|
611 |
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
|
612 |
continue |
21126
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
613 |
anc = ctx.node() |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
614 |
if anc in cahs: |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
615 |
break |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
616 |
else: |
99b5eaf372a7
context: introduce merge.preferancestor for controlling which ancestor to pick
Mads Kiilerich <madski@unity3d.com>
parents:
21125
diff
changeset
|
617 |
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
|
618 |
if warn: |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
619 |
self._repo.ui.status( |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
620 |
(_("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
|
621 |
(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
|
622 |
''.join(_(" alternatively, use --config " |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
623 |
"merge.preferancestor=%s\n") % |
9f12d8665c7b
ancestor: silence multiple ancestor warning outside of merge (issue4234)
Matt Mackall <mpm@selenic.com>
parents:
21126
diff
changeset
|
624 |
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
|
625 |
return changectx(self._repo, anc) |
3125
02b22fefc01f
changectx: add ancestor function
Matt Mackall <mpm@selenic.com>
parents:
3124
diff
changeset
|
626 |
|
17626
3a524b647897
context: add "descendant()" to changectx for efficient descendant examination
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17469
diff
changeset
|
627 |
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
|
628 |
"""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
|
629 |
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
|
630 |
|
6764 | 631 |
def walk(self, match): |
24646
5693c834bcb4
manifest: move changectx.walk() to manifests
Drew Gottlieb <drgott@google.com>
parents:
24633
diff
changeset
|
632 |
'''Generates matching file names.''' |
20292
8dc254198a8f
changectx: increase perf of walk function
Durham Goode <durham@fb.com>
parents:
20236
diff
changeset
|
633 |
|
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
634 |
# 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
|
635 |
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
|
636 |
# 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
|
637 |
# paths into valid subrepos. |
25195 | 638 |
if any(fn == s or fn.startswith(s + '/') |
639 |
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
|
640 |
return |
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
641 |
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
|
642 |
|
25435
a592a6a6f4fe
context: replace match.bad() monkey patching with match.badmatch()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25417
diff
changeset
|
643 |
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
|
644 |
return self._manifest.walk(m) |
6764 | 645 |
|
21985
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
646 |
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
|
647 |
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
|
648 |
|
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
|
649 |
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
|
650 |
"""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
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
directory, |
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
|
655 |
memfilectx: a filecontext that represents files in-memory.""" |
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
|
656 |
def __new__(cls, repo, path, *args, **kwargs): |
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
|
657 |
return super(basefilectx, cls).__new__(cls) |
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
|
658 |
|
19573
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
659 |
@propertycache |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
660 |
def _filelog(self): |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
661 |
return self._repo.file(self._path) |
dffad92ab709
basefilectx: move _filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19572
diff
changeset
|
662 |
|
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
663 |
@propertycache |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
664 |
def _changeid(self): |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
665 |
if '_changeid' in self.__dict__: |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
666 |
return self._changeid |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
667 |
elif '_changectx' in self.__dict__: |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
668 |
return self._changectx.rev() |
23983
ff070a53ee74
filectx: if we have a _descendantrev, use it to adjust linkrev
Matt Mackall <mpm@selenic.com>
parents:
23981
diff
changeset
|
669 |
elif '_descendantrev' in self.__dict__: |
ff070a53ee74
filectx: if we have a _descendantrev, use it to adjust linkrev
Matt Mackall <mpm@selenic.com>
parents:
23981
diff
changeset
|
670 |
# 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
|
671 |
# descendant, we can (lazily) correct for linkrev aliases |
ff070a53ee74
filectx: if we have a _descendantrev, use it to adjust linkrev
Matt Mackall <mpm@selenic.com>
parents:
23981
diff
changeset
|
672 |
return self._adjustlinkrev(self._path, self._filelog, |
ff070a53ee74
filectx: if we have a _descendantrev, use it to adjust linkrev
Matt Mackall <mpm@selenic.com>
parents:
23981
diff
changeset
|
673 |
self._filenode, self._descendantrev) |
19574
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
674 |
else: |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
675 |
return self._filelog.linkrev(self._filerev) |
a01436798988
basefilectx: move _changeid from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19573
diff
changeset
|
676 |
|
19575
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
677 |
@propertycache |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
678 |
def _filenode(self): |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
679 |
if '_fileid' in self.__dict__: |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
680 |
return self._filelog.lookup(self._fileid) |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
681 |
else: |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
682 |
return self._changectx.filenode(self._path) |
5a868137b830
basefilectx: move _filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19574
diff
changeset
|
683 |
|
19576
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
684 |
@propertycache |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
685 |
def _filerev(self): |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
686 |
return self._filelog.rev(self._filenode) |
18bbd8a3abf3
basefilectx: move _filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19575
diff
changeset
|
687 |
|
19577
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
688 |
@propertycache |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
689 |
def _repopath(self): |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
690 |
return self._path |
b52d572a2177
basefilectx: move _repopath from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19576
diff
changeset
|
691 |
|
19578
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
692 |
def __nonzero__(self): |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
693 |
try: |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
694 |
self._filenode |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
695 |
return True |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
696 |
except error.LookupError: |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
697 |
# file is missing |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
698 |
return False |
2c149635c2c5
basefilectx: move __nonzero__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19577
diff
changeset
|
699 |
|
19579
964844d64ef8
basefilectx: move __str__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19578
diff
changeset
|
700 |
def __str__(self): |
19660
86ce68c1ccb8
basefilectx: use basectx __str__ instead of duplicating logic
Sean Farley <sean.michael.farley@gmail.com>
parents:
19659
diff
changeset
|
701 |
return "%s@%s" % (self.path(), self._changectx) |
19579
964844d64ef8
basefilectx: move __str__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19578
diff
changeset
|
702 |
|
19580
e86a594ab11f
basefilectx: move __repr__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19579
diff
changeset
|
703 |
def __repr__(self): |
e86a594ab11f
basefilectx: move __repr__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19579
diff
changeset
|
704 |
return "<%s %s>" % (type(self).__name__, str(self)) |
e86a594ab11f
basefilectx: move __repr__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19579
diff
changeset
|
705 |
|
19581
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
706 |
def __hash__(self): |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
707 |
try: |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
708 |
return hash((self._path, self._filenode)) |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
709 |
except AttributeError: |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
710 |
return id(self) |
fe50d21be01a
basefilectx: move __hash__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19580
diff
changeset
|
711 |
|
19582
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
712 |
def __eq__(self, other): |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
713 |
try: |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
714 |
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
|
715 |
and self._filenode == other._filenode) |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
716 |
except AttributeError: |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
717 |
return False |
bda1d48bb07f
basefilectx: move __eq__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19581
diff
changeset
|
718 |
|
19583
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
719 |
def __ne__(self, other): |
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
720 |
return not (self == other) |
e5074d82afc9
basefilectx: move __ne__ from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19582
diff
changeset
|
721 |
|
19584
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
722 |
def filerev(self): |
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
723 |
return self._filerev |
19585
8e553cd6071e
basefilectx: move filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19584
diff
changeset
|
724 |
def filenode(self): |
8e553cd6071e
basefilectx: move filenode from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19584
diff
changeset
|
725 |
return self._filenode |
19586
43f9ed2f64b1
basefilectx: move flags from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19585
diff
changeset
|
726 |
def flags(self): |
43f9ed2f64b1
basefilectx: move flags from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19585
diff
changeset
|
727 |
return self._changectx.flags(self._path) |
19587
b1c344ebd8e4
basefilectx: move filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19586
diff
changeset
|
728 |
def filelog(self): |
b1c344ebd8e4
basefilectx: move filelog from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19586
diff
changeset
|
729 |
return self._filelog |
19588
a192fff6c97d
basefilectx: move rev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19587
diff
changeset
|
730 |
def rev(self): |
a192fff6c97d
basefilectx: move rev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19587
diff
changeset
|
731 |
return self._changeid |
19589
6a9043fa06d0
basefilectx: move linkrev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19588
diff
changeset
|
732 |
def linkrev(self): |
6a9043fa06d0
basefilectx: move linkrev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19588
diff
changeset
|
733 |
return self._filelog.linkrev(self._filerev) |
19590
90994b176bc1
basefilectx: move node from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19589
diff
changeset
|
734 |
def node(self): |
90994b176bc1
basefilectx: move node from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19589
diff
changeset
|
735 |
return self._changectx.node() |
19591
04fbc85f870a
basefilectx: move hex from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19590
diff
changeset
|
736 |
def hex(self): |
04fbc85f870a
basefilectx: move hex from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19590
diff
changeset
|
737 |
return self._changectx.hex() |
19592
1cdb3b3df4df
basefilectx: move user from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19591
diff
changeset
|
738 |
def user(self): |
1cdb3b3df4df
basefilectx: move user from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19591
diff
changeset
|
739 |
return self._changectx.user() |
19593
e3c241c89350
basefilectx: move date from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19592
diff
changeset
|
740 |
def date(self): |
e3c241c89350
basefilectx: move date from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19592
diff
changeset
|
741 |
return self._changectx.date() |
19594
1c030c24e196
basefilectx: move files from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19593
diff
changeset
|
742 |
def files(self): |
1c030c24e196
basefilectx: move files from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19593
diff
changeset
|
743 |
return self._changectx.files() |
19595
bb6fd06975a6
basefilectx: move description from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19594
diff
changeset
|
744 |
def description(self): |
bb6fd06975a6
basefilectx: move description from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19594
diff
changeset
|
745 |
return self._changectx.description() |
19596
9bc3d0dea371
basefilectx: move branch from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19595
diff
changeset
|
746 |
def branch(self): |
9bc3d0dea371
basefilectx: move branch from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19595
diff
changeset
|
747 |
return self._changectx.branch() |
19597
837bc86370f0
basefilectx: move extra from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19596
diff
changeset
|
748 |
def extra(self): |
837bc86370f0
basefilectx: move extra from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19596
diff
changeset
|
749 |
return self._changectx.extra() |
19598
e8ef893a3150
basefilectx: move phase from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19597
diff
changeset
|
750 |
def phase(self): |
e8ef893a3150
basefilectx: move phase from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19597
diff
changeset
|
751 |
return self._changectx.phase() |
19599
66d83efac20a
basefilectx: move phasestr from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19598
diff
changeset
|
752 |
def phasestr(self): |
66d83efac20a
basefilectx: move phasestr from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19598
diff
changeset
|
753 |
return self._changectx.phasestr() |
19600
12cdff44fdc4
basefilectx: move manifest from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19599
diff
changeset
|
754 |
def manifest(self): |
12cdff44fdc4
basefilectx: move manifest from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19599
diff
changeset
|
755 |
return self._changectx.manifest() |
19601
f284907631f5
basefilectx: move changectx from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19600
diff
changeset
|
756 |
def changectx(self): |
f284907631f5
basefilectx: move changectx from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19600
diff
changeset
|
757 |
return self._changectx |
24333
5da0eb641881
filectx: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24326
diff
changeset
|
758 |
def repo(self): |
5da0eb641881
filectx: add a repo accessor
Matt Harbison <matt_harbison@yahoo.com>
parents:
24326
diff
changeset
|
759 |
return self._repo |
19584
fe300e63c28c
basefilectx: move filerev from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19583
diff
changeset
|
760 |
|
19602
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
761 |
def path(self): |
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
762 |
return self._path |
018ee491a6be
basefilectx: move path from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19601
diff
changeset
|
763 |
|
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
764 |
def isbinary(self): |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
765 |
try: |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
766 |
return util.binary(self.data()) |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
767 |
except IOError: |
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
768 |
return False |
22054
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
769 |
def isexec(self): |
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
770 |
return 'x' in self.flags() |
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
771 |
def islink(self): |
ef0ee0c001bf
basefilectx: move isexec and islink from memfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21992
diff
changeset
|
772 |
return 'l' in self.flags() |
19603
a92302f48a56
basefilectx: move isbinary from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19602
diff
changeset
|
773 |
|
26978
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
774 |
def isabsent(self): |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
775 |
"""whether this filectx represents a file not in self._changectx |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
776 |
|
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
777 |
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
|
778 |
expected to be True for all subclasses of basectx.""" |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
779 |
return False |
9b9d4bcc915e
filectx: add isabsent method
Siddharth Agarwal <sid0@fb.com>
parents:
26977
diff
changeset
|
780 |
|
26977
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
781 |
_customcmp = False |
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
782 |
def cmp(self, fctx): |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
783 |
"""compare with other file context |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
784 |
|
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
785 |
returns True if different than fctx. |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
786 |
""" |
26977
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
787 |
if fctx._customcmp: |
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
788 |
return fctx.cmp(self) |
bd19561b98d9
filectx: allow custom comparators
Siddharth Agarwal <sid0@fb.com>
parents:
26748
diff
changeset
|
789 |
|
19604
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
790 |
if (fctx._filerev is None |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
791 |
and (self._repo._encodefilterpats |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
792 |
# 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
|
793 |
# 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
|
794 |
or self.size() - 4 == fctx.size()) |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
795 |
or self.size() == fctx.size()): |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
796 |
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
|
797 |
|
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
798 |
return True |
ef7c47e4002f
basefilectx: move cmp from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19603
diff
changeset
|
799 |
|
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
800 |
def _adjustlinkrev(self, path, filelog, fnode, srcrev, inclusive=False): |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24050
diff
changeset
|
801 |
"""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
|
802 |
|
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
803 |
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
|
804 |
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
|
805 |
this file revision. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
806 |
|
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
807 |
:repo: a localrepository object (used to access changelog and manifest) |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
808 |
:path: the file path |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
809 |
:fnode: the nodeid of the file revision |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
810 |
:filelog: the filelog of this path |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
811 |
: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
|
812 |
: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
|
813 |
""" |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
814 |
repo = self._repo |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
815 |
cl = repo.unfiltered().changelog |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
816 |
ma = repo.manifest |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
817 |
# fetch the linkrev |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
818 |
fr = filelog.rev(fnode) |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
819 |
lkr = filelog.linkrev(fr) |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
820 |
# 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
|
821 |
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
|
822 |
iteranc = None |
24411
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
823 |
if srcrev is None: |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
824 |
# 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
|
825 |
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
|
826 |
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
|
827 |
else: |
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
828 |
revs = [srcrev] |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
829 |
if memberanc is None: |
24411
5a12ef618c03
adjustlinkrev: handle 'None' value as source
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24410
diff
changeset
|
830 |
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
|
831 |
inclusive=inclusive) |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
832 |
# 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
|
833 |
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
|
834 |
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
|
835 |
iteranc = cl.ancestors(revs, lkr, inclusive=inclusive) |
23980
c1ce5442453f
_adjustlinkrev: reuse ancestors set during rename detection (issue4514)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23979
diff
changeset
|
836 |
for a in iteranc: |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
837 |
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
|
838 |
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
|
839 |
# 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
|
840 |
# similar to the one we search for. |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
841 |
if fnode == ma.readfast(ac[0]).get(path): |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
842 |
return a |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
843 |
# 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
|
844 |
# 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
|
845 |
# 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
|
846 |
# 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
|
847 |
return lkr |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
848 |
|
23703
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
849 |
def introrev(self): |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
850 |
"""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
|
851 |
|
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
'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
|
856 |
changesets. |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
857 |
""" |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
858 |
lkr = self.linkrev() |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
859 |
attrs = vars(self) |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
860 |
noctx = not ('_changeid' in attrs or '_changectx' in attrs) |
aaa76612b3c0
linkrev: introduce an 'introrev' method on filectx
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23702
diff
changeset
|
861 |
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
|
862 |
return self.linkrev() |
23979
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
863 |
return self._adjustlinkrev(self._path, self._filelog, self._filenode, |
087603b50889
filectx: move _adjustlinkrev to a method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23865
diff
changeset
|
864 |
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
|
865 |
|
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
866 |
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
|
867 |
"""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
|
868 |
fctx = filectx(self._repo, path, fileid=fileid, filelog=filelog) |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
869 |
if '_changeid' in vars(self) or '_changectx' in vars(self): |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
870 |
# 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
|
871 |
# 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
|
872 |
# 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
|
873 |
# 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
|
874 |
fctx._descendantrev = self.rev() |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
875 |
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
|
876 |
elif '_descendantrev' in vars(self): |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
877 |
# 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
|
878 |
fctx._descendantrev = self._descendantrev |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
879 |
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
|
880 |
return fctx |
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
881 |
|
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
882 |
def parents(self): |
22201
269688a398c4
cleanup: fix some list comprehension redefinitions of existing vars
Mads Kiilerich <madski@unity3d.com>
parents:
22192
diff
changeset
|
883 |
_path = self._path |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
884 |
fl = self._filelog |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
885 |
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
|
886 |
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
|
887 |
|
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
|
888 |
r = fl.renamed(self._filenode) |
19605
cf7322cb1c13
basefilectx: move parents from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19604
diff
changeset
|
889 |
if r: |
23688
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
890 |
# - 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
|
891 |
# - 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
|
892 |
# 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
|
893 |
# the first one. |
20932983d520
filectx.parents: filter nullrev parent sooner
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23687
diff
changeset
|
894 |
# |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
24050
diff
changeset
|
895 |
# 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
|
896 |
# 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
|
897 |
# 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
|
898 |
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
|
899 |
|
24816
8eec040cb65e
filectx: extract function to create parent fctx keeping ancestry info
Yuya Nishihara <yuya@tcha.org>
parents:
24815
diff
changeset
|
900 |
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
|
901 |
|
19606
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
902 |
def p1(self): |
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
903 |
return self.parents()[0] |
284f91230c07
basefilectx: move p1 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19605
diff
changeset
|
904 |
|
19607
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
905 |
def p2(self): |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
906 |
p = self.parents() |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
907 |
if len(p) == 2: |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
908 |
return p[1] |
056a949799ac
basefilectx: move p2 from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19606
diff
changeset
|
909 |
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
|
910 |
|
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
911 |
def annotate(self, follow=False, linenumber=None, diffopts=None): |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
912 |
'''returns a list of tuples of (ctx, line) for each line |
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
913 |
in the file, where ctx is the filectx of the node where |
4856
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
914 |
that line was last changed. |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
915 |
This returns tuples of ((ctx, linenumber), line) for each line, |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
916 |
if "linenumber" parameter is NOT "None". |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
917 |
In such tuples, linenumber means one at the first appearance |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
918 |
in the managed file. |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
919 |
To reduce annotation cost, |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
920 |
this returns fixed value(False is used) as linenumber, |
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
921 |
if "linenumber" parameter is "False".''' |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
922 |
|
22191
9f9a2b79dcd7
annotate: rewrite long short-circuit statement by if-elif-else
Yuya Nishihara <yuya@tcha.org>
parents:
22075
diff
changeset
|
923 |
if linenumber is None: |
22192
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
924 |
def decorate(text, rev): |
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
925 |
return ([rev] * len(text.splitlines()), text) |
22191
9f9a2b79dcd7
annotate: rewrite long short-circuit statement by if-elif-else
Yuya Nishihara <yuya@tcha.org>
parents:
22075
diff
changeset
|
926 |
elif linenumber: |
22192
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
927 |
def decorate(text, rev): |
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
928 |
size = len(text.splitlines()) |
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
929 |
return ([(rev, i) for i in xrange(1, size + 1)], text) |
22191
9f9a2b79dcd7
annotate: rewrite long short-circuit statement by if-elif-else
Yuya Nishihara <yuya@tcha.org>
parents:
22075
diff
changeset
|
930 |
else: |
22192
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
931 |
def decorate(text, rev): |
d1823cdf8554
annotate: inline definition of decorate() functions
Yuya Nishihara <yuya@tcha.org>
parents:
22191
diff
changeset
|
932 |
return ([(rev, False)] * len(text.splitlines()), text) |
4856
e45c5120ca27
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
4748
diff
changeset
|
933 |
|
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
934 |
def pair(parent, child): |
15528
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
935 |
blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts, |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
936 |
refine=True) |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
937 |
for (a1, a2, b1, b2), t in blocks: |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
938 |
# Changed blocks ('!') or blocks made only of blank lines ('~') |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
939 |
# belong to the child. |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
940 |
if t == '=': |
a84698badf0b
annotate: support diff whitespace filtering flags (issue3030)
Patrick Mezard <pmezard@gmail.com>
parents:
15453
diff
changeset
|
941 |
child[0][b1:b2] = parent[0][a1:a2] |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
942 |
return child |
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
943 |
|
9097
431462bd8478
fix memory usage of revlog caches by limiting cache size [issue1639]
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
944 |
getlog = util.lrucachefunc(lambda x: self._repo.file(x)) |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
945 |
|
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
946 |
def parents(f): |
24862
c82d88dfaf59
annotate: always adjust linkrev before walking down to parents (issue4623)
Yuya Nishihara <yuya@tcha.org>
parents:
24818
diff
changeset
|
947 |
# 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
|
948 |
# 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
|
949 |
# 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
|
950 |
# 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
|
951 |
f._changeid |
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
952 |
pl = f.parents() |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
953 |
|
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
954 |
# 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
|
955 |
if not follow: |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
956 |
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
|
957 |
|
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
958 |
# 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
|
959 |
# from the cache to save time |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
960 |
for p in pl: |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
961 |
if not '_filelog' in p.__dict__: |
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
962 |
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
|
963 |
|
19292
e0aa6fff8f02
annotate: simplify annotate parent function
Durham Goode <durham@fb.com>
parents:
19288
diff
changeset
|
964 |
return pl |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
965 |
|
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
966 |
# use linkrev to find the first changeset where self appeared |
23705
28a302e9225d
linkrev: also adjust linkrev when bootstrapping annotate (issue4305)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23703
diff
changeset
|
967 |
base = self |
28a302e9225d
linkrev: also adjust linkrev when bootstrapping annotate (issue4305)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23703
diff
changeset
|
968 |
introrev = self.introrev() |
28a302e9225d
linkrev: also adjust linkrev when bootstrapping annotate (issue4305)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23703
diff
changeset
|
969 |
if self.rev() != introrev: |
23770
50f0096a7346
filectx: fix annotate to not directly instantiate filectx
Durham Goode <durham@fb.com>
parents:
23757
diff
changeset
|
970 |
base = self.filectx(self.filenode(), changeid=introrev) |
24818
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
971 |
if getattr(base, '_ancestrycontext', None) is None: |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
972 |
cl = self._repo.changelog |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
973 |
if introrev is None: |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
974 |
# wctx is not inclusive, but works because _ancestrycontext |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
975 |
# is used to test filelog revisions |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
976 |
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
|
977 |
inclusive=True) |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
978 |
else: |
8d7d0bf62f9f
annotate: prepare ancestry context of workingfilectx
Yuya Nishihara <yuya@tcha.org>
parents:
24817
diff
changeset
|
979 |
ac = cl.ancestors([introrev], inclusive=True) |
24407
dd01834a696f
annotate: reuse ancestry context when adjusting linkrev (issue4532)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23984
diff
changeset
|
980 |
base._ancestrycontext = ac |
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
981 |
|
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
982 |
# This algorithm would prefer to be recursive, but Python is a |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
983 |
# bit recursion-hostile. Instead we do an iterative |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
984 |
# depth-first search. |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
985 |
|
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
986 |
visit = [base] |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
987 |
hist = {} |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
988 |
pcache = {} |
3404
1a437b0f4902
Fix annotate where linkrev != rev without exporting linkrev
Brendan Cully <brendan@kublai.com>
parents:
3403
diff
changeset
|
989 |
needed = {base: 1} |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
990 |
while visit: |
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
991 |
f = visit[-1] |
18993
0fd0612dc855
annotate: increase refcount of each revisions correctly (issue3841)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18992
diff
changeset
|
992 |
pcached = f in pcache |
0fd0612dc855
annotate: increase refcount of each revisions correctly (issue3841)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18992
diff
changeset
|
993 |
if not pcached: |
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
994 |
pcache[f] = parents(f) |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
995 |
|
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
996 |
ready = True |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
997 |
pl = pcache[f] |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
998 |
for p in pl: |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
999 |
if p not in hist: |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1000 |
ready = False |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1001 |
visit.append(p) |
18993
0fd0612dc855
annotate: increase refcount of each revisions correctly (issue3841)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18992
diff
changeset
|
1002 |
if not pcached: |
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1003 |
needed[p] = needed.get(p, 0) + 1 |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1004 |
if ready: |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1005 |
visit.pop() |
18992
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1006 |
reusable = f in hist |
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1007 |
if reusable: |
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1008 |
curr = hist[f] |
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1009 |
else: |
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1010 |
curr = decorate(f.data(), f) |
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1011 |
for p in pl: |
18992
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1012 |
if not reusable: |
a54ddfae8907
annotate: reuse already calculated annotation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18986
diff
changeset
|
1013 |
curr = pair(hist[p], curr) |
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1014 |
if needed[p] == 1: |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1015 |
del hist[p] |
19061
36067f5baf24
annotate: discard refcount of discarded annotation for memory efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18993
diff
changeset
|
1016 |
del needed[p] |
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1017 |
else: |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1018 |
needed[p] -= 1 |
6762 | 1019 |
|
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1020 |
hist[f] = curr |
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1021 |
pcache[f] = [] |
3172
5c93dd0ae413
Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents:
3152
diff
changeset
|
1022 |
|
13552
7ab85fec60c3
ancestor: rewrite to deal with crossed linkrevs (issue2682)
Matt Mackall <mpm@selenic.com>
parents:
13481
diff
changeset
|
1023 |
return zip(hist[base][0], hist[base][1].splitlines(True)) |
3124
4d021b91cb26
filectx: allow passing filelog in init to avoid opening new filelogs
Matt Mackall <mpm@selenic.com>
parents:
3123
diff
changeset
|
1024 |
|
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1025 |
def ancestors(self, followfirst=False): |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1026 |
visit = {} |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1027 |
c = self |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1028 |
if followfirst: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1029 |
cut = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1030 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1031 |
cut = None |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1032 |
|
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1033 |
while True: |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1034 |
for parent in c.parents()[:cut]: |
23981
24b57c3899f8
filectx: use linkrev to sort ancestors
Matt Mackall <mpm@selenic.com>
parents:
23980
diff
changeset
|
1035 |
visit[(parent.linkrev(), parent.filenode())] = parent |
19610
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1036 |
if not visit: |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1037 |
break |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1038 |
c = visit.pop(max(visit)) |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1039 |
yield c |
0670422d58c6
basefilectx: move ancestors from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19609
diff
changeset
|
1040 |
|
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1041 |
class filectx(basefilectx): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1042 |
"""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
|
1043 |
filerevision convenient.""" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1044 |
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
|
1045 |
filelog=None, changectx=None): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1046 |
"""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
|
1047 |
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
|
1048 |
self._repo = repo |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1049 |
self._path = path |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1050 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1051 |
assert (changeid is not None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1052 |
or fileid is not None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1053 |
or changectx is not None), \ |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1054 |
("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
|
1055 |
% (changeid, fileid, changectx)) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1056 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1057 |
if filelog is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1058 |
self._filelog = filelog |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1059 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1060 |
if changeid is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1061 |
self._changeid = changeid |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1062 |
if changectx is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1063 |
self._changectx = changectx |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1064 |
if fileid is not None: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1065 |
self._fileid = fileid |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1066 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1067 |
@propertycache |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1068 |
def _changectx(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1069 |
try: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1070 |
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
|
1071 |
except error.FilteredRepoLookupError: |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1072 |
# 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
|
1073 |
# 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
|
1074 |
# `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
|
1075 |
# 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
|
1076 |
# 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
|
1077 |
# `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
|
1078 |
# filtering. |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1079 |
# |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1080 |
# 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
|
1081 |
# 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
|
1082 |
# 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
|
1083 |
# behavior" is seen as better as "crash" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1084 |
# |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1085 |
# 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
|
1086 |
# 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
|
1087 |
# 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
|
1088 |
return changectx(self._repo.unfiltered(), self._changeid) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1089 |
|
23770
50f0096a7346
filectx: fix annotate to not directly instantiate filectx
Durham Goode <durham@fb.com>
parents:
23757
diff
changeset
|
1090 |
def filectx(self, fileid, changeid=None): |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1091 |
'''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
|
1092 |
opening a new filelog''' |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1093 |
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
|
1094 |
filelog=self._filelog, changeid=changeid) |
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1095 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1096 |
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
|
1097 |
try: |
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1098 |
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
|
1099 |
except error.CensoredNodeError: |
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1100 |
if self._repo.ui.config("censor", "policy", "abort") == "ignore": |
d81792872984
context: handle censored data in an on-disk file context based on config
Mike Edgar <adgar@google.com>
parents:
22916
diff
changeset
|
1101 |
return "" |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26492
diff
changeset
|
1102 |
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
|
1103 |
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
|
1104 |
|
19608
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1105 |
def size(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1106 |
return self._filelog.size(self._filerev) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1107 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1108 |
def renamed(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1109 |
"""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
|
1110 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1111 |
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
|
1112 |
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
|
1113 |
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
|
1114 |
""" |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1115 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1116 |
renamed = self._filelog.renamed(self._filenode) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1117 |
if not renamed: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1118 |
return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1119 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1120 |
if self.rev() == self.linkrev(): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1121 |
return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1122 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1123 |
name = self.path() |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1124 |
fnode = self._filenode |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1125 |
for p in self._changectx.parents(): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1126 |
try: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1127 |
if fnode == p.filenode(name): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1128 |
return None |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1129 |
except error.LookupError: |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1130 |
pass |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1131 |
return renamed |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1132 |
|
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1133 |
def children(self): |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1134 |
# hard for renames |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1135 |
c = self._filelog.children(self._filenode) |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1136 |
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
|
1137 |
filelog=self._filelog) for x in c] |
896193a9cab4
basefilectx: move annotate from filectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19607
diff
changeset
|
1138 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1139 |
class committablectx(basectx): |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1140 |
"""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
|
1141 |
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
|
1142 |
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
|
1143 |
changes=None): |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1144 |
self._repo = repo |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1145 |
self._rev = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1146 |
self._node = None |
6709
f84f507c53d3
context: let workingctx.date(), .user() and description() be overriden
Patrick Mezard <pmezard@gmail.com>
parents:
6708
diff
changeset
|
1147 |
self._text = text |
6718
4386a7706828
Fix commit date (issue1193)
Christian Ebert <blacktrash@gmx.net>
parents:
6715
diff
changeset
|
1148 |
if date: |
6709
f84f507c53d3
context: let workingctx.date(), .user() and description() be overriden
Patrick Mezard <pmezard@gmail.com>
parents:
6708
diff
changeset
|
1149 |
self._date = util.parsedate(date) |
6817 | 1150 |
if user: |
1151 |
self._user = user |
|
6707
02bad34230a2
localrepo: hide commit() file selection behind workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6705
diff
changeset
|
1152 |
if changes: |
21592
16f62b4203b1
committablectx: simplify caching the status
Sean Farley <sean.michael.farley@gmail.com>
parents:
21590
diff
changeset
|
1153 |
self._status = changes |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1154 |
|
6708
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1155 |
self._extra = {} |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1156 |
if extra: |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1157 |
self._extra = extra.copy() |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1158 |
if 'branch' not in self._extra: |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1159 |
try: |
13047
6c375e07d673
branch: operate on branch names in local string space where possible
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
1160 |
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
|
1161 |
except UnicodeDecodeError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26492
diff
changeset
|
1162 |
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
|
1163 |
self._extra['branch'] = branch |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1164 |
if self._extra['branch'] == '': |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1165 |
self._extra['branch'] = 'default' |
7566f00a3979
localrepo: let commit() get extra data from workingctx
Patrick Mezard <pmezard@gmail.com>
parents:
6707
diff
changeset
|
1166 |
|
19666
09459edfb48b
commitablectx: move __str__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19665
diff
changeset
|
1167 |
def __str__(self): |
09459edfb48b
commitablectx: move __str__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19665
diff
changeset
|
1168 |
return str(self._parents[0]) + "+" |
09459edfb48b
commitablectx: move __str__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19665
diff
changeset
|
1169 |
|
19667
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1170 |
def __nonzero__(self): |
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1171 |
return True |
40040e4015f9
commitablectx: move __nonzero__ from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19666
diff
changeset
|
1172 |
|
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1173 |
def _buildflagfunc(self): |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1174 |
# 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
|
1175 |
# filesystem doesn't support them |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1176 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1177 |
copiesget = self._repo.dirstate.copies().get |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1178 |
parents = self.parents() |
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1179 |
if len(parents) < 2: |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1180 |
# 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
|
1181 |
man = parents[0].manifest() |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1182 |
def func(f): |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1183 |
f = copiesget(f, f) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1184 |
return man.flags(f) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1185 |
else: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1186 |
# 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
|
1187 |
# result from the merge (issue1802) |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1188 |
p1, p2 = parents |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1189 |
pa = p1.ancestor(p2) |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1190 |
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
|
1191 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1192 |
def func(f): |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1193 |
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
|
1194 |
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
|
1195 |
if fl1 == fl2: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1196 |
return fl1 |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1197 |
if fl1 == fla: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1198 |
return fl2 |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1199 |
if fl2 == fla: |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1200 |
return fl1 |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1201 |
return '' # punt for conflicts |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1202 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1203 |
return func |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1204 |
|
19670
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1205 |
@propertycache |
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1206 |
def _flagfunc(self): |
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1207 |
return self._repo.dirstate.flagfunc(self._buildflagfunc) |
6ac735fbea50
commitablectx: move _flagfunc from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19669
diff
changeset
|
1208 |
|
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1209 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1210 |
def _manifest(self): |
23410
cd9e5e57064d
manifest: document the extra letter in working copy manifest node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23404
diff
changeset
|
1211 |
"""generate a manifest corresponding to the values in self._status |
cd9e5e57064d
manifest: document the extra letter in working copy manifest node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23404
diff
changeset
|
1212 |
|
cd9e5e57064d
manifest: document the extra letter in working copy manifest node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23404
diff
changeset
|
1213 |
This reuse the file nodeid from parent, but we append an extra letter |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23410
diff
changeset
|
1214 |
when modified. Modified files get an extra 'm' while added files get |
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23410
diff
changeset
|
1215 |
an extra 'a'. This is used by manifests merge to see that files |
23410
cd9e5e57064d
manifest: document the extra letter in working copy manifest node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23404
diff
changeset
|
1216 |
are different and by update logic to avoid deleting newly added files. |
cd9e5e57064d
manifest: document the extra letter in working copy manifest node
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23404
diff
changeset
|
1217 |
""" |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1218 |
parents = self.parents() |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1219 |
|
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1220 |
man1 = parents[0].manifest() |
23401
fd1bab28a8cc
manifest: fix a bug where working copy file 'add' mark was buggy
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23110
diff
changeset
|
1221 |
man = man1.copy() |
27064
a29db426c5ba
context: avoid extra parents lookups
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27063
diff
changeset
|
1222 |
if len(parents) > 1: |
10921
fb89cd21a7a0
workingctx: correctly compute the flag for noexec filesystems+merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
1223 |
man2 = self.p2().manifest() |
fb89cd21a7a0
workingctx: correctly compute the flag for noexec filesystems+merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
1224 |
def getman(f): |
23401
fd1bab28a8cc
manifest: fix a bug where working copy file 'add' mark was buggy
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23110
diff
changeset
|
1225 |
if f in man1: |
fd1bab28a8cc
manifest: fix a bug where working copy file 'add' mark was buggy
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23110
diff
changeset
|
1226 |
return man1 |
10921
fb89cd21a7a0
workingctx: correctly compute the flag for noexec filesystems+merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
1227 |
return man2 |
fb89cd21a7a0
workingctx: correctly compute the flag for noexec filesystems+merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
1228 |
else: |
23401
fd1bab28a8cc
manifest: fix a bug where working copy file 'add' mark was buggy
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23110
diff
changeset
|
1229 |
getman = lambda f: man1 |
15337
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1230 |
|
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1231 |
copied = self._repo.dirstate.copies() |
cf5f9df6406b
windows: recompute flags when committing a merge (issue1802)
Matt Mackall <mpm@selenic.com>
parents:
14674
diff
changeset
|
1232 |
ff = self._flagfunc |
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1233 |
for i, l in (("a", self._status.added), ("m", self._status.modified)): |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1234 |
for f in l: |
10921
fb89cd21a7a0
workingctx: correctly compute the flag for noexec filesystems+merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
1235 |
orig = copied.get(f, f) |
fb89cd21a7a0
workingctx: correctly compute the flag for noexec filesystems+merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
1236 |
man[f] = getman(orig).get(orig, nullid) + i |
3823
676b75547d13
context: don't spuriously raise abort when a file goes missing.
Matt Mackall <mpm@selenic.com>
parents:
3715
diff
changeset
|
1237 |
try: |
22942
03602f76deee
manifest: rename ambiguously-named set to setflag
Augie Fackler <raf@durin42.com>
parents:
22932
diff
changeset
|
1238 |
man.setflag(f, ff(f)) |
3823
676b75547d13
context: don't spuriously raise abort when a file goes missing.
Matt Mackall <mpm@selenic.com>
parents:
3715
diff
changeset
|
1239 |
except OSError: |
676b75547d13
context: don't spuriously raise abort when a file goes missing.
Matt Mackall <mpm@selenic.com>
parents:
3715
diff
changeset
|
1240 |
pass |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1241 |
|
22916
cfa8d7561938
context: store status class instead of plain tuple in self._status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
1242 |
for f in self._status.deleted + self._status.removed: |
3325
50a18815e3f0
Revert changeset c67920d78248.
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
3313
diff
changeset
|
1243 |
if f in man: |
50a18815e3f0
Revert changeset c67920d78248.
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents:
3313
diff
changeset
|
1244 |
del man[f] |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1245 |
|
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1246 |
return man |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1247 |
|
19672
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1248 |
@propertycache |
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1249 |
def _status(self): |
21592
16f62b4203b1
committablectx: simplify caching the status
Sean Farley <sean.michael.farley@gmail.com>
parents:
21590
diff
changeset
|
1250 |
return self._repo.status() |
19672
375986c02539
commitablectx: move _status from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19671
diff
changeset
|
1251 |
|
19674
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1252 |
@propertycache |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1253 |
def _user(self): |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1254 |
return self._repo.ui.username() |
ec5b2e2b947f
commitablectx: move _user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19673
diff
changeset
|
1255 |
|
19676
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1256 |
@propertycache |
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1257 |
def _date(self): |
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1258 |
return util.makedate() |
103525f36337
commitablectx: move _date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19675
diff
changeset
|
1259 |
|
21587
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1260 |
def subrev(self, subpath): |
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1261 |
return None |
02a8612ddec2
committablectx: add subrev method to return None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21586
diff
changeset
|
1262 |
|
24719
11e8fec00234
committablectx: override manifestnode() to return None
Yuya Nishihara <yuya@tcha.org>
parents:
24646
diff
changeset
|
1263 |
def manifestnode(self): |
11e8fec00234
committablectx: override manifestnode() to return None
Yuya Nishihara <yuya@tcha.org>
parents:
24646
diff
changeset
|
1264 |
return None |
19675
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1265 |
def user(self): |
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1266 |
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
|
1267 |
def date(self): |
e11415510352
commitablectx: move date from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19676
diff
changeset
|
1268 |
return self._date |
19678
897c2dbc0256
commitablectx: move description from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19677
diff
changeset
|
1269 |
def description(self): |
897c2dbc0256
commitablectx: move description from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19677
diff
changeset
|
1270 |
return self._text |
19679
f21804f1582e
commitablectx: move files from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19678
diff
changeset
|
1271 |
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
|
1272 |
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
|
1273 |
self._status.removed) |
19675
84249d49f37c
commitablectx: move user from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19674
diff
changeset
|
1274 |
|
19680
fc33fcfa08f2
commitablectx: move modified from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19679
diff
changeset
|
1275 |
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
|
1276 |
return self._status.modified |
19681
cfc4ae65023f
commitablectx: move added from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19680
diff
changeset
|
1277 |
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
|
1278 |
return self._status.added |
19682
42ffc7f31acf
commitablectx: move removed from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19681
diff
changeset
|
1279 |
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
|
1280 |
return self._status.removed |
19683
6336f35ed77d
commitablectx: move deleted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19682
diff
changeset
|
1281 |
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
|
1282 |
return self._status.deleted |
19687
54b3b4821bfb
commitablectx: move branch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19686
diff
changeset
|
1283 |
def branch(self): |
54b3b4821bfb
commitablectx: move branch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19686
diff
changeset
|
1284 |
return encoding.tolocal(self._extra['branch']) |
19688
21e1068109a7
commitablectx: move closesbranch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19687
diff
changeset
|
1285 |
def closesbranch(self): |
21e1068109a7
commitablectx: move closesbranch from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19687
diff
changeset
|
1286 |
return 'close' in self._extra |
19689
8dbb66f339f3
commitablectx: move extra from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19688
diff
changeset
|
1287 |
def extra(self): |
8dbb66f339f3
commitablectx: move extra from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19688
diff
changeset
|
1288 |
return self._extra |
19680
fc33fcfa08f2
commitablectx: move modified from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19679
diff
changeset
|
1289 |
|
19690
65ff9fd67d8d
commitablectx: move tags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19689
diff
changeset
|
1290 |
def tags(self): |
25688
24cda1dd45ff
workingctx: don't report the tags for its parents
Matt Harbison <matt_harbison@yahoo.com>
parents:
25660
diff
changeset
|
1291 |
return [] |
19690
65ff9fd67d8d
commitablectx: move tags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19689
diff
changeset
|
1292 |
|
19691
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1293 |
def bookmarks(self): |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1294 |
b = [] |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1295 |
for p in self.parents(): |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1296 |
b.extend(p.bookmarks()) |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1297 |
return b |
33ae2052d924
commitablectx: move bookmarks from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19690
diff
changeset
|
1298 |
|
19692
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1299 |
def phase(self): |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1300 |
phase = phases.draft # default phase to draft |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1301 |
for p in self.parents(): |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1302 |
phase = max(phase, p.phase()) |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1303 |
return phase |
594f4d2b0ce9
commitablectx: move phase from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19691
diff
changeset
|
1304 |
|
19693
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1305 |
def hidden(self): |
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1306 |
return False |
56ba14d4bc02
commitablectx: move hidden from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19692
diff
changeset
|
1307 |
|
19694
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1308 |
def children(self): |
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1309 |
return [] |
ba4c01c34df9
commitablectx: move children from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19693
diff
changeset
|
1310 |
|
19695
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1311 |
def flags(self, path): |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1312 |
if '_manifest' in self.__dict__: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1313 |
try: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1314 |
return self._manifest.flags(path) |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1315 |
except KeyError: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1316 |
return '' |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1317 |
|
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1318 |
try: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1319 |
return self._flagfunc(path) |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1320 |
except OSError: |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1321 |
return '' |
6c52adcaba0e
commitablectx: move flags from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19694
diff
changeset
|
1322 |
|
19696
210cc42a8ac2
commitablectx: move ancestor from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19695
diff
changeset
|
1323 |
def ancestor(self, c2): |
22389
94f77624dbb5
comments: describe ancestor consistently - avoid 'least common ancestor'
Mads Kiilerich <madski@unity3d.com>
parents:
22313
diff
changeset
|
1324 |
"""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
|
1325 |
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
|
1326 |
|
19697
8c95e74857c6
commitablectx: move walk from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19696
diff
changeset
|
1327 |
def walk(self, match): |
24646
5693c834bcb4
manifest: move changectx.walk() to manifests
Drew Gottlieb <drgott@google.com>
parents:
24633
diff
changeset
|
1328 |
'''Generates matching file names.''' |
19697
8c95e74857c6
commitablectx: move walk from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19696
diff
changeset
|
1329 |
return sorted(self._repo.dirstate.walk(match, sorted(self.substate), |
8c95e74857c6
commitablectx: move walk from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19696
diff
changeset
|
1330 |
True, False)) |
8c95e74857c6
commitablectx: move walk from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19696
diff
changeset
|
1331 |
|
21985
7e871e771300
context: add a method to efficiently filter by match if possible
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
1332 |
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
|
1333 |
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
|
1334 |
|
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1335 |
def ancestors(self): |
23616
11a160547d7f
context: return dirstate parents in workingctx.ancestors()
Durham Goode <durham@fb.com>
parents:
23603
diff
changeset
|
1336 |
for p in self._parents: |
11a160547d7f
context: return dirstate parents in workingctx.ancestors()
Durham Goode <durham@fb.com>
parents:
23603
diff
changeset
|
1337 |
yield p |
19698
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1338 |
for a in self._repo.changelog.ancestors( |
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1339 |
[p.rev() for p in self._parents]): |
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1340 |
yield changectx(self._repo, a) |
8d4a8f4eb404
commitablectx: move ancestors from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19697
diff
changeset
|
1341 |
|
19699
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1342 |
def markcommitted(self, node): |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1343 |
"""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
|
1344 |
|
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1345 |
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
|
1346 |
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
|
1347 |
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
|
1348 |
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
|
1349 |
|
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1350 |
""" |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1351 |
|
22405
6f63c47cbb86
dirstate: wrap setparent calls with begin/endparentchange (issue4353)
Durham Goode <durham@fb.com>
parents:
22389
diff
changeset
|
1352 |
self._repo.dirstate.beginparentchange() |
19699
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1353 |
for f in self.modified() + self.added(): |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1354 |
self._repo.dirstate.normal(f) |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1355 |
for f in self.removed(): |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1356 |
self._repo.dirstate.drop(f) |
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1357 |
self._repo.dirstate.setparents(node) |
22405
6f63c47cbb86
dirstate: wrap setparent calls with begin/endparentchange (issue4353)
Durham Goode <durham@fb.com>
parents:
22389
diff
changeset
|
1358 |
self._repo.dirstate.endparentchange() |
19699
9fbc193b2358
commitablectx: move markcommitted from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19698
diff
changeset
|
1359 |
|
25757
4d1382fd96ff
context: write dirstate out explicitly at the end of markcommitted
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25753
diff
changeset
|
1360 |
# 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
|
1361 |
# 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
|
1362 |
# 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
|
1363 |
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
|
1364 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1365 |
class workingctx(committablectx): |
19671
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1366 |
"""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
|
1367 |
the current working directory convenient. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1368 |
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
|
1369 |
user - username string, or None. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1370 |
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
|
1371 |
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
|
1372 |
or None to use the repository status. |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1373 |
""" |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1374 |
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
|
1375 |
changes=None): |
367e95bba6e8
commitablectx: move _manifest from workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19670
diff
changeset
|
1376 |
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
|
1377 |
|
14129
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1378 |
def __iter__(self): |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1379 |
d = self._repo.dirstate |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1380 |
for f in d: |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1381 |
if d[f] != 'r': |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1382 |
yield f |
81e6d42b3228
context: provide an efficient iterator for workingctx
Matt Mackall <mpm@selenic.com>
parents:
14004
diff
changeset
|
1383 |
|
21845
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1384 |
def __contains__(self, key): |
04f5b5e3792e
committablectx: move __contains__ into workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21844
diff
changeset
|
1385 |
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
|
1386 |
|
25590
183965a00c76
context: override workingctx.hex() to avoid a crash
Matt Harbison <matt_harbison@yahoo.com>
parents:
25465
diff
changeset
|
1387 |
def hex(self): |
25738
04d26a3c96fd
workingctx: use node.wdirid constant
Yuya Nishihara <yuya@tcha.org>
parents:
25688
diff
changeset
|
1388 |
return hex(wdirid) |
25590
183965a00c76
context: override workingctx.hex() to avoid a crash
Matt Harbison <matt_harbison@yahoo.com>
parents:
25465
diff
changeset
|
1389 |
|
8157
77c5877a668c
context: use Python 2.4 decorator syntax
Martin Geisler <mg@lazybytes.net>
parents:
8151
diff
changeset
|
1390 |
@propertycache |
7368
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1391 |
def _parents(self): |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1392 |
p = self._repo.dirstate.parents() |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1393 |
if p[1] == nullid: |
595ba2537d4f
context: use descriptors to speed up lazy attributes
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7367
diff
changeset
|
1394 |
p = p[:-1] |
17330
32e9d63d9ba6
context: simplify workingctx._parents
Patrick Mezard <patrick@mezard.eu>
parents:
17207
diff
changeset
|
1395 |
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
|
1396 |
|
3966
b4eaa68dea1b
context: create a filectxt with filelog reuse
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3965
diff
changeset
|
1397 |
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
|
1398 |
"""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
|
1399 |
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
|
1400 |
filelog=filelog) |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1401 |
|
16491
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1402 |
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
|
1403 |
"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
|
1404 |
# check subrepos first |
18364
6252b4f1c4b4
subrepos: process subrepos in sorted order
Mads Kiilerich <mads@kiilerich.com>
parents:
18252
diff
changeset
|
1405 |
for s in sorted(self.substate): |
11110
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1406 |
if self.sub(s).dirty(): |
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1407 |
return True |
22f5ad0b5857
subrepo: dirtiness checks should iterate over subrepos
Edouard Gomez <ed.gomez@free.fr>
parents:
11106
diff
changeset
|
1408 |
# check current working dir |
16491
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1409 |
return ((merge and self.p2()) or |
bfe89d65d651
update: make --check abort with dirty subrepos
Patrick Mezard <patrick@mezard.eu>
parents:
16410
diff
changeset
|
1410 |
(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
|
1411 |
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
|
1412 |
(missing and self.deleted())) |
e8de59577257
context: add a dirty method to detect modified contexts
Matt Mackall <mpm@selenic.com>
parents:
8528
diff
changeset
|
1413 |
|
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1414 |
def add(self, list, prefix=""): |
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1415 |
join = lambda f: 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
|
1416 |
wlock = self._repo.wlock() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1417 |
ui, ds = self._repo.ui, self._repo.dirstate |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1418 |
try: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1419 |
rejected = [] |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1420 |
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
|
1421 |
for f in list: |
13962
8b252e826c68
add: introduce a warning message for non-portable filenames (issue2756) (BC)
Adrian Buehlmann <adrian@cadifra.com>
parents:
13877
diff
changeset
|
1422 |
scmutil.checkportable(ui, join(f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1423 |
try: |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1424 |
st = lstat(f) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
13962
diff
changeset
|
1425 |
except OSError: |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1426 |
ui.warn(_("%s does not exist!\n") % join(f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1427 |
rejected.append(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1428 |
continue |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1429 |
if st.st_size > 10000000: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1430 |
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
|
1431 |
"to manage this file\n" |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1432 |
"(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
|
1433 |
"pending addition)\n") |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1434 |
% (f, 3 * st.st_size // 1000000, join(f))) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1435 |
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
|
1436 |
ui.warn(_("%s not added: only files and symlinks " |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1437 |
"supported currently\n") % join(f)) |
19900
7c21e3398931
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19734
diff
changeset
|
1438 |
rejected.append(f) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1439 |
elif ds[f] in 'amn': |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
1440 |
ui.warn(_("%s already tracked!\n") % join(f)) |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1441 |
elif ds[f] == 'r': |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1442 |
ds.normallookup(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1443 |
else: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1444 |
ds.add(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1445 |
return rejected |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1446 |
finally: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1447 |
wlock.release() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1448 |
|
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1449 |
def forget(self, files, prefix=""): |
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1450 |
join = lambda f: 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
|
1451 |
wlock = self._repo.wlock() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1452 |
try: |
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1453 |
rejected = [] |
14435
5f6090e559fa
context: make forget work like commands.forget
Matt Mackall <mpm@selenic.com>
parents:
14434
diff
changeset
|
1454 |
for f in files: |
16111
131d1a09108a
context: make workingctx.forget() really warn about untracked files
Patrick Mezard <patrick@mezard.eu>
parents:
15912
diff
changeset
|
1455 |
if f not in self._repo.dirstate: |
15912
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1456 |
self._repo.ui.warn(_("%s not tracked!\n") % join(f)) |
2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
David M. Carr <david@carrclan.us>
parents:
15895
diff
changeset
|
1457 |
rejected.append(f) |
16111
131d1a09108a
context: make workingctx.forget() really warn about untracked files
Patrick Mezard <patrick@mezard.eu>
parents:
15912
diff
changeset
|
1458 |
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
|
1459 |
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
|
1460 |
else: |
14434
cc8c09855d19
dirstate: rename forget to drop
Matt Mackall <mpm@selenic.com>
parents:
14429
diff
changeset
|
1461 |
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
|
1462 |
return rejected |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1463 |
finally: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1464 |
wlock.release() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1465 |
|
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1466 |
def undelete(self, list): |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1467 |
pctxs = self.parents() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1468 |
wlock = self._repo.wlock() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1469 |
try: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1470 |
for f in list: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1471 |
if self._repo.dirstate[f] != 'r': |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1472 |
self._repo.ui.warn(_("%s not removed!\n") % f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1473 |
else: |
12360
4ae3e5dffa60
context: fix filectx.undelete() (issue2388)
Patrick Mezard <pmezard@gmail.com>
parents:
12344
diff
changeset
|
1474 |
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
|
1475 |
t = fctx.data() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1476 |
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
|
1477 |
self._repo.dirstate.normal(f) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1478 |
finally: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1479 |
wlock.release() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1480 |
|
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1481 |
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
|
1482 |
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
|
1483 |
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
|
1484 |
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
|
1485 |
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
|
1486 |
raise |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1487 |
self._repo.ui.warn(_("%s does not exist!\n") % 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
|
1488 |
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
|
1489 |
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
|
1490 |
self._repo.ui.warn(_("copy failed: %s is not a file or a " |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1491 |
"symbolic link\n") % dest) |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1492 |
else: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1493 |
wlock = self._repo.wlock() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1494 |
try: |
23402
2963d5c9d90b
rename: properly report removed and added file as modified (issue4458)
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23401
diff
changeset
|
1495 |
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
|
1496 |
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
|
1497 |
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
|
1498 |
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
|
1499 |
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
|
1500 |
finally: |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1501 |
wlock.release() |
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11151
diff
changeset
|
1502 |
|
25122
755d23a49170
match: resolve filesets in subrepos for commands given the '-S' argument
Matt Harbison <matt_harbison@yahoo.com>
parents:
24922
diff
changeset
|
1503 |
def match(self, pats=[], 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
|
1504 |
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
|
1505 |
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
|
1506 |
|
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1507 |
# 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
|
1508 |
# to actual case in the filesystem. |
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1509 |
if not util.checkcase(r.root): |
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1510 |
return matchmod.icasefsmatcher(r.root, r.getcwd(), pats, include, |
25122
755d23a49170
match: resolve filesets in subrepos for commands given the '-S' argument
Matt Harbison <matt_harbison@yahoo.com>
parents:
24922
diff
changeset
|
1511 |
exclude, default, r.auditor, self, |
25465
f472228a9e5e
context: add an optional constructor parameter for a match.bad() override
Matt Harbison <matt_harbison@yahoo.com>
parents:
25435
diff
changeset
|
1512 |
listsubrepos=listsubrepos, |
f472228a9e5e
context: add an optional constructor parameter for a match.bad() override
Matt Harbison <matt_harbison@yahoo.com>
parents:
25435
diff
changeset
|
1513 |
badfn=badfn) |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1514 |
return matchmod.match(r.root, r.getcwd(), pats, |
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1515 |
include, exclude, default, |
25122
755d23a49170
match: resolve filesets in subrepos for commands given the '-S' argument
Matt Harbison <matt_harbison@yahoo.com>
parents:
24922
diff
changeset
|
1516 |
auditor=r.auditor, 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
|
1517 |
listsubrepos=listsubrepos, badfn=badfn) |
24790
baa11dde8c0e
match: add a subclass for dirstate normalizing of the matched patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
24776
diff
changeset
|
1518 |
|
21393
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1519 |
def _filtersuspectsymlink(self, files): |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1520 |
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
|
1521 |
return files |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1522 |
|
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1523 |
# 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
|
1524 |
# 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
|
1525 |
# 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
|
1526 |
# symlink |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1527 |
sane = [] |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1528 |
for f in files: |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1529 |
if self.flags(f) == 'l': |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1530 |
d = self[f].data() |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1531 |
if d == '' or len(d) >= 1024 or '\n' in d or util.binary(d): |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1532 |
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
|
1533 |
' "%s"\n' % f) |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1534 |
continue |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1535 |
sane.append(f) |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1536 |
return sane |
a45af4da0421
localrepo: move symlink logic to workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21238
diff
changeset
|
1537 |
|
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1538 |
def _checklookup(self, files): |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1539 |
# 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
|
1540 |
if not files: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1541 |
return [], [] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1542 |
|
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1543 |
modified = [] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1544 |
fixup = [] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1545 |
pctx = self._parents[0] |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1546 |
# 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
|
1547 |
for f in sorted(files): |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1548 |
if (f not in pctx or self.flags(f) != pctx.flags(f) |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1549 |
or pctx[f].cmp(self[f])): |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1550 |
modified.append(f) |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1551 |
else: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1552 |
fixup.append(f) |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1553 |
|
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1554 |
# update dirstate for files that are actually clean |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1555 |
if fixup: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1556 |
try: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1557 |
# 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
|
1558 |
# 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
|
1559 |
# 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
|
1560 |
# taking the lock |
48e32c2c499b
context: call normal on the right object
Siddharth Agarwal <sid0@fb.com>
parents:
21973
diff
changeset
|
1561 |
wlock = self._repo.wlock(False) |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1562 |
normal = self._repo.dirstate.normal |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1563 |
try: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1564 |
for f in fixup: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1565 |
normal(f) |
25753
fe03f522dda9
context: write dirstate out explicitly after marking files as clean
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25738
diff
changeset
|
1566 |
# write changes out explicitly, because nesting |
fe03f522dda9
context: write dirstate out explicitly after marking files as clean
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25738
diff
changeset
|
1567 |
# wlock at runtime may prevent 'wlock.release()' |
fe03f522dda9
context: write dirstate out explicitly after marking files as clean
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25738
diff
changeset
|
1568 |
# below from 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
|
1569 |
self._repo.dirstate.write(self._repo.currenttransaction()) |
21395
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1570 |
finally: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1571 |
wlock.release() |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1572 |
except error.LockError: |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1573 |
pass |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1574 |
return modified, fixup |
f251b92d9ed9
localrepo: factor out parentworking logic for comparing files
Sean Farley <sean.michael.farley@gmail.com>
parents:
21393
diff
changeset
|
1575 |
|
21468
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1576 |
def _manifestmatches(self, match, s): |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1577 |
"""Slow path for workingctx |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1578 |
|
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1579 |
The fast path is when we compare the working directory to its parent |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1580 |
which means this function is comparing with a non-parent; therefore we |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1581 |
need to build a manifest and return what matches. |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1582 |
""" |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1583 |
mf = self._repo['.']._manifestmatches(match, s) |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
1584 |
for f in s.modified + s.added: |
23593
b1179dabc6de
context: stop setting None for modified or added nodes
Augie Fackler <augie@google.com>
parents:
23402
diff
changeset
|
1585 |
mf[f] = _newnode |
22942
03602f76deee
manifest: rename ambiguously-named set to setflag
Augie Fackler <raf@durin42.com>
parents:
22932
diff
changeset
|
1586 |
mf.setflag(f, self.flags(f)) |
23304
dd3f857598a0
context.status: pass status tuple into _buildstatus
Martin von Zweigbergk <martinvonz@google.com>
parents:
23303
diff
changeset
|
1587 |
for f in s.removed: |
21468
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1588 |
if f in mf: |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1589 |
del mf[f] |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1590 |
return mf |
870ddcf24291
localrepo: factor out _manifestmatch logic for workingctx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21466
diff
changeset
|
1591 |
|
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1592 |
def _dirstatestatus(self, match=None, ignored=False, clean=False, |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1593 |
unknown=False): |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1594 |
'''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
|
1595 |
listignored, listclean, listunknown = ignored, clean, unknown |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1596 |
match = match or matchmod.always(self._repo.root, self._repo.getcwd()) |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1597 |
subrepos = [] |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1598 |
if '.hgsub' in self: |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1599 |
subrepos = sorted(self.substate) |
22911
509e2cbee679
dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22671
diff
changeset
|
1600 |
cmp, s = self._repo.dirstate.status(match, subrepos, listignored, |
509e2cbee679
dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22671
diff
changeset
|
1601 |
listclean, listunknown) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1602 |
|
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1603 |
# check for any possibly clean files |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1604 |
if cmp: |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1605 |
modified2, fixup = self._checklookup(cmp) |
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1606 |
s.modified.extend(modified2) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1607 |
|
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1608 |
# update dirstate for files that are actually clean |
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1609 |
if fixup and listclean: |
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1610 |
s.clean.extend(fixup) |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1611 |
|
23776
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1612 |
if match.always(): |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1613 |
# cache for performance |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1614 |
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
|
1615 |
# "_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
|
1616 |
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
|
1617 |
s.deleted, [], [], []) |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1618 |
else: |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1619 |
self._status = s |
70bf92b87410
status: cache dirstate status in _dirstatestatus()
Martin von Zweigbergk <martinvonz@google.com>
parents:
23770
diff
changeset
|
1620 |
|
23303
3f269bd4826c
context.status: avoid de- and reconstructing status tuple
Martin von Zweigbergk <martinvonz@google.com>
parents:
23302
diff
changeset
|
1621 |
return s |
21397
38743c59f3f8
context: add private _dirstatestatus method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21396
diff
changeset
|
1622 |
|
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1623 |
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
|
1624 |
listunknown): |
21480
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1625 |
"""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
|
1626 |
|
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1627 |
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
|
1628 |
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
|
1629 |
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
|
1630 |
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
|
1631 |
""" |
23239
9fbb50444d55
context.status: call _dirstatestatus() from within _buildstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23238
diff
changeset
|
1632 |
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
|
1633 |
# 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
|
1634 |
# 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
|
1635 |
# 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
|
1636 |
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
|
1637 |
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
|
1638 |
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
|
1639 |
listignored, listclean, |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1640 |
listunknown) |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1641 |
return s |
d19f491e5d5b
workingctx: use inheritance for _buildstatus while keeping the fastpath
Sean Farley <sean.michael.farley@gmail.com>
parents:
21477
diff
changeset
|
1642 |
|
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
1643 |
def _matchstatus(self, other, match): |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1644 |
"""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
|
1645 |
|
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1646 |
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
|
1647 |
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
|
1648 |
comparing against the parent changeset. |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1649 |
|
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1650 |
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
|
1651 |
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
|
1652 |
""" |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1653 |
superself = super(workingctx, self) |
23237
98f41a2f8fba
context.status: remove unused arguments from _matchstatus()
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
23236
diff
changeset
|
1654 |
match = superself._matchstatus(other, match) |
21482
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1655 |
if other != self._repo['.']: |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1656 |
def bad(f, msg): |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1657 |
# '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
|
1658 |
# 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
|
1659 |
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
|
1660 |
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
|
1661 |
(self._repo.dirstate.pathto(f), msg)) |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1662 |
match.bad = bad |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1663 |
return match |
869a28d016e9
workingctx: override _matchstatus for parentworking case
Sean Farley <sean.michael.farley@gmail.com>
parents:
21481
diff
changeset
|
1664 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1665 |
class committablefilectx(basefilectx): |
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1666 |
"""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
|
1667 |
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
|
1668 |
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
|
1669 |
self._repo = repo |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1670 |
self._path = path |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1671 |
self._changeid = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1672 |
self._filerev = self._filenode = None |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1673 |
|
19149
921b64e1f7b9
filecontext: use 'is not None' to check for filelog existence
Durham Goode <durham@fb.com>
parents:
19061
diff
changeset
|
1674 |
if filelog is not None: |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1675 |
self._filelog = filelog |
19702
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
1676 |
if ctx: |
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
1677 |
self._changectx = ctx |
d25fdd4c2fd1
commitablefilectx: move __init__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19701
diff
changeset
|
1678 |
|
19703
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
1679 |
def __nonzero__(self): |
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
1680 |
return True |
d2936bec530b
commitablefilectx: move __nonzero__ from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19702
diff
changeset
|
1681 |
|
24420
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
1682 |
def linkrev(self): |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
1683 |
# 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
|
1684 |
return self.rev() |
065b886f61c6
committablefilectx: override linkrev() to point to the associated changectx
Yuya Nishihara <yuya@tcha.org>
parents:
24415
diff
changeset
|
1685 |
|
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1686 |
def parents(self): |
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1687 |
'''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
|
1688 |
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
|
1689 |
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
|
1690 |
|
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1691 |
path = self._path |
3217
6d98149d70fe
contexts: add working dir and working file contexts
Matt Mackall <mpm@selenic.com>
parents:
3216
diff
changeset
|
1692 |
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
|
1693 |
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
|
1694 |
renamed = self.renamed() |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1695 |
|
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1696 |
if renamed: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1697 |
pl = [renamed + (None,)] |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1698 |
else: |
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1699 |
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
|
1700 |
|
4ddffb793d18
workingfilectx: always use the same filelog, even for renames
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8527
diff
changeset
|
1701 |
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
|
1702 |
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
|
1703 |
|
24817
0bb98eee531d
committablefilectx: propagate ancestry info to parent to fix annotation
Yuya Nishihara <yuya@tcha.org>
parents:
24816
diff
changeset
|
1704 |
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
|
1705 |
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
|
1706 |
|
19705
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
1707 |
def children(self): |
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
1708 |
return [] |
79792c8ea6da
commitablefilectx: move children from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19704
diff
changeset
|
1709 |
|
19733
51988f008df3
context: use correct spelling of committable
Sean Farley <sean.michael.farley@gmail.com>
parents:
19705
diff
changeset
|
1710 |
class workingfilectx(committablefilectx): |
19704
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1711 |
"""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
|
1712 |
file in the working directory convenient.""" |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1713 |
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
|
1714 |
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
|
1715 |
|
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1716 |
@propertycache |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1717 |
def _changectx(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1718 |
return workingctx(self._repo) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1719 |
|
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1720 |
def data(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1721 |
return self._repo.wread(self._path) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1722 |
def renamed(self): |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1723 |
rp = self._repo.dirstate.copied(self._path) |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1724 |
if not rp: |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1725 |
return None |
bad0bd99ac96
commitablefilectx: move parents from workingfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
19703
diff
changeset
|
1726 |
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
|
1727 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1728 |
def size(self): |
19901
4d3ce1646dfc
context: use "vfs.lstat()" instead of "os.lstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19900
diff
changeset
|
1729 |
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
|
1730 |
def date(self): |
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1731 |
t, tz = self._changectx.date() |
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1732 |
try: |
27016 | 1733 |
return (self._repo.wvfs.lstat(self._path).st_mtime, tz) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25600
diff
changeset
|
1734 |
except OSError as err: |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1735 |
if err.errno != errno.ENOENT: |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1736 |
raise |
3962
2b8825c94c5a
add date attribute to workingfilectx
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3961
diff
changeset
|
1737 |
return (t, tz) |
3310
0e370798eebf
context: add cmp for filectxs
Matt Mackall <mpm@selenic.com>
parents:
3302
diff
changeset
|
1738 |
|
11702
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
1739 |
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
|
1740 |
"""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
|
1741 |
|
11702
eb07fbc21e9c
filectx: use cmp(self, fctx) instead of cmp(self, text)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11605
diff
changeset
|
1742 |
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
|
1743 |
""" |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17424
diff
changeset
|
1744 |
# 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
|
1745 |
# 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
|
1746 |
return fctx.cmp(self) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1747 |
|
22073
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1748 |
def remove(self, ignoremissing=False): |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1749 |
"""wraps unlink for a repo's working directory""" |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1750 |
util.unlinkpath(self._repo.wjoin(self._path), ignoremissing) |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1751 |
|
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1752 |
def write(self, data, flags): |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1753 |
"""wraps repo.wwrite""" |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1754 |
self._repo.wwrite(self._path, data, flags) |
0c48bc3d0eb2
workingfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22072
diff
changeset
|
1755 |
|
23710
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
1756 |
class workingcommitctx(workingctx): |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
1757 |
"""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
|
1758 |
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
|
1759 |
|
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
1760 |
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
|
1761 |
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
|
1762 |
""" |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
1763 |
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
|
1764 |
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
|
1765 |
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
|
1766 |
changes) |
745e3b485632
context: add workingcommitctx for exact context to be committed
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23709
diff
changeset
|
1767 |
|
23712
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1768 |
def _dirstatestatus(self, match=None, ignored=False, clean=False, |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1769 |
unknown=False): |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1770 |
"""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
|
1771 |
|
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1772 |
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
|
1773 |
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
|
1774 |
""" |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1775 |
match = match or matchmod.always(self._repo.root, self._repo.getcwd()) |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1776 |
if clean: |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1777 |
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
|
1778 |
else: |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1779 |
clean = [] |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1780 |
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
|
1781 |
[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
|
1782 |
[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
|
1783 |
[], [], [], clean) |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1784 |
|
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1785 |
@propertycache |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1786 |
def _changedset(self): |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1787 |
"""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
|
1788 |
""" |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1789 |
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
|
1790 |
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
|
1791 |
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
|
1792 |
return changed |
bfce25d25c96
context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23711
diff
changeset
|
1793 |
|
21665
d2743be1bb06
memctx: inherit from committablectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21664
diff
changeset
|
1794 |
class memctx(committablectx): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1795 |
"""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
|
1796 |
|
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1797 |
Revision information is supplied at initialization time while |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1798 |
related files data and is made available through a callback |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1799 |
mechanism. 'repo' is the current localrepo, 'parents' is a |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1800 |
sequence of two parent revisions identifiers (pass None for every |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1801 |
missing parent), 'text' is the commit message and 'files' lists |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1802 |
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
|
1803 |
repository root). |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1804 |
|
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1805 |
filectxfn(repo, memctx, path) is a callable receiving the |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1806 |
repository, the current memctx object and the normalized path of |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1807 |
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
|
1808 |
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
|
1809 |
undefined. If the file is available in the revision being |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1810 |
committed (updated or added), filectxfn returns a memfilectx |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1811 |
object. If the file was removed, filectxfn raises an |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1812 |
IOError. Moved files are represented by marking the source file |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1813 |
removed and the new file added with copy information (see |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1814 |
memfilectx). |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1815 |
|
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1816 |
user receives the committer name and defaults to current |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1817 |
repository username, date is the commit date in any format |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1818 |
supported by util.parsedate() and defaults to current date, extra |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1819 |
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
|
1820 |
""" |
22313
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
1821 |
|
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
1822 |
# 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
|
1823 |
# 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
|
1824 |
# 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
|
1825 |
_returnnoneformissingfiles = True |
d226fe36e362
memctx: allow extensions to determine what filectxfn should do
Siddharth Agarwal <sid0@fb.com>
parents:
22296
diff
changeset
|
1826 |
|
6721
521c6c6f3b9b
kill some trailing spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6718
diff
changeset
|
1827 |
def __init__(self, repo, parents, text, files, filectxfn, user=None, |
21238
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
1828 |
date=None, extra=None, editor=False): |
21666
31bdc51b0f1e
memctx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21665
diff
changeset
|
1829 |
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
|
1830 |
self._rev = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1831 |
self._node = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1832 |
parents = [(p or nullid) for p in parents] |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1833 |
p1, p2 = parents |
6747
f6c00b17387c
use repo[changeid] to get a changectx
Matt Mackall <mpm@selenic.com>
parents:
6744
diff
changeset
|
1834 |
self._parents = [changectx(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
|
1835 |
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
|
1836 |
self._files = files |
21938
c8411fb5dfef
memctx: substate needs to be {} instead of None
Sean Farley <sean.michael.farley@gmail.com>
parents:
21895
diff
changeset
|
1837 |
self.substate = {} |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1838 |
|
22072
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1839 |
# if store is not callable, wrap it in a function |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1840 |
if not callable(filectxfn): |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1841 |
def getfilectx(repo, memctx, path): |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1842 |
fctx = filectxfn[path] |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1843 |
# this is weird but apparently we only keep track of one parent |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1844 |
# (why not only store that instead of a tuple?) |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1845 |
copied = fctx.renamed() |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1846 |
if copied: |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1847 |
copied = copied[0] |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1848 |
return memfilectx(repo, path, fctx.data(), |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1849 |
islink=fctx.islink(), isexec=fctx.isexec(), |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1850 |
copied=copied, memctx=memctx) |
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1851 |
self._filectxfn = getfilectx |
23587
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1852 |
else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1853 |
# "util.cachefunc" reduces invocation of possibly expensive |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1854 |
# "filectxfn" for performance (e.g. converting from another VCS) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1855 |
self._filectxfn = util.cachefunc(filectxfn) |
22072
443ef664fb55
memctx: create a filectxfn if it is not callable
Sean Farley <sean.michael.farley@gmail.com>
parents:
22055
diff
changeset
|
1856 |
|
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1857 |
if extra: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1858 |
self._extra = extra.copy() |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1859 |
else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1860 |
self._extra = {} |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24300
diff
changeset
|
1861 |
|
14528
0bd69e37fd20
memctx: simplify constructor
Patrick Mezard <pmezard@gmail.com>
parents:
14518
diff
changeset
|
1862 |
if self._extra.get('branch', '') == '': |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1863 |
self._extra['branch'] = 'default' |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1864 |
|
21238
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
1865 |
if editor: |
25d6fdc0294a
context: move editor invocation from "makememctx()" to "memctx.__init__()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21203
diff
changeset
|
1866 |
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
|
1867 |
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
|
1868 |
|
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1869 |
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
|
1870 |
"""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
|
1871 |
|
650b5b6e75ed
convert: use None value for missing files instead of overloading IOError
Mads Kiilerich <madski@unity3d.com>
parents:
22207
diff
changeset
|
1872 |
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
|
1873 |
return self._filectxfn(self._repo, self, path) |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1874 |
|
11151
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
1875 |
def commit(self): |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
1876 |
"""commit context to the repo""" |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
1877 |
return self._repo.commitctx(self) |
c5c190822501
slightly improve memctx api
Alexander Solovyov <piranha@piranha.org.ua>
parents:
11144
diff
changeset
|
1878 |
|
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1879 |
@propertycache |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1880 |
def _manifest(self): |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1881 |
"""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
|
1882 |
|
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1883 |
# 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
|
1884 |
pctx = self._parents[0] |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1885 |
man = pctx.manifest().copy() |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1886 |
|
23603
d74eb8d477d5
memctx: calculate manifest more efficiently
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23602
diff
changeset
|
1887 |
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
|
1888 |
p1node = nullid |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1889 |
p2node = nullid |
22075
2f0358275501
memctx: add note about p2
Sean Farley <sean.michael.farley@gmail.com>
parents:
22074
diff
changeset
|
1890 |
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
|
1891 |
if len(p) > 0: |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1892 |
p1node = p[0].node() |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1893 |
if len(p) > 1: |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1894 |
p2node = p[1].node() |
23603
d74eb8d477d5
memctx: calculate manifest more efficiently
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23602
diff
changeset
|
1895 |
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
|
1896 |
|
23588
87a76cff7147
memctx: calculate manifest including newly added files correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23587
diff
changeset
|
1897 |
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
|
1898 |
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
|
1899 |
|
23589
200215cdf7aa
memctx: calculate manifest correctly with newly-removed files (issue4470)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23588
diff
changeset
|
1900 |
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
|
1901 |
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
|
1902 |
del man[f] |
21835
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1903 |
|
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1904 |
return man |
b342c3e2518a
memctx: add _manifest implementation that computes the filenode
Sean Farley <sean.michael.farley@gmail.com>
parents:
21834
diff
changeset
|
1905 |
|
23587
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1906 |
@propertycache |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1907 |
def _status(self): |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1908 |
"""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
|
1909 |
""" |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1910 |
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
|
1911 |
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
|
1912 |
# "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
|
1913 |
# 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
|
1914 |
# 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
|
1915 |
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
|
1916 |
man2 = p2.manifest() |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1917 |
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
|
1918 |
else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1919 |
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
|
1920 |
|
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1921 |
modified, added, removed = [], [], [] |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1922 |
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
|
1923 |
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
|
1924 |
added.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1925 |
elif self[f]: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1926 |
modified.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1927 |
else: |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1928 |
removed.append(f) |
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1929 |
|
8063901e56cd
memctx: calculate exact status being committed from specified files
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23584
diff
changeset
|
1930 |
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
|
1931 |
|
21688
cc677803bad4
memfilectx: inherit from committablefilectx
Sean Farley <sean.michael.farley@gmail.com>
parents:
21687
diff
changeset
|
1932 |
class memfilectx(committablefilectx): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1933 |
"""memfilectx represents an in-memory file to commit. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1934 |
|
23139
e53f6b72a0e4
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23110
diff
changeset
|
1935 |
See memctx and committablefilectx for more details. |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1936 |
""" |
21689
503bb3af70fe
memfilectx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21688
diff
changeset
|
1937 |
def __init__(self, repo, path, data, islink=False, |
503bb3af70fe
memfilectx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21688
diff
changeset
|
1938 |
isexec=False, copied=None, memctx=None): |
7077
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1939 |
""" |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1940 |
path is the normalized file path relative to repository root. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1941 |
data is the file content as a string. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1942 |
islink is True if the file is a symbolic link. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1943 |
isexec is True if the file is executable. |
ccbd39cad3c3
context: improve memctx documentation
Patrick Mezard <pmezard@gmail.com>
parents:
7008
diff
changeset
|
1944 |
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
|
1945 |
revision being committed, or None.""" |
21689
503bb3af70fe
memfilectx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents:
21688
diff
changeset
|
1946 |
super(memfilectx, self).__init__(repo, path, None, memctx) |
6715
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1947 |
self._data = data |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1948 |
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
|
1949 |
self._copied = None |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1950 |
if copied: |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1951 |
self._copied = (copied, nullid) |
a3c41abfa828
context: add memctx for memory commits
Patrick Mezard <pmezard@gmail.com>
parents:
6709
diff
changeset
|
1952 |
|
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1953 |
def data(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1954 |
return self._data |
21710
14514dd542aa
memfilectx: add a size method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21692
diff
changeset
|
1955 |
def size(self): |
14514dd542aa
memfilectx: add a size method
Sean Farley <sean.michael.farley@gmail.com>
parents:
21692
diff
changeset
|
1956 |
return len(self.data()) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1957 |
def flags(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1958 |
return self._flags |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1959 |
def renamed(self): |
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10264
diff
changeset
|
1960 |
return self._copied |
22074
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1961 |
|
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1962 |
def remove(self, ignoremissing=False): |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1963 |
"""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
|
1964 |
# 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
|
1965 |
del self._changectx[self._path] |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1966 |
|
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1967 |
def write(self, data, flags): |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1968 |
"""wraps repo.wwrite""" |
fbe967b027bd
memfilectx: add remove and write methods
Sean Farley <sean.michael.farley@gmail.com>
parents:
22073
diff
changeset
|
1969 |
self._data = data |