Show More
@@ -1,285 +1,290 b'' | |||
|
1 | 1 | # branchmap.py - logic to computes, maintain and stores branchmap for local repo |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from node import bin, hex, nullid, nullrev |
|
9 | 9 | import encoding |
|
10 | 10 | import util |
|
11 | 11 | |
|
12 | 12 | def _filename(repo): |
|
13 | 13 | """name of a branchcache file for a given repo or repoview""" |
|
14 | 14 | filename = "cache/branch2" |
|
15 | 15 | if repo.filtername: |
|
16 | 16 | filename = '%s-%s' % (filename, repo.filtername) |
|
17 | 17 | return filename |
|
18 | 18 | |
|
19 | 19 | def read(repo): |
|
20 | 20 | try: |
|
21 | 21 | f = repo.opener(_filename(repo)) |
|
22 | 22 | lines = f.read().split('\n') |
|
23 | 23 | f.close() |
|
24 | 24 | except (IOError, OSError): |
|
25 | 25 | return None |
|
26 | 26 | |
|
27 | 27 | try: |
|
28 | 28 | cachekey = lines.pop(0).split(" ", 2) |
|
29 | 29 | last, lrev = cachekey[:2] |
|
30 | 30 | last, lrev = bin(last), int(lrev) |
|
31 | 31 | filteredhash = None |
|
32 | 32 | if len(cachekey) > 2: |
|
33 | 33 | filteredhash = bin(cachekey[2]) |
|
34 | 34 | partial = branchcache(tipnode=last, tiprev=lrev, |
|
35 | 35 | filteredhash=filteredhash) |
|
36 | 36 | if not partial.validfor(repo): |
|
37 | 37 | # invalidate the cache |
|
38 | 38 | raise ValueError('tip differs') |
|
39 | 39 | for l in lines: |
|
40 | 40 | if not l: |
|
41 | 41 | continue |
|
42 | 42 | node, state, label = l.split(" ", 2) |
|
43 | 43 | if state not in 'oc': |
|
44 | 44 | raise ValueError('invalid branch state') |
|
45 | 45 | label = encoding.tolocal(label.strip()) |
|
46 | 46 | if not node in repo: |
|
47 | 47 | raise ValueError('node %s does not exist' % node) |
|
48 | 48 | node = bin(node) |
|
49 | 49 | partial.setdefault(label, []).append(node) |
|
50 | 50 | if state == 'c': |
|
51 | 51 | partial._closednodes.add(node) |
|
52 | 52 | except KeyboardInterrupt: |
|
53 | 53 | raise |
|
54 | 54 | except Exception, inst: |
|
55 | 55 | if repo.ui.debugflag: |
|
56 | 56 | msg = 'invalid branchheads cache' |
|
57 | 57 | if repo.filtername is not None: |
|
58 | 58 | msg += ' (%s)' % repo.filtername |
|
59 | 59 | msg += ': %s\n' |
|
60 | 60 | repo.ui.warn(msg % inst) |
|
61 | 61 | partial = None |
|
62 | 62 | return partial |
|
63 | 63 | |
|
64 | 64 | |
|
65 | 65 | |
|
66 | 66 | ### Nearest subset relation |
|
67 | 67 | # Nearest subset of filter X is a filter Y so that: |
|
68 | 68 | # * Y is included in X, |
|
69 | 69 | # * X - Y is as small as possible. |
|
70 | 70 | # This create and ordering used for branchmap purpose. |
|
71 | 71 | # the ordering may be partial |
|
72 | 72 | subsettable = {None: 'visible', |
|
73 | 73 | 'visible': 'served', |
|
74 | 74 | 'served': 'immutable', |
|
75 | 75 | 'immutable': 'base'} |
|
76 | 76 | |
|
77 | 77 | def updatecache(repo): |
|
78 | 78 | cl = repo.changelog |
|
79 | 79 | filtername = repo.filtername |
|
80 | 80 | partial = repo._branchcaches.get(filtername) |
|
81 | 81 | |
|
82 | 82 | revs = [] |
|
83 | 83 | if partial is None or not partial.validfor(repo): |
|
84 | 84 | partial = read(repo) |
|
85 | 85 | if partial is None: |
|
86 | 86 | subsetname = subsettable.get(filtername) |
|
87 | 87 | if subsetname is None: |
|
88 | 88 | partial = branchcache() |
|
89 | 89 | else: |
|
90 | 90 | subset = repo.filtered(subsetname) |
|
91 | 91 | partial = subset.branchmap().copy() |
|
92 | 92 | extrarevs = subset.changelog.filteredrevs - cl.filteredrevs |
|
93 | 93 | revs.extend(r for r in extrarevs if r <= partial.tiprev) |
|
94 | 94 | revs.extend(cl.revs(start=partial.tiprev + 1)) |
|
95 | 95 | if revs: |
|
96 | 96 | partial.update(repo, revs) |
|
97 | 97 | partial.write(repo) |
|
98 | 98 | assert partial.validfor(repo), filtername |
|
99 | 99 | repo._branchcaches[repo.filtername] = partial |
|
100 | 100 | |
|
101 | 101 | class branchcache(dict): |
|
102 | 102 | """A dict like object that hold branches heads cache. |
|
103 | 103 | |
|
104 | 104 | This cache is used to avoid costly computations to determine all the |
|
105 | 105 | branch heads of a repo. |
|
106 | 106 | |
|
107 | 107 | The cache is serialized on disk in the following format: |
|
108 | 108 | |
|
109 | 109 | <tip hex node> <tip rev number> [optional filtered repo hex hash] |
|
110 | 110 | <branch head hex node> <open/closed state> <branch name> |
|
111 | 111 | <branch head hex node> <open/closed state> <branch name> |
|
112 | 112 | ... |
|
113 | 113 | |
|
114 | 114 | The first line is used to check if the cache is still valid. If the |
|
115 | 115 | branch cache is for a filtered repo view, an optional third hash is |
|
116 | 116 | included that hashes the hashes of all filtered revisions. |
|
117 | 117 | |
|
118 | 118 | The open/closed state is represented by a single letter 'o' or 'c'. |
|
119 | 119 | This field can be used to avoid changelog reads when determining if a |
|
120 | 120 | branch head closes a branch or not. |
|
121 | 121 | """ |
|
122 | 122 | |
|
123 | 123 | def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, |
|
124 | 124 | filteredhash=None, closednodes=None): |
|
125 | 125 | super(branchcache, self).__init__(entries) |
|
126 | 126 | self.tipnode = tipnode |
|
127 | 127 | self.tiprev = tiprev |
|
128 | 128 | self.filteredhash = filteredhash |
|
129 | 129 | # closednodes is a set of nodes that close their branch. If the branch |
|
130 | 130 | # cache has been updated, it may contain nodes that are no longer |
|
131 | 131 | # heads. |
|
132 | 132 | if closednodes is None: |
|
133 | 133 | self._closednodes = set() |
|
134 | 134 | else: |
|
135 | 135 | self._closednodes = closednodes |
|
136 | 136 | |
|
137 | 137 | def _hashfiltered(self, repo): |
|
138 | 138 | """build hash of revision filtered in the current cache |
|
139 | 139 | |
|
140 | 140 | Tracking tipnode and tiprev is not enough to ensure validity of the |
|
141 | 141 | cache as they do not help to distinct cache that ignored various |
|
142 | 142 | revision bellow tiprev. |
|
143 | 143 | |
|
144 | 144 | To detect such difference, we build a cache of all ignored revisions. |
|
145 | 145 | """ |
|
146 | 146 | cl = repo.changelog |
|
147 | 147 | if not cl.filteredrevs: |
|
148 | 148 | return None |
|
149 | 149 | key = None |
|
150 | 150 | revs = sorted(r for r in cl.filteredrevs if r <= self.tiprev) |
|
151 | 151 | if revs: |
|
152 | 152 | s = util.sha1() |
|
153 | 153 | for rev in revs: |
|
154 | 154 | s.update('%s;' % rev) |
|
155 | 155 | key = s.digest() |
|
156 | 156 | return key |
|
157 | 157 | |
|
158 | 158 | def validfor(self, repo): |
|
159 | 159 | """Is the cache content valid regarding a repo |
|
160 | 160 | |
|
161 | 161 | - False when cached tipnode is unknown or if we detect a strip. |
|
162 | 162 | - True when cache is up to date or a subset of current repo.""" |
|
163 | 163 | try: |
|
164 | 164 | return ((self.tipnode == repo.changelog.node(self.tiprev)) |
|
165 | 165 | and (self.filteredhash == self._hashfiltered(repo))) |
|
166 | 166 | except IndexError: |
|
167 | 167 | return False |
|
168 | 168 | |
|
169 | 169 | def _branchtip(self, heads): |
|
170 | '''Return tuple with last open head in heads and false, | |
|
171 | otherwise return last closed head and true.''' | |
|
170 | 172 | tip = heads[-1] |
|
171 | 173 | closed = True |
|
172 | 174 | for h in reversed(heads): |
|
173 | 175 | if h not in self._closednodes: |
|
174 | 176 | tip = h |
|
175 | 177 | closed = False |
|
176 | 178 | break |
|
177 | 179 | return tip, closed |
|
178 | 180 | |
|
179 | 181 | def branchtip(self, branch): |
|
182 | '''Return the tipmost open head on branch head, otherwise return the | |
|
183 | tipmost closed head on branch. | |
|
184 | Raise KeyError for unknown branch.''' | |
|
180 | 185 | return self._branchtip(self[branch])[0] |
|
181 | 186 | |
|
182 | 187 | def branchheads(self, branch, closed=False): |
|
183 | 188 | heads = self[branch] |
|
184 | 189 | if not closed: |
|
185 | 190 | heads = [h for h in heads if h not in self._closednodes] |
|
186 | 191 | return heads |
|
187 | 192 | |
|
188 | 193 | def iterbranches(self): |
|
189 | 194 | for bn, heads in self.iteritems(): |
|
190 | 195 | yield (bn, heads) + self._branchtip(heads) |
|
191 | 196 | |
|
192 | 197 | def copy(self): |
|
193 | 198 | """return an deep copy of the branchcache object""" |
|
194 | 199 | return branchcache(self, self.tipnode, self.tiprev, self.filteredhash, |
|
195 | 200 | self._closednodes) |
|
196 | 201 | |
|
197 | 202 | def write(self, repo): |
|
198 | 203 | try: |
|
199 | 204 | f = repo.opener(_filename(repo), "w", atomictemp=True) |
|
200 | 205 | cachekey = [hex(self.tipnode), str(self.tiprev)] |
|
201 | 206 | if self.filteredhash is not None: |
|
202 | 207 | cachekey.append(hex(self.filteredhash)) |
|
203 | 208 | f.write(" ".join(cachekey) + '\n') |
|
204 | 209 | for label, nodes in sorted(self.iteritems()): |
|
205 | 210 | for node in nodes: |
|
206 | 211 | if node in self._closednodes: |
|
207 | 212 | state = 'c' |
|
208 | 213 | else: |
|
209 | 214 | state = 'o' |
|
210 | 215 | f.write("%s %s %s\n" % (hex(node), state, |
|
211 | 216 | encoding.fromlocal(label))) |
|
212 | 217 | f.close() |
|
213 | 218 | except (IOError, OSError, util.Abort): |
|
214 | 219 | # Abort may be raise by read only opener |
|
215 | 220 | pass |
|
216 | 221 | |
|
217 | 222 | def update(self, repo, revgen): |
|
218 | 223 | """Given a branchhead cache, self, that may have extra nodes or be |
|
219 | 224 | missing heads, and a generator of nodes that are at least a superset of |
|
220 | 225 | heads missing, this function updates self to be correct. |
|
221 | 226 | """ |
|
222 | 227 | cl = repo.changelog |
|
223 | 228 | # collect new branch entries |
|
224 | 229 | newbranches = {} |
|
225 | 230 | getbranchinfo = cl.branchinfo |
|
226 | 231 | for r in revgen: |
|
227 | 232 | branch, closesbranch = getbranchinfo(r) |
|
228 | 233 | node = cl.node(r) |
|
229 | 234 | newbranches.setdefault(branch, []).append(node) |
|
230 | 235 | if closesbranch: |
|
231 | 236 | self._closednodes.add(node) |
|
232 | 237 | # if older branchheads are reachable from new ones, they aren't |
|
233 | 238 | # really branchheads. Note checking parents is insufficient: |
|
234 | 239 | # 1 (branch a) -> 2 (branch b) -> 3 (branch a) |
|
235 | 240 | for branch, newnodes in newbranches.iteritems(): |
|
236 | 241 | bheads = self.setdefault(branch, []) |
|
237 | 242 | # Remove candidate heads that no longer are in the repo (e.g., as |
|
238 | 243 | # the result of a strip that just happened). Avoid using 'node in |
|
239 | 244 | # self' here because that dives down into branchcache code somewhat |
|
240 | 245 | # recursively. |
|
241 | 246 | bheadrevs = [cl.rev(node) for node in bheads |
|
242 | 247 | if cl.hasnode(node)] |
|
243 | 248 | newheadrevs = [cl.rev(node) for node in newnodes |
|
244 | 249 | if cl.hasnode(node)] |
|
245 | 250 | ctxisnew = bheadrevs and min(newheadrevs) > max(bheadrevs) |
|
246 | 251 | # Remove duplicates - nodes that are in newheadrevs and are already |
|
247 | 252 | # in bheadrevs. This can happen if you strip a node whose parent |
|
248 | 253 | # was already a head (because they're on different branches). |
|
249 | 254 | bheadrevs = sorted(set(bheadrevs).union(newheadrevs)) |
|
250 | 255 | |
|
251 | 256 | # Starting from tip means fewer passes over reachable. If we know |
|
252 | 257 | # the new candidates are not ancestors of existing heads, we don't |
|
253 | 258 | # have to examine ancestors of existing heads |
|
254 | 259 | if ctxisnew: |
|
255 | 260 | iterrevs = sorted(newheadrevs) |
|
256 | 261 | else: |
|
257 | 262 | iterrevs = list(bheadrevs) |
|
258 | 263 | |
|
259 | 264 | # This loop prunes out two kinds of heads - heads that are |
|
260 | 265 | # superseded by a head in newheadrevs, and newheadrevs that are not |
|
261 | 266 | # heads because an existing head is their descendant. |
|
262 | 267 | while iterrevs: |
|
263 | 268 | latest = iterrevs.pop() |
|
264 | 269 | if latest not in bheadrevs: |
|
265 | 270 | continue |
|
266 | 271 | ancestors = set(cl.ancestors([latest], |
|
267 | 272 | bheadrevs[0])) |
|
268 | 273 | if ancestors: |
|
269 | 274 | bheadrevs = [b for b in bheadrevs if b not in ancestors] |
|
270 | 275 | self[branch] = [cl.node(rev) for rev in bheadrevs] |
|
271 | 276 | tiprev = max(bheadrevs) |
|
272 | 277 | if tiprev > self.tiprev: |
|
273 | 278 | self.tipnode = cl.node(tiprev) |
|
274 | 279 | self.tiprev = tiprev |
|
275 | 280 | |
|
276 | 281 | if not self.validfor(repo): |
|
277 | 282 | # cache key are not valid anymore |
|
278 | 283 | self.tipnode = nullid |
|
279 | 284 | self.tiprev = nullrev |
|
280 | 285 | for heads in self.values(): |
|
281 | 286 | tiprev = max(cl.rev(node) for node in heads) |
|
282 | 287 | if tiprev > self.tiprev: |
|
283 | 288 | self.tipnode = cl.node(tiprev) |
|
284 | 289 | self.tiprev = tiprev |
|
285 | 290 | self.filteredhash = self._hashfiltered(repo) |
@@ -1,29 +1,29 b'' | |||
|
1 | 1 | Mercurial supports several ways to specify individual revisions. |
|
2 | 2 | |
|
3 | 3 | A plain integer is treated as a revision number. Negative integers are |
|
4 | 4 | treated as sequential offsets from the tip, with -1 denoting the tip, |
|
5 | 5 | -2 denoting the revision prior to the tip, and so forth. |
|
6 | 6 | |
|
7 | 7 | A 40-digit hexadecimal string is treated as a unique revision |
|
8 | 8 | identifier. |
|
9 | 9 | |
|
10 | 10 | A hexadecimal string less than 40 characters long is treated as a |
|
11 | 11 | unique revision identifier and is referred to as a short-form |
|
12 | 12 | identifier. A short-form identifier is only valid if it is the prefix |
|
13 | 13 | of exactly one full-length identifier. |
|
14 | 14 | |
|
15 | 15 | Any other string is treated as a bookmark, tag, or branch name. A |
|
16 | 16 | bookmark is a movable pointer to a revision. A tag is a permanent name |
|
17 |
associated with a revision. A branch name denotes the tipmost |
|
|
18 | of that branch. Bookmark, tag, and branch names must not contain the ":" | |
|
19 | character. | |
|
17 | associated with a revision. A branch name denotes the tipmost open branch head | |
|
18 | of that branch - or if they are all closed, the tipmost closed head of the | |
|
19 | branch. Bookmark, tag, and branch names must not contain the ":" character. | |
|
20 | 20 | |
|
21 | 21 | The reserved name "tip" always identifies the most recent revision. |
|
22 | 22 | |
|
23 | 23 | The reserved name "null" indicates the null revision. This is the |
|
24 | 24 | revision of an empty repository, and the parent of revision 0. |
|
25 | 25 | |
|
26 | 26 | The reserved name "." indicates the working directory parent. If no |
|
27 | 27 | working directory is checked out, it is equivalent to null. If an |
|
28 | 28 | uncommitted merge is in progress, "." is the revision of the first |
|
29 | 29 | parent. |
@@ -1,2447 +1,2448 b'' | |||
|
1 | 1 | # localrepo.py - read/write repository class for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | from node import hex, nullid, short |
|
8 | 8 | from i18n import _ |
|
9 | 9 | import peer, changegroup, subrepo, discovery, pushkey, obsolete, repoview |
|
10 | 10 | import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
|
11 | 11 | import lock as lockmod |
|
12 | 12 | import transaction, store, encoding |
|
13 | 13 | import scmutil, util, extensions, hook, error, revset |
|
14 | 14 | import match as matchmod |
|
15 | 15 | import merge as mergemod |
|
16 | 16 | import tags as tagsmod |
|
17 | 17 | from lock import release |
|
18 | 18 | import weakref, errno, os, time, inspect |
|
19 | 19 | import branchmap, pathutil |
|
20 | 20 | propertycache = util.propertycache |
|
21 | 21 | filecache = scmutil.filecache |
|
22 | 22 | |
|
23 | 23 | class repofilecache(filecache): |
|
24 | 24 | """All filecache usage on repo are done for logic that should be unfiltered |
|
25 | 25 | """ |
|
26 | 26 | |
|
27 | 27 | def __get__(self, repo, type=None): |
|
28 | 28 | return super(repofilecache, self).__get__(repo.unfiltered(), type) |
|
29 | 29 | def __set__(self, repo, value): |
|
30 | 30 | return super(repofilecache, self).__set__(repo.unfiltered(), value) |
|
31 | 31 | def __delete__(self, repo): |
|
32 | 32 | return super(repofilecache, self).__delete__(repo.unfiltered()) |
|
33 | 33 | |
|
34 | 34 | class storecache(repofilecache): |
|
35 | 35 | """filecache for files in the store""" |
|
36 | 36 | def join(self, obj, fname): |
|
37 | 37 | return obj.sjoin(fname) |
|
38 | 38 | |
|
39 | 39 | class unfilteredpropertycache(propertycache): |
|
40 | 40 | """propertycache that apply to unfiltered repo only""" |
|
41 | 41 | |
|
42 | 42 | def __get__(self, repo, type=None): |
|
43 | 43 | unfi = repo.unfiltered() |
|
44 | 44 | if unfi is repo: |
|
45 | 45 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
46 | 46 | return getattr(unfi, self.name) |
|
47 | 47 | |
|
48 | 48 | class filteredpropertycache(propertycache): |
|
49 | 49 | """propertycache that must take filtering in account""" |
|
50 | 50 | |
|
51 | 51 | def cachevalue(self, obj, value): |
|
52 | 52 | object.__setattr__(obj, self.name, value) |
|
53 | 53 | |
|
54 | 54 | |
|
55 | 55 | def hasunfilteredcache(repo, name): |
|
56 | 56 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
57 | 57 | return name in vars(repo.unfiltered()) |
|
58 | 58 | |
|
59 | 59 | def unfilteredmethod(orig): |
|
60 | 60 | """decorate method that always need to be run on unfiltered version""" |
|
61 | 61 | def wrapper(repo, *args, **kwargs): |
|
62 | 62 | return orig(repo.unfiltered(), *args, **kwargs) |
|
63 | 63 | return wrapper |
|
64 | 64 | |
|
65 | 65 | MODERNCAPS = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle')) |
|
66 | 66 | LEGACYCAPS = MODERNCAPS.union(set(['changegroupsubset'])) |
|
67 | 67 | |
|
68 | 68 | class localpeer(peer.peerrepository): |
|
69 | 69 | '''peer for a local repo; reflects only the most recent API''' |
|
70 | 70 | |
|
71 | 71 | def __init__(self, repo, caps=MODERNCAPS): |
|
72 | 72 | peer.peerrepository.__init__(self) |
|
73 | 73 | self._repo = repo.filtered('served') |
|
74 | 74 | self.ui = repo.ui |
|
75 | 75 | self._caps = repo._restrictcapabilities(caps) |
|
76 | 76 | self.requirements = repo.requirements |
|
77 | 77 | self.supportedformats = repo.supportedformats |
|
78 | 78 | |
|
79 | 79 | def close(self): |
|
80 | 80 | self._repo.close() |
|
81 | 81 | |
|
82 | 82 | def _capabilities(self): |
|
83 | 83 | return self._caps |
|
84 | 84 | |
|
85 | 85 | def local(self): |
|
86 | 86 | return self._repo |
|
87 | 87 | |
|
88 | 88 | def canpush(self): |
|
89 | 89 | return True |
|
90 | 90 | |
|
91 | 91 | def url(self): |
|
92 | 92 | return self._repo.url() |
|
93 | 93 | |
|
94 | 94 | def lookup(self, key): |
|
95 | 95 | return self._repo.lookup(key) |
|
96 | 96 | |
|
97 | 97 | def branchmap(self): |
|
98 | 98 | return self._repo.branchmap() |
|
99 | 99 | |
|
100 | 100 | def heads(self): |
|
101 | 101 | return self._repo.heads() |
|
102 | 102 | |
|
103 | 103 | def known(self, nodes): |
|
104 | 104 | return self._repo.known(nodes) |
|
105 | 105 | |
|
106 | 106 | def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
|
107 | 107 | return self._repo.getbundle(source, heads=heads, common=common, |
|
108 | 108 | bundlecaps=None) |
|
109 | 109 | |
|
110 | 110 | # TODO We might want to move the next two calls into legacypeer and add |
|
111 | 111 | # unbundle instead. |
|
112 | 112 | |
|
113 | 113 | def lock(self): |
|
114 | 114 | return self._repo.lock() |
|
115 | 115 | |
|
116 | 116 | def addchangegroup(self, cg, source, url): |
|
117 | 117 | return self._repo.addchangegroup(cg, source, url) |
|
118 | 118 | |
|
119 | 119 | def pushkey(self, namespace, key, old, new): |
|
120 | 120 | return self._repo.pushkey(namespace, key, old, new) |
|
121 | 121 | |
|
122 | 122 | def listkeys(self, namespace): |
|
123 | 123 | return self._repo.listkeys(namespace) |
|
124 | 124 | |
|
125 | 125 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
126 | 126 | '''used to test argument passing over the wire''' |
|
127 | 127 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
128 | 128 | |
|
129 | 129 | class locallegacypeer(localpeer): |
|
130 | 130 | '''peer extension which implements legacy methods too; used for tests with |
|
131 | 131 | restricted capabilities''' |
|
132 | 132 | |
|
133 | 133 | def __init__(self, repo): |
|
134 | 134 | localpeer.__init__(self, repo, caps=LEGACYCAPS) |
|
135 | 135 | |
|
136 | 136 | def branches(self, nodes): |
|
137 | 137 | return self._repo.branches(nodes) |
|
138 | 138 | |
|
139 | 139 | def between(self, pairs): |
|
140 | 140 | return self._repo.between(pairs) |
|
141 | 141 | |
|
142 | 142 | def changegroup(self, basenodes, source): |
|
143 | 143 | return self._repo.changegroup(basenodes, source) |
|
144 | 144 | |
|
145 | 145 | def changegroupsubset(self, bases, heads, source): |
|
146 | 146 | return self._repo.changegroupsubset(bases, heads, source) |
|
147 | 147 | |
|
148 | 148 | class localrepository(object): |
|
149 | 149 | |
|
150 | 150 | supportedformats = set(('revlogv1', 'generaldelta')) |
|
151 | 151 | _basesupported = supportedformats | set(('store', 'fncache', 'shared', |
|
152 | 152 | 'dotencode')) |
|
153 | 153 | openerreqs = set(('revlogv1', 'generaldelta')) |
|
154 | 154 | requirements = ['revlogv1'] |
|
155 | 155 | filtername = None |
|
156 | 156 | |
|
157 | 157 | # a list of (ui, featureset) functions. |
|
158 | 158 | # only functions defined in module of enabled extensions are invoked |
|
159 | 159 | featuresetupfuncs = set() |
|
160 | 160 | |
|
161 | 161 | def _baserequirements(self, create): |
|
162 | 162 | return self.requirements[:] |
|
163 | 163 | |
|
164 | 164 | def __init__(self, baseui, path=None, create=False): |
|
165 | 165 | self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True) |
|
166 | 166 | self.wopener = self.wvfs |
|
167 | 167 | self.root = self.wvfs.base |
|
168 | 168 | self.path = self.wvfs.join(".hg") |
|
169 | 169 | self.origroot = path |
|
170 | 170 | self.auditor = pathutil.pathauditor(self.root, self._checknested) |
|
171 | 171 | self.vfs = scmutil.vfs(self.path) |
|
172 | 172 | self.opener = self.vfs |
|
173 | 173 | self.baseui = baseui |
|
174 | 174 | self.ui = baseui.copy() |
|
175 | 175 | self.ui.copy = baseui.copy # prevent copying repo configuration |
|
176 | 176 | # A list of callback to shape the phase if no data were found. |
|
177 | 177 | # Callback are in the form: func(repo, roots) --> processed root. |
|
178 | 178 | # This list it to be filled by extension during repo setup |
|
179 | 179 | self._phasedefaults = [] |
|
180 | 180 | try: |
|
181 | 181 | self.ui.readconfig(self.join("hgrc"), self.root) |
|
182 | 182 | extensions.loadall(self.ui) |
|
183 | 183 | except IOError: |
|
184 | 184 | pass |
|
185 | 185 | |
|
186 | 186 | if self.featuresetupfuncs: |
|
187 | 187 | self.supported = set(self._basesupported) # use private copy |
|
188 | 188 | extmods = set(m.__name__ for n, m |
|
189 | 189 | in extensions.extensions(self.ui)) |
|
190 | 190 | for setupfunc in self.featuresetupfuncs: |
|
191 | 191 | if setupfunc.__module__ in extmods: |
|
192 | 192 | setupfunc(self.ui, self.supported) |
|
193 | 193 | else: |
|
194 | 194 | self.supported = self._basesupported |
|
195 | 195 | |
|
196 | 196 | if not self.vfs.isdir(): |
|
197 | 197 | if create: |
|
198 | 198 | if not self.wvfs.exists(): |
|
199 | 199 | self.wvfs.makedirs() |
|
200 | 200 | self.vfs.makedir(notindexed=True) |
|
201 | 201 | requirements = self._baserequirements(create) |
|
202 | 202 | if self.ui.configbool('format', 'usestore', True): |
|
203 | 203 | self.vfs.mkdir("store") |
|
204 | 204 | requirements.append("store") |
|
205 | 205 | if self.ui.configbool('format', 'usefncache', True): |
|
206 | 206 | requirements.append("fncache") |
|
207 | 207 | if self.ui.configbool('format', 'dotencode', True): |
|
208 | 208 | requirements.append('dotencode') |
|
209 | 209 | # create an invalid changelog |
|
210 | 210 | self.vfs.append( |
|
211 | 211 | "00changelog.i", |
|
212 | 212 | '\0\0\0\2' # represents revlogv2 |
|
213 | 213 | ' dummy changelog to prevent using the old repo layout' |
|
214 | 214 | ) |
|
215 | 215 | if self.ui.configbool('format', 'generaldelta', False): |
|
216 | 216 | requirements.append("generaldelta") |
|
217 | 217 | requirements = set(requirements) |
|
218 | 218 | else: |
|
219 | 219 | raise error.RepoError(_("repository %s not found") % path) |
|
220 | 220 | elif create: |
|
221 | 221 | raise error.RepoError(_("repository %s already exists") % path) |
|
222 | 222 | else: |
|
223 | 223 | try: |
|
224 | 224 | requirements = scmutil.readrequires(self.vfs, self.supported) |
|
225 | 225 | except IOError, inst: |
|
226 | 226 | if inst.errno != errno.ENOENT: |
|
227 | 227 | raise |
|
228 | 228 | requirements = set() |
|
229 | 229 | |
|
230 | 230 | self.sharedpath = self.path |
|
231 | 231 | try: |
|
232 | 232 | vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'), |
|
233 | 233 | realpath=True) |
|
234 | 234 | s = vfs.base |
|
235 | 235 | if not vfs.exists(): |
|
236 | 236 | raise error.RepoError( |
|
237 | 237 | _('.hg/sharedpath points to nonexistent directory %s') % s) |
|
238 | 238 | self.sharedpath = s |
|
239 | 239 | except IOError, inst: |
|
240 | 240 | if inst.errno != errno.ENOENT: |
|
241 | 241 | raise |
|
242 | 242 | |
|
243 | 243 | self.store = store.store(requirements, self.sharedpath, scmutil.vfs) |
|
244 | 244 | self.spath = self.store.path |
|
245 | 245 | self.svfs = self.store.vfs |
|
246 | 246 | self.sopener = self.svfs |
|
247 | 247 | self.sjoin = self.store.join |
|
248 | 248 | self.vfs.createmode = self.store.createmode |
|
249 | 249 | self._applyrequirements(requirements) |
|
250 | 250 | if create: |
|
251 | 251 | self._writerequirements() |
|
252 | 252 | |
|
253 | 253 | |
|
254 | 254 | self._branchcaches = {} |
|
255 | 255 | self.filterpats = {} |
|
256 | 256 | self._datafilters = {} |
|
257 | 257 | self._transref = self._lockref = self._wlockref = None |
|
258 | 258 | |
|
259 | 259 | # A cache for various files under .hg/ that tracks file changes, |
|
260 | 260 | # (used by the filecache decorator) |
|
261 | 261 | # |
|
262 | 262 | # Maps a property name to its util.filecacheentry |
|
263 | 263 | self._filecache = {} |
|
264 | 264 | |
|
265 | 265 | # hold sets of revision to be filtered |
|
266 | 266 | # should be cleared when something might have changed the filter value: |
|
267 | 267 | # - new changesets, |
|
268 | 268 | # - phase change, |
|
269 | 269 | # - new obsolescence marker, |
|
270 | 270 | # - working directory parent change, |
|
271 | 271 | # - bookmark changes |
|
272 | 272 | self.filteredrevcache = {} |
|
273 | 273 | |
|
274 | 274 | def close(self): |
|
275 | 275 | pass |
|
276 | 276 | |
|
277 | 277 | def _restrictcapabilities(self, caps): |
|
278 | 278 | return caps |
|
279 | 279 | |
|
280 | 280 | def _applyrequirements(self, requirements): |
|
281 | 281 | self.requirements = requirements |
|
282 | 282 | self.sopener.options = dict((r, 1) for r in requirements |
|
283 | 283 | if r in self.openerreqs) |
|
284 | 284 | chunkcachesize = self.ui.configint('format', 'chunkcachesize') |
|
285 | 285 | if chunkcachesize is not None: |
|
286 | 286 | self.sopener.options['chunkcachesize'] = chunkcachesize |
|
287 | 287 | |
|
288 | 288 | def _writerequirements(self): |
|
289 | 289 | reqfile = self.opener("requires", "w") |
|
290 | 290 | for r in sorted(self.requirements): |
|
291 | 291 | reqfile.write("%s\n" % r) |
|
292 | 292 | reqfile.close() |
|
293 | 293 | |
|
294 | 294 | def _checknested(self, path): |
|
295 | 295 | """Determine if path is a legal nested repository.""" |
|
296 | 296 | if not path.startswith(self.root): |
|
297 | 297 | return False |
|
298 | 298 | subpath = path[len(self.root) + 1:] |
|
299 | 299 | normsubpath = util.pconvert(subpath) |
|
300 | 300 | |
|
301 | 301 | # XXX: Checking against the current working copy is wrong in |
|
302 | 302 | # the sense that it can reject things like |
|
303 | 303 | # |
|
304 | 304 | # $ hg cat -r 10 sub/x.txt |
|
305 | 305 | # |
|
306 | 306 | # if sub/ is no longer a subrepository in the working copy |
|
307 | 307 | # parent revision. |
|
308 | 308 | # |
|
309 | 309 | # However, it can of course also allow things that would have |
|
310 | 310 | # been rejected before, such as the above cat command if sub/ |
|
311 | 311 | # is a subrepository now, but was a normal directory before. |
|
312 | 312 | # The old path auditor would have rejected by mistake since it |
|
313 | 313 | # panics when it sees sub/.hg/. |
|
314 | 314 | # |
|
315 | 315 | # All in all, checking against the working copy seems sensible |
|
316 | 316 | # since we want to prevent access to nested repositories on |
|
317 | 317 | # the filesystem *now*. |
|
318 | 318 | ctx = self[None] |
|
319 | 319 | parts = util.splitpath(subpath) |
|
320 | 320 | while parts: |
|
321 | 321 | prefix = '/'.join(parts) |
|
322 | 322 | if prefix in ctx.substate: |
|
323 | 323 | if prefix == normsubpath: |
|
324 | 324 | return True |
|
325 | 325 | else: |
|
326 | 326 | sub = ctx.sub(prefix) |
|
327 | 327 | return sub.checknested(subpath[len(prefix) + 1:]) |
|
328 | 328 | else: |
|
329 | 329 | parts.pop() |
|
330 | 330 | return False |
|
331 | 331 | |
|
332 | 332 | def peer(self): |
|
333 | 333 | return localpeer(self) # not cached to avoid reference cycle |
|
334 | 334 | |
|
335 | 335 | def unfiltered(self): |
|
336 | 336 | """Return unfiltered version of the repository |
|
337 | 337 | |
|
338 | 338 | Intended to be overwritten by filtered repo.""" |
|
339 | 339 | return self |
|
340 | 340 | |
|
341 | 341 | def filtered(self, name): |
|
342 | 342 | """Return a filtered version of a repository""" |
|
343 | 343 | # build a new class with the mixin and the current class |
|
344 | 344 | # (possibly subclass of the repo) |
|
345 | 345 | class proxycls(repoview.repoview, self.unfiltered().__class__): |
|
346 | 346 | pass |
|
347 | 347 | return proxycls(self, name) |
|
348 | 348 | |
|
349 | 349 | @repofilecache('bookmarks') |
|
350 | 350 | def _bookmarks(self): |
|
351 | 351 | return bookmarks.bmstore(self) |
|
352 | 352 | |
|
353 | 353 | @repofilecache('bookmarks.current') |
|
354 | 354 | def _bookmarkcurrent(self): |
|
355 | 355 | return bookmarks.readcurrent(self) |
|
356 | 356 | |
|
357 | 357 | def bookmarkheads(self, bookmark): |
|
358 | 358 | name = bookmark.split('@', 1)[0] |
|
359 | 359 | heads = [] |
|
360 | 360 | for mark, n in self._bookmarks.iteritems(): |
|
361 | 361 | if mark.split('@', 1)[0] == name: |
|
362 | 362 | heads.append(n) |
|
363 | 363 | return heads |
|
364 | 364 | |
|
365 | 365 | @storecache('phaseroots') |
|
366 | 366 | def _phasecache(self): |
|
367 | 367 | return phases.phasecache(self, self._phasedefaults) |
|
368 | 368 | |
|
369 | 369 | @storecache('obsstore') |
|
370 | 370 | def obsstore(self): |
|
371 | 371 | store = obsolete.obsstore(self.sopener) |
|
372 | 372 | if store and not obsolete._enabled: |
|
373 | 373 | # message is rare enough to not be translated |
|
374 | 374 | msg = 'obsolete feature not enabled but %i markers found!\n' |
|
375 | 375 | self.ui.warn(msg % len(list(store))) |
|
376 | 376 | return store |
|
377 | 377 | |
|
378 | 378 | @storecache('00changelog.i') |
|
379 | 379 | def changelog(self): |
|
380 | 380 | c = changelog.changelog(self.sopener) |
|
381 | 381 | if 'HG_PENDING' in os.environ: |
|
382 | 382 | p = os.environ['HG_PENDING'] |
|
383 | 383 | if p.startswith(self.root): |
|
384 | 384 | c.readpending('00changelog.i.a') |
|
385 | 385 | return c |
|
386 | 386 | |
|
387 | 387 | @storecache('00manifest.i') |
|
388 | 388 | def manifest(self): |
|
389 | 389 | return manifest.manifest(self.sopener) |
|
390 | 390 | |
|
391 | 391 | @repofilecache('dirstate') |
|
392 | 392 | def dirstate(self): |
|
393 | 393 | warned = [0] |
|
394 | 394 | def validate(node): |
|
395 | 395 | try: |
|
396 | 396 | self.changelog.rev(node) |
|
397 | 397 | return node |
|
398 | 398 | except error.LookupError: |
|
399 | 399 | if not warned[0]: |
|
400 | 400 | warned[0] = True |
|
401 | 401 | self.ui.warn(_("warning: ignoring unknown" |
|
402 | 402 | " working parent %s!\n") % short(node)) |
|
403 | 403 | return nullid |
|
404 | 404 | |
|
405 | 405 | return dirstate.dirstate(self.opener, self.ui, self.root, validate) |
|
406 | 406 | |
|
407 | 407 | def __getitem__(self, changeid): |
|
408 | 408 | if changeid is None: |
|
409 | 409 | return context.workingctx(self) |
|
410 | 410 | return context.changectx(self, changeid) |
|
411 | 411 | |
|
412 | 412 | def __contains__(self, changeid): |
|
413 | 413 | try: |
|
414 | 414 | return bool(self.lookup(changeid)) |
|
415 | 415 | except error.RepoLookupError: |
|
416 | 416 | return False |
|
417 | 417 | |
|
418 | 418 | def __nonzero__(self): |
|
419 | 419 | return True |
|
420 | 420 | |
|
421 | 421 | def __len__(self): |
|
422 | 422 | return len(self.changelog) |
|
423 | 423 | |
|
424 | 424 | def __iter__(self): |
|
425 | 425 | return iter(self.changelog) |
|
426 | 426 | |
|
427 | 427 | def revs(self, expr, *args): |
|
428 | 428 | '''Return a list of revisions matching the given revset''' |
|
429 | 429 | expr = revset.formatspec(expr, *args) |
|
430 | 430 | m = revset.match(None, expr) |
|
431 | 431 | return [r for r in m(self, list(self))] |
|
432 | 432 | |
|
433 | 433 | def set(self, expr, *args): |
|
434 | 434 | ''' |
|
435 | 435 | Yield a context for each matching revision, after doing arg |
|
436 | 436 | replacement via revset.formatspec |
|
437 | 437 | ''' |
|
438 | 438 | for r in self.revs(expr, *args): |
|
439 | 439 | yield self[r] |
|
440 | 440 | |
|
441 | 441 | def url(self): |
|
442 | 442 | return 'file:' + self.root |
|
443 | 443 | |
|
444 | 444 | def hook(self, name, throw=False, **args): |
|
445 | 445 | return hook.hook(self.ui, self, name, throw, **args) |
|
446 | 446 | |
|
447 | 447 | @unfilteredmethod |
|
448 | 448 | def _tag(self, names, node, message, local, user, date, extra={}): |
|
449 | 449 | if isinstance(names, str): |
|
450 | 450 | names = (names,) |
|
451 | 451 | |
|
452 | 452 | branches = self.branchmap() |
|
453 | 453 | for name in names: |
|
454 | 454 | self.hook('pretag', throw=True, node=hex(node), tag=name, |
|
455 | 455 | local=local) |
|
456 | 456 | if name in branches: |
|
457 | 457 | self.ui.warn(_("warning: tag %s conflicts with existing" |
|
458 | 458 | " branch name\n") % name) |
|
459 | 459 | |
|
460 | 460 | def writetags(fp, names, munge, prevtags): |
|
461 | 461 | fp.seek(0, 2) |
|
462 | 462 | if prevtags and prevtags[-1] != '\n': |
|
463 | 463 | fp.write('\n') |
|
464 | 464 | for name in names: |
|
465 | 465 | m = munge and munge(name) or name |
|
466 | 466 | if (self._tagscache.tagtypes and |
|
467 | 467 | name in self._tagscache.tagtypes): |
|
468 | 468 | old = self.tags().get(name, nullid) |
|
469 | 469 | fp.write('%s %s\n' % (hex(old), m)) |
|
470 | 470 | fp.write('%s %s\n' % (hex(node), m)) |
|
471 | 471 | fp.close() |
|
472 | 472 | |
|
473 | 473 | prevtags = '' |
|
474 | 474 | if local: |
|
475 | 475 | try: |
|
476 | 476 | fp = self.opener('localtags', 'r+') |
|
477 | 477 | except IOError: |
|
478 | 478 | fp = self.opener('localtags', 'a') |
|
479 | 479 | else: |
|
480 | 480 | prevtags = fp.read() |
|
481 | 481 | |
|
482 | 482 | # local tags are stored in the current charset |
|
483 | 483 | writetags(fp, names, None, prevtags) |
|
484 | 484 | for name in names: |
|
485 | 485 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
486 | 486 | return |
|
487 | 487 | |
|
488 | 488 | try: |
|
489 | 489 | fp = self.wfile('.hgtags', 'rb+') |
|
490 | 490 | except IOError, e: |
|
491 | 491 | if e.errno != errno.ENOENT: |
|
492 | 492 | raise |
|
493 | 493 | fp = self.wfile('.hgtags', 'ab') |
|
494 | 494 | else: |
|
495 | 495 | prevtags = fp.read() |
|
496 | 496 | |
|
497 | 497 | # committed tags are stored in UTF-8 |
|
498 | 498 | writetags(fp, names, encoding.fromlocal, prevtags) |
|
499 | 499 | |
|
500 | 500 | fp.close() |
|
501 | 501 | |
|
502 | 502 | self.invalidatecaches() |
|
503 | 503 | |
|
504 | 504 | if '.hgtags' not in self.dirstate: |
|
505 | 505 | self[None].add(['.hgtags']) |
|
506 | 506 | |
|
507 | 507 | m = matchmod.exact(self.root, '', ['.hgtags']) |
|
508 | 508 | tagnode = self.commit(message, user, date, extra=extra, match=m) |
|
509 | 509 | |
|
510 | 510 | for name in names: |
|
511 | 511 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
512 | 512 | |
|
513 | 513 | return tagnode |
|
514 | 514 | |
|
515 | 515 | def tag(self, names, node, message, local, user, date): |
|
516 | 516 | '''tag a revision with one or more symbolic names. |
|
517 | 517 | |
|
518 | 518 | names is a list of strings or, when adding a single tag, names may be a |
|
519 | 519 | string. |
|
520 | 520 | |
|
521 | 521 | if local is True, the tags are stored in a per-repository file. |
|
522 | 522 | otherwise, they are stored in the .hgtags file, and a new |
|
523 | 523 | changeset is committed with the change. |
|
524 | 524 | |
|
525 | 525 | keyword arguments: |
|
526 | 526 | |
|
527 | 527 | local: whether to store tags in non-version-controlled file |
|
528 | 528 | (default False) |
|
529 | 529 | |
|
530 | 530 | message: commit message to use if committing |
|
531 | 531 | |
|
532 | 532 | user: name of user to use if committing |
|
533 | 533 | |
|
534 | 534 | date: date tuple to use if committing''' |
|
535 | 535 | |
|
536 | 536 | if not local: |
|
537 | 537 | for x in self.status()[:5]: |
|
538 | 538 | if '.hgtags' in x: |
|
539 | 539 | raise util.Abort(_('working copy of .hgtags is changed ' |
|
540 | 540 | '(please commit .hgtags manually)')) |
|
541 | 541 | |
|
542 | 542 | self.tags() # instantiate the cache |
|
543 | 543 | self._tag(names, node, message, local, user, date) |
|
544 | 544 | |
|
545 | 545 | @filteredpropertycache |
|
546 | 546 | def _tagscache(self): |
|
547 | 547 | '''Returns a tagscache object that contains various tags related |
|
548 | 548 | caches.''' |
|
549 | 549 | |
|
550 | 550 | # This simplifies its cache management by having one decorated |
|
551 | 551 | # function (this one) and the rest simply fetch things from it. |
|
552 | 552 | class tagscache(object): |
|
553 | 553 | def __init__(self): |
|
554 | 554 | # These two define the set of tags for this repository. tags |
|
555 | 555 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
556 | 556 | # 'local'. (Global tags are defined by .hgtags across all |
|
557 | 557 | # heads, and local tags are defined in .hg/localtags.) |
|
558 | 558 | # They constitute the in-memory cache of tags. |
|
559 | 559 | self.tags = self.tagtypes = None |
|
560 | 560 | |
|
561 | 561 | self.nodetagscache = self.tagslist = None |
|
562 | 562 | |
|
563 | 563 | cache = tagscache() |
|
564 | 564 | cache.tags, cache.tagtypes = self._findtags() |
|
565 | 565 | |
|
566 | 566 | return cache |
|
567 | 567 | |
|
568 | 568 | def tags(self): |
|
569 | 569 | '''return a mapping of tag to node''' |
|
570 | 570 | t = {} |
|
571 | 571 | if self.changelog.filteredrevs: |
|
572 | 572 | tags, tt = self._findtags() |
|
573 | 573 | else: |
|
574 | 574 | tags = self._tagscache.tags |
|
575 | 575 | for k, v in tags.iteritems(): |
|
576 | 576 | try: |
|
577 | 577 | # ignore tags to unknown nodes |
|
578 | 578 | self.changelog.rev(v) |
|
579 | 579 | t[k] = v |
|
580 | 580 | except (error.LookupError, ValueError): |
|
581 | 581 | pass |
|
582 | 582 | return t |
|
583 | 583 | |
|
584 | 584 | def _findtags(self): |
|
585 | 585 | '''Do the hard work of finding tags. Return a pair of dicts |
|
586 | 586 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
587 | 587 | maps tag name to a string like \'global\' or \'local\'. |
|
588 | 588 | Subclasses or extensions are free to add their own tags, but |
|
589 | 589 | should be aware that the returned dicts will be retained for the |
|
590 | 590 | duration of the localrepo object.''' |
|
591 | 591 | |
|
592 | 592 | # XXX what tagtype should subclasses/extensions use? Currently |
|
593 | 593 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
594 | 594 | # Should each extension invent its own tag type? Should there |
|
595 | 595 | # be one tagtype for all such "virtual" tags? Or is the status |
|
596 | 596 | # quo fine? |
|
597 | 597 | |
|
598 | 598 | alltags = {} # map tag name to (node, hist) |
|
599 | 599 | tagtypes = {} |
|
600 | 600 | |
|
601 | 601 | tagsmod.findglobaltags(self.ui, self, alltags, tagtypes) |
|
602 | 602 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
603 | 603 | |
|
604 | 604 | # Build the return dicts. Have to re-encode tag names because |
|
605 | 605 | # the tags module always uses UTF-8 (in order not to lose info |
|
606 | 606 | # writing to the cache), but the rest of Mercurial wants them in |
|
607 | 607 | # local encoding. |
|
608 | 608 | tags = {} |
|
609 | 609 | for (name, (node, hist)) in alltags.iteritems(): |
|
610 | 610 | if node != nullid: |
|
611 | 611 | tags[encoding.tolocal(name)] = node |
|
612 | 612 | tags['tip'] = self.changelog.tip() |
|
613 | 613 | tagtypes = dict([(encoding.tolocal(name), value) |
|
614 | 614 | for (name, value) in tagtypes.iteritems()]) |
|
615 | 615 | return (tags, tagtypes) |
|
616 | 616 | |
|
617 | 617 | def tagtype(self, tagname): |
|
618 | 618 | ''' |
|
619 | 619 | return the type of the given tag. result can be: |
|
620 | 620 | |
|
621 | 621 | 'local' : a local tag |
|
622 | 622 | 'global' : a global tag |
|
623 | 623 | None : tag does not exist |
|
624 | 624 | ''' |
|
625 | 625 | |
|
626 | 626 | return self._tagscache.tagtypes.get(tagname) |
|
627 | 627 | |
|
628 | 628 | def tagslist(self): |
|
629 | 629 | '''return a list of tags ordered by revision''' |
|
630 | 630 | if not self._tagscache.tagslist: |
|
631 | 631 | l = [] |
|
632 | 632 | for t, n in self.tags().iteritems(): |
|
633 | 633 | r = self.changelog.rev(n) |
|
634 | 634 | l.append((r, t, n)) |
|
635 | 635 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
636 | 636 | |
|
637 | 637 | return self._tagscache.tagslist |
|
638 | 638 | |
|
639 | 639 | def nodetags(self, node): |
|
640 | 640 | '''return the tags associated with a node''' |
|
641 | 641 | if not self._tagscache.nodetagscache: |
|
642 | 642 | nodetagscache = {} |
|
643 | 643 | for t, n in self._tagscache.tags.iteritems(): |
|
644 | 644 | nodetagscache.setdefault(n, []).append(t) |
|
645 | 645 | for tags in nodetagscache.itervalues(): |
|
646 | 646 | tags.sort() |
|
647 | 647 | self._tagscache.nodetagscache = nodetagscache |
|
648 | 648 | return self._tagscache.nodetagscache.get(node, []) |
|
649 | 649 | |
|
650 | 650 | def nodebookmarks(self, node): |
|
651 | 651 | marks = [] |
|
652 | 652 | for bookmark, n in self._bookmarks.iteritems(): |
|
653 | 653 | if n == node: |
|
654 | 654 | marks.append(bookmark) |
|
655 | 655 | return sorted(marks) |
|
656 | 656 | |
|
657 | 657 | def branchmap(self): |
|
658 |
'''returns a dictionary {branch: [branchheads]} |
|
|
658 | '''returns a dictionary {branch: [branchheads]} with branchheads | |
|
659 | ordered by increasing revision number''' | |
|
659 | 660 | branchmap.updatecache(self) |
|
660 | 661 | return self._branchcaches[self.filtername] |
|
661 | 662 | |
|
662 | 663 | def branchtip(self, branch): |
|
663 | 664 | '''return the tip node for a given branch''' |
|
664 | 665 | try: |
|
665 | 666 | return self.branchmap().branchtip(branch) |
|
666 | 667 | except KeyError: |
|
667 | 668 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
668 | 669 | |
|
669 | 670 | def lookup(self, key): |
|
670 | 671 | return self[key].node() |
|
671 | 672 | |
|
672 | 673 | def lookupbranch(self, key, remote=None): |
|
673 | 674 | repo = remote or self |
|
674 | 675 | if key in repo.branchmap(): |
|
675 | 676 | return key |
|
676 | 677 | |
|
677 | 678 | repo = (remote and remote.local()) and remote or self |
|
678 | 679 | return repo[key].branch() |
|
679 | 680 | |
|
680 | 681 | def known(self, nodes): |
|
681 | 682 | nm = self.changelog.nodemap |
|
682 | 683 | pc = self._phasecache |
|
683 | 684 | result = [] |
|
684 | 685 | for n in nodes: |
|
685 | 686 | r = nm.get(n) |
|
686 | 687 | resp = not (r is None or pc.phase(self, r) >= phases.secret) |
|
687 | 688 | result.append(resp) |
|
688 | 689 | return result |
|
689 | 690 | |
|
690 | 691 | def local(self): |
|
691 | 692 | return self |
|
692 | 693 | |
|
693 | 694 | def cancopy(self): |
|
694 | 695 | return self.local() # so statichttprepo's override of local() works |
|
695 | 696 | |
|
696 | 697 | def join(self, f): |
|
697 | 698 | return os.path.join(self.path, f) |
|
698 | 699 | |
|
699 | 700 | def wjoin(self, f): |
|
700 | 701 | return os.path.join(self.root, f) |
|
701 | 702 | |
|
702 | 703 | def file(self, f): |
|
703 | 704 | if f[0] == '/': |
|
704 | 705 | f = f[1:] |
|
705 | 706 | return filelog.filelog(self.sopener, f) |
|
706 | 707 | |
|
707 | 708 | def changectx(self, changeid): |
|
708 | 709 | return self[changeid] |
|
709 | 710 | |
|
710 | 711 | def parents(self, changeid=None): |
|
711 | 712 | '''get list of changectxs for parents of changeid''' |
|
712 | 713 | return self[changeid].parents() |
|
713 | 714 | |
|
714 | 715 | def setparents(self, p1, p2=nullid): |
|
715 | 716 | copies = self.dirstate.setparents(p1, p2) |
|
716 | 717 | pctx = self[p1] |
|
717 | 718 | if copies: |
|
718 | 719 | # Adjust copy records, the dirstate cannot do it, it |
|
719 | 720 | # requires access to parents manifests. Preserve them |
|
720 | 721 | # only for entries added to first parent. |
|
721 | 722 | for f in copies: |
|
722 | 723 | if f not in pctx and copies[f] in pctx: |
|
723 | 724 | self.dirstate.copy(copies[f], f) |
|
724 | 725 | if p2 == nullid: |
|
725 | 726 | for f, s in sorted(self.dirstate.copies().items()): |
|
726 | 727 | if f not in pctx and s not in pctx: |
|
727 | 728 | self.dirstate.copy(None, f) |
|
728 | 729 | |
|
729 | 730 | def filectx(self, path, changeid=None, fileid=None): |
|
730 | 731 | """changeid can be a changeset revision, node, or tag. |
|
731 | 732 | fileid can be a file revision or node.""" |
|
732 | 733 | return context.filectx(self, path, changeid, fileid) |
|
733 | 734 | |
|
734 | 735 | def getcwd(self): |
|
735 | 736 | return self.dirstate.getcwd() |
|
736 | 737 | |
|
737 | 738 | def pathto(self, f, cwd=None): |
|
738 | 739 | return self.dirstate.pathto(f, cwd) |
|
739 | 740 | |
|
740 | 741 | def wfile(self, f, mode='r'): |
|
741 | 742 | return self.wopener(f, mode) |
|
742 | 743 | |
|
743 | 744 | def _link(self, f): |
|
744 | 745 | return self.wvfs.islink(f) |
|
745 | 746 | |
|
746 | 747 | def _loadfilter(self, filter): |
|
747 | 748 | if filter not in self.filterpats: |
|
748 | 749 | l = [] |
|
749 | 750 | for pat, cmd in self.ui.configitems(filter): |
|
750 | 751 | if cmd == '!': |
|
751 | 752 | continue |
|
752 | 753 | mf = matchmod.match(self.root, '', [pat]) |
|
753 | 754 | fn = None |
|
754 | 755 | params = cmd |
|
755 | 756 | for name, filterfn in self._datafilters.iteritems(): |
|
756 | 757 | if cmd.startswith(name): |
|
757 | 758 | fn = filterfn |
|
758 | 759 | params = cmd[len(name):].lstrip() |
|
759 | 760 | break |
|
760 | 761 | if not fn: |
|
761 | 762 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
762 | 763 | # Wrap old filters not supporting keyword arguments |
|
763 | 764 | if not inspect.getargspec(fn)[2]: |
|
764 | 765 | oldfn = fn |
|
765 | 766 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
766 | 767 | l.append((mf, fn, params)) |
|
767 | 768 | self.filterpats[filter] = l |
|
768 | 769 | return self.filterpats[filter] |
|
769 | 770 | |
|
770 | 771 | def _filter(self, filterpats, filename, data): |
|
771 | 772 | for mf, fn, cmd in filterpats: |
|
772 | 773 | if mf(filename): |
|
773 | 774 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
|
774 | 775 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
775 | 776 | break |
|
776 | 777 | |
|
777 | 778 | return data |
|
778 | 779 | |
|
779 | 780 | @unfilteredpropertycache |
|
780 | 781 | def _encodefilterpats(self): |
|
781 | 782 | return self._loadfilter('encode') |
|
782 | 783 | |
|
783 | 784 | @unfilteredpropertycache |
|
784 | 785 | def _decodefilterpats(self): |
|
785 | 786 | return self._loadfilter('decode') |
|
786 | 787 | |
|
787 | 788 | def adddatafilter(self, name, filter): |
|
788 | 789 | self._datafilters[name] = filter |
|
789 | 790 | |
|
790 | 791 | def wread(self, filename): |
|
791 | 792 | if self._link(filename): |
|
792 | 793 | data = self.wvfs.readlink(filename) |
|
793 | 794 | else: |
|
794 | 795 | data = self.wopener.read(filename) |
|
795 | 796 | return self._filter(self._encodefilterpats, filename, data) |
|
796 | 797 | |
|
797 | 798 | def wwrite(self, filename, data, flags): |
|
798 | 799 | data = self._filter(self._decodefilterpats, filename, data) |
|
799 | 800 | if 'l' in flags: |
|
800 | 801 | self.wopener.symlink(data, filename) |
|
801 | 802 | else: |
|
802 | 803 | self.wopener.write(filename, data) |
|
803 | 804 | if 'x' in flags: |
|
804 | 805 | self.wvfs.setflags(filename, False, True) |
|
805 | 806 | |
|
806 | 807 | def wwritedata(self, filename, data): |
|
807 | 808 | return self._filter(self._decodefilterpats, filename, data) |
|
808 | 809 | |
|
809 | 810 | def transaction(self, desc, report=None): |
|
810 | 811 | tr = self._transref and self._transref() or None |
|
811 | 812 | if tr and tr.running(): |
|
812 | 813 | return tr.nest() |
|
813 | 814 | |
|
814 | 815 | # abort here if the journal already exists |
|
815 | 816 | if self.svfs.exists("journal"): |
|
816 | 817 | raise error.RepoError( |
|
817 | 818 | _("abandoned transaction found - run hg recover")) |
|
818 | 819 | |
|
819 | 820 | self._writejournal(desc) |
|
820 | 821 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
821 | 822 | rp = report and report or self.ui.warn |
|
822 | 823 | tr = transaction.transaction(rp, self.sopener, |
|
823 | 824 | "journal", |
|
824 | 825 | aftertrans(renames), |
|
825 | 826 | self.store.createmode) |
|
826 | 827 | self._transref = weakref.ref(tr) |
|
827 | 828 | return tr |
|
828 | 829 | |
|
829 | 830 | def _journalfiles(self): |
|
830 | 831 | return ((self.svfs, 'journal'), |
|
831 | 832 | (self.vfs, 'journal.dirstate'), |
|
832 | 833 | (self.vfs, 'journal.branch'), |
|
833 | 834 | (self.vfs, 'journal.desc'), |
|
834 | 835 | (self.vfs, 'journal.bookmarks'), |
|
835 | 836 | (self.svfs, 'journal.phaseroots')) |
|
836 | 837 | |
|
837 | 838 | def undofiles(self): |
|
838 | 839 | return [vfs.join(undoname(x)) for vfs, x in self._journalfiles()] |
|
839 | 840 | |
|
840 | 841 | def _writejournal(self, desc): |
|
841 | 842 | self.opener.write("journal.dirstate", |
|
842 | 843 | self.opener.tryread("dirstate")) |
|
843 | 844 | self.opener.write("journal.branch", |
|
844 | 845 | encoding.fromlocal(self.dirstate.branch())) |
|
845 | 846 | self.opener.write("journal.desc", |
|
846 | 847 | "%d\n%s\n" % (len(self), desc)) |
|
847 | 848 | self.opener.write("journal.bookmarks", |
|
848 | 849 | self.opener.tryread("bookmarks")) |
|
849 | 850 | self.sopener.write("journal.phaseroots", |
|
850 | 851 | self.sopener.tryread("phaseroots")) |
|
851 | 852 | |
|
852 | 853 | def recover(self): |
|
853 | 854 | lock = self.lock() |
|
854 | 855 | try: |
|
855 | 856 | if self.svfs.exists("journal"): |
|
856 | 857 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
857 | 858 | transaction.rollback(self.sopener, "journal", |
|
858 | 859 | self.ui.warn) |
|
859 | 860 | self.invalidate() |
|
860 | 861 | return True |
|
861 | 862 | else: |
|
862 | 863 | self.ui.warn(_("no interrupted transaction available\n")) |
|
863 | 864 | return False |
|
864 | 865 | finally: |
|
865 | 866 | lock.release() |
|
866 | 867 | |
|
867 | 868 | def rollback(self, dryrun=False, force=False): |
|
868 | 869 | wlock = lock = None |
|
869 | 870 | try: |
|
870 | 871 | wlock = self.wlock() |
|
871 | 872 | lock = self.lock() |
|
872 | 873 | if self.svfs.exists("undo"): |
|
873 | 874 | return self._rollback(dryrun, force) |
|
874 | 875 | else: |
|
875 | 876 | self.ui.warn(_("no rollback information available\n")) |
|
876 | 877 | return 1 |
|
877 | 878 | finally: |
|
878 | 879 | release(lock, wlock) |
|
879 | 880 | |
|
880 | 881 | @unfilteredmethod # Until we get smarter cache management |
|
881 | 882 | def _rollback(self, dryrun, force): |
|
882 | 883 | ui = self.ui |
|
883 | 884 | try: |
|
884 | 885 | args = self.opener.read('undo.desc').splitlines() |
|
885 | 886 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
886 | 887 | if len(args) >= 3: |
|
887 | 888 | detail = args[2] |
|
888 | 889 | oldtip = oldlen - 1 |
|
889 | 890 | |
|
890 | 891 | if detail and ui.verbose: |
|
891 | 892 | msg = (_('repository tip rolled back to revision %s' |
|
892 | 893 | ' (undo %s: %s)\n') |
|
893 | 894 | % (oldtip, desc, detail)) |
|
894 | 895 | else: |
|
895 | 896 | msg = (_('repository tip rolled back to revision %s' |
|
896 | 897 | ' (undo %s)\n') |
|
897 | 898 | % (oldtip, desc)) |
|
898 | 899 | except IOError: |
|
899 | 900 | msg = _('rolling back unknown transaction\n') |
|
900 | 901 | desc = None |
|
901 | 902 | |
|
902 | 903 | if not force and self['.'] != self['tip'] and desc == 'commit': |
|
903 | 904 | raise util.Abort( |
|
904 | 905 | _('rollback of last commit while not checked out ' |
|
905 | 906 | 'may lose data'), hint=_('use -f to force')) |
|
906 | 907 | |
|
907 | 908 | ui.status(msg) |
|
908 | 909 | if dryrun: |
|
909 | 910 | return 0 |
|
910 | 911 | |
|
911 | 912 | parents = self.dirstate.parents() |
|
912 | 913 | self.destroying() |
|
913 | 914 | transaction.rollback(self.sopener, 'undo', ui.warn) |
|
914 | 915 | if self.vfs.exists('undo.bookmarks'): |
|
915 | 916 | self.vfs.rename('undo.bookmarks', 'bookmarks') |
|
916 | 917 | if self.svfs.exists('undo.phaseroots'): |
|
917 | 918 | self.svfs.rename('undo.phaseroots', 'phaseroots') |
|
918 | 919 | self.invalidate() |
|
919 | 920 | |
|
920 | 921 | parentgone = (parents[0] not in self.changelog.nodemap or |
|
921 | 922 | parents[1] not in self.changelog.nodemap) |
|
922 | 923 | if parentgone: |
|
923 | 924 | self.vfs.rename('undo.dirstate', 'dirstate') |
|
924 | 925 | try: |
|
925 | 926 | branch = self.opener.read('undo.branch') |
|
926 | 927 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
927 | 928 | except IOError: |
|
928 | 929 | ui.warn(_('named branch could not be reset: ' |
|
929 | 930 | 'current branch is still \'%s\'\n') |
|
930 | 931 | % self.dirstate.branch()) |
|
931 | 932 | |
|
932 | 933 | self.dirstate.invalidate() |
|
933 | 934 | parents = tuple([p.rev() for p in self.parents()]) |
|
934 | 935 | if len(parents) > 1: |
|
935 | 936 | ui.status(_('working directory now based on ' |
|
936 | 937 | 'revisions %d and %d\n') % parents) |
|
937 | 938 | else: |
|
938 | 939 | ui.status(_('working directory now based on ' |
|
939 | 940 | 'revision %d\n') % parents) |
|
940 | 941 | # TODO: if we know which new heads may result from this rollback, pass |
|
941 | 942 | # them to destroy(), which will prevent the branchhead cache from being |
|
942 | 943 | # invalidated. |
|
943 | 944 | self.destroyed() |
|
944 | 945 | return 0 |
|
945 | 946 | |
|
946 | 947 | def invalidatecaches(self): |
|
947 | 948 | |
|
948 | 949 | if '_tagscache' in vars(self): |
|
949 | 950 | # can't use delattr on proxy |
|
950 | 951 | del self.__dict__['_tagscache'] |
|
951 | 952 | |
|
952 | 953 | self.unfiltered()._branchcaches.clear() |
|
953 | 954 | self.invalidatevolatilesets() |
|
954 | 955 | |
|
955 | 956 | def invalidatevolatilesets(self): |
|
956 | 957 | self.filteredrevcache.clear() |
|
957 | 958 | obsolete.clearobscaches(self) |
|
958 | 959 | |
|
959 | 960 | def invalidatedirstate(self): |
|
960 | 961 | '''Invalidates the dirstate, causing the next call to dirstate |
|
961 | 962 | to check if it was modified since the last time it was read, |
|
962 | 963 | rereading it if it has. |
|
963 | 964 | |
|
964 | 965 | This is different to dirstate.invalidate() that it doesn't always |
|
965 | 966 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
966 | 967 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
967 | 968 | known good state).''' |
|
968 | 969 | if hasunfilteredcache(self, 'dirstate'): |
|
969 | 970 | for k in self.dirstate._filecache: |
|
970 | 971 | try: |
|
971 | 972 | delattr(self.dirstate, k) |
|
972 | 973 | except AttributeError: |
|
973 | 974 | pass |
|
974 | 975 | delattr(self.unfiltered(), 'dirstate') |
|
975 | 976 | |
|
976 | 977 | def invalidate(self): |
|
977 | 978 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
978 | 979 | for k in self._filecache: |
|
979 | 980 | # dirstate is invalidated separately in invalidatedirstate() |
|
980 | 981 | if k == 'dirstate': |
|
981 | 982 | continue |
|
982 | 983 | |
|
983 | 984 | try: |
|
984 | 985 | delattr(unfiltered, k) |
|
985 | 986 | except AttributeError: |
|
986 | 987 | pass |
|
987 | 988 | self.invalidatecaches() |
|
988 | 989 | |
|
989 | 990 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc): |
|
990 | 991 | try: |
|
991 | 992 | l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc) |
|
992 | 993 | except error.LockHeld, inst: |
|
993 | 994 | if not wait: |
|
994 | 995 | raise |
|
995 | 996 | self.ui.warn(_("waiting for lock on %s held by %r\n") % |
|
996 | 997 | (desc, inst.locker)) |
|
997 | 998 | # default to 600 seconds timeout |
|
998 | 999 | l = lockmod.lock(vfs, lockname, |
|
999 | 1000 | int(self.ui.config("ui", "timeout", "600")), |
|
1000 | 1001 | releasefn, desc=desc) |
|
1001 | 1002 | if acquirefn: |
|
1002 | 1003 | acquirefn() |
|
1003 | 1004 | return l |
|
1004 | 1005 | |
|
1005 | 1006 | def _afterlock(self, callback): |
|
1006 | 1007 | """add a callback to the current repository lock. |
|
1007 | 1008 | |
|
1008 | 1009 | The callback will be executed on lock release.""" |
|
1009 | 1010 | l = self._lockref and self._lockref() |
|
1010 | 1011 | if l: |
|
1011 | 1012 | l.postrelease.append(callback) |
|
1012 | 1013 | else: |
|
1013 | 1014 | callback() |
|
1014 | 1015 | |
|
1015 | 1016 | def lock(self, wait=True): |
|
1016 | 1017 | '''Lock the repository store (.hg/store) and return a weak reference |
|
1017 | 1018 | to the lock. Use this before modifying the store (e.g. committing or |
|
1018 | 1019 | stripping). If you are opening a transaction, get a lock as well.)''' |
|
1019 | 1020 | l = self._lockref and self._lockref() |
|
1020 | 1021 | if l is not None and l.held: |
|
1021 | 1022 | l.lock() |
|
1022 | 1023 | return l |
|
1023 | 1024 | |
|
1024 | 1025 | def unlock(): |
|
1025 | 1026 | self.store.write() |
|
1026 | 1027 | if hasunfilteredcache(self, '_phasecache'): |
|
1027 | 1028 | self._phasecache.write() |
|
1028 | 1029 | for k, ce in self._filecache.items(): |
|
1029 | 1030 | if k == 'dirstate' or k not in self.__dict__: |
|
1030 | 1031 | continue |
|
1031 | 1032 | ce.refresh() |
|
1032 | 1033 | |
|
1033 | 1034 | l = self._lock(self.svfs, "lock", wait, unlock, |
|
1034 | 1035 | self.invalidate, _('repository %s') % self.origroot) |
|
1035 | 1036 | self._lockref = weakref.ref(l) |
|
1036 | 1037 | return l |
|
1037 | 1038 | |
|
1038 | 1039 | def wlock(self, wait=True): |
|
1039 | 1040 | '''Lock the non-store parts of the repository (everything under |
|
1040 | 1041 | .hg except .hg/store) and return a weak reference to the lock. |
|
1041 | 1042 | Use this before modifying files in .hg.''' |
|
1042 | 1043 | l = self._wlockref and self._wlockref() |
|
1043 | 1044 | if l is not None and l.held: |
|
1044 | 1045 | l.lock() |
|
1045 | 1046 | return l |
|
1046 | 1047 | |
|
1047 | 1048 | def unlock(): |
|
1048 | 1049 | self.dirstate.write() |
|
1049 | 1050 | self._filecache['dirstate'].refresh() |
|
1050 | 1051 | |
|
1051 | 1052 | l = self._lock(self.vfs, "wlock", wait, unlock, |
|
1052 | 1053 | self.invalidatedirstate, _('working directory of %s') % |
|
1053 | 1054 | self.origroot) |
|
1054 | 1055 | self._wlockref = weakref.ref(l) |
|
1055 | 1056 | return l |
|
1056 | 1057 | |
|
1057 | 1058 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
|
1058 | 1059 | """ |
|
1059 | 1060 | commit an individual file as part of a larger transaction |
|
1060 | 1061 | """ |
|
1061 | 1062 | |
|
1062 | 1063 | fname = fctx.path() |
|
1063 | 1064 | text = fctx.data() |
|
1064 | 1065 | flog = self.file(fname) |
|
1065 | 1066 | fparent1 = manifest1.get(fname, nullid) |
|
1066 | 1067 | fparent2 = fparent2o = manifest2.get(fname, nullid) |
|
1067 | 1068 | |
|
1068 | 1069 | meta = {} |
|
1069 | 1070 | copy = fctx.renamed() |
|
1070 | 1071 | if copy and copy[0] != fname: |
|
1071 | 1072 | # Mark the new revision of this file as a copy of another |
|
1072 | 1073 | # file. This copy data will effectively act as a parent |
|
1073 | 1074 | # of this new revision. If this is a merge, the first |
|
1074 | 1075 | # parent will be the nullid (meaning "look up the copy data") |
|
1075 | 1076 | # and the second one will be the other parent. For example: |
|
1076 | 1077 | # |
|
1077 | 1078 | # 0 --- 1 --- 3 rev1 changes file foo |
|
1078 | 1079 | # \ / rev2 renames foo to bar and changes it |
|
1079 | 1080 | # \- 2 -/ rev3 should have bar with all changes and |
|
1080 | 1081 | # should record that bar descends from |
|
1081 | 1082 | # bar in rev2 and foo in rev1 |
|
1082 | 1083 | # |
|
1083 | 1084 | # this allows this merge to succeed: |
|
1084 | 1085 | # |
|
1085 | 1086 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
|
1086 | 1087 | # \ / merging rev3 and rev4 should use bar@rev2 |
|
1087 | 1088 | # \- 2 --- 4 as the merge base |
|
1088 | 1089 | # |
|
1089 | 1090 | |
|
1090 | 1091 | cfname = copy[0] |
|
1091 | 1092 | crev = manifest1.get(cfname) |
|
1092 | 1093 | newfparent = fparent2 |
|
1093 | 1094 | |
|
1094 | 1095 | if manifest2: # branch merge |
|
1095 | 1096 | if fparent2 == nullid or crev is None: # copied on remote side |
|
1096 | 1097 | if cfname in manifest2: |
|
1097 | 1098 | crev = manifest2[cfname] |
|
1098 | 1099 | newfparent = fparent1 |
|
1099 | 1100 | |
|
1100 | 1101 | # find source in nearest ancestor if we've lost track |
|
1101 | 1102 | if not crev: |
|
1102 | 1103 | self.ui.debug(" %s: searching for copy revision for %s\n" % |
|
1103 | 1104 | (fname, cfname)) |
|
1104 | 1105 | for ancestor in self[None].ancestors(): |
|
1105 | 1106 | if cfname in ancestor: |
|
1106 | 1107 | crev = ancestor[cfname].filenode() |
|
1107 | 1108 | break |
|
1108 | 1109 | |
|
1109 | 1110 | if crev: |
|
1110 | 1111 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) |
|
1111 | 1112 | meta["copy"] = cfname |
|
1112 | 1113 | meta["copyrev"] = hex(crev) |
|
1113 | 1114 | fparent1, fparent2 = nullid, newfparent |
|
1114 | 1115 | else: |
|
1115 | 1116 | self.ui.warn(_("warning: can't find ancestor for '%s' " |
|
1116 | 1117 | "copied from '%s'!\n") % (fname, cfname)) |
|
1117 | 1118 | |
|
1118 | 1119 | elif fparent2 != nullid: |
|
1119 | 1120 | # is one parent an ancestor of the other? |
|
1120 | 1121 | fparentancestor = flog.ancestor(fparent1, fparent2) |
|
1121 | 1122 | if fparentancestor == fparent1: |
|
1122 | 1123 | fparent1, fparent2 = fparent2, nullid |
|
1123 | 1124 | elif fparentancestor == fparent2: |
|
1124 | 1125 | fparent2 = nullid |
|
1125 | 1126 | |
|
1126 | 1127 | # is the file changed? |
|
1127 | 1128 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
|
1128 | 1129 | changelist.append(fname) |
|
1129 | 1130 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
|
1130 | 1131 | |
|
1131 | 1132 | # are just the flags changed during merge? |
|
1132 | 1133 | if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags(): |
|
1133 | 1134 | changelist.append(fname) |
|
1134 | 1135 | |
|
1135 | 1136 | return fparent1 |
|
1136 | 1137 | |
|
1137 | 1138 | @unfilteredmethod |
|
1138 | 1139 | def commit(self, text="", user=None, date=None, match=None, force=False, |
|
1139 | 1140 | editor=False, extra={}): |
|
1140 | 1141 | """Add a new revision to current repository. |
|
1141 | 1142 | |
|
1142 | 1143 | Revision information is gathered from the working directory, |
|
1143 | 1144 | match can be used to filter the committed files. If editor is |
|
1144 | 1145 | supplied, it is called to get a commit message. |
|
1145 | 1146 | """ |
|
1146 | 1147 | |
|
1147 | 1148 | def fail(f, msg): |
|
1148 | 1149 | raise util.Abort('%s: %s' % (f, msg)) |
|
1149 | 1150 | |
|
1150 | 1151 | if not match: |
|
1151 | 1152 | match = matchmod.always(self.root, '') |
|
1152 | 1153 | |
|
1153 | 1154 | if not force: |
|
1154 | 1155 | vdirs = [] |
|
1155 | 1156 | match.explicitdir = vdirs.append |
|
1156 | 1157 | match.bad = fail |
|
1157 | 1158 | |
|
1158 | 1159 | wlock = self.wlock() |
|
1159 | 1160 | try: |
|
1160 | 1161 | wctx = self[None] |
|
1161 | 1162 | merge = len(wctx.parents()) > 1 |
|
1162 | 1163 | |
|
1163 | 1164 | if (not force and merge and match and |
|
1164 | 1165 | (match.files() or match.anypats())): |
|
1165 | 1166 | raise util.Abort(_('cannot partially commit a merge ' |
|
1166 | 1167 | '(do not specify files or patterns)')) |
|
1167 | 1168 | |
|
1168 | 1169 | changes = self.status(match=match, clean=force) |
|
1169 | 1170 | if force: |
|
1170 | 1171 | changes[0].extend(changes[6]) # mq may commit unchanged files |
|
1171 | 1172 | |
|
1172 | 1173 | # check subrepos |
|
1173 | 1174 | subs = [] |
|
1174 | 1175 | commitsubs = set() |
|
1175 | 1176 | newstate = wctx.substate.copy() |
|
1176 | 1177 | # only manage subrepos and .hgsubstate if .hgsub is present |
|
1177 | 1178 | if '.hgsub' in wctx: |
|
1178 | 1179 | # we'll decide whether to track this ourselves, thanks |
|
1179 | 1180 | if '.hgsubstate' in changes[0]: |
|
1180 | 1181 | changes[0].remove('.hgsubstate') |
|
1181 | 1182 | if '.hgsubstate' in changes[2]: |
|
1182 | 1183 | changes[2].remove('.hgsubstate') |
|
1183 | 1184 | |
|
1184 | 1185 | # compare current state to last committed state |
|
1185 | 1186 | # build new substate based on last committed state |
|
1186 | 1187 | oldstate = wctx.p1().substate |
|
1187 | 1188 | for s in sorted(newstate.keys()): |
|
1188 | 1189 | if not match(s): |
|
1189 | 1190 | # ignore working copy, use old state if present |
|
1190 | 1191 | if s in oldstate: |
|
1191 | 1192 | newstate[s] = oldstate[s] |
|
1192 | 1193 | continue |
|
1193 | 1194 | if not force: |
|
1194 | 1195 | raise util.Abort( |
|
1195 | 1196 | _("commit with new subrepo %s excluded") % s) |
|
1196 | 1197 | if wctx.sub(s).dirty(True): |
|
1197 | 1198 | if not self.ui.configbool('ui', 'commitsubrepos'): |
|
1198 | 1199 | raise util.Abort( |
|
1199 | 1200 | _("uncommitted changes in subrepo %s") % s, |
|
1200 | 1201 | hint=_("use --subrepos for recursive commit")) |
|
1201 | 1202 | subs.append(s) |
|
1202 | 1203 | commitsubs.add(s) |
|
1203 | 1204 | else: |
|
1204 | 1205 | bs = wctx.sub(s).basestate() |
|
1205 | 1206 | newstate[s] = (newstate[s][0], bs, newstate[s][2]) |
|
1206 | 1207 | if oldstate.get(s, (None, None, None))[1] != bs: |
|
1207 | 1208 | subs.append(s) |
|
1208 | 1209 | |
|
1209 | 1210 | # check for removed subrepos |
|
1210 | 1211 | for p in wctx.parents(): |
|
1211 | 1212 | r = [s for s in p.substate if s not in newstate] |
|
1212 | 1213 | subs += [s for s in r if match(s)] |
|
1213 | 1214 | if subs: |
|
1214 | 1215 | if (not match('.hgsub') and |
|
1215 | 1216 | '.hgsub' in (wctx.modified() + wctx.added())): |
|
1216 | 1217 | raise util.Abort( |
|
1217 | 1218 | _("can't commit subrepos without .hgsub")) |
|
1218 | 1219 | changes[0].insert(0, '.hgsubstate') |
|
1219 | 1220 | |
|
1220 | 1221 | elif '.hgsub' in changes[2]: |
|
1221 | 1222 | # clean up .hgsubstate when .hgsub is removed |
|
1222 | 1223 | if ('.hgsubstate' in wctx and |
|
1223 | 1224 | '.hgsubstate' not in changes[0] + changes[1] + changes[2]): |
|
1224 | 1225 | changes[2].insert(0, '.hgsubstate') |
|
1225 | 1226 | |
|
1226 | 1227 | # make sure all explicit patterns are matched |
|
1227 | 1228 | if not force and match.files(): |
|
1228 | 1229 | matched = set(changes[0] + changes[1] + changes[2]) |
|
1229 | 1230 | |
|
1230 | 1231 | for f in match.files(): |
|
1231 | 1232 | f = self.dirstate.normalize(f) |
|
1232 | 1233 | if f == '.' or f in matched or f in wctx.substate: |
|
1233 | 1234 | continue |
|
1234 | 1235 | if f in changes[3]: # missing |
|
1235 | 1236 | fail(f, _('file not found!')) |
|
1236 | 1237 | if f in vdirs: # visited directory |
|
1237 | 1238 | d = f + '/' |
|
1238 | 1239 | for mf in matched: |
|
1239 | 1240 | if mf.startswith(d): |
|
1240 | 1241 | break |
|
1241 | 1242 | else: |
|
1242 | 1243 | fail(f, _("no match under directory!")) |
|
1243 | 1244 | elif f not in self.dirstate: |
|
1244 | 1245 | fail(f, _("file not tracked!")) |
|
1245 | 1246 | |
|
1246 | 1247 | cctx = context.workingctx(self, text, user, date, extra, changes) |
|
1247 | 1248 | |
|
1248 | 1249 | if (not force and not extra.get("close") and not merge |
|
1249 | 1250 | and not cctx.files() |
|
1250 | 1251 | and wctx.branch() == wctx.p1().branch()): |
|
1251 | 1252 | return None |
|
1252 | 1253 | |
|
1253 | 1254 | if merge and cctx.deleted(): |
|
1254 | 1255 | raise util.Abort(_("cannot commit merge with missing files")) |
|
1255 | 1256 | |
|
1256 | 1257 | ms = mergemod.mergestate(self) |
|
1257 | 1258 | for f in changes[0]: |
|
1258 | 1259 | if f in ms and ms[f] == 'u': |
|
1259 | 1260 | raise util.Abort(_("unresolved merge conflicts " |
|
1260 | 1261 | "(see hg help resolve)")) |
|
1261 | 1262 | |
|
1262 | 1263 | if editor: |
|
1263 | 1264 | cctx._text = editor(self, cctx, subs) |
|
1264 | 1265 | edited = (text != cctx._text) |
|
1265 | 1266 | |
|
1266 | 1267 | # commit subs and write new state |
|
1267 | 1268 | if subs: |
|
1268 | 1269 | for s in sorted(commitsubs): |
|
1269 | 1270 | sub = wctx.sub(s) |
|
1270 | 1271 | self.ui.status(_('committing subrepository %s\n') % |
|
1271 | 1272 | subrepo.subrelpath(sub)) |
|
1272 | 1273 | sr = sub.commit(cctx._text, user, date) |
|
1273 | 1274 | newstate[s] = (newstate[s][0], sr) |
|
1274 | 1275 | subrepo.writestate(self, newstate) |
|
1275 | 1276 | |
|
1276 | 1277 | # Save commit message in case this transaction gets rolled back |
|
1277 | 1278 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
1278 | 1279 | # the assumption that the user will use the same editor again. |
|
1279 | 1280 | msgfn = self.savecommitmessage(cctx._text) |
|
1280 | 1281 | |
|
1281 | 1282 | p1, p2 = self.dirstate.parents() |
|
1282 | 1283 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1283 | 1284 | try: |
|
1284 | 1285 | self.hook("precommit", throw=True, parent1=hookp1, |
|
1285 | 1286 | parent2=hookp2) |
|
1286 | 1287 | ret = self.commitctx(cctx, True) |
|
1287 | 1288 | except: # re-raises |
|
1288 | 1289 | if edited: |
|
1289 | 1290 | self.ui.write( |
|
1290 | 1291 | _('note: commit message saved in %s\n') % msgfn) |
|
1291 | 1292 | raise |
|
1292 | 1293 | |
|
1293 | 1294 | # update bookmarks, dirstate and mergestate |
|
1294 | 1295 | bookmarks.update(self, [p1, p2], ret) |
|
1295 | 1296 | cctx.markcommitted(ret) |
|
1296 | 1297 | ms.reset() |
|
1297 | 1298 | finally: |
|
1298 | 1299 | wlock.release() |
|
1299 | 1300 | |
|
1300 | 1301 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): |
|
1301 | 1302 | self.hook("commit", node=node, parent1=parent1, parent2=parent2) |
|
1302 | 1303 | self._afterlock(commithook) |
|
1303 | 1304 | return ret |
|
1304 | 1305 | |
|
1305 | 1306 | @unfilteredmethod |
|
1306 | 1307 | def commitctx(self, ctx, error=False): |
|
1307 | 1308 | """Add a new revision to current repository. |
|
1308 | 1309 | Revision information is passed via the context argument. |
|
1309 | 1310 | """ |
|
1310 | 1311 | |
|
1311 | 1312 | tr = lock = None |
|
1312 | 1313 | removed = list(ctx.removed()) |
|
1313 | 1314 | p1, p2 = ctx.p1(), ctx.p2() |
|
1314 | 1315 | user = ctx.user() |
|
1315 | 1316 | |
|
1316 | 1317 | lock = self.lock() |
|
1317 | 1318 | try: |
|
1318 | 1319 | tr = self.transaction("commit") |
|
1319 | 1320 | trp = weakref.proxy(tr) |
|
1320 | 1321 | |
|
1321 | 1322 | if ctx.files(): |
|
1322 | 1323 | m1 = p1.manifest().copy() |
|
1323 | 1324 | m2 = p2.manifest() |
|
1324 | 1325 | |
|
1325 | 1326 | # check in files |
|
1326 | 1327 | new = {} |
|
1327 | 1328 | changed = [] |
|
1328 | 1329 | linkrev = len(self) |
|
1329 | 1330 | for f in sorted(ctx.modified() + ctx.added()): |
|
1330 | 1331 | self.ui.note(f + "\n") |
|
1331 | 1332 | try: |
|
1332 | 1333 | fctx = ctx[f] |
|
1333 | 1334 | new[f] = self._filecommit(fctx, m1, m2, linkrev, trp, |
|
1334 | 1335 | changed) |
|
1335 | 1336 | m1.set(f, fctx.flags()) |
|
1336 | 1337 | except OSError, inst: |
|
1337 | 1338 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1338 | 1339 | raise |
|
1339 | 1340 | except IOError, inst: |
|
1340 | 1341 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
1341 | 1342 | if error or errcode and errcode != errno.ENOENT: |
|
1342 | 1343 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1343 | 1344 | raise |
|
1344 | 1345 | else: |
|
1345 | 1346 | removed.append(f) |
|
1346 | 1347 | |
|
1347 | 1348 | # update manifest |
|
1348 | 1349 | m1.update(new) |
|
1349 | 1350 | removed = [f for f in sorted(removed) if f in m1 or f in m2] |
|
1350 | 1351 | drop = [f for f in removed if f in m1] |
|
1351 | 1352 | for f in drop: |
|
1352 | 1353 | del m1[f] |
|
1353 | 1354 | mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(), |
|
1354 | 1355 | p2.manifestnode(), (new, drop)) |
|
1355 | 1356 | files = changed + removed |
|
1356 | 1357 | else: |
|
1357 | 1358 | mn = p1.manifestnode() |
|
1358 | 1359 | files = [] |
|
1359 | 1360 | |
|
1360 | 1361 | # update changelog |
|
1361 | 1362 | self.changelog.delayupdate() |
|
1362 | 1363 | n = self.changelog.add(mn, files, ctx.description(), |
|
1363 | 1364 | trp, p1.node(), p2.node(), |
|
1364 | 1365 | user, ctx.date(), ctx.extra().copy()) |
|
1365 | 1366 | p = lambda: self.changelog.writepending() and self.root or "" |
|
1366 | 1367 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
1367 | 1368 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
1368 | 1369 | parent2=xp2, pending=p) |
|
1369 | 1370 | self.changelog.finalize(trp) |
|
1370 | 1371 | # set the new commit is proper phase |
|
1371 | 1372 | targetphase = subrepo.newcommitphase(self.ui, ctx) |
|
1372 | 1373 | if targetphase: |
|
1373 | 1374 | # retract boundary do not alter parent changeset. |
|
1374 | 1375 | # if a parent have higher the resulting phase will |
|
1375 | 1376 | # be compliant anyway |
|
1376 | 1377 | # |
|
1377 | 1378 | # if minimal phase was 0 we don't need to retract anything |
|
1378 | 1379 | phases.retractboundary(self, targetphase, [n]) |
|
1379 | 1380 | tr.close() |
|
1380 | 1381 | branchmap.updatecache(self.filtered('served')) |
|
1381 | 1382 | return n |
|
1382 | 1383 | finally: |
|
1383 | 1384 | if tr: |
|
1384 | 1385 | tr.release() |
|
1385 | 1386 | lock.release() |
|
1386 | 1387 | |
|
1387 | 1388 | @unfilteredmethod |
|
1388 | 1389 | def destroying(self): |
|
1389 | 1390 | '''Inform the repository that nodes are about to be destroyed. |
|
1390 | 1391 | Intended for use by strip and rollback, so there's a common |
|
1391 | 1392 | place for anything that has to be done before destroying history. |
|
1392 | 1393 | |
|
1393 | 1394 | This is mostly useful for saving state that is in memory and waiting |
|
1394 | 1395 | to be flushed when the current lock is released. Because a call to |
|
1395 | 1396 | destroyed is imminent, the repo will be invalidated causing those |
|
1396 | 1397 | changes to stay in memory (waiting for the next unlock), or vanish |
|
1397 | 1398 | completely. |
|
1398 | 1399 | ''' |
|
1399 | 1400 | # When using the same lock to commit and strip, the phasecache is left |
|
1400 | 1401 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
1401 | 1402 | # causing those changes to disappear. |
|
1402 | 1403 | if '_phasecache' in vars(self): |
|
1403 | 1404 | self._phasecache.write() |
|
1404 | 1405 | |
|
1405 | 1406 | @unfilteredmethod |
|
1406 | 1407 | def destroyed(self): |
|
1407 | 1408 | '''Inform the repository that nodes have been destroyed. |
|
1408 | 1409 | Intended for use by strip and rollback, so there's a common |
|
1409 | 1410 | place for anything that has to be done after destroying history. |
|
1410 | 1411 | ''' |
|
1411 | 1412 | # When one tries to: |
|
1412 | 1413 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
1413 | 1414 | # 2) use phasecache somewhere (e.g. commit) |
|
1414 | 1415 | # |
|
1415 | 1416 | # then 2) will fail because the phasecache contains nodes that were |
|
1416 | 1417 | # removed. We can either remove phasecache from the filecache, |
|
1417 | 1418 | # causing it to reload next time it is accessed, or simply filter |
|
1418 | 1419 | # the removed nodes now and write the updated cache. |
|
1419 | 1420 | self._phasecache.filterunknown(self) |
|
1420 | 1421 | self._phasecache.write() |
|
1421 | 1422 | |
|
1422 | 1423 | # update the 'served' branch cache to help read only server process |
|
1423 | 1424 | # Thanks to branchcache collaboration this is done from the nearest |
|
1424 | 1425 | # filtered subset and it is expected to be fast. |
|
1425 | 1426 | branchmap.updatecache(self.filtered('served')) |
|
1426 | 1427 | |
|
1427 | 1428 | # Ensure the persistent tag cache is updated. Doing it now |
|
1428 | 1429 | # means that the tag cache only has to worry about destroyed |
|
1429 | 1430 | # heads immediately after a strip/rollback. That in turn |
|
1430 | 1431 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
1431 | 1432 | # and node) always means no nodes have been added or destroyed. |
|
1432 | 1433 | |
|
1433 | 1434 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
1434 | 1435 | # head, refresh the tag cache, then immediately add a new head. |
|
1435 | 1436 | # But I think doing it this way is necessary for the "instant |
|
1436 | 1437 | # tag cache retrieval" case to work. |
|
1437 | 1438 | self.invalidate() |
|
1438 | 1439 | |
|
1439 | 1440 | def walk(self, match, node=None): |
|
1440 | 1441 | ''' |
|
1441 | 1442 | walk recursively through the directory tree or a given |
|
1442 | 1443 | changeset, finding all files matched by the match |
|
1443 | 1444 | function |
|
1444 | 1445 | ''' |
|
1445 | 1446 | return self[node].walk(match) |
|
1446 | 1447 | |
|
1447 | 1448 | def status(self, node1='.', node2=None, match=None, |
|
1448 | 1449 | ignored=False, clean=False, unknown=False, |
|
1449 | 1450 | listsubrepos=False): |
|
1450 | 1451 | """return status of files between two nodes or node and working |
|
1451 | 1452 | directory. |
|
1452 | 1453 | |
|
1453 | 1454 | If node1 is None, use the first dirstate parent instead. |
|
1454 | 1455 | If node2 is None, compare node1 with working directory. |
|
1455 | 1456 | """ |
|
1456 | 1457 | |
|
1457 | 1458 | def mfmatches(ctx): |
|
1458 | 1459 | mf = ctx.manifest().copy() |
|
1459 | 1460 | if match.always(): |
|
1460 | 1461 | return mf |
|
1461 | 1462 | for fn in mf.keys(): |
|
1462 | 1463 | if not match(fn): |
|
1463 | 1464 | del mf[fn] |
|
1464 | 1465 | return mf |
|
1465 | 1466 | |
|
1466 | 1467 | ctx1 = self[node1] |
|
1467 | 1468 | ctx2 = self[node2] |
|
1468 | 1469 | |
|
1469 | 1470 | working = ctx2.rev() is None |
|
1470 | 1471 | parentworking = working and ctx1 == self['.'] |
|
1471 | 1472 | match = match or matchmod.always(self.root, self.getcwd()) |
|
1472 | 1473 | listignored, listclean, listunknown = ignored, clean, unknown |
|
1473 | 1474 | |
|
1474 | 1475 | # load earliest manifest first for caching reasons |
|
1475 | 1476 | if not working and ctx2.rev() < ctx1.rev(): |
|
1476 | 1477 | ctx2.manifest() |
|
1477 | 1478 | |
|
1478 | 1479 | if not parentworking: |
|
1479 | 1480 | def bad(f, msg): |
|
1480 | 1481 | # 'f' may be a directory pattern from 'match.files()', |
|
1481 | 1482 | # so 'f not in ctx1' is not enough |
|
1482 | 1483 | if f not in ctx1 and f not in ctx1.dirs(): |
|
1483 | 1484 | self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg)) |
|
1484 | 1485 | match.bad = bad |
|
1485 | 1486 | |
|
1486 | 1487 | if working: # we need to scan the working dir |
|
1487 | 1488 | subrepos = [] |
|
1488 | 1489 | if '.hgsub' in self.dirstate: |
|
1489 | 1490 | subrepos = sorted(ctx2.substate) |
|
1490 | 1491 | s = self.dirstate.status(match, subrepos, listignored, |
|
1491 | 1492 | listclean, listunknown) |
|
1492 | 1493 | cmp, modified, added, removed, deleted, unknown, ignored, clean = s |
|
1493 | 1494 | |
|
1494 | 1495 | # check for any possibly clean files |
|
1495 | 1496 | if parentworking and cmp: |
|
1496 | 1497 | fixup = [] |
|
1497 | 1498 | # do a full compare of any files that might have changed |
|
1498 | 1499 | for f in sorted(cmp): |
|
1499 | 1500 | if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f) |
|
1500 | 1501 | or ctx1[f].cmp(ctx2[f])): |
|
1501 | 1502 | modified.append(f) |
|
1502 | 1503 | else: |
|
1503 | 1504 | fixup.append(f) |
|
1504 | 1505 | |
|
1505 | 1506 | # update dirstate for files that are actually clean |
|
1506 | 1507 | if fixup: |
|
1507 | 1508 | if listclean: |
|
1508 | 1509 | clean += fixup |
|
1509 | 1510 | |
|
1510 | 1511 | try: |
|
1511 | 1512 | # updating the dirstate is optional |
|
1512 | 1513 | # so we don't wait on the lock |
|
1513 | 1514 | wlock = self.wlock(False) |
|
1514 | 1515 | try: |
|
1515 | 1516 | for f in fixup: |
|
1516 | 1517 | self.dirstate.normal(f) |
|
1517 | 1518 | finally: |
|
1518 | 1519 | wlock.release() |
|
1519 | 1520 | except error.LockError: |
|
1520 | 1521 | pass |
|
1521 | 1522 | |
|
1522 | 1523 | if not parentworking: |
|
1523 | 1524 | mf1 = mfmatches(ctx1) |
|
1524 | 1525 | if working: |
|
1525 | 1526 | # we are comparing working dir against non-parent |
|
1526 | 1527 | # generate a pseudo-manifest for the working dir |
|
1527 | 1528 | mf2 = mfmatches(self['.']) |
|
1528 | 1529 | for f in cmp + modified + added: |
|
1529 | 1530 | mf2[f] = None |
|
1530 | 1531 | mf2.set(f, ctx2.flags(f)) |
|
1531 | 1532 | for f in removed: |
|
1532 | 1533 | if f in mf2: |
|
1533 | 1534 | del mf2[f] |
|
1534 | 1535 | else: |
|
1535 | 1536 | # we are comparing two revisions |
|
1536 | 1537 | deleted, unknown, ignored = [], [], [] |
|
1537 | 1538 | mf2 = mfmatches(ctx2) |
|
1538 | 1539 | |
|
1539 | 1540 | modified, added, clean = [], [], [] |
|
1540 | 1541 | withflags = mf1.withflags() | mf2.withflags() |
|
1541 | 1542 | for fn, mf2node in mf2.iteritems(): |
|
1542 | 1543 | if fn in mf1: |
|
1543 | 1544 | if (fn not in deleted and |
|
1544 | 1545 | ((fn in withflags and mf1.flags(fn) != mf2.flags(fn)) or |
|
1545 | 1546 | (mf1[fn] != mf2node and |
|
1546 | 1547 | (mf2node or ctx1[fn].cmp(ctx2[fn]))))): |
|
1547 | 1548 | modified.append(fn) |
|
1548 | 1549 | elif listclean: |
|
1549 | 1550 | clean.append(fn) |
|
1550 | 1551 | del mf1[fn] |
|
1551 | 1552 | elif fn not in deleted: |
|
1552 | 1553 | added.append(fn) |
|
1553 | 1554 | removed = mf1.keys() |
|
1554 | 1555 | |
|
1555 | 1556 | if working and modified and not self.dirstate._checklink: |
|
1556 | 1557 | # Symlink placeholders may get non-symlink-like contents |
|
1557 | 1558 | # via user error or dereferencing by NFS or Samba servers, |
|
1558 | 1559 | # so we filter out any placeholders that don't look like a |
|
1559 | 1560 | # symlink |
|
1560 | 1561 | sane = [] |
|
1561 | 1562 | for f in modified: |
|
1562 | 1563 | if ctx2.flags(f) == 'l': |
|
1563 | 1564 | d = ctx2[f].data() |
|
1564 | 1565 | if d == '' or len(d) >= 1024 or '\n' in d or util.binary(d): |
|
1565 | 1566 | self.ui.debug('ignoring suspect symlink placeholder' |
|
1566 | 1567 | ' "%s"\n' % f) |
|
1567 | 1568 | continue |
|
1568 | 1569 | sane.append(f) |
|
1569 | 1570 | modified = sane |
|
1570 | 1571 | |
|
1571 | 1572 | r = modified, added, removed, deleted, unknown, ignored, clean |
|
1572 | 1573 | |
|
1573 | 1574 | if listsubrepos: |
|
1574 | 1575 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): |
|
1575 | 1576 | if working: |
|
1576 | 1577 | rev2 = None |
|
1577 | 1578 | else: |
|
1578 | 1579 | rev2 = ctx2.substate[subpath][1] |
|
1579 | 1580 | try: |
|
1580 | 1581 | submatch = matchmod.narrowmatcher(subpath, match) |
|
1581 | 1582 | s = sub.status(rev2, match=submatch, ignored=listignored, |
|
1582 | 1583 | clean=listclean, unknown=listunknown, |
|
1583 | 1584 | listsubrepos=True) |
|
1584 | 1585 | for rfiles, sfiles in zip(r, s): |
|
1585 | 1586 | rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) |
|
1586 | 1587 | except error.LookupError: |
|
1587 | 1588 | self.ui.status(_("skipping missing subrepository: %s\n") |
|
1588 | 1589 | % subpath) |
|
1589 | 1590 | |
|
1590 | 1591 | for l in r: |
|
1591 | 1592 | l.sort() |
|
1592 | 1593 | return r |
|
1593 | 1594 | |
|
1594 | 1595 | def heads(self, start=None): |
|
1595 | 1596 | heads = self.changelog.heads(start) |
|
1596 | 1597 | # sort the output in rev descending order |
|
1597 | 1598 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
1598 | 1599 | |
|
1599 | 1600 | def branchheads(self, branch=None, start=None, closed=False): |
|
1600 | 1601 | '''return a (possibly filtered) list of heads for the given branch |
|
1601 | 1602 | |
|
1602 | 1603 | Heads are returned in topological order, from newest to oldest. |
|
1603 | 1604 | If branch is None, use the dirstate branch. |
|
1604 | 1605 | If start is not None, return only heads reachable from start. |
|
1605 | 1606 | If closed is True, return heads that are marked as closed as well. |
|
1606 | 1607 | ''' |
|
1607 | 1608 | if branch is None: |
|
1608 | 1609 | branch = self[None].branch() |
|
1609 | 1610 | branches = self.branchmap() |
|
1610 | 1611 | if branch not in branches: |
|
1611 | 1612 | return [] |
|
1612 | 1613 | # the cache returns heads ordered lowest to highest |
|
1613 | 1614 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
1614 | 1615 | if start is not None: |
|
1615 | 1616 | # filter out the heads that cannot be reached from startrev |
|
1616 | 1617 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
1617 | 1618 | bheads = [h for h in bheads if h in fbheads] |
|
1618 | 1619 | return bheads |
|
1619 | 1620 | |
|
1620 | 1621 | def branches(self, nodes): |
|
1621 | 1622 | if not nodes: |
|
1622 | 1623 | nodes = [self.changelog.tip()] |
|
1623 | 1624 | b = [] |
|
1624 | 1625 | for n in nodes: |
|
1625 | 1626 | t = n |
|
1626 | 1627 | while True: |
|
1627 | 1628 | p = self.changelog.parents(n) |
|
1628 | 1629 | if p[1] != nullid or p[0] == nullid: |
|
1629 | 1630 | b.append((t, n, p[0], p[1])) |
|
1630 | 1631 | break |
|
1631 | 1632 | n = p[0] |
|
1632 | 1633 | return b |
|
1633 | 1634 | |
|
1634 | 1635 | def between(self, pairs): |
|
1635 | 1636 | r = [] |
|
1636 | 1637 | |
|
1637 | 1638 | for top, bottom in pairs: |
|
1638 | 1639 | n, l, i = top, [], 0 |
|
1639 | 1640 | f = 1 |
|
1640 | 1641 | |
|
1641 | 1642 | while n != bottom and n != nullid: |
|
1642 | 1643 | p = self.changelog.parents(n)[0] |
|
1643 | 1644 | if i == f: |
|
1644 | 1645 | l.append(n) |
|
1645 | 1646 | f = f * 2 |
|
1646 | 1647 | n = p |
|
1647 | 1648 | i += 1 |
|
1648 | 1649 | |
|
1649 | 1650 | r.append(l) |
|
1650 | 1651 | |
|
1651 | 1652 | return r |
|
1652 | 1653 | |
|
1653 | 1654 | def pull(self, remote, heads=None, force=False): |
|
1654 | 1655 | if remote.local(): |
|
1655 | 1656 | missing = set(remote.requirements) - self.supported |
|
1656 | 1657 | if missing: |
|
1657 | 1658 | msg = _("required features are not" |
|
1658 | 1659 | " supported in the destination:" |
|
1659 | 1660 | " %s") % (', '.join(sorted(missing))) |
|
1660 | 1661 | raise util.Abort(msg) |
|
1661 | 1662 | |
|
1662 | 1663 | # don't open transaction for nothing or you break future useful |
|
1663 | 1664 | # rollback call |
|
1664 | 1665 | tr = None |
|
1665 | 1666 | trname = 'pull\n' + util.hidepassword(remote.url()) |
|
1666 | 1667 | lock = self.lock() |
|
1667 | 1668 | try: |
|
1668 | 1669 | tmp = discovery.findcommonincoming(self.unfiltered(), remote, |
|
1669 | 1670 | heads=heads, force=force) |
|
1670 | 1671 | common, fetch, rheads = tmp |
|
1671 | 1672 | if not fetch: |
|
1672 | 1673 | self.ui.status(_("no changes found\n")) |
|
1673 | 1674 | result = 0 |
|
1674 | 1675 | else: |
|
1675 | 1676 | tr = self.transaction(trname) |
|
1676 | 1677 | if heads is None and list(common) == [nullid]: |
|
1677 | 1678 | self.ui.status(_("requesting all changes\n")) |
|
1678 | 1679 | elif heads is None and remote.capable('changegroupsubset'): |
|
1679 | 1680 | # issue1320, avoid a race if remote changed after discovery |
|
1680 | 1681 | heads = rheads |
|
1681 | 1682 | |
|
1682 | 1683 | if remote.capable('getbundle'): |
|
1683 | 1684 | # TODO: get bundlecaps from remote |
|
1684 | 1685 | cg = remote.getbundle('pull', common=common, |
|
1685 | 1686 | heads=heads or rheads) |
|
1686 | 1687 | elif heads is None: |
|
1687 | 1688 | cg = remote.changegroup(fetch, 'pull') |
|
1688 | 1689 | elif not remote.capable('changegroupsubset'): |
|
1689 | 1690 | raise util.Abort(_("partial pull cannot be done because " |
|
1690 | 1691 | "other repository doesn't support " |
|
1691 | 1692 | "changegroupsubset.")) |
|
1692 | 1693 | else: |
|
1693 | 1694 | cg = remote.changegroupsubset(fetch, heads, 'pull') |
|
1694 | 1695 | # we use unfiltered changelog here because hidden revision must |
|
1695 | 1696 | # be taken in account for phase synchronization. They may |
|
1696 | 1697 | # becomes public and becomes visible again. |
|
1697 | 1698 | result = self.addchangegroup(cg, 'pull', remote.url()) |
|
1698 | 1699 | |
|
1699 | 1700 | # compute target subset |
|
1700 | 1701 | if heads is None: |
|
1701 | 1702 | # We pulled every thing possible |
|
1702 | 1703 | # sync on everything common |
|
1703 | 1704 | subset = common + rheads |
|
1704 | 1705 | else: |
|
1705 | 1706 | # We pulled a specific subset |
|
1706 | 1707 | # sync on this subset |
|
1707 | 1708 | subset = heads |
|
1708 | 1709 | |
|
1709 | 1710 | # Get remote phases data from remote |
|
1710 | 1711 | remotephases = remote.listkeys('phases') |
|
1711 | 1712 | publishing = bool(remotephases.get('publishing', False)) |
|
1712 | 1713 | if remotephases and not publishing: |
|
1713 | 1714 | # remote is new and unpublishing |
|
1714 | 1715 | pheads, _dr = phases.analyzeremotephases(self, subset, |
|
1715 | 1716 | remotephases) |
|
1716 | 1717 | phases.advanceboundary(self, phases.public, pheads) |
|
1717 | 1718 | phases.advanceboundary(self, phases.draft, subset) |
|
1718 | 1719 | else: |
|
1719 | 1720 | # Remote is old or publishing all common changesets |
|
1720 | 1721 | # should be seen as public |
|
1721 | 1722 | phases.advanceboundary(self, phases.public, subset) |
|
1722 | 1723 | |
|
1723 | 1724 | def gettransaction(): |
|
1724 | 1725 | if tr is None: |
|
1725 | 1726 | return self.transaction(trname) |
|
1726 | 1727 | return tr |
|
1727 | 1728 | |
|
1728 | 1729 | obstr = obsolete.syncpull(self, remote, gettransaction) |
|
1729 | 1730 | if obstr is not None: |
|
1730 | 1731 | tr = obstr |
|
1731 | 1732 | |
|
1732 | 1733 | if tr is not None: |
|
1733 | 1734 | tr.close() |
|
1734 | 1735 | finally: |
|
1735 | 1736 | if tr is not None: |
|
1736 | 1737 | tr.release() |
|
1737 | 1738 | lock.release() |
|
1738 | 1739 | |
|
1739 | 1740 | return result |
|
1740 | 1741 | |
|
1741 | 1742 | def checkpush(self, force, revs): |
|
1742 | 1743 | """Extensions can override this function if additional checks have |
|
1743 | 1744 | to be performed before pushing, or call it if they override push |
|
1744 | 1745 | command. |
|
1745 | 1746 | """ |
|
1746 | 1747 | pass |
|
1747 | 1748 | |
|
1748 | 1749 | def push(self, remote, force=False, revs=None, newbranch=False): |
|
1749 | 1750 | '''Push outgoing changesets (limited by revs) from the current |
|
1750 | 1751 | repository to remote. Return an integer: |
|
1751 | 1752 | - None means nothing to push |
|
1752 | 1753 | - 0 means HTTP error |
|
1753 | 1754 | - 1 means we pushed and remote head count is unchanged *or* |
|
1754 | 1755 | we have outgoing changesets but refused to push |
|
1755 | 1756 | - other values as described by addchangegroup() |
|
1756 | 1757 | ''' |
|
1757 | 1758 | if remote.local(): |
|
1758 | 1759 | missing = set(self.requirements) - remote.local().supported |
|
1759 | 1760 | if missing: |
|
1760 | 1761 | msg = _("required features are not" |
|
1761 | 1762 | " supported in the destination:" |
|
1762 | 1763 | " %s") % (', '.join(sorted(missing))) |
|
1763 | 1764 | raise util.Abort(msg) |
|
1764 | 1765 | |
|
1765 | 1766 | # there are two ways to push to remote repo: |
|
1766 | 1767 | # |
|
1767 | 1768 | # addchangegroup assumes local user can lock remote |
|
1768 | 1769 | # repo (local filesystem, old ssh servers). |
|
1769 | 1770 | # |
|
1770 | 1771 | # unbundle assumes local user cannot lock remote repo (new ssh |
|
1771 | 1772 | # servers, http servers). |
|
1772 | 1773 | |
|
1773 | 1774 | if not remote.canpush(): |
|
1774 | 1775 | raise util.Abort(_("destination does not support push")) |
|
1775 | 1776 | unfi = self.unfiltered() |
|
1776 | 1777 | def localphasemove(nodes, phase=phases.public): |
|
1777 | 1778 | """move <nodes> to <phase> in the local source repo""" |
|
1778 | 1779 | if locallock is not None: |
|
1779 | 1780 | phases.advanceboundary(self, phase, nodes) |
|
1780 | 1781 | else: |
|
1781 | 1782 | # repo is not locked, do not change any phases! |
|
1782 | 1783 | # Informs the user that phases should have been moved when |
|
1783 | 1784 | # applicable. |
|
1784 | 1785 | actualmoves = [n for n in nodes if phase < self[n].phase()] |
|
1785 | 1786 | phasestr = phases.phasenames[phase] |
|
1786 | 1787 | if actualmoves: |
|
1787 | 1788 | self.ui.status(_('cannot lock source repo, skipping local' |
|
1788 | 1789 | ' %s phase update\n') % phasestr) |
|
1789 | 1790 | # get local lock as we might write phase data |
|
1790 | 1791 | locallock = None |
|
1791 | 1792 | try: |
|
1792 | 1793 | locallock = self.lock() |
|
1793 | 1794 | except IOError, err: |
|
1794 | 1795 | if err.errno != errno.EACCES: |
|
1795 | 1796 | raise |
|
1796 | 1797 | # source repo cannot be locked. |
|
1797 | 1798 | # We do not abort the push, but just disable the local phase |
|
1798 | 1799 | # synchronisation. |
|
1799 | 1800 | msg = 'cannot lock source repository: %s\n' % err |
|
1800 | 1801 | self.ui.debug(msg) |
|
1801 | 1802 | try: |
|
1802 | 1803 | self.checkpush(force, revs) |
|
1803 | 1804 | lock = None |
|
1804 | 1805 | unbundle = remote.capable('unbundle') |
|
1805 | 1806 | if not unbundle: |
|
1806 | 1807 | lock = remote.lock() |
|
1807 | 1808 | try: |
|
1808 | 1809 | # discovery |
|
1809 | 1810 | fci = discovery.findcommonincoming |
|
1810 | 1811 | commoninc = fci(unfi, remote, force=force) |
|
1811 | 1812 | common, inc, remoteheads = commoninc |
|
1812 | 1813 | fco = discovery.findcommonoutgoing |
|
1813 | 1814 | outgoing = fco(unfi, remote, onlyheads=revs, |
|
1814 | 1815 | commoninc=commoninc, force=force) |
|
1815 | 1816 | |
|
1816 | 1817 | |
|
1817 | 1818 | if not outgoing.missing: |
|
1818 | 1819 | # nothing to push |
|
1819 | 1820 | scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) |
|
1820 | 1821 | ret = None |
|
1821 | 1822 | else: |
|
1822 | 1823 | # something to push |
|
1823 | 1824 | if not force: |
|
1824 | 1825 | # if self.obsstore == False --> no obsolete |
|
1825 | 1826 | # then, save the iteration |
|
1826 | 1827 | if unfi.obsstore: |
|
1827 | 1828 | # this message are here for 80 char limit reason |
|
1828 | 1829 | mso = _("push includes obsolete changeset: %s!") |
|
1829 | 1830 | mst = "push includes %s changeset: %s!" |
|
1830 | 1831 | # plain versions for i18n tool to detect them |
|
1831 | 1832 | _("push includes unstable changeset: %s!") |
|
1832 | 1833 | _("push includes bumped changeset: %s!") |
|
1833 | 1834 | _("push includes divergent changeset: %s!") |
|
1834 | 1835 | # If we are to push if there is at least one |
|
1835 | 1836 | # obsolete or unstable changeset in missing, at |
|
1836 | 1837 | # least one of the missinghead will be obsolete or |
|
1837 | 1838 | # unstable. So checking heads only is ok |
|
1838 | 1839 | for node in outgoing.missingheads: |
|
1839 | 1840 | ctx = unfi[node] |
|
1840 | 1841 | if ctx.obsolete(): |
|
1841 | 1842 | raise util.Abort(mso % ctx) |
|
1842 | 1843 | elif ctx.troubled(): |
|
1843 | 1844 | raise util.Abort(_(mst) |
|
1844 | 1845 | % (ctx.troubles()[0], |
|
1845 | 1846 | ctx)) |
|
1846 | 1847 | newbm = self.ui.configlist('bookmarks', 'pushing') |
|
1847 | 1848 | discovery.checkheads(unfi, remote, outgoing, |
|
1848 | 1849 | remoteheads, newbranch, |
|
1849 | 1850 | bool(inc), newbm) |
|
1850 | 1851 | |
|
1851 | 1852 | # TODO: get bundlecaps from remote |
|
1852 | 1853 | bundlecaps = None |
|
1853 | 1854 | # create a changegroup from local |
|
1854 | 1855 | if revs is None and not (outgoing.excluded |
|
1855 | 1856 | or self.changelog.filteredrevs): |
|
1856 | 1857 | # push everything, |
|
1857 | 1858 | # use the fast path, no race possible on push |
|
1858 | 1859 | bundler = changegroup.bundle10(self, bundlecaps) |
|
1859 | 1860 | cg = self._changegroupsubset(outgoing, |
|
1860 | 1861 | bundler, |
|
1861 | 1862 | 'push', |
|
1862 | 1863 | fastpath=True) |
|
1863 | 1864 | else: |
|
1864 | 1865 | cg = self.getlocalbundle('push', outgoing, bundlecaps) |
|
1865 | 1866 | |
|
1866 | 1867 | # apply changegroup to remote |
|
1867 | 1868 | if unbundle: |
|
1868 | 1869 | # local repo finds heads on server, finds out what |
|
1869 | 1870 | # revs it must push. once revs transferred, if server |
|
1870 | 1871 | # finds it has different heads (someone else won |
|
1871 | 1872 | # commit/push race), server aborts. |
|
1872 | 1873 | if force: |
|
1873 | 1874 | remoteheads = ['force'] |
|
1874 | 1875 | # ssh: return remote's addchangegroup() |
|
1875 | 1876 | # http: return remote's addchangegroup() or 0 for error |
|
1876 | 1877 | ret = remote.unbundle(cg, remoteheads, 'push') |
|
1877 | 1878 | else: |
|
1878 | 1879 | # we return an integer indicating remote head count |
|
1879 | 1880 | # change |
|
1880 | 1881 | ret = remote.addchangegroup(cg, 'push', self.url()) |
|
1881 | 1882 | |
|
1882 | 1883 | if ret: |
|
1883 | 1884 | # push succeed, synchronize target of the push |
|
1884 | 1885 | cheads = outgoing.missingheads |
|
1885 | 1886 | elif revs is None: |
|
1886 | 1887 | # All out push fails. synchronize all common |
|
1887 | 1888 | cheads = outgoing.commonheads |
|
1888 | 1889 | else: |
|
1889 | 1890 | # I want cheads = heads(::missingheads and ::commonheads) |
|
1890 | 1891 | # (missingheads is revs with secret changeset filtered out) |
|
1891 | 1892 | # |
|
1892 | 1893 | # This can be expressed as: |
|
1893 | 1894 | # cheads = ( (missingheads and ::commonheads) |
|
1894 | 1895 | # + (commonheads and ::missingheads))" |
|
1895 | 1896 | # ) |
|
1896 | 1897 | # |
|
1897 | 1898 | # while trying to push we already computed the following: |
|
1898 | 1899 | # common = (::commonheads) |
|
1899 | 1900 | # missing = ((commonheads::missingheads) - commonheads) |
|
1900 | 1901 | # |
|
1901 | 1902 | # We can pick: |
|
1902 | 1903 | # * missingheads part of common (::commonheads) |
|
1903 | 1904 | common = set(outgoing.common) |
|
1904 | 1905 | cheads = [node for node in revs if node in common] |
|
1905 | 1906 | # and |
|
1906 | 1907 | # * commonheads parents on missing |
|
1907 | 1908 | revset = unfi.set('%ln and parents(roots(%ln))', |
|
1908 | 1909 | outgoing.commonheads, |
|
1909 | 1910 | outgoing.missing) |
|
1910 | 1911 | cheads.extend(c.node() for c in revset) |
|
1911 | 1912 | # even when we don't push, exchanging phase data is useful |
|
1912 | 1913 | remotephases = remote.listkeys('phases') |
|
1913 | 1914 | if (self.ui.configbool('ui', '_usedassubrepo', False) |
|
1914 | 1915 | and remotephases # server supports phases |
|
1915 | 1916 | and ret is None # nothing was pushed |
|
1916 | 1917 | and remotephases.get('publishing', False)): |
|
1917 | 1918 | # When: |
|
1918 | 1919 | # - this is a subrepo push |
|
1919 | 1920 | # - and remote support phase |
|
1920 | 1921 | # - and no changeset was pushed |
|
1921 | 1922 | # - and remote is publishing |
|
1922 | 1923 | # We may be in issue 3871 case! |
|
1923 | 1924 | # We drop the possible phase synchronisation done by |
|
1924 | 1925 | # courtesy to publish changesets possibly locally draft |
|
1925 | 1926 | # on the remote. |
|
1926 | 1927 | remotephases = {'publishing': 'True'} |
|
1927 | 1928 | if not remotephases: # old server or public only repo |
|
1928 | 1929 | localphasemove(cheads) |
|
1929 | 1930 | # don't push any phase data as there is nothing to push |
|
1930 | 1931 | else: |
|
1931 | 1932 | ana = phases.analyzeremotephases(self, cheads, remotephases) |
|
1932 | 1933 | pheads, droots = ana |
|
1933 | 1934 | ### Apply remote phase on local |
|
1934 | 1935 | if remotephases.get('publishing', False): |
|
1935 | 1936 | localphasemove(cheads) |
|
1936 | 1937 | else: # publish = False |
|
1937 | 1938 | localphasemove(pheads) |
|
1938 | 1939 | localphasemove(cheads, phases.draft) |
|
1939 | 1940 | ### Apply local phase on remote |
|
1940 | 1941 | |
|
1941 | 1942 | # Get the list of all revs draft on remote by public here. |
|
1942 | 1943 | # XXX Beware that revset break if droots is not strictly |
|
1943 | 1944 | # XXX root we may want to ensure it is but it is costly |
|
1944 | 1945 | outdated = unfi.set('heads((%ln::%ln) and public())', |
|
1945 | 1946 | droots, cheads) |
|
1946 | 1947 | for newremotehead in outdated: |
|
1947 | 1948 | r = remote.pushkey('phases', |
|
1948 | 1949 | newremotehead.hex(), |
|
1949 | 1950 | str(phases.draft), |
|
1950 | 1951 | str(phases.public)) |
|
1951 | 1952 | if not r: |
|
1952 | 1953 | self.ui.warn(_('updating %s to public failed!\n') |
|
1953 | 1954 | % newremotehead) |
|
1954 | 1955 | self.ui.debug('try to push obsolete markers to remote\n') |
|
1955 | 1956 | obsolete.syncpush(self, remote) |
|
1956 | 1957 | finally: |
|
1957 | 1958 | if lock is not None: |
|
1958 | 1959 | lock.release() |
|
1959 | 1960 | finally: |
|
1960 | 1961 | if locallock is not None: |
|
1961 | 1962 | locallock.release() |
|
1962 | 1963 | |
|
1963 | 1964 | bookmarks.updateremote(self.ui, unfi, remote, revs) |
|
1964 | 1965 | return ret |
|
1965 | 1966 | |
|
1966 | 1967 | def changegroupinfo(self, nodes, source): |
|
1967 | 1968 | if self.ui.verbose or source == 'bundle': |
|
1968 | 1969 | self.ui.status(_("%d changesets found\n") % len(nodes)) |
|
1969 | 1970 | if self.ui.debugflag: |
|
1970 | 1971 | self.ui.debug("list of changesets:\n") |
|
1971 | 1972 | for node in nodes: |
|
1972 | 1973 | self.ui.debug("%s\n" % hex(node)) |
|
1973 | 1974 | |
|
1974 | 1975 | def changegroupsubset(self, bases, heads, source): |
|
1975 | 1976 | """Compute a changegroup consisting of all the nodes that are |
|
1976 | 1977 | descendants of any of the bases and ancestors of any of the heads. |
|
1977 | 1978 | Return a chunkbuffer object whose read() method will return |
|
1978 | 1979 | successive changegroup chunks. |
|
1979 | 1980 | |
|
1980 | 1981 | It is fairly complex as determining which filenodes and which |
|
1981 | 1982 | manifest nodes need to be included for the changeset to be complete |
|
1982 | 1983 | is non-trivial. |
|
1983 | 1984 | |
|
1984 | 1985 | Another wrinkle is doing the reverse, figuring out which changeset in |
|
1985 | 1986 | the changegroup a particular filenode or manifestnode belongs to. |
|
1986 | 1987 | """ |
|
1987 | 1988 | cl = self.changelog |
|
1988 | 1989 | if not bases: |
|
1989 | 1990 | bases = [nullid] |
|
1990 | 1991 | # TODO: remove call to nodesbetween. |
|
1991 | 1992 | csets, bases, heads = cl.nodesbetween(bases, heads) |
|
1992 | 1993 | discbases = [] |
|
1993 | 1994 | for n in bases: |
|
1994 | 1995 | discbases.extend([p for p in cl.parents(n) if p != nullid]) |
|
1995 | 1996 | outgoing = discovery.outgoing(cl, discbases, heads) |
|
1996 | 1997 | bundler = changegroup.bundle10(self) |
|
1997 | 1998 | return self._changegroupsubset(outgoing, bundler, source) |
|
1998 | 1999 | |
|
1999 | 2000 | def getlocalbundle(self, source, outgoing, bundlecaps=None): |
|
2000 | 2001 | """Like getbundle, but taking a discovery.outgoing as an argument. |
|
2001 | 2002 | |
|
2002 | 2003 | This is only implemented for local repos and reuses potentially |
|
2003 | 2004 | precomputed sets in outgoing.""" |
|
2004 | 2005 | if not outgoing.missing: |
|
2005 | 2006 | return None |
|
2006 | 2007 | bundler = changegroup.bundle10(self, bundlecaps) |
|
2007 | 2008 | return self._changegroupsubset(outgoing, bundler, source) |
|
2008 | 2009 | |
|
2009 | 2010 | def getbundle(self, source, heads=None, common=None, bundlecaps=None): |
|
2010 | 2011 | """Like changegroupsubset, but returns the set difference between the |
|
2011 | 2012 | ancestors of heads and the ancestors common. |
|
2012 | 2013 | |
|
2013 | 2014 | If heads is None, use the local heads. If common is None, use [nullid]. |
|
2014 | 2015 | |
|
2015 | 2016 | The nodes in common might not all be known locally due to the way the |
|
2016 | 2017 | current discovery protocol works. |
|
2017 | 2018 | """ |
|
2018 | 2019 | cl = self.changelog |
|
2019 | 2020 | if common: |
|
2020 | 2021 | hasnode = cl.hasnode |
|
2021 | 2022 | common = [n for n in common if hasnode(n)] |
|
2022 | 2023 | else: |
|
2023 | 2024 | common = [nullid] |
|
2024 | 2025 | if not heads: |
|
2025 | 2026 | heads = cl.heads() |
|
2026 | 2027 | return self.getlocalbundle(source, |
|
2027 | 2028 | discovery.outgoing(cl, common, heads), |
|
2028 | 2029 | bundlecaps=bundlecaps) |
|
2029 | 2030 | |
|
2030 | 2031 | @unfilteredmethod |
|
2031 | 2032 | def _changegroupsubset(self, outgoing, bundler, source, |
|
2032 | 2033 | fastpath=False): |
|
2033 | 2034 | commonrevs = outgoing.common |
|
2034 | 2035 | csets = outgoing.missing |
|
2035 | 2036 | heads = outgoing.missingheads |
|
2036 | 2037 | # We go through the fast path if we get told to, or if all (unfiltered |
|
2037 | 2038 | # heads have been requested (since we then know there all linkrevs will |
|
2038 | 2039 | # be pulled by the client). |
|
2039 | 2040 | heads.sort() |
|
2040 | 2041 | fastpathlinkrev = fastpath or ( |
|
2041 | 2042 | self.filtername is None and heads == sorted(self.heads())) |
|
2042 | 2043 | |
|
2043 | 2044 | self.hook('preoutgoing', throw=True, source=source) |
|
2044 | 2045 | self.changegroupinfo(csets, source) |
|
2045 | 2046 | gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source) |
|
2046 | 2047 | return changegroup.unbundle10(util.chunkbuffer(gengroup), 'UN') |
|
2047 | 2048 | |
|
2048 | 2049 | def changegroup(self, basenodes, source): |
|
2049 | 2050 | # to avoid a race we use changegroupsubset() (issue1320) |
|
2050 | 2051 | return self.changegroupsubset(basenodes, self.heads(), source) |
|
2051 | 2052 | |
|
2052 | 2053 | @unfilteredmethod |
|
2053 | 2054 | def addchangegroup(self, source, srctype, url, emptyok=False): |
|
2054 | 2055 | """Add the changegroup returned by source.read() to this repo. |
|
2055 | 2056 | srctype is a string like 'push', 'pull', or 'unbundle'. url is |
|
2056 | 2057 | the URL of the repo where this changegroup is coming from. |
|
2057 | 2058 | |
|
2058 | 2059 | Return an integer summarizing the change to this repo: |
|
2059 | 2060 | - nothing changed or no source: 0 |
|
2060 | 2061 | - more heads than before: 1+added heads (2..n) |
|
2061 | 2062 | - fewer heads than before: -1-removed heads (-2..-n) |
|
2062 | 2063 | - number of heads stays the same: 1 |
|
2063 | 2064 | """ |
|
2064 | 2065 | def csmap(x): |
|
2065 | 2066 | self.ui.debug("add changeset %s\n" % short(x)) |
|
2066 | 2067 | return len(cl) |
|
2067 | 2068 | |
|
2068 | 2069 | def revmap(x): |
|
2069 | 2070 | return cl.rev(x) |
|
2070 | 2071 | |
|
2071 | 2072 | if not source: |
|
2072 | 2073 | return 0 |
|
2073 | 2074 | |
|
2074 | 2075 | self.hook('prechangegroup', throw=True, source=srctype, url=url) |
|
2075 | 2076 | |
|
2076 | 2077 | changesets = files = revisions = 0 |
|
2077 | 2078 | efiles = set() |
|
2078 | 2079 | |
|
2079 | 2080 | # write changelog data to temp files so concurrent readers will not see |
|
2080 | 2081 | # inconsistent view |
|
2081 | 2082 | cl = self.changelog |
|
2082 | 2083 | cl.delayupdate() |
|
2083 | 2084 | oldheads = cl.heads() |
|
2084 | 2085 | |
|
2085 | 2086 | tr = self.transaction("\n".join([srctype, util.hidepassword(url)])) |
|
2086 | 2087 | try: |
|
2087 | 2088 | trp = weakref.proxy(tr) |
|
2088 | 2089 | # pull off the changeset group |
|
2089 | 2090 | self.ui.status(_("adding changesets\n")) |
|
2090 | 2091 | clstart = len(cl) |
|
2091 | 2092 | class prog(object): |
|
2092 | 2093 | step = _('changesets') |
|
2093 | 2094 | count = 1 |
|
2094 | 2095 | ui = self.ui |
|
2095 | 2096 | total = None |
|
2096 | 2097 | def __call__(self): |
|
2097 | 2098 | self.ui.progress(self.step, self.count, unit=_('chunks'), |
|
2098 | 2099 | total=self.total) |
|
2099 | 2100 | self.count += 1 |
|
2100 | 2101 | pr = prog() |
|
2101 | 2102 | source.callback = pr |
|
2102 | 2103 | |
|
2103 | 2104 | source.changelogheader() |
|
2104 | 2105 | srccontent = cl.addgroup(source, csmap, trp) |
|
2105 | 2106 | if not (srccontent or emptyok): |
|
2106 | 2107 | raise util.Abort(_("received changelog group is empty")) |
|
2107 | 2108 | clend = len(cl) |
|
2108 | 2109 | changesets = clend - clstart |
|
2109 | 2110 | for c in xrange(clstart, clend): |
|
2110 | 2111 | efiles.update(self[c].files()) |
|
2111 | 2112 | efiles = len(efiles) |
|
2112 | 2113 | self.ui.progress(_('changesets'), None) |
|
2113 | 2114 | |
|
2114 | 2115 | # pull off the manifest group |
|
2115 | 2116 | self.ui.status(_("adding manifests\n")) |
|
2116 | 2117 | pr.step = _('manifests') |
|
2117 | 2118 | pr.count = 1 |
|
2118 | 2119 | pr.total = changesets # manifests <= changesets |
|
2119 | 2120 | # no need to check for empty manifest group here: |
|
2120 | 2121 | # if the result of the merge of 1 and 2 is the same in 3 and 4, |
|
2121 | 2122 | # no new manifest will be created and the manifest group will |
|
2122 | 2123 | # be empty during the pull |
|
2123 | 2124 | source.manifestheader() |
|
2124 | 2125 | self.manifest.addgroup(source, revmap, trp) |
|
2125 | 2126 | self.ui.progress(_('manifests'), None) |
|
2126 | 2127 | |
|
2127 | 2128 | needfiles = {} |
|
2128 | 2129 | if self.ui.configbool('server', 'validate', default=False): |
|
2129 | 2130 | # validate incoming csets have their manifests |
|
2130 | 2131 | for cset in xrange(clstart, clend): |
|
2131 | 2132 | mfest = self.changelog.read(self.changelog.node(cset))[0] |
|
2132 | 2133 | mfest = self.manifest.readdelta(mfest) |
|
2133 | 2134 | # store file nodes we must see |
|
2134 | 2135 | for f, n in mfest.iteritems(): |
|
2135 | 2136 | needfiles.setdefault(f, set()).add(n) |
|
2136 | 2137 | |
|
2137 | 2138 | # process the files |
|
2138 | 2139 | self.ui.status(_("adding file changes\n")) |
|
2139 | 2140 | pr.step = _('files') |
|
2140 | 2141 | pr.count = 1 |
|
2141 | 2142 | pr.total = efiles |
|
2142 | 2143 | source.callback = None |
|
2143 | 2144 | |
|
2144 | 2145 | newrevs, newfiles = self.addchangegroupfiles(source, revmap, trp, |
|
2145 | 2146 | pr, needfiles) |
|
2146 | 2147 | revisions += newrevs |
|
2147 | 2148 | files += newfiles |
|
2148 | 2149 | |
|
2149 | 2150 | dh = 0 |
|
2150 | 2151 | if oldheads: |
|
2151 | 2152 | heads = cl.heads() |
|
2152 | 2153 | dh = len(heads) - len(oldheads) |
|
2153 | 2154 | for h in heads: |
|
2154 | 2155 | if h not in oldheads and self[h].closesbranch(): |
|
2155 | 2156 | dh -= 1 |
|
2156 | 2157 | htext = "" |
|
2157 | 2158 | if dh: |
|
2158 | 2159 | htext = _(" (%+d heads)") % dh |
|
2159 | 2160 | |
|
2160 | 2161 | self.ui.status(_("added %d changesets" |
|
2161 | 2162 | " with %d changes to %d files%s\n") |
|
2162 | 2163 | % (changesets, revisions, files, htext)) |
|
2163 | 2164 | self.invalidatevolatilesets() |
|
2164 | 2165 | |
|
2165 | 2166 | if changesets > 0: |
|
2166 | 2167 | p = lambda: cl.writepending() and self.root or "" |
|
2167 | 2168 | self.hook('pretxnchangegroup', throw=True, |
|
2168 | 2169 | node=hex(cl.node(clstart)), source=srctype, |
|
2169 | 2170 | url=url, pending=p) |
|
2170 | 2171 | |
|
2171 | 2172 | added = [cl.node(r) for r in xrange(clstart, clend)] |
|
2172 | 2173 | publishing = self.ui.configbool('phases', 'publish', True) |
|
2173 | 2174 | if srctype == 'push': |
|
2174 | 2175 | # Old server can not push the boundary themself. |
|
2175 | 2176 | # New server won't push the boundary if changeset already |
|
2176 | 2177 | # existed locally as secrete |
|
2177 | 2178 | # |
|
2178 | 2179 | # We should not use added here but the list of all change in |
|
2179 | 2180 | # the bundle |
|
2180 | 2181 | if publishing: |
|
2181 | 2182 | phases.advanceboundary(self, phases.public, srccontent) |
|
2182 | 2183 | else: |
|
2183 | 2184 | phases.advanceboundary(self, phases.draft, srccontent) |
|
2184 | 2185 | phases.retractboundary(self, phases.draft, added) |
|
2185 | 2186 | elif srctype != 'strip': |
|
2186 | 2187 | # publishing only alter behavior during push |
|
2187 | 2188 | # |
|
2188 | 2189 | # strip should not touch boundary at all |
|
2189 | 2190 | phases.retractboundary(self, phases.draft, added) |
|
2190 | 2191 | |
|
2191 | 2192 | # make changelog see real files again |
|
2192 | 2193 | cl.finalize(trp) |
|
2193 | 2194 | |
|
2194 | 2195 | tr.close() |
|
2195 | 2196 | |
|
2196 | 2197 | if changesets > 0: |
|
2197 | 2198 | if srctype != 'strip': |
|
2198 | 2199 | # During strip, branchcache is invalid but coming call to |
|
2199 | 2200 | # `destroyed` will repair it. |
|
2200 | 2201 | # In other case we can safely update cache on disk. |
|
2201 | 2202 | branchmap.updatecache(self.filtered('served')) |
|
2202 | 2203 | def runhooks(): |
|
2203 | 2204 | # These hooks run when the lock releases, not when the |
|
2204 | 2205 | # transaction closes. So it's possible for the changelog |
|
2205 | 2206 | # to have changed since we last saw it. |
|
2206 | 2207 | if clstart >= len(self): |
|
2207 | 2208 | return |
|
2208 | 2209 | |
|
2209 | 2210 | # forcefully update the on-disk branch cache |
|
2210 | 2211 | self.ui.debug("updating the branch cache\n") |
|
2211 | 2212 | self.hook("changegroup", node=hex(cl.node(clstart)), |
|
2212 | 2213 | source=srctype, url=url) |
|
2213 | 2214 | |
|
2214 | 2215 | for n in added: |
|
2215 | 2216 | self.hook("incoming", node=hex(n), source=srctype, |
|
2216 | 2217 | url=url) |
|
2217 | 2218 | |
|
2218 | 2219 | newheads = [h for h in self.heads() if h not in oldheads] |
|
2219 | 2220 | self.ui.log("incoming", |
|
2220 | 2221 | "%s incoming changes - new heads: %s\n", |
|
2221 | 2222 | len(added), |
|
2222 | 2223 | ', '.join([hex(c[:6]) for c in newheads])) |
|
2223 | 2224 | self._afterlock(runhooks) |
|
2224 | 2225 | |
|
2225 | 2226 | finally: |
|
2226 | 2227 | tr.release() |
|
2227 | 2228 | # never return 0 here: |
|
2228 | 2229 | if dh < 0: |
|
2229 | 2230 | return dh - 1 |
|
2230 | 2231 | else: |
|
2231 | 2232 | return dh + 1 |
|
2232 | 2233 | |
|
2233 | 2234 | def addchangegroupfiles(self, source, revmap, trp, pr, needfiles): |
|
2234 | 2235 | revisions = 0 |
|
2235 | 2236 | files = 0 |
|
2236 | 2237 | while True: |
|
2237 | 2238 | chunkdata = source.filelogheader() |
|
2238 | 2239 | if not chunkdata: |
|
2239 | 2240 | break |
|
2240 | 2241 | f = chunkdata["filename"] |
|
2241 | 2242 | self.ui.debug("adding %s revisions\n" % f) |
|
2242 | 2243 | pr() |
|
2243 | 2244 | fl = self.file(f) |
|
2244 | 2245 | o = len(fl) |
|
2245 | 2246 | if not fl.addgroup(source, revmap, trp): |
|
2246 | 2247 | raise util.Abort(_("received file revlog group is empty")) |
|
2247 | 2248 | revisions += len(fl) - o |
|
2248 | 2249 | files += 1 |
|
2249 | 2250 | if f in needfiles: |
|
2250 | 2251 | needs = needfiles[f] |
|
2251 | 2252 | for new in xrange(o, len(fl)): |
|
2252 | 2253 | n = fl.node(new) |
|
2253 | 2254 | if n in needs: |
|
2254 | 2255 | needs.remove(n) |
|
2255 | 2256 | else: |
|
2256 | 2257 | raise util.Abort( |
|
2257 | 2258 | _("received spurious file revlog entry")) |
|
2258 | 2259 | if not needs: |
|
2259 | 2260 | del needfiles[f] |
|
2260 | 2261 | self.ui.progress(_('files'), None) |
|
2261 | 2262 | |
|
2262 | 2263 | for f, needs in needfiles.iteritems(): |
|
2263 | 2264 | fl = self.file(f) |
|
2264 | 2265 | for n in needs: |
|
2265 | 2266 | try: |
|
2266 | 2267 | fl.rev(n) |
|
2267 | 2268 | except error.LookupError: |
|
2268 | 2269 | raise util.Abort( |
|
2269 | 2270 | _('missing file data for %s:%s - run hg verify') % |
|
2270 | 2271 | (f, hex(n))) |
|
2271 | 2272 | |
|
2272 | 2273 | return revisions, files |
|
2273 | 2274 | |
|
2274 | 2275 | def stream_in(self, remote, requirements): |
|
2275 | 2276 | lock = self.lock() |
|
2276 | 2277 | try: |
|
2277 | 2278 | # Save remote branchmap. We will use it later |
|
2278 | 2279 | # to speed up branchcache creation |
|
2279 | 2280 | rbranchmap = None |
|
2280 | 2281 | if remote.capable("branchmap"): |
|
2281 | 2282 | rbranchmap = remote.branchmap() |
|
2282 | 2283 | |
|
2283 | 2284 | fp = remote.stream_out() |
|
2284 | 2285 | l = fp.readline() |
|
2285 | 2286 | try: |
|
2286 | 2287 | resp = int(l) |
|
2287 | 2288 | except ValueError: |
|
2288 | 2289 | raise error.ResponseError( |
|
2289 | 2290 | _('unexpected response from remote server:'), l) |
|
2290 | 2291 | if resp == 1: |
|
2291 | 2292 | raise util.Abort(_('operation forbidden by server')) |
|
2292 | 2293 | elif resp == 2: |
|
2293 | 2294 | raise util.Abort(_('locking the remote repository failed')) |
|
2294 | 2295 | elif resp != 0: |
|
2295 | 2296 | raise util.Abort(_('the server sent an unknown error code')) |
|
2296 | 2297 | self.ui.status(_('streaming all changes\n')) |
|
2297 | 2298 | l = fp.readline() |
|
2298 | 2299 | try: |
|
2299 | 2300 | total_files, total_bytes = map(int, l.split(' ', 1)) |
|
2300 | 2301 | except (ValueError, TypeError): |
|
2301 | 2302 | raise error.ResponseError( |
|
2302 | 2303 | _('unexpected response from remote server:'), l) |
|
2303 | 2304 | self.ui.status(_('%d files to transfer, %s of data\n') % |
|
2304 | 2305 | (total_files, util.bytecount(total_bytes))) |
|
2305 | 2306 | handled_bytes = 0 |
|
2306 | 2307 | self.ui.progress(_('clone'), 0, total=total_bytes) |
|
2307 | 2308 | start = time.time() |
|
2308 | 2309 | for i in xrange(total_files): |
|
2309 | 2310 | # XXX doesn't support '\n' or '\r' in filenames |
|
2310 | 2311 | l = fp.readline() |
|
2311 | 2312 | try: |
|
2312 | 2313 | name, size = l.split('\0', 1) |
|
2313 | 2314 | size = int(size) |
|
2314 | 2315 | except (ValueError, TypeError): |
|
2315 | 2316 | raise error.ResponseError( |
|
2316 | 2317 | _('unexpected response from remote server:'), l) |
|
2317 | 2318 | if self.ui.debugflag: |
|
2318 | 2319 | self.ui.debug('adding %s (%s)\n' % |
|
2319 | 2320 | (name, util.bytecount(size))) |
|
2320 | 2321 | # for backwards compat, name was partially encoded |
|
2321 | 2322 | ofp = self.sopener(store.decodedir(name), 'w') |
|
2322 | 2323 | for chunk in util.filechunkiter(fp, limit=size): |
|
2323 | 2324 | handled_bytes += len(chunk) |
|
2324 | 2325 | self.ui.progress(_('clone'), handled_bytes, |
|
2325 | 2326 | total=total_bytes) |
|
2326 | 2327 | ofp.write(chunk) |
|
2327 | 2328 | ofp.close() |
|
2328 | 2329 | elapsed = time.time() - start |
|
2329 | 2330 | if elapsed <= 0: |
|
2330 | 2331 | elapsed = 0.001 |
|
2331 | 2332 | self.ui.progress(_('clone'), None) |
|
2332 | 2333 | self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % |
|
2333 | 2334 | (util.bytecount(total_bytes), elapsed, |
|
2334 | 2335 | util.bytecount(total_bytes / elapsed))) |
|
2335 | 2336 | |
|
2336 | 2337 | # new requirements = old non-format requirements + |
|
2337 | 2338 | # new format-related |
|
2338 | 2339 | # requirements from the streamed-in repository |
|
2339 | 2340 | requirements.update(set(self.requirements) - self.supportedformats) |
|
2340 | 2341 | self._applyrequirements(requirements) |
|
2341 | 2342 | self._writerequirements() |
|
2342 | 2343 | |
|
2343 | 2344 | if rbranchmap: |
|
2344 | 2345 | rbheads = [] |
|
2345 | 2346 | for bheads in rbranchmap.itervalues(): |
|
2346 | 2347 | rbheads.extend(bheads) |
|
2347 | 2348 | |
|
2348 | 2349 | if rbheads: |
|
2349 | 2350 | rtiprev = max((int(self.changelog.rev(node)) |
|
2350 | 2351 | for node in rbheads)) |
|
2351 | 2352 | cache = branchmap.branchcache(rbranchmap, |
|
2352 | 2353 | self[rtiprev].node(), |
|
2353 | 2354 | rtiprev) |
|
2354 | 2355 | # Try to stick it as low as possible |
|
2355 | 2356 | # filter above served are unlikely to be fetch from a clone |
|
2356 | 2357 | for candidate in ('base', 'immutable', 'served'): |
|
2357 | 2358 | rview = self.filtered(candidate) |
|
2358 | 2359 | if cache.validfor(rview): |
|
2359 | 2360 | self._branchcaches[candidate] = cache |
|
2360 | 2361 | cache.write(rview) |
|
2361 | 2362 | break |
|
2362 | 2363 | self.invalidate() |
|
2363 | 2364 | return len(self.heads()) + 1 |
|
2364 | 2365 | finally: |
|
2365 | 2366 | lock.release() |
|
2366 | 2367 | |
|
2367 | 2368 | def clone(self, remote, heads=[], stream=False): |
|
2368 | 2369 | '''clone remote repository. |
|
2369 | 2370 | |
|
2370 | 2371 | keyword arguments: |
|
2371 | 2372 | heads: list of revs to clone (forces use of pull) |
|
2372 | 2373 | stream: use streaming clone if possible''' |
|
2373 | 2374 | |
|
2374 | 2375 | # now, all clients that can request uncompressed clones can |
|
2375 | 2376 | # read repo formats supported by all servers that can serve |
|
2376 | 2377 | # them. |
|
2377 | 2378 | |
|
2378 | 2379 | # if revlog format changes, client will have to check version |
|
2379 | 2380 | # and format flags on "stream" capability, and use |
|
2380 | 2381 | # uncompressed only if compatible. |
|
2381 | 2382 | |
|
2382 | 2383 | if not stream: |
|
2383 | 2384 | # if the server explicitly prefers to stream (for fast LANs) |
|
2384 | 2385 | stream = remote.capable('stream-preferred') |
|
2385 | 2386 | |
|
2386 | 2387 | if stream and not heads: |
|
2387 | 2388 | # 'stream' means remote revlog format is revlogv1 only |
|
2388 | 2389 | if remote.capable('stream'): |
|
2389 | 2390 | return self.stream_in(remote, set(('revlogv1',))) |
|
2390 | 2391 | # otherwise, 'streamreqs' contains the remote revlog format |
|
2391 | 2392 | streamreqs = remote.capable('streamreqs') |
|
2392 | 2393 | if streamreqs: |
|
2393 | 2394 | streamreqs = set(streamreqs.split(',')) |
|
2394 | 2395 | # if we support it, stream in and adjust our requirements |
|
2395 | 2396 | if not streamreqs - self.supportedformats: |
|
2396 | 2397 | return self.stream_in(remote, streamreqs) |
|
2397 | 2398 | return self.pull(remote, heads) |
|
2398 | 2399 | |
|
2399 | 2400 | def pushkey(self, namespace, key, old, new): |
|
2400 | 2401 | self.hook('prepushkey', throw=True, namespace=namespace, key=key, |
|
2401 | 2402 | old=old, new=new) |
|
2402 | 2403 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) |
|
2403 | 2404 | ret = pushkey.push(self, namespace, key, old, new) |
|
2404 | 2405 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, |
|
2405 | 2406 | ret=ret) |
|
2406 | 2407 | return ret |
|
2407 | 2408 | |
|
2408 | 2409 | def listkeys(self, namespace): |
|
2409 | 2410 | self.hook('prelistkeys', throw=True, namespace=namespace) |
|
2410 | 2411 | self.ui.debug('listing keys for "%s"\n' % namespace) |
|
2411 | 2412 | values = pushkey.list(self, namespace) |
|
2412 | 2413 | self.hook('listkeys', namespace=namespace, values=values) |
|
2413 | 2414 | return values |
|
2414 | 2415 | |
|
2415 | 2416 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
2416 | 2417 | '''used to test argument passing over the wire''' |
|
2417 | 2418 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
2418 | 2419 | |
|
2419 | 2420 | def savecommitmessage(self, text): |
|
2420 | 2421 | fp = self.opener('last-message.txt', 'wb') |
|
2421 | 2422 | try: |
|
2422 | 2423 | fp.write(text) |
|
2423 | 2424 | finally: |
|
2424 | 2425 | fp.close() |
|
2425 | 2426 | return self.pathto(fp.name[len(self.root) + 1:]) |
|
2426 | 2427 | |
|
2427 | 2428 | # used to avoid circular references so destructors work |
|
2428 | 2429 | def aftertrans(files): |
|
2429 | 2430 | renamefiles = [tuple(t) for t in files] |
|
2430 | 2431 | def a(): |
|
2431 | 2432 | for vfs, src, dest in renamefiles: |
|
2432 | 2433 | try: |
|
2433 | 2434 | vfs.rename(src, dest) |
|
2434 | 2435 | except OSError: # journal file does not yet exist |
|
2435 | 2436 | pass |
|
2436 | 2437 | return a |
|
2437 | 2438 | |
|
2438 | 2439 | def undoname(fn): |
|
2439 | 2440 | base, name = os.path.split(fn) |
|
2440 | 2441 | assert name.startswith('journal') |
|
2441 | 2442 | return os.path.join(base, name.replace('journal', 'undo', 1)) |
|
2442 | 2443 | |
|
2443 | 2444 | def instance(ui, path, create): |
|
2444 | 2445 | return localrepository(ui, util.urllocalpath(path), create) |
|
2445 | 2446 | |
|
2446 | 2447 | def islocal(path): |
|
2447 | 2448 | return True |
@@ -1,1912 +1,1913 b'' | |||
|
1 | 1 | Short help: |
|
2 | 2 | |
|
3 | 3 | $ hg |
|
4 | 4 | Mercurial Distributed SCM |
|
5 | 5 | |
|
6 | 6 | basic commands: |
|
7 | 7 | |
|
8 | 8 | add add the specified files on the next commit |
|
9 | 9 | annotate show changeset information by line for each file |
|
10 | 10 | clone make a copy of an existing repository |
|
11 | 11 | commit commit the specified files or all outstanding changes |
|
12 | 12 | diff diff repository (or selected files) |
|
13 | 13 | export dump the header and diffs for one or more changesets |
|
14 | 14 | forget forget the specified files on the next commit |
|
15 | 15 | init create a new repository in the given directory |
|
16 | 16 | log show revision history of entire repository or files |
|
17 | 17 | merge merge working directory with another revision |
|
18 | 18 | pull pull changes from the specified source |
|
19 | 19 | push push changes to the specified destination |
|
20 | 20 | remove remove the specified files on the next commit |
|
21 | 21 | serve start stand-alone webserver |
|
22 | 22 | status show changed files in the working directory |
|
23 | 23 | summary summarize working directory state |
|
24 | 24 | update update working directory (or switch revisions) |
|
25 | 25 | |
|
26 | 26 | use "hg help" for the full list of commands or "hg -v" for details |
|
27 | 27 | |
|
28 | 28 | $ hg -q |
|
29 | 29 | add add the specified files on the next commit |
|
30 | 30 | annotate show changeset information by line for each file |
|
31 | 31 | clone make a copy of an existing repository |
|
32 | 32 | commit commit the specified files or all outstanding changes |
|
33 | 33 | diff diff repository (or selected files) |
|
34 | 34 | export dump the header and diffs for one or more changesets |
|
35 | 35 | forget forget the specified files on the next commit |
|
36 | 36 | init create a new repository in the given directory |
|
37 | 37 | log show revision history of entire repository or files |
|
38 | 38 | merge merge working directory with another revision |
|
39 | 39 | pull pull changes from the specified source |
|
40 | 40 | push push changes to the specified destination |
|
41 | 41 | remove remove the specified files on the next commit |
|
42 | 42 | serve start stand-alone webserver |
|
43 | 43 | status show changed files in the working directory |
|
44 | 44 | summary summarize working directory state |
|
45 | 45 | update update working directory (or switch revisions) |
|
46 | 46 | |
|
47 | 47 | $ hg help |
|
48 | 48 | Mercurial Distributed SCM |
|
49 | 49 | |
|
50 | 50 | list of commands: |
|
51 | 51 | |
|
52 | 52 | add add the specified files on the next commit |
|
53 | 53 | addremove add all new files, delete all missing files |
|
54 | 54 | annotate show changeset information by line for each file |
|
55 | 55 | archive create an unversioned archive of a repository revision |
|
56 | 56 | backout reverse effect of earlier changeset |
|
57 | 57 | bisect subdivision search of changesets |
|
58 | 58 | bookmarks track a line of development with movable markers |
|
59 | 59 | branch set or show the current branch name |
|
60 | 60 | branches list repository named branches |
|
61 | 61 | bundle create a changegroup file |
|
62 | 62 | cat output the current or given revision of files |
|
63 | 63 | clone make a copy of an existing repository |
|
64 | 64 | commit commit the specified files or all outstanding changes |
|
65 | 65 | copy mark files as copied for the next commit |
|
66 | 66 | diff diff repository (or selected files) |
|
67 | 67 | export dump the header and diffs for one or more changesets |
|
68 | 68 | forget forget the specified files on the next commit |
|
69 | 69 | graft copy changes from other branches onto the current branch |
|
70 | 70 | grep search for a pattern in specified files and revisions |
|
71 | 71 | heads show branch heads |
|
72 | 72 | help show help for a given topic or a help overview |
|
73 | 73 | identify identify the working copy or specified revision |
|
74 | 74 | import import an ordered set of patches |
|
75 | 75 | incoming show new changesets found in source |
|
76 | 76 | init create a new repository in the given directory |
|
77 | 77 | locate locate files matching specific patterns |
|
78 | 78 | log show revision history of entire repository or files |
|
79 | 79 | manifest output the current or given revision of the project manifest |
|
80 | 80 | merge merge working directory with another revision |
|
81 | 81 | outgoing show changesets not found in the destination |
|
82 | 82 | parents show the parents of the working directory or revision |
|
83 | 83 | paths show aliases for remote repositories |
|
84 | 84 | phase set or show the current phase name |
|
85 | 85 | pull pull changes from the specified source |
|
86 | 86 | push push changes to the specified destination |
|
87 | 87 | recover roll back an interrupted transaction |
|
88 | 88 | remove remove the specified files on the next commit |
|
89 | 89 | rename rename files; equivalent of copy + remove |
|
90 | 90 | resolve redo merges or set/view the merge status of files |
|
91 | 91 | revert restore files to their checkout state |
|
92 | 92 | root print the root (top) of the current working directory |
|
93 | 93 | serve start stand-alone webserver |
|
94 | 94 | showconfig show combined config settings from all hgrc files |
|
95 | 95 | status show changed files in the working directory |
|
96 | 96 | summary summarize working directory state |
|
97 | 97 | tag add one or more tags for the current or given revision |
|
98 | 98 | tags list repository tags |
|
99 | 99 | unbundle apply one or more changegroup files |
|
100 | 100 | update update working directory (or switch revisions) |
|
101 | 101 | verify verify the integrity of the repository |
|
102 | 102 | version output version and copyright information |
|
103 | 103 | |
|
104 | 104 | additional help topics: |
|
105 | 105 | |
|
106 | 106 | config Configuration Files |
|
107 | 107 | dates Date Formats |
|
108 | 108 | diffs Diff Formats |
|
109 | 109 | environment Environment Variables |
|
110 | 110 | extensions Using Additional Features |
|
111 | 111 | filesets Specifying File Sets |
|
112 | 112 | glossary Glossary |
|
113 | 113 | hgignore Syntax for Mercurial Ignore Files |
|
114 | 114 | hgweb Configuring hgweb |
|
115 | 115 | merge-tools Merge Tools |
|
116 | 116 | multirevs Specifying Multiple Revisions |
|
117 | 117 | patterns File Name Patterns |
|
118 | 118 | phases Working with Phases |
|
119 | 119 | revisions Specifying Single Revisions |
|
120 | 120 | revsets Specifying Revision Sets |
|
121 | 121 | subrepos Subrepositories |
|
122 | 122 | templating Template Usage |
|
123 | 123 | urls URL Paths |
|
124 | 124 | |
|
125 | 125 | use "hg -v help" to show builtin aliases and global options |
|
126 | 126 | |
|
127 | 127 | $ hg -q help |
|
128 | 128 | add add the specified files on the next commit |
|
129 | 129 | addremove add all new files, delete all missing files |
|
130 | 130 | annotate show changeset information by line for each file |
|
131 | 131 | archive create an unversioned archive of a repository revision |
|
132 | 132 | backout reverse effect of earlier changeset |
|
133 | 133 | bisect subdivision search of changesets |
|
134 | 134 | bookmarks track a line of development with movable markers |
|
135 | 135 | branch set or show the current branch name |
|
136 | 136 | branches list repository named branches |
|
137 | 137 | bundle create a changegroup file |
|
138 | 138 | cat output the current or given revision of files |
|
139 | 139 | clone make a copy of an existing repository |
|
140 | 140 | commit commit the specified files or all outstanding changes |
|
141 | 141 | copy mark files as copied for the next commit |
|
142 | 142 | diff diff repository (or selected files) |
|
143 | 143 | export dump the header and diffs for one or more changesets |
|
144 | 144 | forget forget the specified files on the next commit |
|
145 | 145 | graft copy changes from other branches onto the current branch |
|
146 | 146 | grep search for a pattern in specified files and revisions |
|
147 | 147 | heads show branch heads |
|
148 | 148 | help show help for a given topic or a help overview |
|
149 | 149 | identify identify the working copy or specified revision |
|
150 | 150 | import import an ordered set of patches |
|
151 | 151 | incoming show new changesets found in source |
|
152 | 152 | init create a new repository in the given directory |
|
153 | 153 | locate locate files matching specific patterns |
|
154 | 154 | log show revision history of entire repository or files |
|
155 | 155 | manifest output the current or given revision of the project manifest |
|
156 | 156 | merge merge working directory with another revision |
|
157 | 157 | outgoing show changesets not found in the destination |
|
158 | 158 | parents show the parents of the working directory or revision |
|
159 | 159 | paths show aliases for remote repositories |
|
160 | 160 | phase set or show the current phase name |
|
161 | 161 | pull pull changes from the specified source |
|
162 | 162 | push push changes to the specified destination |
|
163 | 163 | recover roll back an interrupted transaction |
|
164 | 164 | remove remove the specified files on the next commit |
|
165 | 165 | rename rename files; equivalent of copy + remove |
|
166 | 166 | resolve redo merges or set/view the merge status of files |
|
167 | 167 | revert restore files to their checkout state |
|
168 | 168 | root print the root (top) of the current working directory |
|
169 | 169 | serve start stand-alone webserver |
|
170 | 170 | showconfig show combined config settings from all hgrc files |
|
171 | 171 | status show changed files in the working directory |
|
172 | 172 | summary summarize working directory state |
|
173 | 173 | tag add one or more tags for the current or given revision |
|
174 | 174 | tags list repository tags |
|
175 | 175 | unbundle apply one or more changegroup files |
|
176 | 176 | update update working directory (or switch revisions) |
|
177 | 177 | verify verify the integrity of the repository |
|
178 | 178 | version output version and copyright information |
|
179 | 179 | |
|
180 | 180 | additional help topics: |
|
181 | 181 | |
|
182 | 182 | config Configuration Files |
|
183 | 183 | dates Date Formats |
|
184 | 184 | diffs Diff Formats |
|
185 | 185 | environment Environment Variables |
|
186 | 186 | extensions Using Additional Features |
|
187 | 187 | filesets Specifying File Sets |
|
188 | 188 | glossary Glossary |
|
189 | 189 | hgignore Syntax for Mercurial Ignore Files |
|
190 | 190 | hgweb Configuring hgweb |
|
191 | 191 | merge-tools Merge Tools |
|
192 | 192 | multirevs Specifying Multiple Revisions |
|
193 | 193 | patterns File Name Patterns |
|
194 | 194 | phases Working with Phases |
|
195 | 195 | revisions Specifying Single Revisions |
|
196 | 196 | revsets Specifying Revision Sets |
|
197 | 197 | subrepos Subrepositories |
|
198 | 198 | templating Template Usage |
|
199 | 199 | urls URL Paths |
|
200 | 200 | |
|
201 | 201 | Test short command list with verbose option |
|
202 | 202 | |
|
203 | 203 | $ hg -v help shortlist |
|
204 | 204 | Mercurial Distributed SCM |
|
205 | 205 | |
|
206 | 206 | basic commands: |
|
207 | 207 | |
|
208 | 208 | add add the specified files on the next commit |
|
209 | 209 | annotate, blame |
|
210 | 210 | show changeset information by line for each file |
|
211 | 211 | clone make a copy of an existing repository |
|
212 | 212 | commit, ci commit the specified files or all outstanding changes |
|
213 | 213 | diff diff repository (or selected files) |
|
214 | 214 | export dump the header and diffs for one or more changesets |
|
215 | 215 | forget forget the specified files on the next commit |
|
216 | 216 | init create a new repository in the given directory |
|
217 | 217 | log, history show revision history of entire repository or files |
|
218 | 218 | merge merge working directory with another revision |
|
219 | 219 | pull pull changes from the specified source |
|
220 | 220 | push push changes to the specified destination |
|
221 | 221 | remove, rm remove the specified files on the next commit |
|
222 | 222 | serve start stand-alone webserver |
|
223 | 223 | status, st show changed files in the working directory |
|
224 | 224 | summary, sum summarize working directory state |
|
225 | 225 | update, up, checkout, co |
|
226 | 226 | update working directory (or switch revisions) |
|
227 | 227 | |
|
228 | 228 | global options: |
|
229 | 229 | |
|
230 | 230 | -R --repository REPO repository root directory or name of overlay bundle |
|
231 | 231 | file |
|
232 | 232 | --cwd DIR change working directory |
|
233 | 233 | -y --noninteractive do not prompt, automatically pick the first choice for |
|
234 | 234 | all prompts |
|
235 | 235 | -q --quiet suppress output |
|
236 | 236 | -v --verbose enable additional output |
|
237 | 237 | --config CONFIG [+] set/override config option (use 'section.name=value') |
|
238 | 238 | --debug enable debugging output |
|
239 | 239 | --debugger start debugger |
|
240 | 240 | --encoding ENCODE set the charset encoding (default: ascii) |
|
241 | 241 | --encodingmode MODE set the charset encoding mode (default: strict) |
|
242 | 242 | --traceback always print a traceback on exception |
|
243 | 243 | --time time how long the command takes |
|
244 | 244 | --profile print command execution profile |
|
245 | 245 | --version output version information and exit |
|
246 | 246 | -h --help display help and exit |
|
247 | 247 | --hidden consider hidden changesets |
|
248 | 248 | |
|
249 | 249 | [+] marked option can be specified multiple times |
|
250 | 250 | |
|
251 | 251 | use "hg help" for the full list of commands |
|
252 | 252 | |
|
253 | 253 | $ hg add -h |
|
254 | 254 | hg add [OPTION]... [FILE]... |
|
255 | 255 | |
|
256 | 256 | add the specified files on the next commit |
|
257 | 257 | |
|
258 | 258 | Schedule files to be version controlled and added to the repository. |
|
259 | 259 | |
|
260 | 260 | The files will be added to the repository at the next commit. To undo an |
|
261 | 261 | add before that, see "hg forget". |
|
262 | 262 | |
|
263 | 263 | If no names are given, add all files to the repository. |
|
264 | 264 | |
|
265 | 265 | Returns 0 if all files are successfully added. |
|
266 | 266 | |
|
267 | 267 | options: |
|
268 | 268 | |
|
269 | 269 | -I --include PATTERN [+] include names matching the given patterns |
|
270 | 270 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
271 | 271 | -S --subrepos recurse into subrepositories |
|
272 | 272 | -n --dry-run do not perform actions, just print output |
|
273 | 273 | |
|
274 | 274 | [+] marked option can be specified multiple times |
|
275 | 275 | |
|
276 | 276 | use "hg -v help add" to show more complete help and the global options |
|
277 | 277 | |
|
278 | 278 | Verbose help for add |
|
279 | 279 | |
|
280 | 280 | $ hg add -hv |
|
281 | 281 | hg add [OPTION]... [FILE]... |
|
282 | 282 | |
|
283 | 283 | add the specified files on the next commit |
|
284 | 284 | |
|
285 | 285 | Schedule files to be version controlled and added to the repository. |
|
286 | 286 | |
|
287 | 287 | The files will be added to the repository at the next commit. To undo an |
|
288 | 288 | add before that, see "hg forget". |
|
289 | 289 | |
|
290 | 290 | If no names are given, add all files to the repository. |
|
291 | 291 | |
|
292 | 292 | An example showing how new (unknown) files are added automatically by "hg |
|
293 | 293 | add": |
|
294 | 294 | |
|
295 | 295 | $ ls |
|
296 | 296 | foo.c |
|
297 | 297 | $ hg status |
|
298 | 298 | ? foo.c |
|
299 | 299 | $ hg add |
|
300 | 300 | adding foo.c |
|
301 | 301 | $ hg status |
|
302 | 302 | A foo.c |
|
303 | 303 | |
|
304 | 304 | Returns 0 if all files are successfully added. |
|
305 | 305 | |
|
306 | 306 | options: |
|
307 | 307 | |
|
308 | 308 | -I --include PATTERN [+] include names matching the given patterns |
|
309 | 309 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
310 | 310 | -S --subrepos recurse into subrepositories |
|
311 | 311 | -n --dry-run do not perform actions, just print output |
|
312 | 312 | |
|
313 | 313 | [+] marked option can be specified multiple times |
|
314 | 314 | |
|
315 | 315 | global options: |
|
316 | 316 | |
|
317 | 317 | -R --repository REPO repository root directory or name of overlay bundle |
|
318 | 318 | file |
|
319 | 319 | --cwd DIR change working directory |
|
320 | 320 | -y --noninteractive do not prompt, automatically pick the first choice for |
|
321 | 321 | all prompts |
|
322 | 322 | -q --quiet suppress output |
|
323 | 323 | -v --verbose enable additional output |
|
324 | 324 | --config CONFIG [+] set/override config option (use 'section.name=value') |
|
325 | 325 | --debug enable debugging output |
|
326 | 326 | --debugger start debugger |
|
327 | 327 | --encoding ENCODE set the charset encoding (default: ascii) |
|
328 | 328 | --encodingmode MODE set the charset encoding mode (default: strict) |
|
329 | 329 | --traceback always print a traceback on exception |
|
330 | 330 | --time time how long the command takes |
|
331 | 331 | --profile print command execution profile |
|
332 | 332 | --version output version information and exit |
|
333 | 333 | -h --help display help and exit |
|
334 | 334 | --hidden consider hidden changesets |
|
335 | 335 | |
|
336 | 336 | [+] marked option can be specified multiple times |
|
337 | 337 | |
|
338 | 338 | Test help option with version option |
|
339 | 339 | |
|
340 | 340 | $ hg add -h --version |
|
341 | 341 | Mercurial Distributed SCM (version *) (glob) |
|
342 | 342 | (see http://mercurial.selenic.com for more information) |
|
343 | 343 | |
|
344 | 344 | Copyright (C) 2005-2014 Matt Mackall and others |
|
345 | 345 | This is free software; see the source for copying conditions. There is NO |
|
346 | 346 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
347 | 347 | |
|
348 | 348 | $ hg add --skjdfks |
|
349 | 349 | hg add: option --skjdfks not recognized |
|
350 | 350 | hg add [OPTION]... [FILE]... |
|
351 | 351 | |
|
352 | 352 | add the specified files on the next commit |
|
353 | 353 | |
|
354 | 354 | options: |
|
355 | 355 | |
|
356 | 356 | -I --include PATTERN [+] include names matching the given patterns |
|
357 | 357 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
358 | 358 | -S --subrepos recurse into subrepositories |
|
359 | 359 | -n --dry-run do not perform actions, just print output |
|
360 | 360 | |
|
361 | 361 | [+] marked option can be specified multiple times |
|
362 | 362 | |
|
363 | 363 | use "hg help add" to show the full help text |
|
364 | 364 | [255] |
|
365 | 365 | |
|
366 | 366 | Test ambiguous command help |
|
367 | 367 | |
|
368 | 368 | $ hg help ad |
|
369 | 369 | list of commands: |
|
370 | 370 | |
|
371 | 371 | add add the specified files on the next commit |
|
372 | 372 | addremove add all new files, delete all missing files |
|
373 | 373 | |
|
374 | 374 | use "hg -v help ad" to show builtin aliases and global options |
|
375 | 375 | |
|
376 | 376 | Test command without options |
|
377 | 377 | |
|
378 | 378 | $ hg help verify |
|
379 | 379 | hg verify |
|
380 | 380 | |
|
381 | 381 | verify the integrity of the repository |
|
382 | 382 | |
|
383 | 383 | Verify the integrity of the current repository. |
|
384 | 384 | |
|
385 | 385 | This will perform an extensive check of the repository's integrity, |
|
386 | 386 | validating the hashes and checksums of each entry in the changelog, |
|
387 | 387 | manifest, and tracked files, as well as the integrity of their crosslinks |
|
388 | 388 | and indices. |
|
389 | 389 | |
|
390 | 390 | Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more |
|
391 | 391 | information about recovery from corruption of the repository. |
|
392 | 392 | |
|
393 | 393 | Returns 0 on success, 1 if errors are encountered. |
|
394 | 394 | |
|
395 | 395 | use "hg -v help verify" to show the global options |
|
396 | 396 | |
|
397 | 397 | $ hg help diff |
|
398 | 398 | hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]... |
|
399 | 399 | |
|
400 | 400 | diff repository (or selected files) |
|
401 | 401 | |
|
402 | 402 | Show differences between revisions for the specified files. |
|
403 | 403 | |
|
404 | 404 | Differences between files are shown using the unified diff format. |
|
405 | 405 | |
|
406 | 406 | Note: |
|
407 | 407 | diff may generate unexpected results for merges, as it will default to |
|
408 | 408 | comparing against the working directory's first parent changeset if no |
|
409 | 409 | revisions are specified. |
|
410 | 410 | |
|
411 | 411 | When two revision arguments are given, then changes are shown between |
|
412 | 412 | those revisions. If only one revision is specified then that revision is |
|
413 | 413 | compared to the working directory, and, when no revisions are specified, |
|
414 | 414 | the working directory files are compared to its parent. |
|
415 | 415 | |
|
416 | 416 | Alternatively you can specify -c/--change with a revision to see the |
|
417 | 417 | changes in that changeset relative to its first parent. |
|
418 | 418 | |
|
419 | 419 | Without the -a/--text option, diff will avoid generating diffs of files it |
|
420 | 420 | detects as binary. With -a, diff will generate a diff anyway, probably |
|
421 | 421 | with undesirable results. |
|
422 | 422 | |
|
423 | 423 | Use the -g/--git option to generate diffs in the git extended diff format. |
|
424 | 424 | For more information, read "hg help diffs". |
|
425 | 425 | |
|
426 | 426 | Returns 0 on success. |
|
427 | 427 | |
|
428 | 428 | options: |
|
429 | 429 | |
|
430 | 430 | -r --rev REV [+] revision |
|
431 | 431 | -c --change REV change made by revision |
|
432 | 432 | -a --text treat all files as text |
|
433 | 433 | -g --git use git extended diff format |
|
434 | 434 | --nodates omit dates from diff headers |
|
435 | 435 | -p --show-function show which function each change is in |
|
436 | 436 | --reverse produce a diff that undoes the changes |
|
437 | 437 | -w --ignore-all-space ignore white space when comparing lines |
|
438 | 438 | -b --ignore-space-change ignore changes in the amount of white space |
|
439 | 439 | -B --ignore-blank-lines ignore changes whose lines are all blank |
|
440 | 440 | -U --unified NUM number of lines of context to show |
|
441 | 441 | --stat output diffstat-style summary of changes |
|
442 | 442 | -I --include PATTERN [+] include names matching the given patterns |
|
443 | 443 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
444 | 444 | -S --subrepos recurse into subrepositories |
|
445 | 445 | |
|
446 | 446 | [+] marked option can be specified multiple times |
|
447 | 447 | |
|
448 | 448 | use "hg -v help diff" to show more complete help and the global options |
|
449 | 449 | |
|
450 | 450 | $ hg help status |
|
451 | 451 | hg status [OPTION]... [FILE]... |
|
452 | 452 | |
|
453 | 453 | aliases: st |
|
454 | 454 | |
|
455 | 455 | show changed files in the working directory |
|
456 | 456 | |
|
457 | 457 | Show status of files in the repository. If names are given, only files |
|
458 | 458 | that match are shown. Files that are clean or ignored or the source of a |
|
459 | 459 | copy/move operation, are not listed unless -c/--clean, -i/--ignored, |
|
460 | 460 | -C/--copies or -A/--all are given. Unless options described with "show |
|
461 | 461 | only ..." are given, the options -mardu are used. |
|
462 | 462 | |
|
463 | 463 | Option -q/--quiet hides untracked (unknown and ignored) files unless |
|
464 | 464 | explicitly requested with -u/--unknown or -i/--ignored. |
|
465 | 465 | |
|
466 | 466 | Note: |
|
467 | 467 | status may appear to disagree with diff if permissions have changed or |
|
468 | 468 | a merge has occurred. The standard diff format does not report |
|
469 | 469 | permission changes and diff only reports changes relative to one merge |
|
470 | 470 | parent. |
|
471 | 471 | |
|
472 | 472 | If one revision is given, it is used as the base revision. If two |
|
473 | 473 | revisions are given, the differences between them are shown. The --change |
|
474 | 474 | option can also be used as a shortcut to list the changed files of a |
|
475 | 475 | revision from its first parent. |
|
476 | 476 | |
|
477 | 477 | The codes used to show the status of files are: |
|
478 | 478 | |
|
479 | 479 | M = modified |
|
480 | 480 | A = added |
|
481 | 481 | R = removed |
|
482 | 482 | C = clean |
|
483 | 483 | ! = missing (deleted by non-hg command, but still tracked) |
|
484 | 484 | ? = not tracked |
|
485 | 485 | I = ignored |
|
486 | 486 | = origin of the previous file listed as A (added) |
|
487 | 487 | |
|
488 | 488 | Returns 0 on success. |
|
489 | 489 | |
|
490 | 490 | options: |
|
491 | 491 | |
|
492 | 492 | -A --all show status of all files |
|
493 | 493 | -m --modified show only modified files |
|
494 | 494 | -a --added show only added files |
|
495 | 495 | -r --removed show only removed files |
|
496 | 496 | -d --deleted show only deleted (but tracked) files |
|
497 | 497 | -c --clean show only files without changes |
|
498 | 498 | -u --unknown show only unknown (not tracked) files |
|
499 | 499 | -i --ignored show only ignored files |
|
500 | 500 | -n --no-status hide status prefix |
|
501 | 501 | -C --copies show source of copied files |
|
502 | 502 | -0 --print0 end filenames with NUL, for use with xargs |
|
503 | 503 | --rev REV [+] show difference from revision |
|
504 | 504 | --change REV list the changed files of a revision |
|
505 | 505 | -I --include PATTERN [+] include names matching the given patterns |
|
506 | 506 | -X --exclude PATTERN [+] exclude names matching the given patterns |
|
507 | 507 | -S --subrepos recurse into subrepositories |
|
508 | 508 | |
|
509 | 509 | [+] marked option can be specified multiple times |
|
510 | 510 | |
|
511 | 511 | use "hg -v help status" to show more complete help and the global options |
|
512 | 512 | |
|
513 | 513 | $ hg -q help status |
|
514 | 514 | hg status [OPTION]... [FILE]... |
|
515 | 515 | |
|
516 | 516 | show changed files in the working directory |
|
517 | 517 | |
|
518 | 518 | $ hg help foo |
|
519 | 519 | hg: unknown command 'foo' |
|
520 | 520 | Mercurial Distributed SCM |
|
521 | 521 | |
|
522 | 522 | basic commands: |
|
523 | 523 | |
|
524 | 524 | add add the specified files on the next commit |
|
525 | 525 | annotate show changeset information by line for each file |
|
526 | 526 | clone make a copy of an existing repository |
|
527 | 527 | commit commit the specified files or all outstanding changes |
|
528 | 528 | diff diff repository (or selected files) |
|
529 | 529 | export dump the header and diffs for one or more changesets |
|
530 | 530 | forget forget the specified files on the next commit |
|
531 | 531 | init create a new repository in the given directory |
|
532 | 532 | log show revision history of entire repository or files |
|
533 | 533 | merge merge working directory with another revision |
|
534 | 534 | pull pull changes from the specified source |
|
535 | 535 | push push changes to the specified destination |
|
536 | 536 | remove remove the specified files on the next commit |
|
537 | 537 | serve start stand-alone webserver |
|
538 | 538 | status show changed files in the working directory |
|
539 | 539 | summary summarize working directory state |
|
540 | 540 | update update working directory (or switch revisions) |
|
541 | 541 | |
|
542 | 542 | use "hg help" for the full list of commands or "hg -v" for details |
|
543 | 543 | [255] |
|
544 | 544 | |
|
545 | 545 | $ hg skjdfks |
|
546 | 546 | hg: unknown command 'skjdfks' |
|
547 | 547 | Mercurial Distributed SCM |
|
548 | 548 | |
|
549 | 549 | basic commands: |
|
550 | 550 | |
|
551 | 551 | add add the specified files on the next commit |
|
552 | 552 | annotate show changeset information by line for each file |
|
553 | 553 | clone make a copy of an existing repository |
|
554 | 554 | commit commit the specified files or all outstanding changes |
|
555 | 555 | diff diff repository (or selected files) |
|
556 | 556 | export dump the header and diffs for one or more changesets |
|
557 | 557 | forget forget the specified files on the next commit |
|
558 | 558 | init create a new repository in the given directory |
|
559 | 559 | log show revision history of entire repository or files |
|
560 | 560 | merge merge working directory with another revision |
|
561 | 561 | pull pull changes from the specified source |
|
562 | 562 | push push changes to the specified destination |
|
563 | 563 | remove remove the specified files on the next commit |
|
564 | 564 | serve start stand-alone webserver |
|
565 | 565 | status show changed files in the working directory |
|
566 | 566 | summary summarize working directory state |
|
567 | 567 | update update working directory (or switch revisions) |
|
568 | 568 | |
|
569 | 569 | use "hg help" for the full list of commands or "hg -v" for details |
|
570 | 570 | [255] |
|
571 | 571 | |
|
572 | 572 | $ cat > helpext.py <<EOF |
|
573 | 573 | > import os |
|
574 | 574 | > from mercurial import commands |
|
575 | 575 | > |
|
576 | 576 | > def nohelp(ui, *args, **kwargs): |
|
577 | 577 | > pass |
|
578 | 578 | > |
|
579 | 579 | > cmdtable = { |
|
580 | 580 | > "nohelp": (nohelp, [], "hg nohelp"), |
|
581 | 581 | > } |
|
582 | 582 | > |
|
583 | 583 | > commands.norepo += ' nohelp' |
|
584 | 584 | > EOF |
|
585 | 585 | $ echo '[extensions]' >> $HGRCPATH |
|
586 | 586 | $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH |
|
587 | 587 | |
|
588 | 588 | Test command with no help text |
|
589 | 589 | |
|
590 | 590 | $ hg help nohelp |
|
591 | 591 | hg nohelp |
|
592 | 592 | |
|
593 | 593 | (no help text available) |
|
594 | 594 | |
|
595 | 595 | use "hg -v help nohelp" to show the global options |
|
596 | 596 | |
|
597 | 597 | $ hg help -k nohelp |
|
598 | 598 | Commands: |
|
599 | 599 | |
|
600 | 600 | nohelp hg nohelp |
|
601 | 601 | |
|
602 | 602 | Extension Commands: |
|
603 | 603 | |
|
604 | 604 | nohelp (no help text available) |
|
605 | 605 | |
|
606 | 606 | Test that default list of commands omits extension commands |
|
607 | 607 | |
|
608 | 608 | $ hg help |
|
609 | 609 | Mercurial Distributed SCM |
|
610 | 610 | |
|
611 | 611 | list of commands: |
|
612 | 612 | |
|
613 | 613 | add add the specified files on the next commit |
|
614 | 614 | addremove add all new files, delete all missing files |
|
615 | 615 | annotate show changeset information by line for each file |
|
616 | 616 | archive create an unversioned archive of a repository revision |
|
617 | 617 | backout reverse effect of earlier changeset |
|
618 | 618 | bisect subdivision search of changesets |
|
619 | 619 | bookmarks track a line of development with movable markers |
|
620 | 620 | branch set or show the current branch name |
|
621 | 621 | branches list repository named branches |
|
622 | 622 | bundle create a changegroup file |
|
623 | 623 | cat output the current or given revision of files |
|
624 | 624 | clone make a copy of an existing repository |
|
625 | 625 | commit commit the specified files or all outstanding changes |
|
626 | 626 | copy mark files as copied for the next commit |
|
627 | 627 | diff diff repository (or selected files) |
|
628 | 628 | export dump the header and diffs for one or more changesets |
|
629 | 629 | forget forget the specified files on the next commit |
|
630 | 630 | graft copy changes from other branches onto the current branch |
|
631 | 631 | grep search for a pattern in specified files and revisions |
|
632 | 632 | heads show branch heads |
|
633 | 633 | help show help for a given topic or a help overview |
|
634 | 634 | identify identify the working copy or specified revision |
|
635 | 635 | import import an ordered set of patches |
|
636 | 636 | incoming show new changesets found in source |
|
637 | 637 | init create a new repository in the given directory |
|
638 | 638 | locate locate files matching specific patterns |
|
639 | 639 | log show revision history of entire repository or files |
|
640 | 640 | manifest output the current or given revision of the project manifest |
|
641 | 641 | merge merge working directory with another revision |
|
642 | 642 | outgoing show changesets not found in the destination |
|
643 | 643 | parents show the parents of the working directory or revision |
|
644 | 644 | paths show aliases for remote repositories |
|
645 | 645 | phase set or show the current phase name |
|
646 | 646 | pull pull changes from the specified source |
|
647 | 647 | push push changes to the specified destination |
|
648 | 648 | recover roll back an interrupted transaction |
|
649 | 649 | remove remove the specified files on the next commit |
|
650 | 650 | rename rename files; equivalent of copy + remove |
|
651 | 651 | resolve redo merges or set/view the merge status of files |
|
652 | 652 | revert restore files to their checkout state |
|
653 | 653 | root print the root (top) of the current working directory |
|
654 | 654 | serve start stand-alone webserver |
|
655 | 655 | showconfig show combined config settings from all hgrc files |
|
656 | 656 | status show changed files in the working directory |
|
657 | 657 | summary summarize working directory state |
|
658 | 658 | tag add one or more tags for the current or given revision |
|
659 | 659 | tags list repository tags |
|
660 | 660 | unbundle apply one or more changegroup files |
|
661 | 661 | update update working directory (or switch revisions) |
|
662 | 662 | verify verify the integrity of the repository |
|
663 | 663 | version output version and copyright information |
|
664 | 664 | |
|
665 | 665 | enabled extensions: |
|
666 | 666 | |
|
667 | 667 | helpext (no help text available) |
|
668 | 668 | |
|
669 | 669 | additional help topics: |
|
670 | 670 | |
|
671 | 671 | config Configuration Files |
|
672 | 672 | dates Date Formats |
|
673 | 673 | diffs Diff Formats |
|
674 | 674 | environment Environment Variables |
|
675 | 675 | extensions Using Additional Features |
|
676 | 676 | filesets Specifying File Sets |
|
677 | 677 | glossary Glossary |
|
678 | 678 | hgignore Syntax for Mercurial Ignore Files |
|
679 | 679 | hgweb Configuring hgweb |
|
680 | 680 | merge-tools Merge Tools |
|
681 | 681 | multirevs Specifying Multiple Revisions |
|
682 | 682 | patterns File Name Patterns |
|
683 | 683 | phases Working with Phases |
|
684 | 684 | revisions Specifying Single Revisions |
|
685 | 685 | revsets Specifying Revision Sets |
|
686 | 686 | subrepos Subrepositories |
|
687 | 687 | templating Template Usage |
|
688 | 688 | urls URL Paths |
|
689 | 689 | |
|
690 | 690 | use "hg -v help" to show builtin aliases and global options |
|
691 | 691 | |
|
692 | 692 | |
|
693 | 693 | |
|
694 | 694 | Test list of commands with command with no help text |
|
695 | 695 | |
|
696 | 696 | $ hg help helpext |
|
697 | 697 | helpext extension - no help text available |
|
698 | 698 | |
|
699 | 699 | list of commands: |
|
700 | 700 | |
|
701 | 701 | nohelp (no help text available) |
|
702 | 702 | |
|
703 | 703 | use "hg -v help helpext" to show builtin aliases and global options |
|
704 | 704 | |
|
705 | 705 | Test a help topic |
|
706 | 706 | |
|
707 | 707 | $ hg help revs |
|
708 | 708 | Specifying Single Revisions |
|
709 | 709 | """"""""""""""""""""""""""" |
|
710 | 710 | |
|
711 | 711 | Mercurial supports several ways to specify individual revisions. |
|
712 | 712 | |
|
713 | 713 | A plain integer is treated as a revision number. Negative integers are |
|
714 | 714 | treated as sequential offsets from the tip, with -1 denoting the tip, -2 |
|
715 | 715 | denoting the revision prior to the tip, and so forth. |
|
716 | 716 | |
|
717 | 717 | A 40-digit hexadecimal string is treated as a unique revision identifier. |
|
718 | 718 | |
|
719 | 719 | A hexadecimal string less than 40 characters long is treated as a unique |
|
720 | 720 | revision identifier and is referred to as a short-form identifier. A |
|
721 | 721 | short-form identifier is only valid if it is the prefix of exactly one |
|
722 | 722 | full-length identifier. |
|
723 | 723 | |
|
724 | 724 | Any other string is treated as a bookmark, tag, or branch name. A bookmark |
|
725 | 725 | is a movable pointer to a revision. A tag is a permanent name associated |
|
726 |
with a revision. A branch name denotes the tipmost |
|
|
726 | with a revision. A branch name denotes the tipmost open branch head of | |
|
727 | that branch - or if they are all closed, the tipmost closed head of the | |
|
727 | 728 | branch. Bookmark, tag, and branch names must not contain the ":" |
|
728 | 729 | character. |
|
729 | 730 | |
|
730 | 731 | The reserved name "tip" always identifies the most recent revision. |
|
731 | 732 | |
|
732 | 733 | The reserved name "null" indicates the null revision. This is the revision |
|
733 | 734 | of an empty repository, and the parent of revision 0. |
|
734 | 735 | |
|
735 | 736 | The reserved name "." indicates the working directory parent. If no |
|
736 | 737 | working directory is checked out, it is equivalent to null. If an |
|
737 | 738 | uncommitted merge is in progress, "." is the revision of the first parent. |
|
738 | 739 | |
|
739 | 740 | Test templating help |
|
740 | 741 | |
|
741 | 742 | $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) ' |
|
742 | 743 | desc String. The text of the changeset description. |
|
743 | 744 | diffstat String. Statistics of changes with the following format: |
|
744 | 745 | firstline Any text. Returns the first line of text. |
|
745 | 746 | nonempty Any text. Returns '(none)' if the string is empty. |
|
746 | 747 | |
|
747 | 748 | Test help hooks |
|
748 | 749 | |
|
749 | 750 | $ cat > helphook1.py <<EOF |
|
750 | 751 | > from mercurial import help |
|
751 | 752 | > |
|
752 | 753 | > def rewrite(topic, doc): |
|
753 | 754 | > return doc + '\nhelphook1\n' |
|
754 | 755 | > |
|
755 | 756 | > def extsetup(ui): |
|
756 | 757 | > help.addtopichook('revsets', rewrite) |
|
757 | 758 | > EOF |
|
758 | 759 | $ cat > helphook2.py <<EOF |
|
759 | 760 | > from mercurial import help |
|
760 | 761 | > |
|
761 | 762 | > def rewrite(topic, doc): |
|
762 | 763 | > return doc + '\nhelphook2\n' |
|
763 | 764 | > |
|
764 | 765 | > def extsetup(ui): |
|
765 | 766 | > help.addtopichook('revsets', rewrite) |
|
766 | 767 | > EOF |
|
767 | 768 | $ echo '[extensions]' >> $HGRCPATH |
|
768 | 769 | $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH |
|
769 | 770 | $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH |
|
770 | 771 | $ hg help revsets | grep helphook |
|
771 | 772 | helphook1 |
|
772 | 773 | helphook2 |
|
773 | 774 | |
|
774 | 775 | Test keyword search help |
|
775 | 776 | |
|
776 | 777 | $ cat > prefixedname.py <<EOF |
|
777 | 778 | > '''matched against word "clone" |
|
778 | 779 | > ''' |
|
779 | 780 | > EOF |
|
780 | 781 | $ echo '[extensions]' >> $HGRCPATH |
|
781 | 782 | $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH |
|
782 | 783 | $ hg help -k clone |
|
783 | 784 | Topics: |
|
784 | 785 | |
|
785 | 786 | config Configuration Files |
|
786 | 787 | extensions Using Additional Features |
|
787 | 788 | glossary Glossary |
|
788 | 789 | phases Working with Phases |
|
789 | 790 | subrepos Subrepositories |
|
790 | 791 | urls URL Paths |
|
791 | 792 | |
|
792 | 793 | Commands: |
|
793 | 794 | |
|
794 | 795 | bookmarks track a line of development with movable markers |
|
795 | 796 | clone make a copy of an existing repository |
|
796 | 797 | paths show aliases for remote repositories |
|
797 | 798 | update update working directory (or switch revisions) |
|
798 | 799 | |
|
799 | 800 | Extensions: |
|
800 | 801 | |
|
801 | 802 | prefixedname matched against word "clone" |
|
802 | 803 | relink recreates hardlinks between repository clones |
|
803 | 804 | |
|
804 | 805 | Extension Commands: |
|
805 | 806 | |
|
806 | 807 | qclone clone main and patch repository at same time |
|
807 | 808 | |
|
808 | 809 | Test omit indicating for help |
|
809 | 810 | |
|
810 | 811 | $ cat > addverboseitems.py <<EOF |
|
811 | 812 | > '''extension to test omit indicating. |
|
812 | 813 | > |
|
813 | 814 | > This paragraph is never omitted (for extension) |
|
814 | 815 | > |
|
815 | 816 | > .. container:: verbose |
|
816 | 817 | > |
|
817 | 818 | > This paragraph is omitted, |
|
818 | 819 | > if :hg:\`help\` is invoked witout \`\`-v\`\` (for extension) |
|
819 | 820 | > |
|
820 | 821 | > This paragraph is never omitted, too (for extension) |
|
821 | 822 | > ''' |
|
822 | 823 | > |
|
823 | 824 | > from mercurial import help, commands |
|
824 | 825 | > testtopic = """This paragraph is never omitted (for topic). |
|
825 | 826 | > |
|
826 | 827 | > .. container:: verbose |
|
827 | 828 | > |
|
828 | 829 | > This paragraph is omitted, |
|
829 | 830 | > if :hg:\`help\` is invoked witout \`\`-v\`\` (for topic) |
|
830 | 831 | > |
|
831 | 832 | > This paragraph is never omitted, too (for topic) |
|
832 | 833 | > """ |
|
833 | 834 | > def extsetup(ui): |
|
834 | 835 | > help.helptable.append((["topic-containing-verbose"], |
|
835 | 836 | > "This is the topic to test omit indicating.", |
|
836 | 837 | > lambda : testtopic)) |
|
837 | 838 | > EOF |
|
838 | 839 | $ echo '[extensions]' >> $HGRCPATH |
|
839 | 840 | $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH |
|
840 | 841 | $ hg help addverboseitems |
|
841 | 842 | addverboseitems extension - extension to test omit indicating. |
|
842 | 843 | |
|
843 | 844 | This paragraph is never omitted (for extension) |
|
844 | 845 | |
|
845 | 846 | This paragraph is never omitted, too (for extension) |
|
846 | 847 | |
|
847 | 848 | use "hg help -v addverboseitems" to show more complete help |
|
848 | 849 | |
|
849 | 850 | no commands defined |
|
850 | 851 | $ hg help -v addverboseitems |
|
851 | 852 | addverboseitems extension - extension to test omit indicating. |
|
852 | 853 | |
|
853 | 854 | This paragraph is never omitted (for extension) |
|
854 | 855 | |
|
855 | 856 | This paragraph is omitted, if "hg help" is invoked witout "-v" (for extension) |
|
856 | 857 | |
|
857 | 858 | This paragraph is never omitted, too (for extension) |
|
858 | 859 | |
|
859 | 860 | no commands defined |
|
860 | 861 | $ hg help topic-containing-verbose |
|
861 | 862 | This is the topic to test omit indicating. |
|
862 | 863 | """""""""""""""""""""""""""""""""""""""""" |
|
863 | 864 | |
|
864 | 865 | This paragraph is never omitted (for topic). |
|
865 | 866 | |
|
866 | 867 | This paragraph is never omitted, too (for topic) |
|
867 | 868 | |
|
868 | 869 | use "hg help -v topic-containing-verbose" to show more complete help |
|
869 | 870 | $ hg help -v topic-containing-verbose |
|
870 | 871 | This is the topic to test omit indicating. |
|
871 | 872 | """""""""""""""""""""""""""""""""""""""""" |
|
872 | 873 | |
|
873 | 874 | This paragraph is never omitted (for topic). |
|
874 | 875 | |
|
875 | 876 | This paragraph is omitted, if "hg help" is invoked witout "-v" (for topic) |
|
876 | 877 | |
|
877 | 878 | This paragraph is never omitted, too (for topic) |
|
878 | 879 | |
|
879 | 880 | Test usage of section marks in help documents |
|
880 | 881 | |
|
881 | 882 | $ cd "$TESTDIR"/../doc |
|
882 | 883 | $ python check-seclevel.py |
|
883 | 884 | $ cd $TESTTMP |
|
884 | 885 | |
|
885 | 886 | #if serve |
|
886 | 887 | |
|
887 | 888 | Test the help pages in hgweb. |
|
888 | 889 | |
|
889 | 890 | Dish up an empty repo; serve it cold. |
|
890 | 891 | |
|
891 | 892 | $ hg init "$TESTTMP/test" |
|
892 | 893 | $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid |
|
893 | 894 | $ cat hg.pid >> $DAEMON_PIDS |
|
894 | 895 | |
|
895 | 896 | $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help" |
|
896 | 897 | 200 Script output follows |
|
897 | 898 | |
|
898 | 899 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
899 | 900 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
900 | 901 | <head> |
|
901 | 902 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
902 | 903 | <meta name="robots" content="index, nofollow" /> |
|
903 | 904 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
904 | 905 | <script type="text/javascript" src="/static/mercurial.js"></script> |
|
905 | 906 | |
|
906 | 907 | <title>Help: Index</title> |
|
907 | 908 | </head> |
|
908 | 909 | <body> |
|
909 | 910 | |
|
910 | 911 | <div class="container"> |
|
911 | 912 | <div class="menu"> |
|
912 | 913 | <div class="logo"> |
|
913 | 914 | <a href="http://mercurial.selenic.com/"> |
|
914 | 915 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
915 | 916 | </div> |
|
916 | 917 | <ul> |
|
917 | 918 | <li><a href="/shortlog">log</a></li> |
|
918 | 919 | <li><a href="/graph">graph</a></li> |
|
919 | 920 | <li><a href="/tags">tags</a></li> |
|
920 | 921 | <li><a href="/bookmarks">bookmarks</a></li> |
|
921 | 922 | <li><a href="/branches">branches</a></li> |
|
922 | 923 | </ul> |
|
923 | 924 | <ul> |
|
924 | 925 | <li class="active">help</li> |
|
925 | 926 | </ul> |
|
926 | 927 | </div> |
|
927 | 928 | |
|
928 | 929 | <div class="main"> |
|
929 | 930 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> |
|
930 | 931 | <form class="search" action="/log"> |
|
931 | 932 | |
|
932 | 933 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
933 | 934 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision |
|
934 | 935 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> |
|
935 | 936 | </form> |
|
936 | 937 | <table class="bigtable"> |
|
937 | 938 | <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr> |
|
938 | 939 | |
|
939 | 940 | <tr><td> |
|
940 | 941 | <a href="/help/config"> |
|
941 | 942 | config |
|
942 | 943 | </a> |
|
943 | 944 | </td><td> |
|
944 | 945 | Configuration Files |
|
945 | 946 | </td></tr> |
|
946 | 947 | <tr><td> |
|
947 | 948 | <a href="/help/dates"> |
|
948 | 949 | dates |
|
949 | 950 | </a> |
|
950 | 951 | </td><td> |
|
951 | 952 | Date Formats |
|
952 | 953 | </td></tr> |
|
953 | 954 | <tr><td> |
|
954 | 955 | <a href="/help/diffs"> |
|
955 | 956 | diffs |
|
956 | 957 | </a> |
|
957 | 958 | </td><td> |
|
958 | 959 | Diff Formats |
|
959 | 960 | </td></tr> |
|
960 | 961 | <tr><td> |
|
961 | 962 | <a href="/help/environment"> |
|
962 | 963 | environment |
|
963 | 964 | </a> |
|
964 | 965 | </td><td> |
|
965 | 966 | Environment Variables |
|
966 | 967 | </td></tr> |
|
967 | 968 | <tr><td> |
|
968 | 969 | <a href="/help/extensions"> |
|
969 | 970 | extensions |
|
970 | 971 | </a> |
|
971 | 972 | </td><td> |
|
972 | 973 | Using Additional Features |
|
973 | 974 | </td></tr> |
|
974 | 975 | <tr><td> |
|
975 | 976 | <a href="/help/filesets"> |
|
976 | 977 | filesets |
|
977 | 978 | </a> |
|
978 | 979 | </td><td> |
|
979 | 980 | Specifying File Sets |
|
980 | 981 | </td></tr> |
|
981 | 982 | <tr><td> |
|
982 | 983 | <a href="/help/glossary"> |
|
983 | 984 | glossary |
|
984 | 985 | </a> |
|
985 | 986 | </td><td> |
|
986 | 987 | Glossary |
|
987 | 988 | </td></tr> |
|
988 | 989 | <tr><td> |
|
989 | 990 | <a href="/help/hgignore"> |
|
990 | 991 | hgignore |
|
991 | 992 | </a> |
|
992 | 993 | </td><td> |
|
993 | 994 | Syntax for Mercurial Ignore Files |
|
994 | 995 | </td></tr> |
|
995 | 996 | <tr><td> |
|
996 | 997 | <a href="/help/hgweb"> |
|
997 | 998 | hgweb |
|
998 | 999 | </a> |
|
999 | 1000 | </td><td> |
|
1000 | 1001 | Configuring hgweb |
|
1001 | 1002 | </td></tr> |
|
1002 | 1003 | <tr><td> |
|
1003 | 1004 | <a href="/help/merge-tools"> |
|
1004 | 1005 | merge-tools |
|
1005 | 1006 | </a> |
|
1006 | 1007 | </td><td> |
|
1007 | 1008 | Merge Tools |
|
1008 | 1009 | </td></tr> |
|
1009 | 1010 | <tr><td> |
|
1010 | 1011 | <a href="/help/multirevs"> |
|
1011 | 1012 | multirevs |
|
1012 | 1013 | </a> |
|
1013 | 1014 | </td><td> |
|
1014 | 1015 | Specifying Multiple Revisions |
|
1015 | 1016 | </td></tr> |
|
1016 | 1017 | <tr><td> |
|
1017 | 1018 | <a href="/help/patterns"> |
|
1018 | 1019 | patterns |
|
1019 | 1020 | </a> |
|
1020 | 1021 | </td><td> |
|
1021 | 1022 | File Name Patterns |
|
1022 | 1023 | </td></tr> |
|
1023 | 1024 | <tr><td> |
|
1024 | 1025 | <a href="/help/phases"> |
|
1025 | 1026 | phases |
|
1026 | 1027 | </a> |
|
1027 | 1028 | </td><td> |
|
1028 | 1029 | Working with Phases |
|
1029 | 1030 | </td></tr> |
|
1030 | 1031 | <tr><td> |
|
1031 | 1032 | <a href="/help/revisions"> |
|
1032 | 1033 | revisions |
|
1033 | 1034 | </a> |
|
1034 | 1035 | </td><td> |
|
1035 | 1036 | Specifying Single Revisions |
|
1036 | 1037 | </td></tr> |
|
1037 | 1038 | <tr><td> |
|
1038 | 1039 | <a href="/help/revsets"> |
|
1039 | 1040 | revsets |
|
1040 | 1041 | </a> |
|
1041 | 1042 | </td><td> |
|
1042 | 1043 | Specifying Revision Sets |
|
1043 | 1044 | </td></tr> |
|
1044 | 1045 | <tr><td> |
|
1045 | 1046 | <a href="/help/subrepos"> |
|
1046 | 1047 | subrepos |
|
1047 | 1048 | </a> |
|
1048 | 1049 | </td><td> |
|
1049 | 1050 | Subrepositories |
|
1050 | 1051 | </td></tr> |
|
1051 | 1052 | <tr><td> |
|
1052 | 1053 | <a href="/help/templating"> |
|
1053 | 1054 | templating |
|
1054 | 1055 | </a> |
|
1055 | 1056 | </td><td> |
|
1056 | 1057 | Template Usage |
|
1057 | 1058 | </td></tr> |
|
1058 | 1059 | <tr><td> |
|
1059 | 1060 | <a href="/help/urls"> |
|
1060 | 1061 | urls |
|
1061 | 1062 | </a> |
|
1062 | 1063 | </td><td> |
|
1063 | 1064 | URL Paths |
|
1064 | 1065 | </td></tr> |
|
1065 | 1066 | <tr><td> |
|
1066 | 1067 | <a href="/help/topic-containing-verbose"> |
|
1067 | 1068 | topic-containing-verbose |
|
1068 | 1069 | </a> |
|
1069 | 1070 | </td><td> |
|
1070 | 1071 | This is the topic to test omit indicating. |
|
1071 | 1072 | </td></tr> |
|
1072 | 1073 | |
|
1073 | 1074 | <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr> |
|
1074 | 1075 | |
|
1075 | 1076 | <tr><td> |
|
1076 | 1077 | <a href="/help/add"> |
|
1077 | 1078 | add |
|
1078 | 1079 | </a> |
|
1079 | 1080 | </td><td> |
|
1080 | 1081 | add the specified files on the next commit |
|
1081 | 1082 | </td></tr> |
|
1082 | 1083 | <tr><td> |
|
1083 | 1084 | <a href="/help/annotate"> |
|
1084 | 1085 | annotate |
|
1085 | 1086 | </a> |
|
1086 | 1087 | </td><td> |
|
1087 | 1088 | show changeset information by line for each file |
|
1088 | 1089 | </td></tr> |
|
1089 | 1090 | <tr><td> |
|
1090 | 1091 | <a href="/help/clone"> |
|
1091 | 1092 | clone |
|
1092 | 1093 | </a> |
|
1093 | 1094 | </td><td> |
|
1094 | 1095 | make a copy of an existing repository |
|
1095 | 1096 | </td></tr> |
|
1096 | 1097 | <tr><td> |
|
1097 | 1098 | <a href="/help/commit"> |
|
1098 | 1099 | commit |
|
1099 | 1100 | </a> |
|
1100 | 1101 | </td><td> |
|
1101 | 1102 | commit the specified files or all outstanding changes |
|
1102 | 1103 | </td></tr> |
|
1103 | 1104 | <tr><td> |
|
1104 | 1105 | <a href="/help/diff"> |
|
1105 | 1106 | diff |
|
1106 | 1107 | </a> |
|
1107 | 1108 | </td><td> |
|
1108 | 1109 | diff repository (or selected files) |
|
1109 | 1110 | </td></tr> |
|
1110 | 1111 | <tr><td> |
|
1111 | 1112 | <a href="/help/export"> |
|
1112 | 1113 | export |
|
1113 | 1114 | </a> |
|
1114 | 1115 | </td><td> |
|
1115 | 1116 | dump the header and diffs for one or more changesets |
|
1116 | 1117 | </td></tr> |
|
1117 | 1118 | <tr><td> |
|
1118 | 1119 | <a href="/help/forget"> |
|
1119 | 1120 | forget |
|
1120 | 1121 | </a> |
|
1121 | 1122 | </td><td> |
|
1122 | 1123 | forget the specified files on the next commit |
|
1123 | 1124 | </td></tr> |
|
1124 | 1125 | <tr><td> |
|
1125 | 1126 | <a href="/help/init"> |
|
1126 | 1127 | init |
|
1127 | 1128 | </a> |
|
1128 | 1129 | </td><td> |
|
1129 | 1130 | create a new repository in the given directory |
|
1130 | 1131 | </td></tr> |
|
1131 | 1132 | <tr><td> |
|
1132 | 1133 | <a href="/help/log"> |
|
1133 | 1134 | log |
|
1134 | 1135 | </a> |
|
1135 | 1136 | </td><td> |
|
1136 | 1137 | show revision history of entire repository or files |
|
1137 | 1138 | </td></tr> |
|
1138 | 1139 | <tr><td> |
|
1139 | 1140 | <a href="/help/merge"> |
|
1140 | 1141 | merge |
|
1141 | 1142 | </a> |
|
1142 | 1143 | </td><td> |
|
1143 | 1144 | merge working directory with another revision |
|
1144 | 1145 | </td></tr> |
|
1145 | 1146 | <tr><td> |
|
1146 | 1147 | <a href="/help/pull"> |
|
1147 | 1148 | pull |
|
1148 | 1149 | </a> |
|
1149 | 1150 | </td><td> |
|
1150 | 1151 | pull changes from the specified source |
|
1151 | 1152 | </td></tr> |
|
1152 | 1153 | <tr><td> |
|
1153 | 1154 | <a href="/help/push"> |
|
1154 | 1155 | push |
|
1155 | 1156 | </a> |
|
1156 | 1157 | </td><td> |
|
1157 | 1158 | push changes to the specified destination |
|
1158 | 1159 | </td></tr> |
|
1159 | 1160 | <tr><td> |
|
1160 | 1161 | <a href="/help/remove"> |
|
1161 | 1162 | remove |
|
1162 | 1163 | </a> |
|
1163 | 1164 | </td><td> |
|
1164 | 1165 | remove the specified files on the next commit |
|
1165 | 1166 | </td></tr> |
|
1166 | 1167 | <tr><td> |
|
1167 | 1168 | <a href="/help/serve"> |
|
1168 | 1169 | serve |
|
1169 | 1170 | </a> |
|
1170 | 1171 | </td><td> |
|
1171 | 1172 | start stand-alone webserver |
|
1172 | 1173 | </td></tr> |
|
1173 | 1174 | <tr><td> |
|
1174 | 1175 | <a href="/help/status"> |
|
1175 | 1176 | status |
|
1176 | 1177 | </a> |
|
1177 | 1178 | </td><td> |
|
1178 | 1179 | show changed files in the working directory |
|
1179 | 1180 | </td></tr> |
|
1180 | 1181 | <tr><td> |
|
1181 | 1182 | <a href="/help/summary"> |
|
1182 | 1183 | summary |
|
1183 | 1184 | </a> |
|
1184 | 1185 | </td><td> |
|
1185 | 1186 | summarize working directory state |
|
1186 | 1187 | </td></tr> |
|
1187 | 1188 | <tr><td> |
|
1188 | 1189 | <a href="/help/update"> |
|
1189 | 1190 | update |
|
1190 | 1191 | </a> |
|
1191 | 1192 | </td><td> |
|
1192 | 1193 | update working directory (or switch revisions) |
|
1193 | 1194 | </td></tr> |
|
1194 | 1195 | |
|
1195 | 1196 | <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr> |
|
1196 | 1197 | |
|
1197 | 1198 | <tr><td> |
|
1198 | 1199 | <a href="/help/addremove"> |
|
1199 | 1200 | addremove |
|
1200 | 1201 | </a> |
|
1201 | 1202 | </td><td> |
|
1202 | 1203 | add all new files, delete all missing files |
|
1203 | 1204 | </td></tr> |
|
1204 | 1205 | <tr><td> |
|
1205 | 1206 | <a href="/help/archive"> |
|
1206 | 1207 | archive |
|
1207 | 1208 | </a> |
|
1208 | 1209 | </td><td> |
|
1209 | 1210 | create an unversioned archive of a repository revision |
|
1210 | 1211 | </td></tr> |
|
1211 | 1212 | <tr><td> |
|
1212 | 1213 | <a href="/help/backout"> |
|
1213 | 1214 | backout |
|
1214 | 1215 | </a> |
|
1215 | 1216 | </td><td> |
|
1216 | 1217 | reverse effect of earlier changeset |
|
1217 | 1218 | </td></tr> |
|
1218 | 1219 | <tr><td> |
|
1219 | 1220 | <a href="/help/bisect"> |
|
1220 | 1221 | bisect |
|
1221 | 1222 | </a> |
|
1222 | 1223 | </td><td> |
|
1223 | 1224 | subdivision search of changesets |
|
1224 | 1225 | </td></tr> |
|
1225 | 1226 | <tr><td> |
|
1226 | 1227 | <a href="/help/bookmarks"> |
|
1227 | 1228 | bookmarks |
|
1228 | 1229 | </a> |
|
1229 | 1230 | </td><td> |
|
1230 | 1231 | track a line of development with movable markers |
|
1231 | 1232 | </td></tr> |
|
1232 | 1233 | <tr><td> |
|
1233 | 1234 | <a href="/help/branch"> |
|
1234 | 1235 | branch |
|
1235 | 1236 | </a> |
|
1236 | 1237 | </td><td> |
|
1237 | 1238 | set or show the current branch name |
|
1238 | 1239 | </td></tr> |
|
1239 | 1240 | <tr><td> |
|
1240 | 1241 | <a href="/help/branches"> |
|
1241 | 1242 | branches |
|
1242 | 1243 | </a> |
|
1243 | 1244 | </td><td> |
|
1244 | 1245 | list repository named branches |
|
1245 | 1246 | </td></tr> |
|
1246 | 1247 | <tr><td> |
|
1247 | 1248 | <a href="/help/bundle"> |
|
1248 | 1249 | bundle |
|
1249 | 1250 | </a> |
|
1250 | 1251 | </td><td> |
|
1251 | 1252 | create a changegroup file |
|
1252 | 1253 | </td></tr> |
|
1253 | 1254 | <tr><td> |
|
1254 | 1255 | <a href="/help/cat"> |
|
1255 | 1256 | cat |
|
1256 | 1257 | </a> |
|
1257 | 1258 | </td><td> |
|
1258 | 1259 | output the current or given revision of files |
|
1259 | 1260 | </td></tr> |
|
1260 | 1261 | <tr><td> |
|
1261 | 1262 | <a href="/help/copy"> |
|
1262 | 1263 | copy |
|
1263 | 1264 | </a> |
|
1264 | 1265 | </td><td> |
|
1265 | 1266 | mark files as copied for the next commit |
|
1266 | 1267 | </td></tr> |
|
1267 | 1268 | <tr><td> |
|
1268 | 1269 | <a href="/help/graft"> |
|
1269 | 1270 | graft |
|
1270 | 1271 | </a> |
|
1271 | 1272 | </td><td> |
|
1272 | 1273 | copy changes from other branches onto the current branch |
|
1273 | 1274 | </td></tr> |
|
1274 | 1275 | <tr><td> |
|
1275 | 1276 | <a href="/help/grep"> |
|
1276 | 1277 | grep |
|
1277 | 1278 | </a> |
|
1278 | 1279 | </td><td> |
|
1279 | 1280 | search for a pattern in specified files and revisions |
|
1280 | 1281 | </td></tr> |
|
1281 | 1282 | <tr><td> |
|
1282 | 1283 | <a href="/help/heads"> |
|
1283 | 1284 | heads |
|
1284 | 1285 | </a> |
|
1285 | 1286 | </td><td> |
|
1286 | 1287 | show branch heads |
|
1287 | 1288 | </td></tr> |
|
1288 | 1289 | <tr><td> |
|
1289 | 1290 | <a href="/help/help"> |
|
1290 | 1291 | help |
|
1291 | 1292 | </a> |
|
1292 | 1293 | </td><td> |
|
1293 | 1294 | show help for a given topic or a help overview |
|
1294 | 1295 | </td></tr> |
|
1295 | 1296 | <tr><td> |
|
1296 | 1297 | <a href="/help/identify"> |
|
1297 | 1298 | identify |
|
1298 | 1299 | </a> |
|
1299 | 1300 | </td><td> |
|
1300 | 1301 | identify the working copy or specified revision |
|
1301 | 1302 | </td></tr> |
|
1302 | 1303 | <tr><td> |
|
1303 | 1304 | <a href="/help/import"> |
|
1304 | 1305 | import |
|
1305 | 1306 | </a> |
|
1306 | 1307 | </td><td> |
|
1307 | 1308 | import an ordered set of patches |
|
1308 | 1309 | </td></tr> |
|
1309 | 1310 | <tr><td> |
|
1310 | 1311 | <a href="/help/incoming"> |
|
1311 | 1312 | incoming |
|
1312 | 1313 | </a> |
|
1313 | 1314 | </td><td> |
|
1314 | 1315 | show new changesets found in source |
|
1315 | 1316 | </td></tr> |
|
1316 | 1317 | <tr><td> |
|
1317 | 1318 | <a href="/help/locate"> |
|
1318 | 1319 | locate |
|
1319 | 1320 | </a> |
|
1320 | 1321 | </td><td> |
|
1321 | 1322 | locate files matching specific patterns |
|
1322 | 1323 | </td></tr> |
|
1323 | 1324 | <tr><td> |
|
1324 | 1325 | <a href="/help/manifest"> |
|
1325 | 1326 | manifest |
|
1326 | 1327 | </a> |
|
1327 | 1328 | </td><td> |
|
1328 | 1329 | output the current or given revision of the project manifest |
|
1329 | 1330 | </td></tr> |
|
1330 | 1331 | <tr><td> |
|
1331 | 1332 | <a href="/help/nohelp"> |
|
1332 | 1333 | nohelp |
|
1333 | 1334 | </a> |
|
1334 | 1335 | </td><td> |
|
1335 | 1336 | (no help text available) |
|
1336 | 1337 | </td></tr> |
|
1337 | 1338 | <tr><td> |
|
1338 | 1339 | <a href="/help/outgoing"> |
|
1339 | 1340 | outgoing |
|
1340 | 1341 | </a> |
|
1341 | 1342 | </td><td> |
|
1342 | 1343 | show changesets not found in the destination |
|
1343 | 1344 | </td></tr> |
|
1344 | 1345 | <tr><td> |
|
1345 | 1346 | <a href="/help/parents"> |
|
1346 | 1347 | parents |
|
1347 | 1348 | </a> |
|
1348 | 1349 | </td><td> |
|
1349 | 1350 | show the parents of the working directory or revision |
|
1350 | 1351 | </td></tr> |
|
1351 | 1352 | <tr><td> |
|
1352 | 1353 | <a href="/help/paths"> |
|
1353 | 1354 | paths |
|
1354 | 1355 | </a> |
|
1355 | 1356 | </td><td> |
|
1356 | 1357 | show aliases for remote repositories |
|
1357 | 1358 | </td></tr> |
|
1358 | 1359 | <tr><td> |
|
1359 | 1360 | <a href="/help/phase"> |
|
1360 | 1361 | phase |
|
1361 | 1362 | </a> |
|
1362 | 1363 | </td><td> |
|
1363 | 1364 | set or show the current phase name |
|
1364 | 1365 | </td></tr> |
|
1365 | 1366 | <tr><td> |
|
1366 | 1367 | <a href="/help/recover"> |
|
1367 | 1368 | recover |
|
1368 | 1369 | </a> |
|
1369 | 1370 | </td><td> |
|
1370 | 1371 | roll back an interrupted transaction |
|
1371 | 1372 | </td></tr> |
|
1372 | 1373 | <tr><td> |
|
1373 | 1374 | <a href="/help/rename"> |
|
1374 | 1375 | rename |
|
1375 | 1376 | </a> |
|
1376 | 1377 | </td><td> |
|
1377 | 1378 | rename files; equivalent of copy + remove |
|
1378 | 1379 | </td></tr> |
|
1379 | 1380 | <tr><td> |
|
1380 | 1381 | <a href="/help/resolve"> |
|
1381 | 1382 | resolve |
|
1382 | 1383 | </a> |
|
1383 | 1384 | </td><td> |
|
1384 | 1385 | redo merges or set/view the merge status of files |
|
1385 | 1386 | </td></tr> |
|
1386 | 1387 | <tr><td> |
|
1387 | 1388 | <a href="/help/revert"> |
|
1388 | 1389 | revert |
|
1389 | 1390 | </a> |
|
1390 | 1391 | </td><td> |
|
1391 | 1392 | restore files to their checkout state |
|
1392 | 1393 | </td></tr> |
|
1393 | 1394 | <tr><td> |
|
1394 | 1395 | <a href="/help/root"> |
|
1395 | 1396 | root |
|
1396 | 1397 | </a> |
|
1397 | 1398 | </td><td> |
|
1398 | 1399 | print the root (top) of the current working directory |
|
1399 | 1400 | </td></tr> |
|
1400 | 1401 | <tr><td> |
|
1401 | 1402 | <a href="/help/showconfig"> |
|
1402 | 1403 | showconfig |
|
1403 | 1404 | </a> |
|
1404 | 1405 | </td><td> |
|
1405 | 1406 | show combined config settings from all hgrc files |
|
1406 | 1407 | </td></tr> |
|
1407 | 1408 | <tr><td> |
|
1408 | 1409 | <a href="/help/tag"> |
|
1409 | 1410 | tag |
|
1410 | 1411 | </a> |
|
1411 | 1412 | </td><td> |
|
1412 | 1413 | add one or more tags for the current or given revision |
|
1413 | 1414 | </td></tr> |
|
1414 | 1415 | <tr><td> |
|
1415 | 1416 | <a href="/help/tags"> |
|
1416 | 1417 | tags |
|
1417 | 1418 | </a> |
|
1418 | 1419 | </td><td> |
|
1419 | 1420 | list repository tags |
|
1420 | 1421 | </td></tr> |
|
1421 | 1422 | <tr><td> |
|
1422 | 1423 | <a href="/help/unbundle"> |
|
1423 | 1424 | unbundle |
|
1424 | 1425 | </a> |
|
1425 | 1426 | </td><td> |
|
1426 | 1427 | apply one or more changegroup files |
|
1427 | 1428 | </td></tr> |
|
1428 | 1429 | <tr><td> |
|
1429 | 1430 | <a href="/help/verify"> |
|
1430 | 1431 | verify |
|
1431 | 1432 | </a> |
|
1432 | 1433 | </td><td> |
|
1433 | 1434 | verify the integrity of the repository |
|
1434 | 1435 | </td></tr> |
|
1435 | 1436 | <tr><td> |
|
1436 | 1437 | <a href="/help/version"> |
|
1437 | 1438 | version |
|
1438 | 1439 | </a> |
|
1439 | 1440 | </td><td> |
|
1440 | 1441 | output version and copyright information |
|
1441 | 1442 | </td></tr> |
|
1442 | 1443 | </table> |
|
1443 | 1444 | </div> |
|
1444 | 1445 | </div> |
|
1445 | 1446 | |
|
1446 | 1447 | <script type="text/javascript">process_dates()</script> |
|
1447 | 1448 | |
|
1448 | 1449 | |
|
1449 | 1450 | </body> |
|
1450 | 1451 | </html> |
|
1451 | 1452 | |
|
1452 | 1453 | |
|
1453 | 1454 | $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/add" |
|
1454 | 1455 | 200 Script output follows |
|
1455 | 1456 | |
|
1456 | 1457 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
1457 | 1458 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
1458 | 1459 | <head> |
|
1459 | 1460 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
1460 | 1461 | <meta name="robots" content="index, nofollow" /> |
|
1461 | 1462 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
1462 | 1463 | <script type="text/javascript" src="/static/mercurial.js"></script> |
|
1463 | 1464 | |
|
1464 | 1465 | <title>Help: add</title> |
|
1465 | 1466 | </head> |
|
1466 | 1467 | <body> |
|
1467 | 1468 | |
|
1468 | 1469 | <div class="container"> |
|
1469 | 1470 | <div class="menu"> |
|
1470 | 1471 | <div class="logo"> |
|
1471 | 1472 | <a href="http://mercurial.selenic.com/"> |
|
1472 | 1473 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
1473 | 1474 | </div> |
|
1474 | 1475 | <ul> |
|
1475 | 1476 | <li><a href="/shortlog">log</a></li> |
|
1476 | 1477 | <li><a href="/graph">graph</a></li> |
|
1477 | 1478 | <li><a href="/tags">tags</a></li> |
|
1478 | 1479 | <li><a href="/bookmarks">bookmarks</a></li> |
|
1479 | 1480 | <li><a href="/branches">branches</a></li> |
|
1480 | 1481 | </ul> |
|
1481 | 1482 | <ul> |
|
1482 | 1483 | <li class="active"><a href="/help">help</a></li> |
|
1483 | 1484 | </ul> |
|
1484 | 1485 | </div> |
|
1485 | 1486 | |
|
1486 | 1487 | <div class="main"> |
|
1487 | 1488 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> |
|
1488 | 1489 | <h3>Help: add</h3> |
|
1489 | 1490 | |
|
1490 | 1491 | <form class="search" action="/log"> |
|
1491 | 1492 | |
|
1492 | 1493 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
1493 | 1494 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision |
|
1494 | 1495 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> |
|
1495 | 1496 | </form> |
|
1496 | 1497 | <div id="doc"> |
|
1497 | 1498 | <p> |
|
1498 | 1499 | hg add [OPTION]... [FILE]... |
|
1499 | 1500 | </p> |
|
1500 | 1501 | <p> |
|
1501 | 1502 | add the specified files on the next commit |
|
1502 | 1503 | </p> |
|
1503 | 1504 | <p> |
|
1504 | 1505 | Schedule files to be version controlled and added to the |
|
1505 | 1506 | repository. |
|
1506 | 1507 | </p> |
|
1507 | 1508 | <p> |
|
1508 | 1509 | The files will be added to the repository at the next commit. To |
|
1509 | 1510 | undo an add before that, see "hg forget". |
|
1510 | 1511 | </p> |
|
1511 | 1512 | <p> |
|
1512 | 1513 | If no names are given, add all files to the repository. |
|
1513 | 1514 | </p> |
|
1514 | 1515 | <p> |
|
1515 | 1516 | An example showing how new (unknown) files are added |
|
1516 | 1517 | automatically by "hg add": |
|
1517 | 1518 | </p> |
|
1518 | 1519 | <pre> |
|
1519 | 1520 | \$ ls (re) |
|
1520 | 1521 | foo.c |
|
1521 | 1522 | \$ hg status (re) |
|
1522 | 1523 | ? foo.c |
|
1523 | 1524 | \$ hg add (re) |
|
1524 | 1525 | adding foo.c |
|
1525 | 1526 | \$ hg status (re) |
|
1526 | 1527 | A foo.c |
|
1527 | 1528 | </pre> |
|
1528 | 1529 | <p> |
|
1529 | 1530 | Returns 0 if all files are successfully added. |
|
1530 | 1531 | </p> |
|
1531 | 1532 | <p> |
|
1532 | 1533 | options: |
|
1533 | 1534 | </p> |
|
1534 | 1535 | <table> |
|
1535 | 1536 | <tr><td>-I</td> |
|
1536 | 1537 | <td>--include PATTERN [+]</td> |
|
1537 | 1538 | <td>include names matching the given patterns</td></tr> |
|
1538 | 1539 | <tr><td>-X</td> |
|
1539 | 1540 | <td>--exclude PATTERN [+]</td> |
|
1540 | 1541 | <td>exclude names matching the given patterns</td></tr> |
|
1541 | 1542 | <tr><td>-S</td> |
|
1542 | 1543 | <td>--subrepos</td> |
|
1543 | 1544 | <td>recurse into subrepositories</td></tr> |
|
1544 | 1545 | <tr><td>-n</td> |
|
1545 | 1546 | <td>--dry-run</td> |
|
1546 | 1547 | <td>do not perform actions, just print output</td></tr> |
|
1547 | 1548 | </table> |
|
1548 | 1549 | <p> |
|
1549 | 1550 | [+] marked option can be specified multiple times |
|
1550 | 1551 | </p> |
|
1551 | 1552 | <p> |
|
1552 | 1553 | global options: |
|
1553 | 1554 | </p> |
|
1554 | 1555 | <table> |
|
1555 | 1556 | <tr><td>-R</td> |
|
1556 | 1557 | <td>--repository REPO</td> |
|
1557 | 1558 | <td>repository root directory or name of overlay bundle file</td></tr> |
|
1558 | 1559 | <tr><td></td> |
|
1559 | 1560 | <td>--cwd DIR</td> |
|
1560 | 1561 | <td>change working directory</td></tr> |
|
1561 | 1562 | <tr><td>-y</td> |
|
1562 | 1563 | <td>--noninteractive</td> |
|
1563 | 1564 | <td>do not prompt, automatically pick the first choice for all prompts</td></tr> |
|
1564 | 1565 | <tr><td>-q</td> |
|
1565 | 1566 | <td>--quiet</td> |
|
1566 | 1567 | <td>suppress output</td></tr> |
|
1567 | 1568 | <tr><td>-v</td> |
|
1568 | 1569 | <td>--verbose</td> |
|
1569 | 1570 | <td>enable additional output</td></tr> |
|
1570 | 1571 | <tr><td></td> |
|
1571 | 1572 | <td>--config CONFIG [+]</td> |
|
1572 | 1573 | <td>set/override config option (use 'section.name=value')</td></tr> |
|
1573 | 1574 | <tr><td></td> |
|
1574 | 1575 | <td>--debug</td> |
|
1575 | 1576 | <td>enable debugging output</td></tr> |
|
1576 | 1577 | <tr><td></td> |
|
1577 | 1578 | <td>--debugger</td> |
|
1578 | 1579 | <td>start debugger</td></tr> |
|
1579 | 1580 | <tr><td></td> |
|
1580 | 1581 | <td>--encoding ENCODE</td> |
|
1581 | 1582 | <td>set the charset encoding (default: ascii)</td></tr> |
|
1582 | 1583 | <tr><td></td> |
|
1583 | 1584 | <td>--encodingmode MODE</td> |
|
1584 | 1585 | <td>set the charset encoding mode (default: strict)</td></tr> |
|
1585 | 1586 | <tr><td></td> |
|
1586 | 1587 | <td>--traceback</td> |
|
1587 | 1588 | <td>always print a traceback on exception</td></tr> |
|
1588 | 1589 | <tr><td></td> |
|
1589 | 1590 | <td>--time</td> |
|
1590 | 1591 | <td>time how long the command takes</td></tr> |
|
1591 | 1592 | <tr><td></td> |
|
1592 | 1593 | <td>--profile</td> |
|
1593 | 1594 | <td>print command execution profile</td></tr> |
|
1594 | 1595 | <tr><td></td> |
|
1595 | 1596 | <td>--version</td> |
|
1596 | 1597 | <td>output version information and exit</td></tr> |
|
1597 | 1598 | <tr><td>-h</td> |
|
1598 | 1599 | <td>--help</td> |
|
1599 | 1600 | <td>display help and exit</td></tr> |
|
1600 | 1601 | <tr><td></td> |
|
1601 | 1602 | <td>--hidden</td> |
|
1602 | 1603 | <td>consider hidden changesets</td></tr> |
|
1603 | 1604 | </table> |
|
1604 | 1605 | <p> |
|
1605 | 1606 | [+] marked option can be specified multiple times |
|
1606 | 1607 | </p> |
|
1607 | 1608 | |
|
1608 | 1609 | </div> |
|
1609 | 1610 | </div> |
|
1610 | 1611 | </div> |
|
1611 | 1612 | |
|
1612 | 1613 | <script type="text/javascript">process_dates()</script> |
|
1613 | 1614 | |
|
1614 | 1615 | |
|
1615 | 1616 | </body> |
|
1616 | 1617 | </html> |
|
1617 | 1618 | |
|
1618 | 1619 | |
|
1619 | 1620 | $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/remove" |
|
1620 | 1621 | 200 Script output follows |
|
1621 | 1622 | |
|
1622 | 1623 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
1623 | 1624 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
1624 | 1625 | <head> |
|
1625 | 1626 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
1626 | 1627 | <meta name="robots" content="index, nofollow" /> |
|
1627 | 1628 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
1628 | 1629 | <script type="text/javascript" src="/static/mercurial.js"></script> |
|
1629 | 1630 | |
|
1630 | 1631 | <title>Help: remove</title> |
|
1631 | 1632 | </head> |
|
1632 | 1633 | <body> |
|
1633 | 1634 | |
|
1634 | 1635 | <div class="container"> |
|
1635 | 1636 | <div class="menu"> |
|
1636 | 1637 | <div class="logo"> |
|
1637 | 1638 | <a href="http://mercurial.selenic.com/"> |
|
1638 | 1639 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
1639 | 1640 | </div> |
|
1640 | 1641 | <ul> |
|
1641 | 1642 | <li><a href="/shortlog">log</a></li> |
|
1642 | 1643 | <li><a href="/graph">graph</a></li> |
|
1643 | 1644 | <li><a href="/tags">tags</a></li> |
|
1644 | 1645 | <li><a href="/bookmarks">bookmarks</a></li> |
|
1645 | 1646 | <li><a href="/branches">branches</a></li> |
|
1646 | 1647 | </ul> |
|
1647 | 1648 | <ul> |
|
1648 | 1649 | <li class="active"><a href="/help">help</a></li> |
|
1649 | 1650 | </ul> |
|
1650 | 1651 | </div> |
|
1651 | 1652 | |
|
1652 | 1653 | <div class="main"> |
|
1653 | 1654 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> |
|
1654 | 1655 | <h3>Help: remove</h3> |
|
1655 | 1656 | |
|
1656 | 1657 | <form class="search" action="/log"> |
|
1657 | 1658 | |
|
1658 | 1659 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
1659 | 1660 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision |
|
1660 | 1661 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> |
|
1661 | 1662 | </form> |
|
1662 | 1663 | <div id="doc"> |
|
1663 | 1664 | <p> |
|
1664 | 1665 | hg remove [OPTION]... FILE... |
|
1665 | 1666 | </p> |
|
1666 | 1667 | <p> |
|
1667 | 1668 | aliases: rm |
|
1668 | 1669 | </p> |
|
1669 | 1670 | <p> |
|
1670 | 1671 | remove the specified files on the next commit |
|
1671 | 1672 | </p> |
|
1672 | 1673 | <p> |
|
1673 | 1674 | Schedule the indicated files for removal from the current branch. |
|
1674 | 1675 | </p> |
|
1675 | 1676 | <p> |
|
1676 | 1677 | This command schedules the files to be removed at the next commit. |
|
1677 | 1678 | To undo a remove before that, see "hg revert". To undo added |
|
1678 | 1679 | files, see "hg forget". |
|
1679 | 1680 | </p> |
|
1680 | 1681 | <p> |
|
1681 | 1682 | -A/--after can be used to remove only files that have already |
|
1682 | 1683 | been deleted, -f/--force can be used to force deletion, and -Af |
|
1683 | 1684 | can be used to remove files from the next revision without |
|
1684 | 1685 | deleting them from the working directory. |
|
1685 | 1686 | </p> |
|
1686 | 1687 | <p> |
|
1687 | 1688 | The following table details the behavior of remove for different |
|
1688 | 1689 | file states (columns) and option combinations (rows). The file |
|
1689 | 1690 | states are Added [A], Clean [C], Modified [M] and Missing [!] |
|
1690 | 1691 | (as reported by "hg status"). The actions are Warn, Remove |
|
1691 | 1692 | (from branch) and Delete (from disk): |
|
1692 | 1693 | </p> |
|
1693 | 1694 | <table> |
|
1694 | 1695 | <tr><td>opt/state</td> |
|
1695 | 1696 | <td>A</td> |
|
1696 | 1697 | <td>C</td> |
|
1697 | 1698 | <td>M</td> |
|
1698 | 1699 | <td>!</td></tr> |
|
1699 | 1700 | <tr><td>none</td> |
|
1700 | 1701 | <td>W</td> |
|
1701 | 1702 | <td>RD</td> |
|
1702 | 1703 | <td>W</td> |
|
1703 | 1704 | <td>R</td></tr> |
|
1704 | 1705 | <tr><td>-f</td> |
|
1705 | 1706 | <td>R</td> |
|
1706 | 1707 | <td>RD</td> |
|
1707 | 1708 | <td>RD</td> |
|
1708 | 1709 | <td>R</td></tr> |
|
1709 | 1710 | <tr><td>-A</td> |
|
1710 | 1711 | <td>W</td> |
|
1711 | 1712 | <td>W</td> |
|
1712 | 1713 | <td>W</td> |
|
1713 | 1714 | <td>R</td></tr> |
|
1714 | 1715 | <tr><td>-Af</td> |
|
1715 | 1716 | <td>R</td> |
|
1716 | 1717 | <td>R</td> |
|
1717 | 1718 | <td>R</td> |
|
1718 | 1719 | <td>R</td></tr> |
|
1719 | 1720 | </table> |
|
1720 | 1721 | <p> |
|
1721 | 1722 | Note that remove never deletes files in Added [A] state from the |
|
1722 | 1723 | working directory, not even if option --force is specified. |
|
1723 | 1724 | </p> |
|
1724 | 1725 | <p> |
|
1725 | 1726 | Returns 0 on success, 1 if any warnings encountered. |
|
1726 | 1727 | </p> |
|
1727 | 1728 | <p> |
|
1728 | 1729 | options: |
|
1729 | 1730 | </p> |
|
1730 | 1731 | <table> |
|
1731 | 1732 | <tr><td>-A</td> |
|
1732 | 1733 | <td>--after</td> |
|
1733 | 1734 | <td>record delete for missing files</td></tr> |
|
1734 | 1735 | <tr><td>-f</td> |
|
1735 | 1736 | <td>--force</td> |
|
1736 | 1737 | <td>remove (and delete) file even if added or modified</td></tr> |
|
1737 | 1738 | <tr><td>-I</td> |
|
1738 | 1739 | <td>--include PATTERN [+]</td> |
|
1739 | 1740 | <td>include names matching the given patterns</td></tr> |
|
1740 | 1741 | <tr><td>-X</td> |
|
1741 | 1742 | <td>--exclude PATTERN [+]</td> |
|
1742 | 1743 | <td>exclude names matching the given patterns</td></tr> |
|
1743 | 1744 | </table> |
|
1744 | 1745 | <p> |
|
1745 | 1746 | [+] marked option can be specified multiple times |
|
1746 | 1747 | </p> |
|
1747 | 1748 | <p> |
|
1748 | 1749 | global options: |
|
1749 | 1750 | </p> |
|
1750 | 1751 | <table> |
|
1751 | 1752 | <tr><td>-R</td> |
|
1752 | 1753 | <td>--repository REPO</td> |
|
1753 | 1754 | <td>repository root directory or name of overlay bundle file</td></tr> |
|
1754 | 1755 | <tr><td></td> |
|
1755 | 1756 | <td>--cwd DIR</td> |
|
1756 | 1757 | <td>change working directory</td></tr> |
|
1757 | 1758 | <tr><td>-y</td> |
|
1758 | 1759 | <td>--noninteractive</td> |
|
1759 | 1760 | <td>do not prompt, automatically pick the first choice for all prompts</td></tr> |
|
1760 | 1761 | <tr><td>-q</td> |
|
1761 | 1762 | <td>--quiet</td> |
|
1762 | 1763 | <td>suppress output</td></tr> |
|
1763 | 1764 | <tr><td>-v</td> |
|
1764 | 1765 | <td>--verbose</td> |
|
1765 | 1766 | <td>enable additional output</td></tr> |
|
1766 | 1767 | <tr><td></td> |
|
1767 | 1768 | <td>--config CONFIG [+]</td> |
|
1768 | 1769 | <td>set/override config option (use 'section.name=value')</td></tr> |
|
1769 | 1770 | <tr><td></td> |
|
1770 | 1771 | <td>--debug</td> |
|
1771 | 1772 | <td>enable debugging output</td></tr> |
|
1772 | 1773 | <tr><td></td> |
|
1773 | 1774 | <td>--debugger</td> |
|
1774 | 1775 | <td>start debugger</td></tr> |
|
1775 | 1776 | <tr><td></td> |
|
1776 | 1777 | <td>--encoding ENCODE</td> |
|
1777 | 1778 | <td>set the charset encoding (default: ascii)</td></tr> |
|
1778 | 1779 | <tr><td></td> |
|
1779 | 1780 | <td>--encodingmode MODE</td> |
|
1780 | 1781 | <td>set the charset encoding mode (default: strict)</td></tr> |
|
1781 | 1782 | <tr><td></td> |
|
1782 | 1783 | <td>--traceback</td> |
|
1783 | 1784 | <td>always print a traceback on exception</td></tr> |
|
1784 | 1785 | <tr><td></td> |
|
1785 | 1786 | <td>--time</td> |
|
1786 | 1787 | <td>time how long the command takes</td></tr> |
|
1787 | 1788 | <tr><td></td> |
|
1788 | 1789 | <td>--profile</td> |
|
1789 | 1790 | <td>print command execution profile</td></tr> |
|
1790 | 1791 | <tr><td></td> |
|
1791 | 1792 | <td>--version</td> |
|
1792 | 1793 | <td>output version information and exit</td></tr> |
|
1793 | 1794 | <tr><td>-h</td> |
|
1794 | 1795 | <td>--help</td> |
|
1795 | 1796 | <td>display help and exit</td></tr> |
|
1796 | 1797 | <tr><td></td> |
|
1797 | 1798 | <td>--hidden</td> |
|
1798 | 1799 | <td>consider hidden changesets</td></tr> |
|
1799 | 1800 | </table> |
|
1800 | 1801 | <p> |
|
1801 | 1802 | [+] marked option can be specified multiple times |
|
1802 | 1803 | </p> |
|
1803 | 1804 | |
|
1804 | 1805 | </div> |
|
1805 | 1806 | </div> |
|
1806 | 1807 | </div> |
|
1807 | 1808 | |
|
1808 | 1809 | <script type="text/javascript">process_dates()</script> |
|
1809 | 1810 | |
|
1810 | 1811 | |
|
1811 | 1812 | </body> |
|
1812 | 1813 | </html> |
|
1813 | 1814 | |
|
1814 | 1815 | |
|
1815 | 1816 | $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/revisions" |
|
1816 | 1817 | 200 Script output follows |
|
1817 | 1818 | |
|
1818 | 1819 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
1819 | 1820 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
1820 | 1821 | <head> |
|
1821 | 1822 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
1822 | 1823 | <meta name="robots" content="index, nofollow" /> |
|
1823 | 1824 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
1824 | 1825 | <script type="text/javascript" src="/static/mercurial.js"></script> |
|
1825 | 1826 | |
|
1826 | 1827 | <title>Help: revisions</title> |
|
1827 | 1828 | </head> |
|
1828 | 1829 | <body> |
|
1829 | 1830 | |
|
1830 | 1831 | <div class="container"> |
|
1831 | 1832 | <div class="menu"> |
|
1832 | 1833 | <div class="logo"> |
|
1833 | 1834 | <a href="http://mercurial.selenic.com/"> |
|
1834 | 1835 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
1835 | 1836 | </div> |
|
1836 | 1837 | <ul> |
|
1837 | 1838 | <li><a href="/shortlog">log</a></li> |
|
1838 | 1839 | <li><a href="/graph">graph</a></li> |
|
1839 | 1840 | <li><a href="/tags">tags</a></li> |
|
1840 | 1841 | <li><a href="/bookmarks">bookmarks</a></li> |
|
1841 | 1842 | <li><a href="/branches">branches</a></li> |
|
1842 | 1843 | </ul> |
|
1843 | 1844 | <ul> |
|
1844 | 1845 | <li class="active"><a href="/help">help</a></li> |
|
1845 | 1846 | </ul> |
|
1846 | 1847 | </div> |
|
1847 | 1848 | |
|
1848 | 1849 | <div class="main"> |
|
1849 | 1850 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> |
|
1850 | 1851 | <h3>Help: revisions</h3> |
|
1851 | 1852 | |
|
1852 | 1853 | <form class="search" action="/log"> |
|
1853 | 1854 | |
|
1854 | 1855 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
1855 | 1856 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision |
|
1856 | 1857 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> |
|
1857 | 1858 | </form> |
|
1858 | 1859 | <div id="doc"> |
|
1859 | 1860 | <h1>Specifying Single Revisions</h1> |
|
1860 | 1861 | <p> |
|
1861 | 1862 | Mercurial supports several ways to specify individual revisions. |
|
1862 | 1863 | </p> |
|
1863 | 1864 | <p> |
|
1864 | 1865 | A plain integer is treated as a revision number. Negative integers are |
|
1865 | 1866 | treated as sequential offsets from the tip, with -1 denoting the tip, |
|
1866 | 1867 | -2 denoting the revision prior to the tip, and so forth. |
|
1867 | 1868 | </p> |
|
1868 | 1869 | <p> |
|
1869 | 1870 | A 40-digit hexadecimal string is treated as a unique revision |
|
1870 | 1871 | identifier. |
|
1871 | 1872 | </p> |
|
1872 | 1873 | <p> |
|
1873 | 1874 | A hexadecimal string less than 40 characters long is treated as a |
|
1874 | 1875 | unique revision identifier and is referred to as a short-form |
|
1875 | 1876 | identifier. A short-form identifier is only valid if it is the prefix |
|
1876 | 1877 | of exactly one full-length identifier. |
|
1877 | 1878 | </p> |
|
1878 | 1879 | <p> |
|
1879 | 1880 | Any other string is treated as a bookmark, tag, or branch name. A |
|
1880 | 1881 | bookmark is a movable pointer to a revision. A tag is a permanent name |
|
1881 |
associated with a revision. A branch name denotes the tipmost |
|
|
1882 | of that branch. Bookmark, tag, and branch names must not contain the ":" | |
|
1883 | character. | |
|
1882 | associated with a revision. A branch name denotes the tipmost open branch head | |
|
1883 | of that branch - or if they are all closed, the tipmost closed head of the | |
|
1884 | branch. Bookmark, tag, and branch names must not contain the ":" character. | |
|
1884 | 1885 | </p> |
|
1885 | 1886 | <p> |
|
1886 | 1887 | The reserved name "tip" always identifies the most recent revision. |
|
1887 | 1888 | </p> |
|
1888 | 1889 | <p> |
|
1889 | 1890 | The reserved name "null" indicates the null revision. This is the |
|
1890 | 1891 | revision of an empty repository, and the parent of revision 0. |
|
1891 | 1892 | </p> |
|
1892 | 1893 | <p> |
|
1893 | 1894 | The reserved name "." indicates the working directory parent. If no |
|
1894 | 1895 | working directory is checked out, it is equivalent to null. If an |
|
1895 | 1896 | uncommitted merge is in progress, "." is the revision of the first |
|
1896 | 1897 | parent. |
|
1897 | 1898 | </p> |
|
1898 | 1899 | |
|
1899 | 1900 | </div> |
|
1900 | 1901 | </div> |
|
1901 | 1902 | </div> |
|
1902 | 1903 | |
|
1903 | 1904 | <script type="text/javascript">process_dates()</script> |
|
1904 | 1905 | |
|
1905 | 1906 | |
|
1906 | 1907 | </body> |
|
1907 | 1908 | </html> |
|
1908 | 1909 | |
|
1909 | 1910 | |
|
1910 | 1911 | $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS |
|
1911 | 1912 | |
|
1912 | 1913 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now