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