##// END OF EJS Templates
strip: do not update branchcache during strip (issue3745)...
Pierre-Yves David -
r18137:d8e7b3a1 default
parent child Browse files
Show More
@@ -1,2585 +1,2589 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, transaction, store, encoding, base85
11 import lock, transaction, store, encoding, base85
12 import scmutil, util, extensions, hook, error, revset
12 import scmutil, util, extensions, hook, error, revset
13 import match as matchmod
13 import match as matchmod
14 import merge as mergemod
14 import merge as mergemod
15 import tags as tagsmod
15 import tags as tagsmod
16 from lock import release
16 from lock import release
17 import weakref, errno, os, time, inspect
17 import weakref, errno, os, time, inspect
18 import branchmap
18 import branchmap
19 propertycache = util.propertycache
19 propertycache = util.propertycache
20 filecache = scmutil.filecache
20 filecache = scmutil.filecache
21
21
22 class repofilecache(filecache):
22 class repofilecache(filecache):
23 """All filecache usage on repo are done for logic that should be unfiltered
23 """All filecache usage on repo are done for logic that should be unfiltered
24 """
24 """
25
25
26 def __get__(self, repo, type=None):
26 def __get__(self, repo, type=None):
27 return super(repofilecache, self).__get__(repo.unfiltered(), type)
27 return super(repofilecache, self).__get__(repo.unfiltered(), type)
28 def __set__(self, repo, value):
28 def __set__(self, repo, value):
29 return super(repofilecache, self).__set__(repo.unfiltered(), value)
29 return super(repofilecache, self).__set__(repo.unfiltered(), value)
30 def __delete__(self, repo):
30 def __delete__(self, repo):
31 return super(repofilecache, self).__delete__(repo.unfiltered())
31 return super(repofilecache, self).__delete__(repo.unfiltered())
32
32
33 class storecache(repofilecache):
33 class storecache(repofilecache):
34 """filecache for files in the store"""
34 """filecache for files in the store"""
35 def join(self, obj, fname):
35 def join(self, obj, fname):
36 return obj.sjoin(fname)
36 return obj.sjoin(fname)
37
37
38 class unfilteredpropertycache(propertycache):
38 class unfilteredpropertycache(propertycache):
39 """propertycache that apply to unfiltered repo only"""
39 """propertycache that apply to unfiltered repo only"""
40
40
41 def __get__(self, repo, type=None):
41 def __get__(self, repo, type=None):
42 return super(unfilteredpropertycache, self).__get__(repo.unfiltered())
42 return super(unfilteredpropertycache, self).__get__(repo.unfiltered())
43
43
44 class filteredpropertycache(propertycache):
44 class filteredpropertycache(propertycache):
45 """propertycache that must take filtering in account"""
45 """propertycache that must take filtering in account"""
46
46
47 def cachevalue(self, obj, value):
47 def cachevalue(self, obj, value):
48 object.__setattr__(obj, self.name, value)
48 object.__setattr__(obj, self.name, value)
49
49
50
50
51 def hasunfilteredcache(repo, name):
51 def hasunfilteredcache(repo, name):
52 """check if an repo and a unfilteredproperty cached value for <name>"""
52 """check if an repo and a unfilteredproperty cached value for <name>"""
53 return name in vars(repo.unfiltered())
53 return name in vars(repo.unfiltered())
54
54
55 def unfilteredmethod(orig):
55 def unfilteredmethod(orig):
56 """decorate method that always need to be run on unfiltered version"""
56 """decorate method that always need to be run on unfiltered version"""
57 def wrapper(repo, *args, **kwargs):
57 def wrapper(repo, *args, **kwargs):
58 return orig(repo.unfiltered(), *args, **kwargs)
58 return orig(repo.unfiltered(), *args, **kwargs)
59 return wrapper
59 return wrapper
60
60
61 MODERNCAPS = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle'))
61 MODERNCAPS = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle'))
62 LEGACYCAPS = MODERNCAPS.union(set(['changegroupsubset']))
62 LEGACYCAPS = MODERNCAPS.union(set(['changegroupsubset']))
63
63
64 class localpeer(peer.peerrepository):
64 class localpeer(peer.peerrepository):
65 '''peer for a local repo; reflects only the most recent API'''
65 '''peer for a local repo; reflects only the most recent API'''
66
66
67 def __init__(self, repo, caps=MODERNCAPS):
67 def __init__(self, repo, caps=MODERNCAPS):
68 peer.peerrepository.__init__(self)
68 peer.peerrepository.__init__(self)
69 self._repo = repo
69 self._repo = repo
70 self.ui = repo.ui
70 self.ui = repo.ui
71 self._caps = repo._restrictcapabilities(caps)
71 self._caps = repo._restrictcapabilities(caps)
72 self.requirements = repo.requirements
72 self.requirements = repo.requirements
73 self.supportedformats = repo.supportedformats
73 self.supportedformats = repo.supportedformats
74
74
75 def close(self):
75 def close(self):
76 self._repo.close()
76 self._repo.close()
77
77
78 def _capabilities(self):
78 def _capabilities(self):
79 return self._caps
79 return self._caps
80
80
81 def local(self):
81 def local(self):
82 return self._repo
82 return self._repo
83
83
84 def canpush(self):
84 def canpush(self):
85 return True
85 return True
86
86
87 def url(self):
87 def url(self):
88 return self._repo.url()
88 return self._repo.url()
89
89
90 def lookup(self, key):
90 def lookup(self, key):
91 return self._repo.lookup(key)
91 return self._repo.lookup(key)
92
92
93 def branchmap(self):
93 def branchmap(self):
94 return discovery.visiblebranchmap(self._repo)
94 return discovery.visiblebranchmap(self._repo)
95
95
96 def heads(self):
96 def heads(self):
97 return discovery.visibleheads(self._repo)
97 return discovery.visibleheads(self._repo)
98
98
99 def known(self, nodes):
99 def known(self, nodes):
100 return self._repo.known(nodes)
100 return self._repo.known(nodes)
101
101
102 def getbundle(self, source, heads=None, common=None):
102 def getbundle(self, source, heads=None, common=None):
103 return self._repo.getbundle(source, heads=heads, common=common)
103 return self._repo.getbundle(source, heads=heads, common=common)
104
104
105 # TODO We might want to move the next two calls into legacypeer and add
105 # TODO We might want to move the next two calls into legacypeer and add
106 # unbundle instead.
106 # unbundle instead.
107
107
108 def lock(self):
108 def lock(self):
109 return self._repo.lock()
109 return self._repo.lock()
110
110
111 def addchangegroup(self, cg, source, url):
111 def addchangegroup(self, cg, source, url):
112 return self._repo.addchangegroup(cg, source, url)
112 return self._repo.addchangegroup(cg, source, url)
113
113
114 def pushkey(self, namespace, key, old, new):
114 def pushkey(self, namespace, key, old, new):
115 return self._repo.pushkey(namespace, key, old, new)
115 return self._repo.pushkey(namespace, key, old, new)
116
116
117 def listkeys(self, namespace):
117 def listkeys(self, namespace):
118 return self._repo.listkeys(namespace)
118 return self._repo.listkeys(namespace)
119
119
120 def debugwireargs(self, one, two, three=None, four=None, five=None):
120 def debugwireargs(self, one, two, three=None, four=None, five=None):
121 '''used to test argument passing over the wire'''
121 '''used to test argument passing over the wire'''
122 return "%s %s %s %s %s" % (one, two, three, four, five)
122 return "%s %s %s %s %s" % (one, two, three, four, five)
123
123
124 class locallegacypeer(localpeer):
124 class locallegacypeer(localpeer):
125 '''peer extension which implements legacy methods too; used for tests with
125 '''peer extension which implements legacy methods too; used for tests with
126 restricted capabilities'''
126 restricted capabilities'''
127
127
128 def __init__(self, repo):
128 def __init__(self, repo):
129 localpeer.__init__(self, repo, caps=LEGACYCAPS)
129 localpeer.__init__(self, repo, caps=LEGACYCAPS)
130
130
131 def branches(self, nodes):
131 def branches(self, nodes):
132 return self._repo.branches(nodes)
132 return self._repo.branches(nodes)
133
133
134 def between(self, pairs):
134 def between(self, pairs):
135 return self._repo.between(pairs)
135 return self._repo.between(pairs)
136
136
137 def changegroup(self, basenodes, source):
137 def changegroup(self, basenodes, source):
138 return self._repo.changegroup(basenodes, source)
138 return self._repo.changegroup(basenodes, source)
139
139
140 def changegroupsubset(self, bases, heads, source):
140 def changegroupsubset(self, bases, heads, source):
141 return self._repo.changegroupsubset(bases, heads, source)
141 return self._repo.changegroupsubset(bases, heads, source)
142
142
143 class localrepository(object):
143 class localrepository(object):
144
144
145 supportedformats = set(('revlogv1', 'generaldelta'))
145 supportedformats = set(('revlogv1', 'generaldelta'))
146 supported = supportedformats | set(('store', 'fncache', 'shared',
146 supported = supportedformats | set(('store', 'fncache', 'shared',
147 'dotencode'))
147 'dotencode'))
148 openerreqs = set(('revlogv1', 'generaldelta'))
148 openerreqs = set(('revlogv1', 'generaldelta'))
149 requirements = ['revlogv1']
149 requirements = ['revlogv1']
150
150
151 def _baserequirements(self, create):
151 def _baserequirements(self, create):
152 return self.requirements[:]
152 return self.requirements[:]
153
153
154 def __init__(self, baseui, path=None, create=False):
154 def __init__(self, baseui, path=None, create=False):
155 self.wvfs = scmutil.vfs(path, expand=True)
155 self.wvfs = scmutil.vfs(path, expand=True)
156 self.wopener = self.wvfs
156 self.wopener = self.wvfs
157 self.root = self.wvfs.base
157 self.root = self.wvfs.base
158 self.path = self.wvfs.join(".hg")
158 self.path = self.wvfs.join(".hg")
159 self.origroot = path
159 self.origroot = path
160 self.auditor = scmutil.pathauditor(self.root, self._checknested)
160 self.auditor = scmutil.pathauditor(self.root, self._checknested)
161 self.vfs = scmutil.vfs(self.path)
161 self.vfs = scmutil.vfs(self.path)
162 self.opener = self.vfs
162 self.opener = self.vfs
163 self.baseui = baseui
163 self.baseui = baseui
164 self.ui = baseui.copy()
164 self.ui = baseui.copy()
165 # A list of callback to shape the phase if no data were found.
165 # A list of callback to shape the phase if no data were found.
166 # Callback are in the form: func(repo, roots) --> processed root.
166 # Callback are in the form: func(repo, roots) --> processed root.
167 # This list it to be filled by extension during repo setup
167 # This list it to be filled by extension during repo setup
168 self._phasedefaults = []
168 self._phasedefaults = []
169 try:
169 try:
170 self.ui.readconfig(self.join("hgrc"), self.root)
170 self.ui.readconfig(self.join("hgrc"), self.root)
171 extensions.loadall(self.ui)
171 extensions.loadall(self.ui)
172 except IOError:
172 except IOError:
173 pass
173 pass
174
174
175 if not self.vfs.isdir():
175 if not self.vfs.isdir():
176 if create:
176 if create:
177 if not self.wvfs.exists():
177 if not self.wvfs.exists():
178 self.wvfs.makedirs()
178 self.wvfs.makedirs()
179 self.vfs.makedir(notindexed=True)
179 self.vfs.makedir(notindexed=True)
180 requirements = self._baserequirements(create)
180 requirements = self._baserequirements(create)
181 if self.ui.configbool('format', 'usestore', True):
181 if self.ui.configbool('format', 'usestore', True):
182 self.vfs.mkdir("store")
182 self.vfs.mkdir("store")
183 requirements.append("store")
183 requirements.append("store")
184 if self.ui.configbool('format', 'usefncache', True):
184 if self.ui.configbool('format', 'usefncache', True):
185 requirements.append("fncache")
185 requirements.append("fncache")
186 if self.ui.configbool('format', 'dotencode', True):
186 if self.ui.configbool('format', 'dotencode', True):
187 requirements.append('dotencode')
187 requirements.append('dotencode')
188 # create an invalid changelog
188 # create an invalid changelog
189 self.vfs.append(
189 self.vfs.append(
190 "00changelog.i",
190 "00changelog.i",
191 '\0\0\0\2' # represents revlogv2
191 '\0\0\0\2' # represents revlogv2
192 ' dummy changelog to prevent using the old repo layout'
192 ' dummy changelog to prevent using the old repo layout'
193 )
193 )
194 if self.ui.configbool('format', 'generaldelta', False):
194 if self.ui.configbool('format', 'generaldelta', False):
195 requirements.append("generaldelta")
195 requirements.append("generaldelta")
196 requirements = set(requirements)
196 requirements = set(requirements)
197 else:
197 else:
198 raise error.RepoError(_("repository %s not found") % path)
198 raise error.RepoError(_("repository %s not found") % path)
199 elif create:
199 elif create:
200 raise error.RepoError(_("repository %s already exists") % path)
200 raise error.RepoError(_("repository %s already exists") % path)
201 else:
201 else:
202 try:
202 try:
203 requirements = scmutil.readrequires(self.vfs, self.supported)
203 requirements = scmutil.readrequires(self.vfs, self.supported)
204 except IOError, inst:
204 except IOError, inst:
205 if inst.errno != errno.ENOENT:
205 if inst.errno != errno.ENOENT:
206 raise
206 raise
207 requirements = set()
207 requirements = set()
208
208
209 self.sharedpath = self.path
209 self.sharedpath = self.path
210 try:
210 try:
211 s = os.path.realpath(self.opener.read("sharedpath").rstrip('\n'))
211 s = os.path.realpath(self.opener.read("sharedpath").rstrip('\n'))
212 if not os.path.exists(s):
212 if not os.path.exists(s):
213 raise error.RepoError(
213 raise error.RepoError(
214 _('.hg/sharedpath points to nonexistent directory %s') % s)
214 _('.hg/sharedpath points to nonexistent directory %s') % s)
215 self.sharedpath = s
215 self.sharedpath = s
216 except IOError, inst:
216 except IOError, inst:
217 if inst.errno != errno.ENOENT:
217 if inst.errno != errno.ENOENT:
218 raise
218 raise
219
219
220 self.store = store.store(requirements, self.sharedpath, scmutil.vfs)
220 self.store = store.store(requirements, self.sharedpath, scmutil.vfs)
221 self.spath = self.store.path
221 self.spath = self.store.path
222 self.svfs = self.store.vfs
222 self.svfs = self.store.vfs
223 self.sopener = self.svfs
223 self.sopener = self.svfs
224 self.sjoin = self.store.join
224 self.sjoin = self.store.join
225 self.vfs.createmode = self.store.createmode
225 self.vfs.createmode = self.store.createmode
226 self._applyrequirements(requirements)
226 self._applyrequirements(requirements)
227 if create:
227 if create:
228 self._writerequirements()
228 self._writerequirements()
229
229
230
230
231 self._branchcache = None
231 self._branchcache = None
232 self.filterpats = {}
232 self.filterpats = {}
233 self._datafilters = {}
233 self._datafilters = {}
234 self._transref = self._lockref = self._wlockref = None
234 self._transref = self._lockref = self._wlockref = None
235
235
236 # A cache for various files under .hg/ that tracks file changes,
236 # A cache for various files under .hg/ that tracks file changes,
237 # (used by the filecache decorator)
237 # (used by the filecache decorator)
238 #
238 #
239 # Maps a property name to its util.filecacheentry
239 # Maps a property name to its util.filecacheentry
240 self._filecache = {}
240 self._filecache = {}
241
241
242 # hold sets of revision to be filtered
242 # hold sets of revision to be filtered
243 # should be cleared when something might have changed the filter value:
243 # should be cleared when something might have changed the filter value:
244 # - new changesets,
244 # - new changesets,
245 # - phase change,
245 # - phase change,
246 # - new obsolescence marker,
246 # - new obsolescence marker,
247 # - working directory parent change,
247 # - working directory parent change,
248 # - bookmark changes
248 # - bookmark changes
249 self.filteredrevcache = {}
249 self.filteredrevcache = {}
250
250
251 def close(self):
251 def close(self):
252 pass
252 pass
253
253
254 def _restrictcapabilities(self, caps):
254 def _restrictcapabilities(self, caps):
255 return caps
255 return caps
256
256
257 def _applyrequirements(self, requirements):
257 def _applyrequirements(self, requirements):
258 self.requirements = requirements
258 self.requirements = requirements
259 self.sopener.options = dict((r, 1) for r in requirements
259 self.sopener.options = dict((r, 1) for r in requirements
260 if r in self.openerreqs)
260 if r in self.openerreqs)
261
261
262 def _writerequirements(self):
262 def _writerequirements(self):
263 reqfile = self.opener("requires", "w")
263 reqfile = self.opener("requires", "w")
264 for r in self.requirements:
264 for r in self.requirements:
265 reqfile.write("%s\n" % r)
265 reqfile.write("%s\n" % r)
266 reqfile.close()
266 reqfile.close()
267
267
268 def _checknested(self, path):
268 def _checknested(self, path):
269 """Determine if path is a legal nested repository."""
269 """Determine if path is a legal nested repository."""
270 if not path.startswith(self.root):
270 if not path.startswith(self.root):
271 return False
271 return False
272 subpath = path[len(self.root) + 1:]
272 subpath = path[len(self.root) + 1:]
273 normsubpath = util.pconvert(subpath)
273 normsubpath = util.pconvert(subpath)
274
274
275 # XXX: Checking against the current working copy is wrong in
275 # XXX: Checking against the current working copy is wrong in
276 # the sense that it can reject things like
276 # the sense that it can reject things like
277 #
277 #
278 # $ hg cat -r 10 sub/x.txt
278 # $ hg cat -r 10 sub/x.txt
279 #
279 #
280 # if sub/ is no longer a subrepository in the working copy
280 # if sub/ is no longer a subrepository in the working copy
281 # parent revision.
281 # parent revision.
282 #
282 #
283 # However, it can of course also allow things that would have
283 # However, it can of course also allow things that would have
284 # been rejected before, such as the above cat command if sub/
284 # been rejected before, such as the above cat command if sub/
285 # is a subrepository now, but was a normal directory before.
285 # is a subrepository now, but was a normal directory before.
286 # The old path auditor would have rejected by mistake since it
286 # The old path auditor would have rejected by mistake since it
287 # panics when it sees sub/.hg/.
287 # panics when it sees sub/.hg/.
288 #
288 #
289 # All in all, checking against the working copy seems sensible
289 # All in all, checking against the working copy seems sensible
290 # since we want to prevent access to nested repositories on
290 # since we want to prevent access to nested repositories on
291 # the filesystem *now*.
291 # the filesystem *now*.
292 ctx = self[None]
292 ctx = self[None]
293 parts = util.splitpath(subpath)
293 parts = util.splitpath(subpath)
294 while parts:
294 while parts:
295 prefix = '/'.join(parts)
295 prefix = '/'.join(parts)
296 if prefix in ctx.substate:
296 if prefix in ctx.substate:
297 if prefix == normsubpath:
297 if prefix == normsubpath:
298 return True
298 return True
299 else:
299 else:
300 sub = ctx.sub(prefix)
300 sub = ctx.sub(prefix)
301 return sub.checknested(subpath[len(prefix) + 1:])
301 return sub.checknested(subpath[len(prefix) + 1:])
302 else:
302 else:
303 parts.pop()
303 parts.pop()
304 return False
304 return False
305
305
306 def peer(self):
306 def peer(self):
307 return localpeer(self) # not cached to avoid reference cycle
307 return localpeer(self) # not cached to avoid reference cycle
308
308
309 def unfiltered(self):
309 def unfiltered(self):
310 """Return unfiltered version of the repository
310 """Return unfiltered version of the repository
311
311
312 Intended to be ovewritten by filtered repo."""
312 Intended to be ovewritten by filtered repo."""
313 return self
313 return self
314
314
315 def filtered(self, name):
315 def filtered(self, name):
316 """Return a filtered version of a repository"""
316 """Return a filtered version of a repository"""
317 # build a new class with the mixin and the current class
317 # build a new class with the mixin and the current class
318 # (possibily subclass of the repo)
318 # (possibily subclass of the repo)
319 class proxycls(repoview.repoview, self.unfiltered().__class__):
319 class proxycls(repoview.repoview, self.unfiltered().__class__):
320 pass
320 pass
321 return proxycls(self, name)
321 return proxycls(self, name)
322
322
323 @repofilecache('bookmarks')
323 @repofilecache('bookmarks')
324 def _bookmarks(self):
324 def _bookmarks(self):
325 return bookmarks.bmstore(self)
325 return bookmarks.bmstore(self)
326
326
327 @repofilecache('bookmarks.current')
327 @repofilecache('bookmarks.current')
328 def _bookmarkcurrent(self):
328 def _bookmarkcurrent(self):
329 return bookmarks.readcurrent(self)
329 return bookmarks.readcurrent(self)
330
330
331 def bookmarkheads(self, bookmark):
331 def bookmarkheads(self, bookmark):
332 name = bookmark.split('@', 1)[0]
332 name = bookmark.split('@', 1)[0]
333 heads = []
333 heads = []
334 for mark, n in self._bookmarks.iteritems():
334 for mark, n in self._bookmarks.iteritems():
335 if mark.split('@', 1)[0] == name:
335 if mark.split('@', 1)[0] == name:
336 heads.append(n)
336 heads.append(n)
337 return heads
337 return heads
338
338
339 @storecache('phaseroots')
339 @storecache('phaseroots')
340 def _phasecache(self):
340 def _phasecache(self):
341 return phases.phasecache(self, self._phasedefaults)
341 return phases.phasecache(self, self._phasedefaults)
342
342
343 @storecache('obsstore')
343 @storecache('obsstore')
344 def obsstore(self):
344 def obsstore(self):
345 store = obsolete.obsstore(self.sopener)
345 store = obsolete.obsstore(self.sopener)
346 if store and not obsolete._enabled:
346 if store and not obsolete._enabled:
347 # message is rare enough to not be translated
347 # message is rare enough to not be translated
348 msg = 'obsolete feature not enabled but %i markers found!\n'
348 msg = 'obsolete feature not enabled but %i markers found!\n'
349 self.ui.warn(msg % len(list(store)))
349 self.ui.warn(msg % len(list(store)))
350 return store
350 return store
351
351
352 @unfilteredpropertycache
352 @unfilteredpropertycache
353 def hiddenrevs(self):
353 def hiddenrevs(self):
354 """hiddenrevs: revs that should be hidden by command and tools
354 """hiddenrevs: revs that should be hidden by command and tools
355
355
356 This set is carried on the repo to ease initialization and lazy
356 This set is carried on the repo to ease initialization and lazy
357 loading; it'll probably move back to changelog for efficiency and
357 loading; it'll probably move back to changelog for efficiency and
358 consistency reasons.
358 consistency reasons.
359
359
360 Note that the hiddenrevs will needs invalidations when
360 Note that the hiddenrevs will needs invalidations when
361 - a new changesets is added (possible unstable above extinct)
361 - a new changesets is added (possible unstable above extinct)
362 - a new obsolete marker is added (possible new extinct changeset)
362 - a new obsolete marker is added (possible new extinct changeset)
363
363
364 hidden changesets cannot have non-hidden descendants
364 hidden changesets cannot have non-hidden descendants
365 """
365 """
366 hidden = set()
366 hidden = set()
367 if self.obsstore:
367 if self.obsstore:
368 ### hide extinct changeset that are not accessible by any mean
368 ### hide extinct changeset that are not accessible by any mean
369 hiddenquery = 'extinct() - ::(. + bookmark())'
369 hiddenquery = 'extinct() - ::(. + bookmark())'
370 hidden.update(self.revs(hiddenquery))
370 hidden.update(self.revs(hiddenquery))
371 return hidden
371 return hidden
372
372
373 @storecache('00changelog.i')
373 @storecache('00changelog.i')
374 def changelog(self):
374 def changelog(self):
375 c = changelog.changelog(self.sopener)
375 c = changelog.changelog(self.sopener)
376 if 'HG_PENDING' in os.environ:
376 if 'HG_PENDING' in os.environ:
377 p = os.environ['HG_PENDING']
377 p = os.environ['HG_PENDING']
378 if p.startswith(self.root):
378 if p.startswith(self.root):
379 c.readpending('00changelog.i.a')
379 c.readpending('00changelog.i.a')
380 return c
380 return c
381
381
382 @storecache('00manifest.i')
382 @storecache('00manifest.i')
383 def manifest(self):
383 def manifest(self):
384 return manifest.manifest(self.sopener)
384 return manifest.manifest(self.sopener)
385
385
386 @repofilecache('dirstate')
386 @repofilecache('dirstate')
387 def dirstate(self):
387 def dirstate(self):
388 warned = [0]
388 warned = [0]
389 def validate(node):
389 def validate(node):
390 try:
390 try:
391 self.changelog.rev(node)
391 self.changelog.rev(node)
392 return node
392 return node
393 except error.LookupError:
393 except error.LookupError:
394 if not warned[0]:
394 if not warned[0]:
395 warned[0] = True
395 warned[0] = True
396 self.ui.warn(_("warning: ignoring unknown"
396 self.ui.warn(_("warning: ignoring unknown"
397 " working parent %s!\n") % short(node))
397 " working parent %s!\n") % short(node))
398 return nullid
398 return nullid
399
399
400 return dirstate.dirstate(self.opener, self.ui, self.root, validate)
400 return dirstate.dirstate(self.opener, self.ui, self.root, validate)
401
401
402 def __getitem__(self, changeid):
402 def __getitem__(self, changeid):
403 if changeid is None:
403 if changeid is None:
404 return context.workingctx(self)
404 return context.workingctx(self)
405 return context.changectx(self, changeid)
405 return context.changectx(self, changeid)
406
406
407 def __contains__(self, changeid):
407 def __contains__(self, changeid):
408 try:
408 try:
409 return bool(self.lookup(changeid))
409 return bool(self.lookup(changeid))
410 except error.RepoLookupError:
410 except error.RepoLookupError:
411 return False
411 return False
412
412
413 def __nonzero__(self):
413 def __nonzero__(self):
414 return True
414 return True
415
415
416 def __len__(self):
416 def __len__(self):
417 return len(self.changelog)
417 return len(self.changelog)
418
418
419 def __iter__(self):
419 def __iter__(self):
420 return iter(self.changelog)
420 return iter(self.changelog)
421
421
422 def revs(self, expr, *args):
422 def revs(self, expr, *args):
423 '''Return a list of revisions matching the given revset'''
423 '''Return a list of revisions matching the given revset'''
424 expr = revset.formatspec(expr, *args)
424 expr = revset.formatspec(expr, *args)
425 m = revset.match(None, expr)
425 m = revset.match(None, expr)
426 return [r for r in m(self, list(self))]
426 return [r for r in m(self, list(self))]
427
427
428 def set(self, expr, *args):
428 def set(self, expr, *args):
429 '''
429 '''
430 Yield a context for each matching revision, after doing arg
430 Yield a context for each matching revision, after doing arg
431 replacement via revset.formatspec
431 replacement via revset.formatspec
432 '''
432 '''
433 for r in self.revs(expr, *args):
433 for r in self.revs(expr, *args):
434 yield self[r]
434 yield self[r]
435
435
436 def url(self):
436 def url(self):
437 return 'file:' + self.root
437 return 'file:' + self.root
438
438
439 def hook(self, name, throw=False, **args):
439 def hook(self, name, throw=False, **args):
440 return hook.hook(self.ui, self, name, throw, **args)
440 return hook.hook(self.ui, self, name, throw, **args)
441
441
442 @unfilteredmethod
442 @unfilteredmethod
443 def _tag(self, names, node, message, local, user, date, extra={}):
443 def _tag(self, names, node, message, local, user, date, extra={}):
444 if isinstance(names, str):
444 if isinstance(names, str):
445 names = (names,)
445 names = (names,)
446
446
447 branches = self.branchmap()
447 branches = self.branchmap()
448 for name in names:
448 for name in names:
449 self.hook('pretag', throw=True, node=hex(node), tag=name,
449 self.hook('pretag', throw=True, node=hex(node), tag=name,
450 local=local)
450 local=local)
451 if name in branches:
451 if name in branches:
452 self.ui.warn(_("warning: tag %s conflicts with existing"
452 self.ui.warn(_("warning: tag %s conflicts with existing"
453 " branch name\n") % name)
453 " branch name\n") % name)
454
454
455 def writetags(fp, names, munge, prevtags):
455 def writetags(fp, names, munge, prevtags):
456 fp.seek(0, 2)
456 fp.seek(0, 2)
457 if prevtags and prevtags[-1] != '\n':
457 if prevtags and prevtags[-1] != '\n':
458 fp.write('\n')
458 fp.write('\n')
459 for name in names:
459 for name in names:
460 m = munge and munge(name) or name
460 m = munge and munge(name) or name
461 if (self._tagscache.tagtypes and
461 if (self._tagscache.tagtypes and
462 name in self._tagscache.tagtypes):
462 name in self._tagscache.tagtypes):
463 old = self.tags().get(name, nullid)
463 old = self.tags().get(name, nullid)
464 fp.write('%s %s\n' % (hex(old), m))
464 fp.write('%s %s\n' % (hex(old), m))
465 fp.write('%s %s\n' % (hex(node), m))
465 fp.write('%s %s\n' % (hex(node), m))
466 fp.close()
466 fp.close()
467
467
468 prevtags = ''
468 prevtags = ''
469 if local:
469 if local:
470 try:
470 try:
471 fp = self.opener('localtags', 'r+')
471 fp = self.opener('localtags', 'r+')
472 except IOError:
472 except IOError:
473 fp = self.opener('localtags', 'a')
473 fp = self.opener('localtags', 'a')
474 else:
474 else:
475 prevtags = fp.read()
475 prevtags = fp.read()
476
476
477 # local tags are stored in the current charset
477 # local tags are stored in the current charset
478 writetags(fp, names, None, prevtags)
478 writetags(fp, names, None, prevtags)
479 for name in names:
479 for name in names:
480 self.hook('tag', node=hex(node), tag=name, local=local)
480 self.hook('tag', node=hex(node), tag=name, local=local)
481 return
481 return
482
482
483 try:
483 try:
484 fp = self.wfile('.hgtags', 'rb+')
484 fp = self.wfile('.hgtags', 'rb+')
485 except IOError, e:
485 except IOError, e:
486 if e.errno != errno.ENOENT:
486 if e.errno != errno.ENOENT:
487 raise
487 raise
488 fp = self.wfile('.hgtags', 'ab')
488 fp = self.wfile('.hgtags', 'ab')
489 else:
489 else:
490 prevtags = fp.read()
490 prevtags = fp.read()
491
491
492 # committed tags are stored in UTF-8
492 # committed tags are stored in UTF-8
493 writetags(fp, names, encoding.fromlocal, prevtags)
493 writetags(fp, names, encoding.fromlocal, prevtags)
494
494
495 fp.close()
495 fp.close()
496
496
497 self.invalidatecaches()
497 self.invalidatecaches()
498
498
499 if '.hgtags' not in self.dirstate:
499 if '.hgtags' not in self.dirstate:
500 self[None].add(['.hgtags'])
500 self[None].add(['.hgtags'])
501
501
502 m = matchmod.exact(self.root, '', ['.hgtags'])
502 m = matchmod.exact(self.root, '', ['.hgtags'])
503 tagnode = self.commit(message, user, date, extra=extra, match=m)
503 tagnode = self.commit(message, user, date, extra=extra, match=m)
504
504
505 for name in names:
505 for name in names:
506 self.hook('tag', node=hex(node), tag=name, local=local)
506 self.hook('tag', node=hex(node), tag=name, local=local)
507
507
508 return tagnode
508 return tagnode
509
509
510 def tag(self, names, node, message, local, user, date):
510 def tag(self, names, node, message, local, user, date):
511 '''tag a revision with one or more symbolic names.
511 '''tag a revision with one or more symbolic names.
512
512
513 names is a list of strings or, when adding a single tag, names may be a
513 names is a list of strings or, when adding a single tag, names may be a
514 string.
514 string.
515
515
516 if local is True, the tags are stored in a per-repository file.
516 if local is True, the tags are stored in a per-repository file.
517 otherwise, they are stored in the .hgtags file, and a new
517 otherwise, they are stored in the .hgtags file, and a new
518 changeset is committed with the change.
518 changeset is committed with the change.
519
519
520 keyword arguments:
520 keyword arguments:
521
521
522 local: whether to store tags in non-version-controlled file
522 local: whether to store tags in non-version-controlled file
523 (default False)
523 (default False)
524
524
525 message: commit message to use if committing
525 message: commit message to use if committing
526
526
527 user: name of user to use if committing
527 user: name of user to use if committing
528
528
529 date: date tuple to use if committing'''
529 date: date tuple to use if committing'''
530
530
531 if not local:
531 if not local:
532 for x in self.status()[:5]:
532 for x in self.status()[:5]:
533 if '.hgtags' in x:
533 if '.hgtags' in x:
534 raise util.Abort(_('working copy of .hgtags is changed '
534 raise util.Abort(_('working copy of .hgtags is changed '
535 '(please commit .hgtags manually)'))
535 '(please commit .hgtags manually)'))
536
536
537 self.tags() # instantiate the cache
537 self.tags() # instantiate the cache
538 self._tag(names, node, message, local, user, date)
538 self._tag(names, node, message, local, user, date)
539
539
540 @filteredpropertycache
540 @filteredpropertycache
541 def _tagscache(self):
541 def _tagscache(self):
542 '''Returns a tagscache object that contains various tags related
542 '''Returns a tagscache object that contains various tags related
543 caches.'''
543 caches.'''
544
544
545 # This simplifies its cache management by having one decorated
545 # This simplifies its cache management by having one decorated
546 # function (this one) and the rest simply fetch things from it.
546 # function (this one) and the rest simply fetch things from it.
547 class tagscache(object):
547 class tagscache(object):
548 def __init__(self):
548 def __init__(self):
549 # These two define the set of tags for this repository. tags
549 # These two define the set of tags for this repository. tags
550 # maps tag name to node; tagtypes maps tag name to 'global' or
550 # maps tag name to node; tagtypes maps tag name to 'global' or
551 # 'local'. (Global tags are defined by .hgtags across all
551 # 'local'. (Global tags are defined by .hgtags across all
552 # heads, and local tags are defined in .hg/localtags.)
552 # heads, and local tags are defined in .hg/localtags.)
553 # They constitute the in-memory cache of tags.
553 # They constitute the in-memory cache of tags.
554 self.tags = self.tagtypes = None
554 self.tags = self.tagtypes = None
555
555
556 self.nodetagscache = self.tagslist = None
556 self.nodetagscache = self.tagslist = None
557
557
558 cache = tagscache()
558 cache = tagscache()
559 cache.tags, cache.tagtypes = self._findtags()
559 cache.tags, cache.tagtypes = self._findtags()
560
560
561 return cache
561 return cache
562
562
563 def tags(self):
563 def tags(self):
564 '''return a mapping of tag to node'''
564 '''return a mapping of tag to node'''
565 t = {}
565 t = {}
566 if self.changelog.filteredrevs:
566 if self.changelog.filteredrevs:
567 tags, tt = self._findtags()
567 tags, tt = self._findtags()
568 else:
568 else:
569 tags = self._tagscache.tags
569 tags = self._tagscache.tags
570 for k, v in tags.iteritems():
570 for k, v in tags.iteritems():
571 try:
571 try:
572 # ignore tags to unknown nodes
572 # ignore tags to unknown nodes
573 self.changelog.rev(v)
573 self.changelog.rev(v)
574 t[k] = v
574 t[k] = v
575 except (error.LookupError, ValueError):
575 except (error.LookupError, ValueError):
576 pass
576 pass
577 return t
577 return t
578
578
579 def _findtags(self):
579 def _findtags(self):
580 '''Do the hard work of finding tags. Return a pair of dicts
580 '''Do the hard work of finding tags. Return a pair of dicts
581 (tags, tagtypes) where tags maps tag name to node, and tagtypes
581 (tags, tagtypes) where tags maps tag name to node, and tagtypes
582 maps tag name to a string like \'global\' or \'local\'.
582 maps tag name to a string like \'global\' or \'local\'.
583 Subclasses or extensions are free to add their own tags, but
583 Subclasses or extensions are free to add their own tags, but
584 should be aware that the returned dicts will be retained for the
584 should be aware that the returned dicts will be retained for the
585 duration of the localrepo object.'''
585 duration of the localrepo object.'''
586
586
587 # XXX what tagtype should subclasses/extensions use? Currently
587 # XXX what tagtype should subclasses/extensions use? Currently
588 # mq and bookmarks add tags, but do not set the tagtype at all.
588 # mq and bookmarks add tags, but do not set the tagtype at all.
589 # Should each extension invent its own tag type? Should there
589 # Should each extension invent its own tag type? Should there
590 # be one tagtype for all such "virtual" tags? Or is the status
590 # be one tagtype for all such "virtual" tags? Or is the status
591 # quo fine?
591 # quo fine?
592
592
593 alltags = {} # map tag name to (node, hist)
593 alltags = {} # map tag name to (node, hist)
594 tagtypes = {}
594 tagtypes = {}
595
595
596 tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
596 tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
597 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
597 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
598
598
599 # Build the return dicts. Have to re-encode tag names because
599 # Build the return dicts. Have to re-encode tag names because
600 # the tags module always uses UTF-8 (in order not to lose info
600 # the tags module always uses UTF-8 (in order not to lose info
601 # writing to the cache), but the rest of Mercurial wants them in
601 # writing to the cache), but the rest of Mercurial wants them in
602 # local encoding.
602 # local encoding.
603 tags = {}
603 tags = {}
604 for (name, (node, hist)) in alltags.iteritems():
604 for (name, (node, hist)) in alltags.iteritems():
605 if node != nullid:
605 if node != nullid:
606 tags[encoding.tolocal(name)] = node
606 tags[encoding.tolocal(name)] = node
607 tags['tip'] = self.changelog.tip()
607 tags['tip'] = self.changelog.tip()
608 tagtypes = dict([(encoding.tolocal(name), value)
608 tagtypes = dict([(encoding.tolocal(name), value)
609 for (name, value) in tagtypes.iteritems()])
609 for (name, value) in tagtypes.iteritems()])
610 return (tags, tagtypes)
610 return (tags, tagtypes)
611
611
612 def tagtype(self, tagname):
612 def tagtype(self, tagname):
613 '''
613 '''
614 return the type of the given tag. result can be:
614 return the type of the given tag. result can be:
615
615
616 'local' : a local tag
616 'local' : a local tag
617 'global' : a global tag
617 'global' : a global tag
618 None : tag does not exist
618 None : tag does not exist
619 '''
619 '''
620
620
621 return self._tagscache.tagtypes.get(tagname)
621 return self._tagscache.tagtypes.get(tagname)
622
622
623 def tagslist(self):
623 def tagslist(self):
624 '''return a list of tags ordered by revision'''
624 '''return a list of tags ordered by revision'''
625 if not self._tagscache.tagslist:
625 if not self._tagscache.tagslist:
626 l = []
626 l = []
627 for t, n in self.tags().iteritems():
627 for t, n in self.tags().iteritems():
628 r = self.changelog.rev(n)
628 r = self.changelog.rev(n)
629 l.append((r, t, n))
629 l.append((r, t, n))
630 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
630 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
631
631
632 return self._tagscache.tagslist
632 return self._tagscache.tagslist
633
633
634 def nodetags(self, node):
634 def nodetags(self, node):
635 '''return the tags associated with a node'''
635 '''return the tags associated with a node'''
636 if not self._tagscache.nodetagscache:
636 if not self._tagscache.nodetagscache:
637 nodetagscache = {}
637 nodetagscache = {}
638 for t, n in self._tagscache.tags.iteritems():
638 for t, n in self._tagscache.tags.iteritems():
639 nodetagscache.setdefault(n, []).append(t)
639 nodetagscache.setdefault(n, []).append(t)
640 for tags in nodetagscache.itervalues():
640 for tags in nodetagscache.itervalues():
641 tags.sort()
641 tags.sort()
642 self._tagscache.nodetagscache = nodetagscache
642 self._tagscache.nodetagscache = nodetagscache
643 return self._tagscache.nodetagscache.get(node, [])
643 return self._tagscache.nodetagscache.get(node, [])
644
644
645 def nodebookmarks(self, node):
645 def nodebookmarks(self, node):
646 marks = []
646 marks = []
647 for bookmark, n in self._bookmarks.iteritems():
647 for bookmark, n in self._bookmarks.iteritems():
648 if n == node:
648 if n == node:
649 marks.append(bookmark)
649 marks.append(bookmark)
650 return sorted(marks)
650 return sorted(marks)
651
651
652 def _cacheabletip(self):
652 def _cacheabletip(self):
653 """tip-most revision stable enought to used in persistent cache
653 """tip-most revision stable enought to used in persistent cache
654
654
655 This function is overwritten by MQ to ensure we do not write cache for
655 This function is overwritten by MQ to ensure we do not write cache for
656 a part of the history that will likely change.
656 a part of the history that will likely change.
657
657
658 Efficient handling of filtered revision in branchcache should offer a
658 Efficient handling of filtered revision in branchcache should offer a
659 better alternative. But we are using this approach until it is ready.
659 better alternative. But we are using this approach until it is ready.
660 """
660 """
661 cl = self.changelog
661 cl = self.changelog
662 return cl.rev(cl.tip())
662 return cl.rev(cl.tip())
663
663
664 def branchmap(self):
664 def branchmap(self):
665 '''returns a dictionary {branch: [branchheads]}'''
665 '''returns a dictionary {branch: [branchheads]}'''
666 if self.changelog.filteredrevs:
666 if self.changelog.filteredrevs:
667 # some changeset are excluded we can't use the cache
667 # some changeset are excluded we can't use the cache
668 bmap = branchmap.branchcache()
668 bmap = branchmap.branchcache()
669 bmap.update(self, (self[r] for r in self))
669 bmap.update(self, (self[r] for r in self))
670 return bmap
670 return bmap
671 else:
671 else:
672 branchmap.updatecache(self)
672 branchmap.updatecache(self)
673 return self._branchcache
673 return self._branchcache
674
674
675
675
676 def _branchtip(self, heads):
676 def _branchtip(self, heads):
677 '''return the tipmost branch head in heads'''
677 '''return the tipmost branch head in heads'''
678 tip = heads[-1]
678 tip = heads[-1]
679 for h in reversed(heads):
679 for h in reversed(heads):
680 if not self[h].closesbranch():
680 if not self[h].closesbranch():
681 tip = h
681 tip = h
682 break
682 break
683 return tip
683 return tip
684
684
685 def branchtip(self, branch):
685 def branchtip(self, branch):
686 '''return the tip node for a given branch'''
686 '''return the tip node for a given branch'''
687 if branch not in self.branchmap():
687 if branch not in self.branchmap():
688 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
688 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
689 return self._branchtip(self.branchmap()[branch])
689 return self._branchtip(self.branchmap()[branch])
690
690
691 def branchtags(self):
691 def branchtags(self):
692 '''return a dict where branch names map to the tipmost head of
692 '''return a dict where branch names map to the tipmost head of
693 the branch, open heads come before closed'''
693 the branch, open heads come before closed'''
694 bt = {}
694 bt = {}
695 for bn, heads in self.branchmap().iteritems():
695 for bn, heads in self.branchmap().iteritems():
696 bt[bn] = self._branchtip(heads)
696 bt[bn] = self._branchtip(heads)
697 return bt
697 return bt
698
698
699 def lookup(self, key):
699 def lookup(self, key):
700 return self[key].node()
700 return self[key].node()
701
701
702 def lookupbranch(self, key, remote=None):
702 def lookupbranch(self, key, remote=None):
703 repo = remote or self
703 repo = remote or self
704 if key in repo.branchmap():
704 if key in repo.branchmap():
705 return key
705 return key
706
706
707 repo = (remote and remote.local()) and remote or self
707 repo = (remote and remote.local()) and remote or self
708 return repo[key].branch()
708 return repo[key].branch()
709
709
710 def known(self, nodes):
710 def known(self, nodes):
711 nm = self.changelog.nodemap
711 nm = self.changelog.nodemap
712 pc = self._phasecache
712 pc = self._phasecache
713 result = []
713 result = []
714 for n in nodes:
714 for n in nodes:
715 r = nm.get(n)
715 r = nm.get(n)
716 resp = not (r is None or pc.phase(self, r) >= phases.secret)
716 resp = not (r is None or pc.phase(self, r) >= phases.secret)
717 result.append(resp)
717 result.append(resp)
718 return result
718 return result
719
719
720 def local(self):
720 def local(self):
721 return self
721 return self
722
722
723 def cancopy(self):
723 def cancopy(self):
724 return self.local() # so statichttprepo's override of local() works
724 return self.local() # so statichttprepo's override of local() works
725
725
726 def join(self, f):
726 def join(self, f):
727 return os.path.join(self.path, f)
727 return os.path.join(self.path, f)
728
728
729 def wjoin(self, f):
729 def wjoin(self, f):
730 return os.path.join(self.root, f)
730 return os.path.join(self.root, f)
731
731
732 def file(self, f):
732 def file(self, f):
733 if f[0] == '/':
733 if f[0] == '/':
734 f = f[1:]
734 f = f[1:]
735 return filelog.filelog(self.sopener, f)
735 return filelog.filelog(self.sopener, f)
736
736
737 def changectx(self, changeid):
737 def changectx(self, changeid):
738 return self[changeid]
738 return self[changeid]
739
739
740 def parents(self, changeid=None):
740 def parents(self, changeid=None):
741 '''get list of changectxs for parents of changeid'''
741 '''get list of changectxs for parents of changeid'''
742 return self[changeid].parents()
742 return self[changeid].parents()
743
743
744 def setparents(self, p1, p2=nullid):
744 def setparents(self, p1, p2=nullid):
745 copies = self.dirstate.setparents(p1, p2)
745 copies = self.dirstate.setparents(p1, p2)
746 if copies:
746 if copies:
747 # Adjust copy records, the dirstate cannot do it, it
747 # Adjust copy records, the dirstate cannot do it, it
748 # requires access to parents manifests. Preserve them
748 # requires access to parents manifests. Preserve them
749 # only for entries added to first parent.
749 # only for entries added to first parent.
750 pctx = self[p1]
750 pctx = self[p1]
751 for f in copies:
751 for f in copies:
752 if f not in pctx and copies[f] in pctx:
752 if f not in pctx and copies[f] in pctx:
753 self.dirstate.copy(copies[f], f)
753 self.dirstate.copy(copies[f], f)
754
754
755 def filectx(self, path, changeid=None, fileid=None):
755 def filectx(self, path, changeid=None, fileid=None):
756 """changeid can be a changeset revision, node, or tag.
756 """changeid can be a changeset revision, node, or tag.
757 fileid can be a file revision or node."""
757 fileid can be a file revision or node."""
758 return context.filectx(self, path, changeid, fileid)
758 return context.filectx(self, path, changeid, fileid)
759
759
760 def getcwd(self):
760 def getcwd(self):
761 return self.dirstate.getcwd()
761 return self.dirstate.getcwd()
762
762
763 def pathto(self, f, cwd=None):
763 def pathto(self, f, cwd=None):
764 return self.dirstate.pathto(f, cwd)
764 return self.dirstate.pathto(f, cwd)
765
765
766 def wfile(self, f, mode='r'):
766 def wfile(self, f, mode='r'):
767 return self.wopener(f, mode)
767 return self.wopener(f, mode)
768
768
769 def _link(self, f):
769 def _link(self, f):
770 return os.path.islink(self.wjoin(f))
770 return os.path.islink(self.wjoin(f))
771
771
772 def _loadfilter(self, filter):
772 def _loadfilter(self, filter):
773 if filter not in self.filterpats:
773 if filter not in self.filterpats:
774 l = []
774 l = []
775 for pat, cmd in self.ui.configitems(filter):
775 for pat, cmd in self.ui.configitems(filter):
776 if cmd == '!':
776 if cmd == '!':
777 continue
777 continue
778 mf = matchmod.match(self.root, '', [pat])
778 mf = matchmod.match(self.root, '', [pat])
779 fn = None
779 fn = None
780 params = cmd
780 params = cmd
781 for name, filterfn in self._datafilters.iteritems():
781 for name, filterfn in self._datafilters.iteritems():
782 if cmd.startswith(name):
782 if cmd.startswith(name):
783 fn = filterfn
783 fn = filterfn
784 params = cmd[len(name):].lstrip()
784 params = cmd[len(name):].lstrip()
785 break
785 break
786 if not fn:
786 if not fn:
787 fn = lambda s, c, **kwargs: util.filter(s, c)
787 fn = lambda s, c, **kwargs: util.filter(s, c)
788 # Wrap old filters not supporting keyword arguments
788 # Wrap old filters not supporting keyword arguments
789 if not inspect.getargspec(fn)[2]:
789 if not inspect.getargspec(fn)[2]:
790 oldfn = fn
790 oldfn = fn
791 fn = lambda s, c, **kwargs: oldfn(s, c)
791 fn = lambda s, c, **kwargs: oldfn(s, c)
792 l.append((mf, fn, params))
792 l.append((mf, fn, params))
793 self.filterpats[filter] = l
793 self.filterpats[filter] = l
794 return self.filterpats[filter]
794 return self.filterpats[filter]
795
795
796 def _filter(self, filterpats, filename, data):
796 def _filter(self, filterpats, filename, data):
797 for mf, fn, cmd in filterpats:
797 for mf, fn, cmd in filterpats:
798 if mf(filename):
798 if mf(filename):
799 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
799 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
800 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
800 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
801 break
801 break
802
802
803 return data
803 return data
804
804
805 @unfilteredpropertycache
805 @unfilteredpropertycache
806 def _encodefilterpats(self):
806 def _encodefilterpats(self):
807 return self._loadfilter('encode')
807 return self._loadfilter('encode')
808
808
809 @unfilteredpropertycache
809 @unfilteredpropertycache
810 def _decodefilterpats(self):
810 def _decodefilterpats(self):
811 return self._loadfilter('decode')
811 return self._loadfilter('decode')
812
812
813 def adddatafilter(self, name, filter):
813 def adddatafilter(self, name, filter):
814 self._datafilters[name] = filter
814 self._datafilters[name] = filter
815
815
816 def wread(self, filename):
816 def wread(self, filename):
817 if self._link(filename):
817 if self._link(filename):
818 data = os.readlink(self.wjoin(filename))
818 data = os.readlink(self.wjoin(filename))
819 else:
819 else:
820 data = self.wopener.read(filename)
820 data = self.wopener.read(filename)
821 return self._filter(self._encodefilterpats, filename, data)
821 return self._filter(self._encodefilterpats, filename, data)
822
822
823 def wwrite(self, filename, data, flags):
823 def wwrite(self, filename, data, flags):
824 data = self._filter(self._decodefilterpats, filename, data)
824 data = self._filter(self._decodefilterpats, filename, data)
825 if 'l' in flags:
825 if 'l' in flags:
826 self.wopener.symlink(data, filename)
826 self.wopener.symlink(data, filename)
827 else:
827 else:
828 self.wopener.write(filename, data)
828 self.wopener.write(filename, data)
829 if 'x' in flags:
829 if 'x' in flags:
830 util.setflags(self.wjoin(filename), False, True)
830 util.setflags(self.wjoin(filename), False, True)
831
831
832 def wwritedata(self, filename, data):
832 def wwritedata(self, filename, data):
833 return self._filter(self._decodefilterpats, filename, data)
833 return self._filter(self._decodefilterpats, filename, data)
834
834
835 def transaction(self, desc):
835 def transaction(self, desc):
836 tr = self._transref and self._transref() or None
836 tr = self._transref and self._transref() or None
837 if tr and tr.running():
837 if tr and tr.running():
838 return tr.nest()
838 return tr.nest()
839
839
840 # abort here if the journal already exists
840 # abort here if the journal already exists
841 if os.path.exists(self.sjoin("journal")):
841 if os.path.exists(self.sjoin("journal")):
842 raise error.RepoError(
842 raise error.RepoError(
843 _("abandoned transaction found - run hg recover"))
843 _("abandoned transaction found - run hg recover"))
844
844
845 self._writejournal(desc)
845 self._writejournal(desc)
846 renames = [(x, undoname(x)) for x in self._journalfiles()]
846 renames = [(x, undoname(x)) for x in self._journalfiles()]
847
847
848 tr = transaction.transaction(self.ui.warn, self.sopener,
848 tr = transaction.transaction(self.ui.warn, self.sopener,
849 self.sjoin("journal"),
849 self.sjoin("journal"),
850 aftertrans(renames),
850 aftertrans(renames),
851 self.store.createmode)
851 self.store.createmode)
852 self._transref = weakref.ref(tr)
852 self._transref = weakref.ref(tr)
853 return tr
853 return tr
854
854
855 def _journalfiles(self):
855 def _journalfiles(self):
856 return (self.sjoin('journal'), self.join('journal.dirstate'),
856 return (self.sjoin('journal'), self.join('journal.dirstate'),
857 self.join('journal.branch'), self.join('journal.desc'),
857 self.join('journal.branch'), self.join('journal.desc'),
858 self.join('journal.bookmarks'),
858 self.join('journal.bookmarks'),
859 self.sjoin('journal.phaseroots'))
859 self.sjoin('journal.phaseroots'))
860
860
861 def undofiles(self):
861 def undofiles(self):
862 return [undoname(x) for x in self._journalfiles()]
862 return [undoname(x) for x in self._journalfiles()]
863
863
864 def _writejournal(self, desc):
864 def _writejournal(self, desc):
865 self.opener.write("journal.dirstate",
865 self.opener.write("journal.dirstate",
866 self.opener.tryread("dirstate"))
866 self.opener.tryread("dirstate"))
867 self.opener.write("journal.branch",
867 self.opener.write("journal.branch",
868 encoding.fromlocal(self.dirstate.branch()))
868 encoding.fromlocal(self.dirstate.branch()))
869 self.opener.write("journal.desc",
869 self.opener.write("journal.desc",
870 "%d\n%s\n" % (len(self), desc))
870 "%d\n%s\n" % (len(self), desc))
871 self.opener.write("journal.bookmarks",
871 self.opener.write("journal.bookmarks",
872 self.opener.tryread("bookmarks"))
872 self.opener.tryread("bookmarks"))
873 self.sopener.write("journal.phaseroots",
873 self.sopener.write("journal.phaseroots",
874 self.sopener.tryread("phaseroots"))
874 self.sopener.tryread("phaseroots"))
875
875
876 def recover(self):
876 def recover(self):
877 lock = self.lock()
877 lock = self.lock()
878 try:
878 try:
879 if os.path.exists(self.sjoin("journal")):
879 if os.path.exists(self.sjoin("journal")):
880 self.ui.status(_("rolling back interrupted transaction\n"))
880 self.ui.status(_("rolling back interrupted transaction\n"))
881 transaction.rollback(self.sopener, self.sjoin("journal"),
881 transaction.rollback(self.sopener, self.sjoin("journal"),
882 self.ui.warn)
882 self.ui.warn)
883 self.invalidate()
883 self.invalidate()
884 return True
884 return True
885 else:
885 else:
886 self.ui.warn(_("no interrupted transaction available\n"))
886 self.ui.warn(_("no interrupted transaction available\n"))
887 return False
887 return False
888 finally:
888 finally:
889 lock.release()
889 lock.release()
890
890
891 def rollback(self, dryrun=False, force=False):
891 def rollback(self, dryrun=False, force=False):
892 wlock = lock = None
892 wlock = lock = None
893 try:
893 try:
894 wlock = self.wlock()
894 wlock = self.wlock()
895 lock = self.lock()
895 lock = self.lock()
896 if os.path.exists(self.sjoin("undo")):
896 if os.path.exists(self.sjoin("undo")):
897 return self._rollback(dryrun, force)
897 return self._rollback(dryrun, force)
898 else:
898 else:
899 self.ui.warn(_("no rollback information available\n"))
899 self.ui.warn(_("no rollback information available\n"))
900 return 1
900 return 1
901 finally:
901 finally:
902 release(lock, wlock)
902 release(lock, wlock)
903
903
904 @unfilteredmethod # Until we get smarter cache management
904 @unfilteredmethod # Until we get smarter cache management
905 def _rollback(self, dryrun, force):
905 def _rollback(self, dryrun, force):
906 ui = self.ui
906 ui = self.ui
907 try:
907 try:
908 args = self.opener.read('undo.desc').splitlines()
908 args = self.opener.read('undo.desc').splitlines()
909 (oldlen, desc, detail) = (int(args[0]), args[1], None)
909 (oldlen, desc, detail) = (int(args[0]), args[1], None)
910 if len(args) >= 3:
910 if len(args) >= 3:
911 detail = args[2]
911 detail = args[2]
912 oldtip = oldlen - 1
912 oldtip = oldlen - 1
913
913
914 if detail and ui.verbose:
914 if detail and ui.verbose:
915 msg = (_('repository tip rolled back to revision %s'
915 msg = (_('repository tip rolled back to revision %s'
916 ' (undo %s: %s)\n')
916 ' (undo %s: %s)\n')
917 % (oldtip, desc, detail))
917 % (oldtip, desc, detail))
918 else:
918 else:
919 msg = (_('repository tip rolled back to revision %s'
919 msg = (_('repository tip rolled back to revision %s'
920 ' (undo %s)\n')
920 ' (undo %s)\n')
921 % (oldtip, desc))
921 % (oldtip, desc))
922 except IOError:
922 except IOError:
923 msg = _('rolling back unknown transaction\n')
923 msg = _('rolling back unknown transaction\n')
924 desc = None
924 desc = None
925
925
926 if not force and self['.'] != self['tip'] and desc == 'commit':
926 if not force and self['.'] != self['tip'] and desc == 'commit':
927 raise util.Abort(
927 raise util.Abort(
928 _('rollback of last commit while not checked out '
928 _('rollback of last commit while not checked out '
929 'may lose data'), hint=_('use -f to force'))
929 'may lose data'), hint=_('use -f to force'))
930
930
931 ui.status(msg)
931 ui.status(msg)
932 if dryrun:
932 if dryrun:
933 return 0
933 return 0
934
934
935 parents = self.dirstate.parents()
935 parents = self.dirstate.parents()
936 transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
936 transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
937 if os.path.exists(self.join('undo.bookmarks')):
937 if os.path.exists(self.join('undo.bookmarks')):
938 util.rename(self.join('undo.bookmarks'),
938 util.rename(self.join('undo.bookmarks'),
939 self.join('bookmarks'))
939 self.join('bookmarks'))
940 if os.path.exists(self.sjoin('undo.phaseroots')):
940 if os.path.exists(self.sjoin('undo.phaseroots')):
941 util.rename(self.sjoin('undo.phaseroots'),
941 util.rename(self.sjoin('undo.phaseroots'),
942 self.sjoin('phaseroots'))
942 self.sjoin('phaseroots'))
943 self.invalidate()
943 self.invalidate()
944
944
945 # Discard all cache entries to force reloading everything.
945 # Discard all cache entries to force reloading everything.
946 self._filecache.clear()
946 self._filecache.clear()
947
947
948 parentgone = (parents[0] not in self.changelog.nodemap or
948 parentgone = (parents[0] not in self.changelog.nodemap or
949 parents[1] not in self.changelog.nodemap)
949 parents[1] not in self.changelog.nodemap)
950 if parentgone:
950 if parentgone:
951 util.rename(self.join('undo.dirstate'), self.join('dirstate'))
951 util.rename(self.join('undo.dirstate'), self.join('dirstate'))
952 try:
952 try:
953 branch = self.opener.read('undo.branch')
953 branch = self.opener.read('undo.branch')
954 self.dirstate.setbranch(encoding.tolocal(branch))
954 self.dirstate.setbranch(encoding.tolocal(branch))
955 except IOError:
955 except IOError:
956 ui.warn(_('named branch could not be reset: '
956 ui.warn(_('named branch could not be reset: '
957 'current branch is still \'%s\'\n')
957 'current branch is still \'%s\'\n')
958 % self.dirstate.branch())
958 % self.dirstate.branch())
959
959
960 self.dirstate.invalidate()
960 self.dirstate.invalidate()
961 parents = tuple([p.rev() for p in self.parents()])
961 parents = tuple([p.rev() for p in self.parents()])
962 if len(parents) > 1:
962 if len(parents) > 1:
963 ui.status(_('working directory now based on '
963 ui.status(_('working directory now based on '
964 'revisions %d and %d\n') % parents)
964 'revisions %d and %d\n') % parents)
965 else:
965 else:
966 ui.status(_('working directory now based on '
966 ui.status(_('working directory now based on '
967 'revision %d\n') % parents)
967 'revision %d\n') % parents)
968 # TODO: if we know which new heads may result from this rollback, pass
968 # TODO: if we know which new heads may result from this rollback, pass
969 # them to destroy(), which will prevent the branchhead cache from being
969 # them to destroy(), which will prevent the branchhead cache from being
970 # invalidated.
970 # invalidated.
971 self.destroyed()
971 self.destroyed()
972 return 0
972 return 0
973
973
974 def invalidatecaches(self):
974 def invalidatecaches(self):
975
975
976 if '_tagscache' in vars(self):
976 if '_tagscache' in vars(self):
977 # can't use delattr on proxy
977 # can't use delattr on proxy
978 del self.__dict__['_tagscache']
978 del self.__dict__['_tagscache']
979
979
980 self.unfiltered()._branchcache = None # in UTF-8
980 self.unfiltered()._branchcache = None # in UTF-8
981 self.invalidatevolatilesets()
981 self.invalidatevolatilesets()
982
982
983 def invalidatevolatilesets(self):
983 def invalidatevolatilesets(self):
984 self.filteredrevcache.clear()
984 self.filteredrevcache.clear()
985 obsolete.clearobscaches(self)
985 obsolete.clearobscaches(self)
986 if 'hiddenrevs' in vars(self):
986 if 'hiddenrevs' in vars(self):
987 del self.hiddenrevs
987 del self.hiddenrevs
988
988
989 def invalidatedirstate(self):
989 def invalidatedirstate(self):
990 '''Invalidates the dirstate, causing the next call to dirstate
990 '''Invalidates the dirstate, causing the next call to dirstate
991 to check if it was modified since the last time it was read,
991 to check if it was modified since the last time it was read,
992 rereading it if it has.
992 rereading it if it has.
993
993
994 This is different to dirstate.invalidate() that it doesn't always
994 This is different to dirstate.invalidate() that it doesn't always
995 rereads the dirstate. Use dirstate.invalidate() if you want to
995 rereads the dirstate. Use dirstate.invalidate() if you want to
996 explicitly read the dirstate again (i.e. restoring it to a previous
996 explicitly read the dirstate again (i.e. restoring it to a previous
997 known good state).'''
997 known good state).'''
998 if hasunfilteredcache(self, 'dirstate'):
998 if hasunfilteredcache(self, 'dirstate'):
999 for k in self.dirstate._filecache:
999 for k in self.dirstate._filecache:
1000 try:
1000 try:
1001 delattr(self.dirstate, k)
1001 delattr(self.dirstate, k)
1002 except AttributeError:
1002 except AttributeError:
1003 pass
1003 pass
1004 delattr(self.unfiltered(), 'dirstate')
1004 delattr(self.unfiltered(), 'dirstate')
1005
1005
1006 def invalidate(self):
1006 def invalidate(self):
1007 unfiltered = self.unfiltered() # all filecaches are stored on unfiltered
1007 unfiltered = self.unfiltered() # all filecaches are stored on unfiltered
1008 for k in self._filecache:
1008 for k in self._filecache:
1009 # dirstate is invalidated separately in invalidatedirstate()
1009 # dirstate is invalidated separately in invalidatedirstate()
1010 if k == 'dirstate':
1010 if k == 'dirstate':
1011 continue
1011 continue
1012
1012
1013 try:
1013 try:
1014 delattr(unfiltered, k)
1014 delattr(unfiltered, k)
1015 except AttributeError:
1015 except AttributeError:
1016 pass
1016 pass
1017 self.invalidatecaches()
1017 self.invalidatecaches()
1018
1018
1019 def _lock(self, lockname, wait, releasefn, acquirefn, desc):
1019 def _lock(self, lockname, wait, releasefn, acquirefn, desc):
1020 try:
1020 try:
1021 l = lock.lock(lockname, 0, releasefn, desc=desc)
1021 l = lock.lock(lockname, 0, releasefn, desc=desc)
1022 except error.LockHeld, inst:
1022 except error.LockHeld, inst:
1023 if not wait:
1023 if not wait:
1024 raise
1024 raise
1025 self.ui.warn(_("waiting for lock on %s held by %r\n") %
1025 self.ui.warn(_("waiting for lock on %s held by %r\n") %
1026 (desc, inst.locker))
1026 (desc, inst.locker))
1027 # default to 600 seconds timeout
1027 # default to 600 seconds timeout
1028 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
1028 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
1029 releasefn, desc=desc)
1029 releasefn, desc=desc)
1030 if acquirefn:
1030 if acquirefn:
1031 acquirefn()
1031 acquirefn()
1032 return l
1032 return l
1033
1033
1034 def _afterlock(self, callback):
1034 def _afterlock(self, callback):
1035 """add a callback to the current repository lock.
1035 """add a callback to the current repository lock.
1036
1036
1037 The callback will be executed on lock release."""
1037 The callback will be executed on lock release."""
1038 l = self._lockref and self._lockref()
1038 l = self._lockref and self._lockref()
1039 if l:
1039 if l:
1040 l.postrelease.append(callback)
1040 l.postrelease.append(callback)
1041 else:
1041 else:
1042 callback()
1042 callback()
1043
1043
1044 def lock(self, wait=True):
1044 def lock(self, wait=True):
1045 '''Lock the repository store (.hg/store) and return a weak reference
1045 '''Lock the repository store (.hg/store) and return a weak reference
1046 to the lock. Use this before modifying the store (e.g. committing or
1046 to the lock. Use this before modifying the store (e.g. committing or
1047 stripping). If you are opening a transaction, get a lock as well.)'''
1047 stripping). If you are opening a transaction, get a lock as well.)'''
1048 l = self._lockref and self._lockref()
1048 l = self._lockref and self._lockref()
1049 if l is not None and l.held:
1049 if l is not None and l.held:
1050 l.lock()
1050 l.lock()
1051 return l
1051 return l
1052
1052
1053 def unlock():
1053 def unlock():
1054 self.store.write()
1054 self.store.write()
1055 if hasunfilteredcache(self, '_phasecache'):
1055 if hasunfilteredcache(self, '_phasecache'):
1056 self._phasecache.write()
1056 self._phasecache.write()
1057 for k, ce in self._filecache.items():
1057 for k, ce in self._filecache.items():
1058 if k == 'dirstate':
1058 if k == 'dirstate':
1059 continue
1059 continue
1060 ce.refresh()
1060 ce.refresh()
1061
1061
1062 l = self._lock(self.sjoin("lock"), wait, unlock,
1062 l = self._lock(self.sjoin("lock"), wait, unlock,
1063 self.invalidate, _('repository %s') % self.origroot)
1063 self.invalidate, _('repository %s') % self.origroot)
1064 self._lockref = weakref.ref(l)
1064 self._lockref = weakref.ref(l)
1065 return l
1065 return l
1066
1066
1067 def wlock(self, wait=True):
1067 def wlock(self, wait=True):
1068 '''Lock the non-store parts of the repository (everything under
1068 '''Lock the non-store parts of the repository (everything under
1069 .hg except .hg/store) and return a weak reference to the lock.
1069 .hg except .hg/store) and return a weak reference to the lock.
1070 Use this before modifying files in .hg.'''
1070 Use this before modifying files in .hg.'''
1071 l = self._wlockref and self._wlockref()
1071 l = self._wlockref and self._wlockref()
1072 if l is not None and l.held:
1072 if l is not None and l.held:
1073 l.lock()
1073 l.lock()
1074 return l
1074 return l
1075
1075
1076 def unlock():
1076 def unlock():
1077 self.dirstate.write()
1077 self.dirstate.write()
1078 ce = self._filecache.get('dirstate')
1078 ce = self._filecache.get('dirstate')
1079 if ce:
1079 if ce:
1080 ce.refresh()
1080 ce.refresh()
1081
1081
1082 l = self._lock(self.join("wlock"), wait, unlock,
1082 l = self._lock(self.join("wlock"), wait, unlock,
1083 self.invalidatedirstate, _('working directory of %s') %
1083 self.invalidatedirstate, _('working directory of %s') %
1084 self.origroot)
1084 self.origroot)
1085 self._wlockref = weakref.ref(l)
1085 self._wlockref = weakref.ref(l)
1086 return l
1086 return l
1087
1087
1088 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1088 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1089 """
1089 """
1090 commit an individual file as part of a larger transaction
1090 commit an individual file as part of a larger transaction
1091 """
1091 """
1092
1092
1093 fname = fctx.path()
1093 fname = fctx.path()
1094 text = fctx.data()
1094 text = fctx.data()
1095 flog = self.file(fname)
1095 flog = self.file(fname)
1096 fparent1 = manifest1.get(fname, nullid)
1096 fparent1 = manifest1.get(fname, nullid)
1097 fparent2 = fparent2o = manifest2.get(fname, nullid)
1097 fparent2 = fparent2o = manifest2.get(fname, nullid)
1098
1098
1099 meta = {}
1099 meta = {}
1100 copy = fctx.renamed()
1100 copy = fctx.renamed()
1101 if copy and copy[0] != fname:
1101 if copy and copy[0] != fname:
1102 # Mark the new revision of this file as a copy of another
1102 # Mark the new revision of this file as a copy of another
1103 # file. This copy data will effectively act as a parent
1103 # file. This copy data will effectively act as a parent
1104 # of this new revision. If this is a merge, the first
1104 # of this new revision. If this is a merge, the first
1105 # parent will be the nullid (meaning "look up the copy data")
1105 # parent will be the nullid (meaning "look up the copy data")
1106 # and the second one will be the other parent. For example:
1106 # and the second one will be the other parent. For example:
1107 #
1107 #
1108 # 0 --- 1 --- 3 rev1 changes file foo
1108 # 0 --- 1 --- 3 rev1 changes file foo
1109 # \ / rev2 renames foo to bar and changes it
1109 # \ / rev2 renames foo to bar and changes it
1110 # \- 2 -/ rev3 should have bar with all changes and
1110 # \- 2 -/ rev3 should have bar with all changes and
1111 # should record that bar descends from
1111 # should record that bar descends from
1112 # bar in rev2 and foo in rev1
1112 # bar in rev2 and foo in rev1
1113 #
1113 #
1114 # this allows this merge to succeed:
1114 # this allows this merge to succeed:
1115 #
1115 #
1116 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1116 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1117 # \ / merging rev3 and rev4 should use bar@rev2
1117 # \ / merging rev3 and rev4 should use bar@rev2
1118 # \- 2 --- 4 as the merge base
1118 # \- 2 --- 4 as the merge base
1119 #
1119 #
1120
1120
1121 cfname = copy[0]
1121 cfname = copy[0]
1122 crev = manifest1.get(cfname)
1122 crev = manifest1.get(cfname)
1123 newfparent = fparent2
1123 newfparent = fparent2
1124
1124
1125 if manifest2: # branch merge
1125 if manifest2: # branch merge
1126 if fparent2 == nullid or crev is None: # copied on remote side
1126 if fparent2 == nullid or crev is None: # copied on remote side
1127 if cfname in manifest2:
1127 if cfname in manifest2:
1128 crev = manifest2[cfname]
1128 crev = manifest2[cfname]
1129 newfparent = fparent1
1129 newfparent = fparent1
1130
1130
1131 # find source in nearest ancestor if we've lost track
1131 # find source in nearest ancestor if we've lost track
1132 if not crev:
1132 if not crev:
1133 self.ui.debug(" %s: searching for copy revision for %s\n" %
1133 self.ui.debug(" %s: searching for copy revision for %s\n" %
1134 (fname, cfname))
1134 (fname, cfname))
1135 for ancestor in self[None].ancestors():
1135 for ancestor in self[None].ancestors():
1136 if cfname in ancestor:
1136 if cfname in ancestor:
1137 crev = ancestor[cfname].filenode()
1137 crev = ancestor[cfname].filenode()
1138 break
1138 break
1139
1139
1140 if crev:
1140 if crev:
1141 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1141 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1142 meta["copy"] = cfname
1142 meta["copy"] = cfname
1143 meta["copyrev"] = hex(crev)
1143 meta["copyrev"] = hex(crev)
1144 fparent1, fparent2 = nullid, newfparent
1144 fparent1, fparent2 = nullid, newfparent
1145 else:
1145 else:
1146 self.ui.warn(_("warning: can't find ancestor for '%s' "
1146 self.ui.warn(_("warning: can't find ancestor for '%s' "
1147 "copied from '%s'!\n") % (fname, cfname))
1147 "copied from '%s'!\n") % (fname, cfname))
1148
1148
1149 elif fparent2 != nullid:
1149 elif fparent2 != nullid:
1150 # is one parent an ancestor of the other?
1150 # is one parent an ancestor of the other?
1151 fparentancestor = flog.ancestor(fparent1, fparent2)
1151 fparentancestor = flog.ancestor(fparent1, fparent2)
1152 if fparentancestor == fparent1:
1152 if fparentancestor == fparent1:
1153 fparent1, fparent2 = fparent2, nullid
1153 fparent1, fparent2 = fparent2, nullid
1154 elif fparentancestor == fparent2:
1154 elif fparentancestor == fparent2:
1155 fparent2 = nullid
1155 fparent2 = nullid
1156
1156
1157 # is the file changed?
1157 # is the file changed?
1158 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1158 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1159 changelist.append(fname)
1159 changelist.append(fname)
1160 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1160 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1161
1161
1162 # are just the flags changed during merge?
1162 # are just the flags changed during merge?
1163 if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags():
1163 if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags():
1164 changelist.append(fname)
1164 changelist.append(fname)
1165
1165
1166 return fparent1
1166 return fparent1
1167
1167
1168 @unfilteredmethod
1168 @unfilteredmethod
1169 def commit(self, text="", user=None, date=None, match=None, force=False,
1169 def commit(self, text="", user=None, date=None, match=None, force=False,
1170 editor=False, extra={}):
1170 editor=False, extra={}):
1171 """Add a new revision to current repository.
1171 """Add a new revision to current repository.
1172
1172
1173 Revision information is gathered from the working directory,
1173 Revision information is gathered from the working directory,
1174 match can be used to filter the committed files. If editor is
1174 match can be used to filter the committed files. If editor is
1175 supplied, it is called to get a commit message.
1175 supplied, it is called to get a commit message.
1176 """
1176 """
1177
1177
1178 def fail(f, msg):
1178 def fail(f, msg):
1179 raise util.Abort('%s: %s' % (f, msg))
1179 raise util.Abort('%s: %s' % (f, msg))
1180
1180
1181 if not match:
1181 if not match:
1182 match = matchmod.always(self.root, '')
1182 match = matchmod.always(self.root, '')
1183
1183
1184 if not force:
1184 if not force:
1185 vdirs = []
1185 vdirs = []
1186 match.dir = vdirs.append
1186 match.dir = vdirs.append
1187 match.bad = fail
1187 match.bad = fail
1188
1188
1189 wlock = self.wlock()
1189 wlock = self.wlock()
1190 try:
1190 try:
1191 wctx = self[None]
1191 wctx = self[None]
1192 merge = len(wctx.parents()) > 1
1192 merge = len(wctx.parents()) > 1
1193
1193
1194 if (not force and merge and match and
1194 if (not force and merge and match and
1195 (match.files() or match.anypats())):
1195 (match.files() or match.anypats())):
1196 raise util.Abort(_('cannot partially commit a merge '
1196 raise util.Abort(_('cannot partially commit a merge '
1197 '(do not specify files or patterns)'))
1197 '(do not specify files or patterns)'))
1198
1198
1199 changes = self.status(match=match, clean=force)
1199 changes = self.status(match=match, clean=force)
1200 if force:
1200 if force:
1201 changes[0].extend(changes[6]) # mq may commit unchanged files
1201 changes[0].extend(changes[6]) # mq may commit unchanged files
1202
1202
1203 # check subrepos
1203 # check subrepos
1204 subs = []
1204 subs = []
1205 commitsubs = set()
1205 commitsubs = set()
1206 newstate = wctx.substate.copy()
1206 newstate = wctx.substate.copy()
1207 # only manage subrepos and .hgsubstate if .hgsub is present
1207 # only manage subrepos and .hgsubstate if .hgsub is present
1208 if '.hgsub' in wctx:
1208 if '.hgsub' in wctx:
1209 # we'll decide whether to track this ourselves, thanks
1209 # we'll decide whether to track this ourselves, thanks
1210 if '.hgsubstate' in changes[0]:
1210 if '.hgsubstate' in changes[0]:
1211 changes[0].remove('.hgsubstate')
1211 changes[0].remove('.hgsubstate')
1212 if '.hgsubstate' in changes[2]:
1212 if '.hgsubstate' in changes[2]:
1213 changes[2].remove('.hgsubstate')
1213 changes[2].remove('.hgsubstate')
1214
1214
1215 # compare current state to last committed state
1215 # compare current state to last committed state
1216 # build new substate based on last committed state
1216 # build new substate based on last committed state
1217 oldstate = wctx.p1().substate
1217 oldstate = wctx.p1().substate
1218 for s in sorted(newstate.keys()):
1218 for s in sorted(newstate.keys()):
1219 if not match(s):
1219 if not match(s):
1220 # ignore working copy, use old state if present
1220 # ignore working copy, use old state if present
1221 if s in oldstate:
1221 if s in oldstate:
1222 newstate[s] = oldstate[s]
1222 newstate[s] = oldstate[s]
1223 continue
1223 continue
1224 if not force:
1224 if not force:
1225 raise util.Abort(
1225 raise util.Abort(
1226 _("commit with new subrepo %s excluded") % s)
1226 _("commit with new subrepo %s excluded") % s)
1227 if wctx.sub(s).dirty(True):
1227 if wctx.sub(s).dirty(True):
1228 if not self.ui.configbool('ui', 'commitsubrepos'):
1228 if not self.ui.configbool('ui', 'commitsubrepos'):
1229 raise util.Abort(
1229 raise util.Abort(
1230 _("uncommitted changes in subrepo %s") % s,
1230 _("uncommitted changes in subrepo %s") % s,
1231 hint=_("use --subrepos for recursive commit"))
1231 hint=_("use --subrepos for recursive commit"))
1232 subs.append(s)
1232 subs.append(s)
1233 commitsubs.add(s)
1233 commitsubs.add(s)
1234 else:
1234 else:
1235 bs = wctx.sub(s).basestate()
1235 bs = wctx.sub(s).basestate()
1236 newstate[s] = (newstate[s][0], bs, newstate[s][2])
1236 newstate[s] = (newstate[s][0], bs, newstate[s][2])
1237 if oldstate.get(s, (None, None, None))[1] != bs:
1237 if oldstate.get(s, (None, None, None))[1] != bs:
1238 subs.append(s)
1238 subs.append(s)
1239
1239
1240 # check for removed subrepos
1240 # check for removed subrepos
1241 for p in wctx.parents():
1241 for p in wctx.parents():
1242 r = [s for s in p.substate if s not in newstate]
1242 r = [s for s in p.substate if s not in newstate]
1243 subs += [s for s in r if match(s)]
1243 subs += [s for s in r if match(s)]
1244 if subs:
1244 if subs:
1245 if (not match('.hgsub') and
1245 if (not match('.hgsub') and
1246 '.hgsub' in (wctx.modified() + wctx.added())):
1246 '.hgsub' in (wctx.modified() + wctx.added())):
1247 raise util.Abort(
1247 raise util.Abort(
1248 _("can't commit subrepos without .hgsub"))
1248 _("can't commit subrepos without .hgsub"))
1249 changes[0].insert(0, '.hgsubstate')
1249 changes[0].insert(0, '.hgsubstate')
1250
1250
1251 elif '.hgsub' in changes[2]:
1251 elif '.hgsub' in changes[2]:
1252 # clean up .hgsubstate when .hgsub is removed
1252 # clean up .hgsubstate when .hgsub is removed
1253 if ('.hgsubstate' in wctx and
1253 if ('.hgsubstate' in wctx and
1254 '.hgsubstate' not in changes[0] + changes[1] + changes[2]):
1254 '.hgsubstate' not in changes[0] + changes[1] + changes[2]):
1255 changes[2].insert(0, '.hgsubstate')
1255 changes[2].insert(0, '.hgsubstate')
1256
1256
1257 # make sure all explicit patterns are matched
1257 # make sure all explicit patterns are matched
1258 if not force and match.files():
1258 if not force and match.files():
1259 matched = set(changes[0] + changes[1] + changes[2])
1259 matched = set(changes[0] + changes[1] + changes[2])
1260
1260
1261 for f in match.files():
1261 for f in match.files():
1262 f = self.dirstate.normalize(f)
1262 f = self.dirstate.normalize(f)
1263 if f == '.' or f in matched or f in wctx.substate:
1263 if f == '.' or f in matched or f in wctx.substate:
1264 continue
1264 continue
1265 if f in changes[3]: # missing
1265 if f in changes[3]: # missing
1266 fail(f, _('file not found!'))
1266 fail(f, _('file not found!'))
1267 if f in vdirs: # visited directory
1267 if f in vdirs: # visited directory
1268 d = f + '/'
1268 d = f + '/'
1269 for mf in matched:
1269 for mf in matched:
1270 if mf.startswith(d):
1270 if mf.startswith(d):
1271 break
1271 break
1272 else:
1272 else:
1273 fail(f, _("no match under directory!"))
1273 fail(f, _("no match under directory!"))
1274 elif f not in self.dirstate:
1274 elif f not in self.dirstate:
1275 fail(f, _("file not tracked!"))
1275 fail(f, _("file not tracked!"))
1276
1276
1277 if (not force and not extra.get("close") and not merge
1277 if (not force and not extra.get("close") and not merge
1278 and not (changes[0] or changes[1] or changes[2])
1278 and not (changes[0] or changes[1] or changes[2])
1279 and wctx.branch() == wctx.p1().branch()):
1279 and wctx.branch() == wctx.p1().branch()):
1280 return None
1280 return None
1281
1281
1282 if merge and changes[3]:
1282 if merge and changes[3]:
1283 raise util.Abort(_("cannot commit merge with missing files"))
1283 raise util.Abort(_("cannot commit merge with missing files"))
1284
1284
1285 ms = mergemod.mergestate(self)
1285 ms = mergemod.mergestate(self)
1286 for f in changes[0]:
1286 for f in changes[0]:
1287 if f in ms and ms[f] == 'u':
1287 if f in ms and ms[f] == 'u':
1288 raise util.Abort(_("unresolved merge conflicts "
1288 raise util.Abort(_("unresolved merge conflicts "
1289 "(see hg help resolve)"))
1289 "(see hg help resolve)"))
1290
1290
1291 cctx = context.workingctx(self, text, user, date, extra, changes)
1291 cctx = context.workingctx(self, text, user, date, extra, changes)
1292 if editor:
1292 if editor:
1293 cctx._text = editor(self, cctx, subs)
1293 cctx._text = editor(self, cctx, subs)
1294 edited = (text != cctx._text)
1294 edited = (text != cctx._text)
1295
1295
1296 # commit subs and write new state
1296 # commit subs and write new state
1297 if subs:
1297 if subs:
1298 for s in sorted(commitsubs):
1298 for s in sorted(commitsubs):
1299 sub = wctx.sub(s)
1299 sub = wctx.sub(s)
1300 self.ui.status(_('committing subrepository %s\n') %
1300 self.ui.status(_('committing subrepository %s\n') %
1301 subrepo.subrelpath(sub))
1301 subrepo.subrelpath(sub))
1302 sr = sub.commit(cctx._text, user, date)
1302 sr = sub.commit(cctx._text, user, date)
1303 newstate[s] = (newstate[s][0], sr)
1303 newstate[s] = (newstate[s][0], sr)
1304 subrepo.writestate(self, newstate)
1304 subrepo.writestate(self, newstate)
1305
1305
1306 # Save commit message in case this transaction gets rolled back
1306 # Save commit message in case this transaction gets rolled back
1307 # (e.g. by a pretxncommit hook). Leave the content alone on
1307 # (e.g. by a pretxncommit hook). Leave the content alone on
1308 # the assumption that the user will use the same editor again.
1308 # the assumption that the user will use the same editor again.
1309 msgfn = self.savecommitmessage(cctx._text)
1309 msgfn = self.savecommitmessage(cctx._text)
1310
1310
1311 p1, p2 = self.dirstate.parents()
1311 p1, p2 = self.dirstate.parents()
1312 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1312 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1313 try:
1313 try:
1314 self.hook("precommit", throw=True, parent1=hookp1,
1314 self.hook("precommit", throw=True, parent1=hookp1,
1315 parent2=hookp2)
1315 parent2=hookp2)
1316 ret = self.commitctx(cctx, True)
1316 ret = self.commitctx(cctx, True)
1317 except: # re-raises
1317 except: # re-raises
1318 if edited:
1318 if edited:
1319 self.ui.write(
1319 self.ui.write(
1320 _('note: commit message saved in %s\n') % msgfn)
1320 _('note: commit message saved in %s\n') % msgfn)
1321 raise
1321 raise
1322
1322
1323 # update bookmarks, dirstate and mergestate
1323 # update bookmarks, dirstate and mergestate
1324 bookmarks.update(self, [p1, p2], ret)
1324 bookmarks.update(self, [p1, p2], ret)
1325 for f in changes[0] + changes[1]:
1325 for f in changes[0] + changes[1]:
1326 self.dirstate.normal(f)
1326 self.dirstate.normal(f)
1327 for f in changes[2]:
1327 for f in changes[2]:
1328 self.dirstate.drop(f)
1328 self.dirstate.drop(f)
1329 self.dirstate.setparents(ret)
1329 self.dirstate.setparents(ret)
1330 ms.reset()
1330 ms.reset()
1331 finally:
1331 finally:
1332 wlock.release()
1332 wlock.release()
1333
1333
1334 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
1334 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
1335 self.hook("commit", node=node, parent1=parent1, parent2=parent2)
1335 self.hook("commit", node=node, parent1=parent1, parent2=parent2)
1336 self._afterlock(commithook)
1336 self._afterlock(commithook)
1337 return ret
1337 return ret
1338
1338
1339 @unfilteredmethod
1339 @unfilteredmethod
1340 def commitctx(self, ctx, error=False):
1340 def commitctx(self, ctx, error=False):
1341 """Add a new revision to current repository.
1341 """Add a new revision to current repository.
1342 Revision information is passed via the context argument.
1342 Revision information is passed via the context argument.
1343 """
1343 """
1344
1344
1345 tr = lock = None
1345 tr = lock = None
1346 removed = list(ctx.removed())
1346 removed = list(ctx.removed())
1347 p1, p2 = ctx.p1(), ctx.p2()
1347 p1, p2 = ctx.p1(), ctx.p2()
1348 user = ctx.user()
1348 user = ctx.user()
1349
1349
1350 lock = self.lock()
1350 lock = self.lock()
1351 try:
1351 try:
1352 tr = self.transaction("commit")
1352 tr = self.transaction("commit")
1353 trp = weakref.proxy(tr)
1353 trp = weakref.proxy(tr)
1354
1354
1355 if ctx.files():
1355 if ctx.files():
1356 m1 = p1.manifest().copy()
1356 m1 = p1.manifest().copy()
1357 m2 = p2.manifest()
1357 m2 = p2.manifest()
1358
1358
1359 # check in files
1359 # check in files
1360 new = {}
1360 new = {}
1361 changed = []
1361 changed = []
1362 linkrev = len(self)
1362 linkrev = len(self)
1363 for f in sorted(ctx.modified() + ctx.added()):
1363 for f in sorted(ctx.modified() + ctx.added()):
1364 self.ui.note(f + "\n")
1364 self.ui.note(f + "\n")
1365 try:
1365 try:
1366 fctx = ctx[f]
1366 fctx = ctx[f]
1367 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
1367 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
1368 changed)
1368 changed)
1369 m1.set(f, fctx.flags())
1369 m1.set(f, fctx.flags())
1370 except OSError, inst:
1370 except OSError, inst:
1371 self.ui.warn(_("trouble committing %s!\n") % f)
1371 self.ui.warn(_("trouble committing %s!\n") % f)
1372 raise
1372 raise
1373 except IOError, inst:
1373 except IOError, inst:
1374 errcode = getattr(inst, 'errno', errno.ENOENT)
1374 errcode = getattr(inst, 'errno', errno.ENOENT)
1375 if error or errcode and errcode != errno.ENOENT:
1375 if error or errcode and errcode != errno.ENOENT:
1376 self.ui.warn(_("trouble committing %s!\n") % f)
1376 self.ui.warn(_("trouble committing %s!\n") % f)
1377 raise
1377 raise
1378 else:
1378 else:
1379 removed.append(f)
1379 removed.append(f)
1380
1380
1381 # update manifest
1381 # update manifest
1382 m1.update(new)
1382 m1.update(new)
1383 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1383 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1384 drop = [f for f in removed if f in m1]
1384 drop = [f for f in removed if f in m1]
1385 for f in drop:
1385 for f in drop:
1386 del m1[f]
1386 del m1[f]
1387 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
1387 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
1388 p2.manifestnode(), (new, drop))
1388 p2.manifestnode(), (new, drop))
1389 files = changed + removed
1389 files = changed + removed
1390 else:
1390 else:
1391 mn = p1.manifestnode()
1391 mn = p1.manifestnode()
1392 files = []
1392 files = []
1393
1393
1394 # update changelog
1394 # update changelog
1395 self.changelog.delayupdate()
1395 self.changelog.delayupdate()
1396 n = self.changelog.add(mn, files, ctx.description(),
1396 n = self.changelog.add(mn, files, ctx.description(),
1397 trp, p1.node(), p2.node(),
1397 trp, p1.node(), p2.node(),
1398 user, ctx.date(), ctx.extra().copy())
1398 user, ctx.date(), ctx.extra().copy())
1399 p = lambda: self.changelog.writepending() and self.root or ""
1399 p = lambda: self.changelog.writepending() and self.root or ""
1400 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1400 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1401 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1401 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1402 parent2=xp2, pending=p)
1402 parent2=xp2, pending=p)
1403 self.changelog.finalize(trp)
1403 self.changelog.finalize(trp)
1404 # set the new commit is proper phase
1404 # set the new commit is proper phase
1405 targetphase = phases.newcommitphase(self.ui)
1405 targetphase = phases.newcommitphase(self.ui)
1406 if targetphase:
1406 if targetphase:
1407 # retract boundary do not alter parent changeset.
1407 # retract boundary do not alter parent changeset.
1408 # if a parent have higher the resulting phase will
1408 # if a parent have higher the resulting phase will
1409 # be compliant anyway
1409 # be compliant anyway
1410 #
1410 #
1411 # if minimal phase was 0 we don't need to retract anything
1411 # if minimal phase was 0 we don't need to retract anything
1412 phases.retractboundary(self, targetphase, [n])
1412 phases.retractboundary(self, targetphase, [n])
1413 tr.close()
1413 tr.close()
1414 branchmap.updatecache(self)
1414 branchmap.updatecache(self)
1415 return n
1415 return n
1416 finally:
1416 finally:
1417 if tr:
1417 if tr:
1418 tr.release()
1418 tr.release()
1419 lock.release()
1419 lock.release()
1420
1420
1421 @unfilteredmethod
1421 @unfilteredmethod
1422 def destroyed(self, newheadnodes=None):
1422 def destroyed(self, newheadnodes=None):
1423 '''Inform the repository that nodes have been destroyed.
1423 '''Inform the repository that nodes have been destroyed.
1424 Intended for use by strip and rollback, so there's a common
1424 Intended for use by strip and rollback, so there's a common
1425 place for anything that has to be done after destroying history.
1425 place for anything that has to be done after destroying history.
1426
1426
1427 If you know the branchheadcache was uptodate before nodes were removed
1427 If you know the branchheadcache was uptodate before nodes were removed
1428 and you also know the set of candidate new heads that may have resulted
1428 and you also know the set of candidate new heads that may have resulted
1429 from the destruction, you can set newheadnodes. This will enable the
1429 from the destruction, you can set newheadnodes. This will enable the
1430 code to update the branchheads cache, rather than having future code
1430 code to update the branchheads cache, rather than having future code
1431 decide it's invalid and regenerating it from scratch.
1431 decide it's invalid and regenerating it from scratch.
1432 '''
1432 '''
1433 # If we have info, newheadnodes, on how to update the branch cache, do
1433 # If we have info, newheadnodes, on how to update the branch cache, do
1434 # it, Otherwise, since nodes were destroyed, the cache is stale and this
1434 # it, Otherwise, since nodes were destroyed, the cache is stale and this
1435 # will be caught the next time it is read.
1435 # will be caught the next time it is read.
1436 if newheadnodes:
1436 if newheadnodes:
1437 ctxgen = (self[node] for node in newheadnodes
1437 ctxgen = (self[node] for node in newheadnodes
1438 if self.changelog.hasnode(node))
1438 if self.changelog.hasnode(node))
1439 cache = self._branchcache
1439 cache = self._branchcache
1440 cache.update(self, ctxgen)
1440 cache.update(self, ctxgen)
1441 cache.write(self)
1441 cache.write(self)
1442
1442
1443 # Ensure the persistent tag cache is updated. Doing it now
1443 # Ensure the persistent tag cache is updated. Doing it now
1444 # means that the tag cache only has to worry about destroyed
1444 # means that the tag cache only has to worry about destroyed
1445 # heads immediately after a strip/rollback. That in turn
1445 # heads immediately after a strip/rollback. That in turn
1446 # guarantees that "cachetip == currenttip" (comparing both rev
1446 # guarantees that "cachetip == currenttip" (comparing both rev
1447 # and node) always means no nodes have been added or destroyed.
1447 # and node) always means no nodes have been added or destroyed.
1448
1448
1449 # XXX this is suboptimal when qrefresh'ing: we strip the current
1449 # XXX this is suboptimal when qrefresh'ing: we strip the current
1450 # head, refresh the tag cache, then immediately add a new head.
1450 # head, refresh the tag cache, then immediately add a new head.
1451 # But I think doing it this way is necessary for the "instant
1451 # But I think doing it this way is necessary for the "instant
1452 # tag cache retrieval" case to work.
1452 # tag cache retrieval" case to work.
1453 self.invalidatecaches()
1453 self.invalidatecaches()
1454
1454
1455 # Discard all cache entries to force reloading everything.
1455 # Discard all cache entries to force reloading everything.
1456 self._filecache.clear()
1456 self._filecache.clear()
1457
1457
1458 def walk(self, match, node=None):
1458 def walk(self, match, node=None):
1459 '''
1459 '''
1460 walk recursively through the directory tree or a given
1460 walk recursively through the directory tree or a given
1461 changeset, finding all files matched by the match
1461 changeset, finding all files matched by the match
1462 function
1462 function
1463 '''
1463 '''
1464 return self[node].walk(match)
1464 return self[node].walk(match)
1465
1465
1466 def status(self, node1='.', node2=None, match=None,
1466 def status(self, node1='.', node2=None, match=None,
1467 ignored=False, clean=False, unknown=False,
1467 ignored=False, clean=False, unknown=False,
1468 listsubrepos=False):
1468 listsubrepos=False):
1469 """return status of files between two nodes or node and working
1469 """return status of files between two nodes or node and working
1470 directory.
1470 directory.
1471
1471
1472 If node1 is None, use the first dirstate parent instead.
1472 If node1 is None, use the first dirstate parent instead.
1473 If node2 is None, compare node1 with working directory.
1473 If node2 is None, compare node1 with working directory.
1474 """
1474 """
1475
1475
1476 def mfmatches(ctx):
1476 def mfmatches(ctx):
1477 mf = ctx.manifest().copy()
1477 mf = ctx.manifest().copy()
1478 if match.always():
1478 if match.always():
1479 return mf
1479 return mf
1480 for fn in mf.keys():
1480 for fn in mf.keys():
1481 if not match(fn):
1481 if not match(fn):
1482 del mf[fn]
1482 del mf[fn]
1483 return mf
1483 return mf
1484
1484
1485 if isinstance(node1, context.changectx):
1485 if isinstance(node1, context.changectx):
1486 ctx1 = node1
1486 ctx1 = node1
1487 else:
1487 else:
1488 ctx1 = self[node1]
1488 ctx1 = self[node1]
1489 if isinstance(node2, context.changectx):
1489 if isinstance(node2, context.changectx):
1490 ctx2 = node2
1490 ctx2 = node2
1491 else:
1491 else:
1492 ctx2 = self[node2]
1492 ctx2 = self[node2]
1493
1493
1494 working = ctx2.rev() is None
1494 working = ctx2.rev() is None
1495 parentworking = working and ctx1 == self['.']
1495 parentworking = working and ctx1 == self['.']
1496 match = match or matchmod.always(self.root, self.getcwd())
1496 match = match or matchmod.always(self.root, self.getcwd())
1497 listignored, listclean, listunknown = ignored, clean, unknown
1497 listignored, listclean, listunknown = ignored, clean, unknown
1498
1498
1499 # load earliest manifest first for caching reasons
1499 # load earliest manifest first for caching reasons
1500 if not working and ctx2.rev() < ctx1.rev():
1500 if not working and ctx2.rev() < ctx1.rev():
1501 ctx2.manifest()
1501 ctx2.manifest()
1502
1502
1503 if not parentworking:
1503 if not parentworking:
1504 def bad(f, msg):
1504 def bad(f, msg):
1505 # 'f' may be a directory pattern from 'match.files()',
1505 # 'f' may be a directory pattern from 'match.files()',
1506 # so 'f not in ctx1' is not enough
1506 # so 'f not in ctx1' is not enough
1507 if f not in ctx1 and f not in ctx1.dirs():
1507 if f not in ctx1 and f not in ctx1.dirs():
1508 self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
1508 self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
1509 match.bad = bad
1509 match.bad = bad
1510
1510
1511 if working: # we need to scan the working dir
1511 if working: # we need to scan the working dir
1512 subrepos = []
1512 subrepos = []
1513 if '.hgsub' in self.dirstate:
1513 if '.hgsub' in self.dirstate:
1514 subrepos = ctx2.substate.keys()
1514 subrepos = ctx2.substate.keys()
1515 s = self.dirstate.status(match, subrepos, listignored,
1515 s = self.dirstate.status(match, subrepos, listignored,
1516 listclean, listunknown)
1516 listclean, listunknown)
1517 cmp, modified, added, removed, deleted, unknown, ignored, clean = s
1517 cmp, modified, added, removed, deleted, unknown, ignored, clean = s
1518
1518
1519 # check for any possibly clean files
1519 # check for any possibly clean files
1520 if parentworking and cmp:
1520 if parentworking and cmp:
1521 fixup = []
1521 fixup = []
1522 # do a full compare of any files that might have changed
1522 # do a full compare of any files that might have changed
1523 for f in sorted(cmp):
1523 for f in sorted(cmp):
1524 if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f)
1524 if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f)
1525 or ctx1[f].cmp(ctx2[f])):
1525 or ctx1[f].cmp(ctx2[f])):
1526 modified.append(f)
1526 modified.append(f)
1527 else:
1527 else:
1528 fixup.append(f)
1528 fixup.append(f)
1529
1529
1530 # update dirstate for files that are actually clean
1530 # update dirstate for files that are actually clean
1531 if fixup:
1531 if fixup:
1532 if listclean:
1532 if listclean:
1533 clean += fixup
1533 clean += fixup
1534
1534
1535 try:
1535 try:
1536 # updating the dirstate is optional
1536 # updating the dirstate is optional
1537 # so we don't wait on the lock
1537 # so we don't wait on the lock
1538 wlock = self.wlock(False)
1538 wlock = self.wlock(False)
1539 try:
1539 try:
1540 for f in fixup:
1540 for f in fixup:
1541 self.dirstate.normal(f)
1541 self.dirstate.normal(f)
1542 finally:
1542 finally:
1543 wlock.release()
1543 wlock.release()
1544 except error.LockError:
1544 except error.LockError:
1545 pass
1545 pass
1546
1546
1547 if not parentworking:
1547 if not parentworking:
1548 mf1 = mfmatches(ctx1)
1548 mf1 = mfmatches(ctx1)
1549 if working:
1549 if working:
1550 # we are comparing working dir against non-parent
1550 # we are comparing working dir against non-parent
1551 # generate a pseudo-manifest for the working dir
1551 # generate a pseudo-manifest for the working dir
1552 mf2 = mfmatches(self['.'])
1552 mf2 = mfmatches(self['.'])
1553 for f in cmp + modified + added:
1553 for f in cmp + modified + added:
1554 mf2[f] = None
1554 mf2[f] = None
1555 mf2.set(f, ctx2.flags(f))
1555 mf2.set(f, ctx2.flags(f))
1556 for f in removed:
1556 for f in removed:
1557 if f in mf2:
1557 if f in mf2:
1558 del mf2[f]
1558 del mf2[f]
1559 else:
1559 else:
1560 # we are comparing two revisions
1560 # we are comparing two revisions
1561 deleted, unknown, ignored = [], [], []
1561 deleted, unknown, ignored = [], [], []
1562 mf2 = mfmatches(ctx2)
1562 mf2 = mfmatches(ctx2)
1563
1563
1564 modified, added, clean = [], [], []
1564 modified, added, clean = [], [], []
1565 withflags = mf1.withflags() | mf2.withflags()
1565 withflags = mf1.withflags() | mf2.withflags()
1566 for fn in mf2:
1566 for fn in mf2:
1567 if fn in mf1:
1567 if fn in mf1:
1568 if (fn not in deleted and
1568 if (fn not in deleted and
1569 ((fn in withflags and mf1.flags(fn) != mf2.flags(fn)) or
1569 ((fn in withflags and mf1.flags(fn) != mf2.flags(fn)) or
1570 (mf1[fn] != mf2[fn] and
1570 (mf1[fn] != mf2[fn] and
1571 (mf2[fn] or ctx1[fn].cmp(ctx2[fn]))))):
1571 (mf2[fn] or ctx1[fn].cmp(ctx2[fn]))))):
1572 modified.append(fn)
1572 modified.append(fn)
1573 elif listclean:
1573 elif listclean:
1574 clean.append(fn)
1574 clean.append(fn)
1575 del mf1[fn]
1575 del mf1[fn]
1576 elif fn not in deleted:
1576 elif fn not in deleted:
1577 added.append(fn)
1577 added.append(fn)
1578 removed = mf1.keys()
1578 removed = mf1.keys()
1579
1579
1580 if working and modified and not self.dirstate._checklink:
1580 if working and modified and not self.dirstate._checklink:
1581 # Symlink placeholders may get non-symlink-like contents
1581 # Symlink placeholders may get non-symlink-like contents
1582 # via user error or dereferencing by NFS or Samba servers,
1582 # via user error or dereferencing by NFS or Samba servers,
1583 # so we filter out any placeholders that don't look like a
1583 # so we filter out any placeholders that don't look like a
1584 # symlink
1584 # symlink
1585 sane = []
1585 sane = []
1586 for f in modified:
1586 for f in modified:
1587 if ctx2.flags(f) == 'l':
1587 if ctx2.flags(f) == 'l':
1588 d = ctx2[f].data()
1588 d = ctx2[f].data()
1589 if len(d) >= 1024 or '\n' in d or util.binary(d):
1589 if len(d) >= 1024 or '\n' in d or util.binary(d):
1590 self.ui.debug('ignoring suspect symlink placeholder'
1590 self.ui.debug('ignoring suspect symlink placeholder'
1591 ' "%s"\n' % f)
1591 ' "%s"\n' % f)
1592 continue
1592 continue
1593 sane.append(f)
1593 sane.append(f)
1594 modified = sane
1594 modified = sane
1595
1595
1596 r = modified, added, removed, deleted, unknown, ignored, clean
1596 r = modified, added, removed, deleted, unknown, ignored, clean
1597
1597
1598 if listsubrepos:
1598 if listsubrepos:
1599 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
1599 for subpath, sub in subrepo.itersubrepos(ctx1, ctx2):
1600 if working:
1600 if working:
1601 rev2 = None
1601 rev2 = None
1602 else:
1602 else:
1603 rev2 = ctx2.substate[subpath][1]
1603 rev2 = ctx2.substate[subpath][1]
1604 try:
1604 try:
1605 submatch = matchmod.narrowmatcher(subpath, match)
1605 submatch = matchmod.narrowmatcher(subpath, match)
1606 s = sub.status(rev2, match=submatch, ignored=listignored,
1606 s = sub.status(rev2, match=submatch, ignored=listignored,
1607 clean=listclean, unknown=listunknown,
1607 clean=listclean, unknown=listunknown,
1608 listsubrepos=True)
1608 listsubrepos=True)
1609 for rfiles, sfiles in zip(r, s):
1609 for rfiles, sfiles in zip(r, s):
1610 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
1610 rfiles.extend("%s/%s" % (subpath, f) for f in sfiles)
1611 except error.LookupError:
1611 except error.LookupError:
1612 self.ui.status(_("skipping missing subrepository: %s\n")
1612 self.ui.status(_("skipping missing subrepository: %s\n")
1613 % subpath)
1613 % subpath)
1614
1614
1615 for l in r:
1615 for l in r:
1616 l.sort()
1616 l.sort()
1617 return r
1617 return r
1618
1618
1619 def heads(self, start=None):
1619 def heads(self, start=None):
1620 heads = self.changelog.heads(start)
1620 heads = self.changelog.heads(start)
1621 # sort the output in rev descending order
1621 # sort the output in rev descending order
1622 return sorted(heads, key=self.changelog.rev, reverse=True)
1622 return sorted(heads, key=self.changelog.rev, reverse=True)
1623
1623
1624 def branchheads(self, branch=None, start=None, closed=False):
1624 def branchheads(self, branch=None, start=None, closed=False):
1625 '''return a (possibly filtered) list of heads for the given branch
1625 '''return a (possibly filtered) list of heads for the given branch
1626
1626
1627 Heads are returned in topological order, from newest to oldest.
1627 Heads are returned in topological order, from newest to oldest.
1628 If branch is None, use the dirstate branch.
1628 If branch is None, use the dirstate branch.
1629 If start is not None, return only heads reachable from start.
1629 If start is not None, return only heads reachable from start.
1630 If closed is True, return heads that are marked as closed as well.
1630 If closed is True, return heads that are marked as closed as well.
1631 '''
1631 '''
1632 if branch is None:
1632 if branch is None:
1633 branch = self[None].branch()
1633 branch = self[None].branch()
1634 branches = self.branchmap()
1634 branches = self.branchmap()
1635 if branch not in branches:
1635 if branch not in branches:
1636 return []
1636 return []
1637 # the cache returns heads ordered lowest to highest
1637 # the cache returns heads ordered lowest to highest
1638 bheads = list(reversed(branches[branch]))
1638 bheads = list(reversed(branches[branch]))
1639 if start is not None:
1639 if start is not None:
1640 # filter out the heads that cannot be reached from startrev
1640 # filter out the heads that cannot be reached from startrev
1641 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
1641 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
1642 bheads = [h for h in bheads if h in fbheads]
1642 bheads = [h for h in bheads if h in fbheads]
1643 if not closed:
1643 if not closed:
1644 bheads = [h for h in bheads if not self[h].closesbranch()]
1644 bheads = [h for h in bheads if not self[h].closesbranch()]
1645 return bheads
1645 return bheads
1646
1646
1647 def branches(self, nodes):
1647 def branches(self, nodes):
1648 if not nodes:
1648 if not nodes:
1649 nodes = [self.changelog.tip()]
1649 nodes = [self.changelog.tip()]
1650 b = []
1650 b = []
1651 for n in nodes:
1651 for n in nodes:
1652 t = n
1652 t = n
1653 while True:
1653 while True:
1654 p = self.changelog.parents(n)
1654 p = self.changelog.parents(n)
1655 if p[1] != nullid or p[0] == nullid:
1655 if p[1] != nullid or p[0] == nullid:
1656 b.append((t, n, p[0], p[1]))
1656 b.append((t, n, p[0], p[1]))
1657 break
1657 break
1658 n = p[0]
1658 n = p[0]
1659 return b
1659 return b
1660
1660
1661 def between(self, pairs):
1661 def between(self, pairs):
1662 r = []
1662 r = []
1663
1663
1664 for top, bottom in pairs:
1664 for top, bottom in pairs:
1665 n, l, i = top, [], 0
1665 n, l, i = top, [], 0
1666 f = 1
1666 f = 1
1667
1667
1668 while n != bottom and n != nullid:
1668 while n != bottom and n != nullid:
1669 p = self.changelog.parents(n)[0]
1669 p = self.changelog.parents(n)[0]
1670 if i == f:
1670 if i == f:
1671 l.append(n)
1671 l.append(n)
1672 f = f * 2
1672 f = f * 2
1673 n = p
1673 n = p
1674 i += 1
1674 i += 1
1675
1675
1676 r.append(l)
1676 r.append(l)
1677
1677
1678 return r
1678 return r
1679
1679
1680 def pull(self, remote, heads=None, force=False):
1680 def pull(self, remote, heads=None, force=False):
1681 # don't open transaction for nothing or you break future useful
1681 # don't open transaction for nothing or you break future useful
1682 # rollback call
1682 # rollback call
1683 tr = None
1683 tr = None
1684 trname = 'pull\n' + util.hidepassword(remote.url())
1684 trname = 'pull\n' + util.hidepassword(remote.url())
1685 lock = self.lock()
1685 lock = self.lock()
1686 try:
1686 try:
1687 tmp = discovery.findcommonincoming(self, remote, heads=heads,
1687 tmp = discovery.findcommonincoming(self, remote, heads=heads,
1688 force=force)
1688 force=force)
1689 common, fetch, rheads = tmp
1689 common, fetch, rheads = tmp
1690 if not fetch:
1690 if not fetch:
1691 self.ui.status(_("no changes found\n"))
1691 self.ui.status(_("no changes found\n"))
1692 added = []
1692 added = []
1693 result = 0
1693 result = 0
1694 else:
1694 else:
1695 tr = self.transaction(trname)
1695 tr = self.transaction(trname)
1696 if heads is None and list(common) == [nullid]:
1696 if heads is None and list(common) == [nullid]:
1697 self.ui.status(_("requesting all changes\n"))
1697 self.ui.status(_("requesting all changes\n"))
1698 elif heads is None and remote.capable('changegroupsubset'):
1698 elif heads is None and remote.capable('changegroupsubset'):
1699 # issue1320, avoid a race if remote changed after discovery
1699 # issue1320, avoid a race if remote changed after discovery
1700 heads = rheads
1700 heads = rheads
1701
1701
1702 if remote.capable('getbundle'):
1702 if remote.capable('getbundle'):
1703 cg = remote.getbundle('pull', common=common,
1703 cg = remote.getbundle('pull', common=common,
1704 heads=heads or rheads)
1704 heads=heads or rheads)
1705 elif heads is None:
1705 elif heads is None:
1706 cg = remote.changegroup(fetch, 'pull')
1706 cg = remote.changegroup(fetch, 'pull')
1707 elif not remote.capable('changegroupsubset'):
1707 elif not remote.capable('changegroupsubset'):
1708 raise util.Abort(_("partial pull cannot be done because "
1708 raise util.Abort(_("partial pull cannot be done because "
1709 "other repository doesn't support "
1709 "other repository doesn't support "
1710 "changegroupsubset."))
1710 "changegroupsubset."))
1711 else:
1711 else:
1712 cg = remote.changegroupsubset(fetch, heads, 'pull')
1712 cg = remote.changegroupsubset(fetch, heads, 'pull')
1713 clstart = len(self.changelog)
1713 clstart = len(self.changelog)
1714 result = self.addchangegroup(cg, 'pull', remote.url())
1714 result = self.addchangegroup(cg, 'pull', remote.url())
1715 clend = len(self.changelog)
1715 clend = len(self.changelog)
1716 added = [self.changelog.node(r) for r in xrange(clstart, clend)]
1716 added = [self.changelog.node(r) for r in xrange(clstart, clend)]
1717
1717
1718 # compute target subset
1718 # compute target subset
1719 if heads is None:
1719 if heads is None:
1720 # We pulled every thing possible
1720 # We pulled every thing possible
1721 # sync on everything common
1721 # sync on everything common
1722 subset = common + added
1722 subset = common + added
1723 else:
1723 else:
1724 # We pulled a specific subset
1724 # We pulled a specific subset
1725 # sync on this subset
1725 # sync on this subset
1726 subset = heads
1726 subset = heads
1727
1727
1728 # Get remote phases data from remote
1728 # Get remote phases data from remote
1729 remotephases = remote.listkeys('phases')
1729 remotephases = remote.listkeys('phases')
1730 publishing = bool(remotephases.get('publishing', False))
1730 publishing = bool(remotephases.get('publishing', False))
1731 if remotephases and not publishing:
1731 if remotephases and not publishing:
1732 # remote is new and unpublishing
1732 # remote is new and unpublishing
1733 pheads, _dr = phases.analyzeremotephases(self, subset,
1733 pheads, _dr = phases.analyzeremotephases(self, subset,
1734 remotephases)
1734 remotephases)
1735 phases.advanceboundary(self, phases.public, pheads)
1735 phases.advanceboundary(self, phases.public, pheads)
1736 phases.advanceboundary(self, phases.draft, subset)
1736 phases.advanceboundary(self, phases.draft, subset)
1737 else:
1737 else:
1738 # Remote is old or publishing all common changesets
1738 # Remote is old or publishing all common changesets
1739 # should be seen as public
1739 # should be seen as public
1740 phases.advanceboundary(self, phases.public, subset)
1740 phases.advanceboundary(self, phases.public, subset)
1741
1741
1742 if obsolete._enabled:
1742 if obsolete._enabled:
1743 self.ui.debug('fetching remote obsolete markers\n')
1743 self.ui.debug('fetching remote obsolete markers\n')
1744 remoteobs = remote.listkeys('obsolete')
1744 remoteobs = remote.listkeys('obsolete')
1745 if 'dump0' in remoteobs:
1745 if 'dump0' in remoteobs:
1746 if tr is None:
1746 if tr is None:
1747 tr = self.transaction(trname)
1747 tr = self.transaction(trname)
1748 for key in sorted(remoteobs, reverse=True):
1748 for key in sorted(remoteobs, reverse=True):
1749 if key.startswith('dump'):
1749 if key.startswith('dump'):
1750 data = base85.b85decode(remoteobs[key])
1750 data = base85.b85decode(remoteobs[key])
1751 self.obsstore.mergemarkers(tr, data)
1751 self.obsstore.mergemarkers(tr, data)
1752 self.invalidatevolatilesets()
1752 self.invalidatevolatilesets()
1753 if tr is not None:
1753 if tr is not None:
1754 tr.close()
1754 tr.close()
1755 finally:
1755 finally:
1756 if tr is not None:
1756 if tr is not None:
1757 tr.release()
1757 tr.release()
1758 lock.release()
1758 lock.release()
1759
1759
1760 return result
1760 return result
1761
1761
1762 def checkpush(self, force, revs):
1762 def checkpush(self, force, revs):
1763 """Extensions can override this function if additional checks have
1763 """Extensions can override this function if additional checks have
1764 to be performed before pushing, or call it if they override push
1764 to be performed before pushing, or call it if they override push
1765 command.
1765 command.
1766 """
1766 """
1767 pass
1767 pass
1768
1768
1769 def push(self, remote, force=False, revs=None, newbranch=False):
1769 def push(self, remote, force=False, revs=None, newbranch=False):
1770 '''Push outgoing changesets (limited by revs) from the current
1770 '''Push outgoing changesets (limited by revs) from the current
1771 repository to remote. Return an integer:
1771 repository to remote. Return an integer:
1772 - None means nothing to push
1772 - None means nothing to push
1773 - 0 means HTTP error
1773 - 0 means HTTP error
1774 - 1 means we pushed and remote head count is unchanged *or*
1774 - 1 means we pushed and remote head count is unchanged *or*
1775 we have outgoing changesets but refused to push
1775 we have outgoing changesets but refused to push
1776 - other values as described by addchangegroup()
1776 - other values as described by addchangegroup()
1777 '''
1777 '''
1778 # there are two ways to push to remote repo:
1778 # there are two ways to push to remote repo:
1779 #
1779 #
1780 # addchangegroup assumes local user can lock remote
1780 # addchangegroup assumes local user can lock remote
1781 # repo (local filesystem, old ssh servers).
1781 # repo (local filesystem, old ssh servers).
1782 #
1782 #
1783 # unbundle assumes local user cannot lock remote repo (new ssh
1783 # unbundle assumes local user cannot lock remote repo (new ssh
1784 # servers, http servers).
1784 # servers, http servers).
1785
1785
1786 if not remote.canpush():
1786 if not remote.canpush():
1787 raise util.Abort(_("destination does not support push"))
1787 raise util.Abort(_("destination does not support push"))
1788 unfi = self.unfiltered()
1788 unfi = self.unfiltered()
1789 # get local lock as we might write phase data
1789 # get local lock as we might write phase data
1790 locallock = self.lock()
1790 locallock = self.lock()
1791 try:
1791 try:
1792 self.checkpush(force, revs)
1792 self.checkpush(force, revs)
1793 lock = None
1793 lock = None
1794 unbundle = remote.capable('unbundle')
1794 unbundle = remote.capable('unbundle')
1795 if not unbundle:
1795 if not unbundle:
1796 lock = remote.lock()
1796 lock = remote.lock()
1797 try:
1797 try:
1798 # discovery
1798 # discovery
1799 fci = discovery.findcommonincoming
1799 fci = discovery.findcommonincoming
1800 commoninc = fci(unfi, remote, force=force)
1800 commoninc = fci(unfi, remote, force=force)
1801 common, inc, remoteheads = commoninc
1801 common, inc, remoteheads = commoninc
1802 fco = discovery.findcommonoutgoing
1802 fco = discovery.findcommonoutgoing
1803 outgoing = fco(unfi, remote, onlyheads=revs,
1803 outgoing = fco(unfi, remote, onlyheads=revs,
1804 commoninc=commoninc, force=force)
1804 commoninc=commoninc, force=force)
1805
1805
1806
1806
1807 if not outgoing.missing:
1807 if not outgoing.missing:
1808 # nothing to push
1808 # nothing to push
1809 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
1809 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
1810 ret = None
1810 ret = None
1811 else:
1811 else:
1812 # something to push
1812 # something to push
1813 if not force:
1813 if not force:
1814 # if self.obsstore == False --> no obsolete
1814 # if self.obsstore == False --> no obsolete
1815 # then, save the iteration
1815 # then, save the iteration
1816 if unfi.obsstore:
1816 if unfi.obsstore:
1817 # this message are here for 80 char limit reason
1817 # this message are here for 80 char limit reason
1818 mso = _("push includes obsolete changeset: %s!")
1818 mso = _("push includes obsolete changeset: %s!")
1819 msu = _("push includes unstable changeset: %s!")
1819 msu = _("push includes unstable changeset: %s!")
1820 msb = _("push includes bumped changeset: %s!")
1820 msb = _("push includes bumped changeset: %s!")
1821 msd = _("push includes divergent changeset: %s!")
1821 msd = _("push includes divergent changeset: %s!")
1822 # If we are to push if there is at least one
1822 # If we are to push if there is at least one
1823 # obsolete or unstable changeset in missing, at
1823 # obsolete or unstable changeset in missing, at
1824 # least one of the missinghead will be obsolete or
1824 # least one of the missinghead will be obsolete or
1825 # unstable. So checking heads only is ok
1825 # unstable. So checking heads only is ok
1826 for node in outgoing.missingheads:
1826 for node in outgoing.missingheads:
1827 ctx = unfi[node]
1827 ctx = unfi[node]
1828 if ctx.obsolete():
1828 if ctx.obsolete():
1829 raise util.Abort(mso % ctx)
1829 raise util.Abort(mso % ctx)
1830 elif ctx.unstable():
1830 elif ctx.unstable():
1831 raise util.Abort(msu % ctx)
1831 raise util.Abort(msu % ctx)
1832 elif ctx.bumped():
1832 elif ctx.bumped():
1833 raise util.Abort(msb % ctx)
1833 raise util.Abort(msb % ctx)
1834 elif ctx.divergent():
1834 elif ctx.divergent():
1835 raise util.Abort(msd % ctx)
1835 raise util.Abort(msd % ctx)
1836 discovery.checkheads(unfi, remote, outgoing,
1836 discovery.checkheads(unfi, remote, outgoing,
1837 remoteheads, newbranch,
1837 remoteheads, newbranch,
1838 bool(inc))
1838 bool(inc))
1839
1839
1840 # create a changegroup from local
1840 # create a changegroup from local
1841 if revs is None and not outgoing.excluded:
1841 if revs is None and not outgoing.excluded:
1842 # push everything,
1842 # push everything,
1843 # use the fast path, no race possible on push
1843 # use the fast path, no race possible on push
1844 cg = self._changegroup(outgoing.missing, 'push')
1844 cg = self._changegroup(outgoing.missing, 'push')
1845 else:
1845 else:
1846 cg = self.getlocalbundle('push', outgoing)
1846 cg = self.getlocalbundle('push', outgoing)
1847
1847
1848 # apply changegroup to remote
1848 # apply changegroup to remote
1849 if unbundle:
1849 if unbundle:
1850 # local repo finds heads on server, finds out what
1850 # local repo finds heads on server, finds out what
1851 # revs it must push. once revs transferred, if server
1851 # revs it must push. once revs transferred, if server
1852 # finds it has different heads (someone else won
1852 # finds it has different heads (someone else won
1853 # commit/push race), server aborts.
1853 # commit/push race), server aborts.
1854 if force:
1854 if force:
1855 remoteheads = ['force']
1855 remoteheads = ['force']
1856 # ssh: return remote's addchangegroup()
1856 # ssh: return remote's addchangegroup()
1857 # http: return remote's addchangegroup() or 0 for error
1857 # http: return remote's addchangegroup() or 0 for error
1858 ret = remote.unbundle(cg, remoteheads, 'push')
1858 ret = remote.unbundle(cg, remoteheads, 'push')
1859 else:
1859 else:
1860 # we return an integer indicating remote head count
1860 # we return an integer indicating remote head count
1861 # change
1861 # change
1862 ret = remote.addchangegroup(cg, 'push', self.url())
1862 ret = remote.addchangegroup(cg, 'push', self.url())
1863
1863
1864 if ret:
1864 if ret:
1865 # push succeed, synchronize target of the push
1865 # push succeed, synchronize target of the push
1866 cheads = outgoing.missingheads
1866 cheads = outgoing.missingheads
1867 elif revs is None:
1867 elif revs is None:
1868 # All out push fails. synchronize all common
1868 # All out push fails. synchronize all common
1869 cheads = outgoing.commonheads
1869 cheads = outgoing.commonheads
1870 else:
1870 else:
1871 # I want cheads = heads(::missingheads and ::commonheads)
1871 # I want cheads = heads(::missingheads and ::commonheads)
1872 # (missingheads is revs with secret changeset filtered out)
1872 # (missingheads is revs with secret changeset filtered out)
1873 #
1873 #
1874 # This can be expressed as:
1874 # This can be expressed as:
1875 # cheads = ( (missingheads and ::commonheads)
1875 # cheads = ( (missingheads and ::commonheads)
1876 # + (commonheads and ::missingheads))"
1876 # + (commonheads and ::missingheads))"
1877 # )
1877 # )
1878 #
1878 #
1879 # while trying to push we already computed the following:
1879 # while trying to push we already computed the following:
1880 # common = (::commonheads)
1880 # common = (::commonheads)
1881 # missing = ((commonheads::missingheads) - commonheads)
1881 # missing = ((commonheads::missingheads) - commonheads)
1882 #
1882 #
1883 # We can pick:
1883 # We can pick:
1884 # * missingheads part of common (::commonheads)
1884 # * missingheads part of common (::commonheads)
1885 common = set(outgoing.common)
1885 common = set(outgoing.common)
1886 cheads = [node for node in revs if node in common]
1886 cheads = [node for node in revs if node in common]
1887 # and
1887 # and
1888 # * commonheads parents on missing
1888 # * commonheads parents on missing
1889 revset = unfi.set('%ln and parents(roots(%ln))',
1889 revset = unfi.set('%ln and parents(roots(%ln))',
1890 outgoing.commonheads,
1890 outgoing.commonheads,
1891 outgoing.missing)
1891 outgoing.missing)
1892 cheads.extend(c.node() for c in revset)
1892 cheads.extend(c.node() for c in revset)
1893 # even when we don't push, exchanging phase data is useful
1893 # even when we don't push, exchanging phase data is useful
1894 remotephases = remote.listkeys('phases')
1894 remotephases = remote.listkeys('phases')
1895 if not remotephases: # old server or public only repo
1895 if not remotephases: # old server or public only repo
1896 phases.advanceboundary(self, phases.public, cheads)
1896 phases.advanceboundary(self, phases.public, cheads)
1897 # don't push any phase data as there is nothing to push
1897 # don't push any phase data as there is nothing to push
1898 else:
1898 else:
1899 ana = phases.analyzeremotephases(self, cheads, remotephases)
1899 ana = phases.analyzeremotephases(self, cheads, remotephases)
1900 pheads, droots = ana
1900 pheads, droots = ana
1901 ### Apply remote phase on local
1901 ### Apply remote phase on local
1902 if remotephases.get('publishing', False):
1902 if remotephases.get('publishing', False):
1903 phases.advanceboundary(self, phases.public, cheads)
1903 phases.advanceboundary(self, phases.public, cheads)
1904 else: # publish = False
1904 else: # publish = False
1905 phases.advanceboundary(self, phases.public, pheads)
1905 phases.advanceboundary(self, phases.public, pheads)
1906 phases.advanceboundary(self, phases.draft, cheads)
1906 phases.advanceboundary(self, phases.draft, cheads)
1907 ### Apply local phase on remote
1907 ### Apply local phase on remote
1908
1908
1909 # Get the list of all revs draft on remote by public here.
1909 # Get the list of all revs draft on remote by public here.
1910 # XXX Beware that revset break if droots is not strictly
1910 # XXX Beware that revset break if droots is not strictly
1911 # XXX root we may want to ensure it is but it is costly
1911 # XXX root we may want to ensure it is but it is costly
1912 outdated = unfi.set('heads((%ln::%ln) and public())',
1912 outdated = unfi.set('heads((%ln::%ln) and public())',
1913 droots, cheads)
1913 droots, cheads)
1914 for newremotehead in outdated:
1914 for newremotehead in outdated:
1915 r = remote.pushkey('phases',
1915 r = remote.pushkey('phases',
1916 newremotehead.hex(),
1916 newremotehead.hex(),
1917 str(phases.draft),
1917 str(phases.draft),
1918 str(phases.public))
1918 str(phases.public))
1919 if not r:
1919 if not r:
1920 self.ui.warn(_('updating %s to public failed!\n')
1920 self.ui.warn(_('updating %s to public failed!\n')
1921 % newremotehead)
1921 % newremotehead)
1922 self.ui.debug('try to push obsolete markers to remote\n')
1922 self.ui.debug('try to push obsolete markers to remote\n')
1923 if (obsolete._enabled and self.obsstore and
1923 if (obsolete._enabled and self.obsstore and
1924 'obsolete' in remote.listkeys('namespaces')):
1924 'obsolete' in remote.listkeys('namespaces')):
1925 rslts = []
1925 rslts = []
1926 remotedata = self.listkeys('obsolete')
1926 remotedata = self.listkeys('obsolete')
1927 for key in sorted(remotedata, reverse=True):
1927 for key in sorted(remotedata, reverse=True):
1928 # reverse sort to ensure we end with dump0
1928 # reverse sort to ensure we end with dump0
1929 data = remotedata[key]
1929 data = remotedata[key]
1930 rslts.append(remote.pushkey('obsolete', key, '', data))
1930 rslts.append(remote.pushkey('obsolete', key, '', data))
1931 if [r for r in rslts if not r]:
1931 if [r for r in rslts if not r]:
1932 msg = _('failed to push some obsolete markers!\n')
1932 msg = _('failed to push some obsolete markers!\n')
1933 self.ui.warn(msg)
1933 self.ui.warn(msg)
1934 finally:
1934 finally:
1935 if lock is not None:
1935 if lock is not None:
1936 lock.release()
1936 lock.release()
1937 finally:
1937 finally:
1938 locallock.release()
1938 locallock.release()
1939
1939
1940 self.ui.debug("checking for updated bookmarks\n")
1940 self.ui.debug("checking for updated bookmarks\n")
1941 rb = remote.listkeys('bookmarks')
1941 rb = remote.listkeys('bookmarks')
1942 for k in rb.keys():
1942 for k in rb.keys():
1943 if k in unfi._bookmarks:
1943 if k in unfi._bookmarks:
1944 nr, nl = rb[k], hex(self._bookmarks[k])
1944 nr, nl = rb[k], hex(self._bookmarks[k])
1945 if nr in unfi:
1945 if nr in unfi:
1946 cr = unfi[nr]
1946 cr = unfi[nr]
1947 cl = unfi[nl]
1947 cl = unfi[nl]
1948 if bookmarks.validdest(unfi, cr, cl):
1948 if bookmarks.validdest(unfi, cr, cl):
1949 r = remote.pushkey('bookmarks', k, nr, nl)
1949 r = remote.pushkey('bookmarks', k, nr, nl)
1950 if r:
1950 if r:
1951 self.ui.status(_("updating bookmark %s\n") % k)
1951 self.ui.status(_("updating bookmark %s\n") % k)
1952 else:
1952 else:
1953 self.ui.warn(_('updating bookmark %s'
1953 self.ui.warn(_('updating bookmark %s'
1954 ' failed!\n') % k)
1954 ' failed!\n') % k)
1955
1955
1956 return ret
1956 return ret
1957
1957
1958 def changegroupinfo(self, nodes, source):
1958 def changegroupinfo(self, nodes, source):
1959 if self.ui.verbose or source == 'bundle':
1959 if self.ui.verbose or source == 'bundle':
1960 self.ui.status(_("%d changesets found\n") % len(nodes))
1960 self.ui.status(_("%d changesets found\n") % len(nodes))
1961 if self.ui.debugflag:
1961 if self.ui.debugflag:
1962 self.ui.debug("list of changesets:\n")
1962 self.ui.debug("list of changesets:\n")
1963 for node in nodes:
1963 for node in nodes:
1964 self.ui.debug("%s\n" % hex(node))
1964 self.ui.debug("%s\n" % hex(node))
1965
1965
1966 def changegroupsubset(self, bases, heads, source):
1966 def changegroupsubset(self, bases, heads, source):
1967 """Compute a changegroup consisting of all the nodes that are
1967 """Compute a changegroup consisting of all the nodes that are
1968 descendants of any of the bases and ancestors of any of the heads.
1968 descendants of any of the bases and ancestors of any of the heads.
1969 Return a chunkbuffer object whose read() method will return
1969 Return a chunkbuffer object whose read() method will return
1970 successive changegroup chunks.
1970 successive changegroup chunks.
1971
1971
1972 It is fairly complex as determining which filenodes and which
1972 It is fairly complex as determining which filenodes and which
1973 manifest nodes need to be included for the changeset to be complete
1973 manifest nodes need to be included for the changeset to be complete
1974 is non-trivial.
1974 is non-trivial.
1975
1975
1976 Another wrinkle is doing the reverse, figuring out which changeset in
1976 Another wrinkle is doing the reverse, figuring out which changeset in
1977 the changegroup a particular filenode or manifestnode belongs to.
1977 the changegroup a particular filenode or manifestnode belongs to.
1978 """
1978 """
1979 cl = self.changelog
1979 cl = self.changelog
1980 if not bases:
1980 if not bases:
1981 bases = [nullid]
1981 bases = [nullid]
1982 csets, bases, heads = cl.nodesbetween(bases, heads)
1982 csets, bases, heads = cl.nodesbetween(bases, heads)
1983 # We assume that all ancestors of bases are known
1983 # We assume that all ancestors of bases are known
1984 common = cl.ancestors([cl.rev(n) for n in bases])
1984 common = cl.ancestors([cl.rev(n) for n in bases])
1985 return self._changegroupsubset(common, csets, heads, source)
1985 return self._changegroupsubset(common, csets, heads, source)
1986
1986
1987 def getlocalbundle(self, source, outgoing):
1987 def getlocalbundle(self, source, outgoing):
1988 """Like getbundle, but taking a discovery.outgoing as an argument.
1988 """Like getbundle, but taking a discovery.outgoing as an argument.
1989
1989
1990 This is only implemented for local repos and reuses potentially
1990 This is only implemented for local repos and reuses potentially
1991 precomputed sets in outgoing."""
1991 precomputed sets in outgoing."""
1992 if not outgoing.missing:
1992 if not outgoing.missing:
1993 return None
1993 return None
1994 return self._changegroupsubset(outgoing.common,
1994 return self._changegroupsubset(outgoing.common,
1995 outgoing.missing,
1995 outgoing.missing,
1996 outgoing.missingheads,
1996 outgoing.missingheads,
1997 source)
1997 source)
1998
1998
1999 def getbundle(self, source, heads=None, common=None):
1999 def getbundle(self, source, heads=None, common=None):
2000 """Like changegroupsubset, but returns the set difference between the
2000 """Like changegroupsubset, but returns the set difference between the
2001 ancestors of heads and the ancestors common.
2001 ancestors of heads and the ancestors common.
2002
2002
2003 If heads is None, use the local heads. If common is None, use [nullid].
2003 If heads is None, use the local heads. If common is None, use [nullid].
2004
2004
2005 The nodes in common might not all be known locally due to the way the
2005 The nodes in common might not all be known locally due to the way the
2006 current discovery protocol works.
2006 current discovery protocol works.
2007 """
2007 """
2008 cl = self.changelog
2008 cl = self.changelog
2009 if common:
2009 if common:
2010 hasnode = cl.hasnode
2010 hasnode = cl.hasnode
2011 common = [n for n in common if hasnode(n)]
2011 common = [n for n in common if hasnode(n)]
2012 else:
2012 else:
2013 common = [nullid]
2013 common = [nullid]
2014 if not heads:
2014 if not heads:
2015 heads = cl.heads()
2015 heads = cl.heads()
2016 return self.getlocalbundle(source,
2016 return self.getlocalbundle(source,
2017 discovery.outgoing(cl, common, heads))
2017 discovery.outgoing(cl, common, heads))
2018
2018
2019 @unfilteredmethod
2019 @unfilteredmethod
2020 def _changegroupsubset(self, commonrevs, csets, heads, source):
2020 def _changegroupsubset(self, commonrevs, csets, heads, source):
2021
2021
2022 cl = self.changelog
2022 cl = self.changelog
2023 mf = self.manifest
2023 mf = self.manifest
2024 mfs = {} # needed manifests
2024 mfs = {} # needed manifests
2025 fnodes = {} # needed file nodes
2025 fnodes = {} # needed file nodes
2026 changedfiles = set()
2026 changedfiles = set()
2027 fstate = ['', {}]
2027 fstate = ['', {}]
2028 count = [0, 0]
2028 count = [0, 0]
2029
2029
2030 # can we go through the fast path ?
2030 # can we go through the fast path ?
2031 heads.sort()
2031 heads.sort()
2032 if heads == sorted(self.heads()):
2032 if heads == sorted(self.heads()):
2033 return self._changegroup(csets, source)
2033 return self._changegroup(csets, source)
2034
2034
2035 # slow path
2035 # slow path
2036 self.hook('preoutgoing', throw=True, source=source)
2036 self.hook('preoutgoing', throw=True, source=source)
2037 self.changegroupinfo(csets, source)
2037 self.changegroupinfo(csets, source)
2038
2038
2039 # filter any nodes that claim to be part of the known set
2039 # filter any nodes that claim to be part of the known set
2040 def prune(revlog, missing):
2040 def prune(revlog, missing):
2041 rr, rl = revlog.rev, revlog.linkrev
2041 rr, rl = revlog.rev, revlog.linkrev
2042 return [n for n in missing
2042 return [n for n in missing
2043 if rl(rr(n)) not in commonrevs]
2043 if rl(rr(n)) not in commonrevs]
2044
2044
2045 progress = self.ui.progress
2045 progress = self.ui.progress
2046 _bundling = _('bundling')
2046 _bundling = _('bundling')
2047 _changesets = _('changesets')
2047 _changesets = _('changesets')
2048 _manifests = _('manifests')
2048 _manifests = _('manifests')
2049 _files = _('files')
2049 _files = _('files')
2050
2050
2051 def lookup(revlog, x):
2051 def lookup(revlog, x):
2052 if revlog == cl:
2052 if revlog == cl:
2053 c = cl.read(x)
2053 c = cl.read(x)
2054 changedfiles.update(c[3])
2054 changedfiles.update(c[3])
2055 mfs.setdefault(c[0], x)
2055 mfs.setdefault(c[0], x)
2056 count[0] += 1
2056 count[0] += 1
2057 progress(_bundling, count[0],
2057 progress(_bundling, count[0],
2058 unit=_changesets, total=count[1])
2058 unit=_changesets, total=count[1])
2059 return x
2059 return x
2060 elif revlog == mf:
2060 elif revlog == mf:
2061 clnode = mfs[x]
2061 clnode = mfs[x]
2062 mdata = mf.readfast(x)
2062 mdata = mf.readfast(x)
2063 for f, n in mdata.iteritems():
2063 for f, n in mdata.iteritems():
2064 if f in changedfiles:
2064 if f in changedfiles:
2065 fnodes[f].setdefault(n, clnode)
2065 fnodes[f].setdefault(n, clnode)
2066 count[0] += 1
2066 count[0] += 1
2067 progress(_bundling, count[0],
2067 progress(_bundling, count[0],
2068 unit=_manifests, total=count[1])
2068 unit=_manifests, total=count[1])
2069 return clnode
2069 return clnode
2070 else:
2070 else:
2071 progress(_bundling, count[0], item=fstate[0],
2071 progress(_bundling, count[0], item=fstate[0],
2072 unit=_files, total=count[1])
2072 unit=_files, total=count[1])
2073 return fstate[1][x]
2073 return fstate[1][x]
2074
2074
2075 bundler = changegroup.bundle10(lookup)
2075 bundler = changegroup.bundle10(lookup)
2076 reorder = self.ui.config('bundle', 'reorder', 'auto')
2076 reorder = self.ui.config('bundle', 'reorder', 'auto')
2077 if reorder == 'auto':
2077 if reorder == 'auto':
2078 reorder = None
2078 reorder = None
2079 else:
2079 else:
2080 reorder = util.parsebool(reorder)
2080 reorder = util.parsebool(reorder)
2081
2081
2082 def gengroup():
2082 def gengroup():
2083 # Create a changenode group generator that will call our functions
2083 # Create a changenode group generator that will call our functions
2084 # back to lookup the owning changenode and collect information.
2084 # back to lookup the owning changenode and collect information.
2085 count[:] = [0, len(csets)]
2085 count[:] = [0, len(csets)]
2086 for chunk in cl.group(csets, bundler, reorder=reorder):
2086 for chunk in cl.group(csets, bundler, reorder=reorder):
2087 yield chunk
2087 yield chunk
2088 progress(_bundling, None)
2088 progress(_bundling, None)
2089
2089
2090 # Create a generator for the manifestnodes that calls our lookup
2090 # Create a generator for the manifestnodes that calls our lookup
2091 # and data collection functions back.
2091 # and data collection functions back.
2092 for f in changedfiles:
2092 for f in changedfiles:
2093 fnodes[f] = {}
2093 fnodes[f] = {}
2094 count[:] = [0, len(mfs)]
2094 count[:] = [0, len(mfs)]
2095 for chunk in mf.group(prune(mf, mfs), bundler, reorder=reorder):
2095 for chunk in mf.group(prune(mf, mfs), bundler, reorder=reorder):
2096 yield chunk
2096 yield chunk
2097 progress(_bundling, None)
2097 progress(_bundling, None)
2098
2098
2099 mfs.clear()
2099 mfs.clear()
2100
2100
2101 # Go through all our files in order sorted by name.
2101 # Go through all our files in order sorted by name.
2102 count[:] = [0, len(changedfiles)]
2102 count[:] = [0, len(changedfiles)]
2103 for fname in sorted(changedfiles):
2103 for fname in sorted(changedfiles):
2104 filerevlog = self.file(fname)
2104 filerevlog = self.file(fname)
2105 if not len(filerevlog):
2105 if not len(filerevlog):
2106 raise util.Abort(_("empty or missing revlog for %s")
2106 raise util.Abort(_("empty or missing revlog for %s")
2107 % fname)
2107 % fname)
2108 fstate[0] = fname
2108 fstate[0] = fname
2109 fstate[1] = fnodes.pop(fname, {})
2109 fstate[1] = fnodes.pop(fname, {})
2110
2110
2111 nodelist = prune(filerevlog, fstate[1])
2111 nodelist = prune(filerevlog, fstate[1])
2112 if nodelist:
2112 if nodelist:
2113 count[0] += 1
2113 count[0] += 1
2114 yield bundler.fileheader(fname)
2114 yield bundler.fileheader(fname)
2115 for chunk in filerevlog.group(nodelist, bundler, reorder):
2115 for chunk in filerevlog.group(nodelist, bundler, reorder):
2116 yield chunk
2116 yield chunk
2117
2117
2118 # Signal that no more groups are left.
2118 # Signal that no more groups are left.
2119 yield bundler.close()
2119 yield bundler.close()
2120 progress(_bundling, None)
2120 progress(_bundling, None)
2121
2121
2122 if csets:
2122 if csets:
2123 self.hook('outgoing', node=hex(csets[0]), source=source)
2123 self.hook('outgoing', node=hex(csets[0]), source=source)
2124
2124
2125 return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
2125 return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
2126
2126
2127 def changegroup(self, basenodes, source):
2127 def changegroup(self, basenodes, source):
2128 # to avoid a race we use changegroupsubset() (issue1320)
2128 # to avoid a race we use changegroupsubset() (issue1320)
2129 return self.changegroupsubset(basenodes, self.heads(), source)
2129 return self.changegroupsubset(basenodes, self.heads(), source)
2130
2130
2131 @unfilteredmethod
2131 @unfilteredmethod
2132 def _changegroup(self, nodes, source):
2132 def _changegroup(self, nodes, source):
2133 """Compute the changegroup of all nodes that we have that a recipient
2133 """Compute the changegroup of all nodes that we have that a recipient
2134 doesn't. Return a chunkbuffer object whose read() method will return
2134 doesn't. Return a chunkbuffer object whose read() method will return
2135 successive changegroup chunks.
2135 successive changegroup chunks.
2136
2136
2137 This is much easier than the previous function as we can assume that
2137 This is much easier than the previous function as we can assume that
2138 the recipient has any changenode we aren't sending them.
2138 the recipient has any changenode we aren't sending them.
2139
2139
2140 nodes is the set of nodes to send"""
2140 nodes is the set of nodes to send"""
2141
2141
2142 cl = self.changelog
2142 cl = self.changelog
2143 mf = self.manifest
2143 mf = self.manifest
2144 mfs = {}
2144 mfs = {}
2145 changedfiles = set()
2145 changedfiles = set()
2146 fstate = ['']
2146 fstate = ['']
2147 count = [0, 0]
2147 count = [0, 0]
2148
2148
2149 self.hook('preoutgoing', throw=True, source=source)
2149 self.hook('preoutgoing', throw=True, source=source)
2150 self.changegroupinfo(nodes, source)
2150 self.changegroupinfo(nodes, source)
2151
2151
2152 revset = set([cl.rev(n) for n in nodes])
2152 revset = set([cl.rev(n) for n in nodes])
2153
2153
2154 def gennodelst(log):
2154 def gennodelst(log):
2155 ln, llr = log.node, log.linkrev
2155 ln, llr = log.node, log.linkrev
2156 return [ln(r) for r in log if llr(r) in revset]
2156 return [ln(r) for r in log if llr(r) in revset]
2157
2157
2158 progress = self.ui.progress
2158 progress = self.ui.progress
2159 _bundling = _('bundling')
2159 _bundling = _('bundling')
2160 _changesets = _('changesets')
2160 _changesets = _('changesets')
2161 _manifests = _('manifests')
2161 _manifests = _('manifests')
2162 _files = _('files')
2162 _files = _('files')
2163
2163
2164 def lookup(revlog, x):
2164 def lookup(revlog, x):
2165 if revlog == cl:
2165 if revlog == cl:
2166 c = cl.read(x)
2166 c = cl.read(x)
2167 changedfiles.update(c[3])
2167 changedfiles.update(c[3])
2168 mfs.setdefault(c[0], x)
2168 mfs.setdefault(c[0], x)
2169 count[0] += 1
2169 count[0] += 1
2170 progress(_bundling, count[0],
2170 progress(_bundling, count[0],
2171 unit=_changesets, total=count[1])
2171 unit=_changesets, total=count[1])
2172 return x
2172 return x
2173 elif revlog == mf:
2173 elif revlog == mf:
2174 count[0] += 1
2174 count[0] += 1
2175 progress(_bundling, count[0],
2175 progress(_bundling, count[0],
2176 unit=_manifests, total=count[1])
2176 unit=_manifests, total=count[1])
2177 return cl.node(revlog.linkrev(revlog.rev(x)))
2177 return cl.node(revlog.linkrev(revlog.rev(x)))
2178 else:
2178 else:
2179 progress(_bundling, count[0], item=fstate[0],
2179 progress(_bundling, count[0], item=fstate[0],
2180 total=count[1], unit=_files)
2180 total=count[1], unit=_files)
2181 return cl.node(revlog.linkrev(revlog.rev(x)))
2181 return cl.node(revlog.linkrev(revlog.rev(x)))
2182
2182
2183 bundler = changegroup.bundle10(lookup)
2183 bundler = changegroup.bundle10(lookup)
2184 reorder = self.ui.config('bundle', 'reorder', 'auto')
2184 reorder = self.ui.config('bundle', 'reorder', 'auto')
2185 if reorder == 'auto':
2185 if reorder == 'auto':
2186 reorder = None
2186 reorder = None
2187 else:
2187 else:
2188 reorder = util.parsebool(reorder)
2188 reorder = util.parsebool(reorder)
2189
2189
2190 def gengroup():
2190 def gengroup():
2191 '''yield a sequence of changegroup chunks (strings)'''
2191 '''yield a sequence of changegroup chunks (strings)'''
2192 # construct a list of all changed files
2192 # construct a list of all changed files
2193
2193
2194 count[:] = [0, len(nodes)]
2194 count[:] = [0, len(nodes)]
2195 for chunk in cl.group(nodes, bundler, reorder=reorder):
2195 for chunk in cl.group(nodes, bundler, reorder=reorder):
2196 yield chunk
2196 yield chunk
2197 progress(_bundling, None)
2197 progress(_bundling, None)
2198
2198
2199 count[:] = [0, len(mfs)]
2199 count[:] = [0, len(mfs)]
2200 for chunk in mf.group(gennodelst(mf), bundler, reorder=reorder):
2200 for chunk in mf.group(gennodelst(mf), bundler, reorder=reorder):
2201 yield chunk
2201 yield chunk
2202 progress(_bundling, None)
2202 progress(_bundling, None)
2203
2203
2204 count[:] = [0, len(changedfiles)]
2204 count[:] = [0, len(changedfiles)]
2205 for fname in sorted(changedfiles):
2205 for fname in sorted(changedfiles):
2206 filerevlog = self.file(fname)
2206 filerevlog = self.file(fname)
2207 if not len(filerevlog):
2207 if not len(filerevlog):
2208 raise util.Abort(_("empty or missing revlog for %s")
2208 raise util.Abort(_("empty or missing revlog for %s")
2209 % fname)
2209 % fname)
2210 fstate[0] = fname
2210 fstate[0] = fname
2211 nodelist = gennodelst(filerevlog)
2211 nodelist = gennodelst(filerevlog)
2212 if nodelist:
2212 if nodelist:
2213 count[0] += 1
2213 count[0] += 1
2214 yield bundler.fileheader(fname)
2214 yield bundler.fileheader(fname)
2215 for chunk in filerevlog.group(nodelist, bundler, reorder):
2215 for chunk in filerevlog.group(nodelist, bundler, reorder):
2216 yield chunk
2216 yield chunk
2217 yield bundler.close()
2217 yield bundler.close()
2218 progress(_bundling, None)
2218 progress(_bundling, None)
2219
2219
2220 if nodes:
2220 if nodes:
2221 self.hook('outgoing', node=hex(nodes[0]), source=source)
2221 self.hook('outgoing', node=hex(nodes[0]), source=source)
2222
2222
2223 return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
2223 return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
2224
2224
2225 @unfilteredmethod
2225 @unfilteredmethod
2226 def addchangegroup(self, source, srctype, url, emptyok=False):
2226 def addchangegroup(self, source, srctype, url, emptyok=False):
2227 """Add the changegroup returned by source.read() to this repo.
2227 """Add the changegroup returned by source.read() to this repo.
2228 srctype is a string like 'push', 'pull', or 'unbundle'. url is
2228 srctype is a string like 'push', 'pull', or 'unbundle'. url is
2229 the URL of the repo where this changegroup is coming from.
2229 the URL of the repo where this changegroup is coming from.
2230
2230
2231 Return an integer summarizing the change to this repo:
2231 Return an integer summarizing the change to this repo:
2232 - nothing changed or no source: 0
2232 - nothing changed or no source: 0
2233 - more heads than before: 1+added heads (2..n)
2233 - more heads than before: 1+added heads (2..n)
2234 - fewer heads than before: -1-removed heads (-2..-n)
2234 - fewer heads than before: -1-removed heads (-2..-n)
2235 - number of heads stays the same: 1
2235 - number of heads stays the same: 1
2236 """
2236 """
2237 def csmap(x):
2237 def csmap(x):
2238 self.ui.debug("add changeset %s\n" % short(x))
2238 self.ui.debug("add changeset %s\n" % short(x))
2239 return len(cl)
2239 return len(cl)
2240
2240
2241 def revmap(x):
2241 def revmap(x):
2242 return cl.rev(x)
2242 return cl.rev(x)
2243
2243
2244 if not source:
2244 if not source:
2245 return 0
2245 return 0
2246
2246
2247 self.hook('prechangegroup', throw=True, source=srctype, url=url)
2247 self.hook('prechangegroup', throw=True, source=srctype, url=url)
2248
2248
2249 changesets = files = revisions = 0
2249 changesets = files = revisions = 0
2250 efiles = set()
2250 efiles = set()
2251
2251
2252 # write changelog data to temp files so concurrent readers will not see
2252 # write changelog data to temp files so concurrent readers will not see
2253 # inconsistent view
2253 # inconsistent view
2254 cl = self.changelog
2254 cl = self.changelog
2255 cl.delayupdate()
2255 cl.delayupdate()
2256 oldheads = cl.heads()
2256 oldheads = cl.heads()
2257
2257
2258 tr = self.transaction("\n".join([srctype, util.hidepassword(url)]))
2258 tr = self.transaction("\n".join([srctype, util.hidepassword(url)]))
2259 try:
2259 try:
2260 trp = weakref.proxy(tr)
2260 trp = weakref.proxy(tr)
2261 # pull off the changeset group
2261 # pull off the changeset group
2262 self.ui.status(_("adding changesets\n"))
2262 self.ui.status(_("adding changesets\n"))
2263 clstart = len(cl)
2263 clstart = len(cl)
2264 class prog(object):
2264 class prog(object):
2265 step = _('changesets')
2265 step = _('changesets')
2266 count = 1
2266 count = 1
2267 ui = self.ui
2267 ui = self.ui
2268 total = None
2268 total = None
2269 def __call__(self):
2269 def __call__(self):
2270 self.ui.progress(self.step, self.count, unit=_('chunks'),
2270 self.ui.progress(self.step, self.count, unit=_('chunks'),
2271 total=self.total)
2271 total=self.total)
2272 self.count += 1
2272 self.count += 1
2273 pr = prog()
2273 pr = prog()
2274 source.callback = pr
2274 source.callback = pr
2275
2275
2276 source.changelogheader()
2276 source.changelogheader()
2277 srccontent = cl.addgroup(source, csmap, trp)
2277 srccontent = cl.addgroup(source, csmap, trp)
2278 if not (srccontent or emptyok):
2278 if not (srccontent or emptyok):
2279 raise util.Abort(_("received changelog group is empty"))
2279 raise util.Abort(_("received changelog group is empty"))
2280 clend = len(cl)
2280 clend = len(cl)
2281 changesets = clend - clstart
2281 changesets = clend - clstart
2282 for c in xrange(clstart, clend):
2282 for c in xrange(clstart, clend):
2283 efiles.update(self[c].files())
2283 efiles.update(self[c].files())
2284 efiles = len(efiles)
2284 efiles = len(efiles)
2285 self.ui.progress(_('changesets'), None)
2285 self.ui.progress(_('changesets'), None)
2286
2286
2287 # pull off the manifest group
2287 # pull off the manifest group
2288 self.ui.status(_("adding manifests\n"))
2288 self.ui.status(_("adding manifests\n"))
2289 pr.step = _('manifests')
2289 pr.step = _('manifests')
2290 pr.count = 1
2290 pr.count = 1
2291 pr.total = changesets # manifests <= changesets
2291 pr.total = changesets # manifests <= changesets
2292 # no need to check for empty manifest group here:
2292 # no need to check for empty manifest group here:
2293 # if the result of the merge of 1 and 2 is the same in 3 and 4,
2293 # if the result of the merge of 1 and 2 is the same in 3 and 4,
2294 # no new manifest will be created and the manifest group will
2294 # no new manifest will be created and the manifest group will
2295 # be empty during the pull
2295 # be empty during the pull
2296 source.manifestheader()
2296 source.manifestheader()
2297 self.manifest.addgroup(source, revmap, trp)
2297 self.manifest.addgroup(source, revmap, trp)
2298 self.ui.progress(_('manifests'), None)
2298 self.ui.progress(_('manifests'), None)
2299
2299
2300 needfiles = {}
2300 needfiles = {}
2301 if self.ui.configbool('server', 'validate', default=False):
2301 if self.ui.configbool('server', 'validate', default=False):
2302 # validate incoming csets have their manifests
2302 # validate incoming csets have their manifests
2303 for cset in xrange(clstart, clend):
2303 for cset in xrange(clstart, clend):
2304 mfest = self.changelog.read(self.changelog.node(cset))[0]
2304 mfest = self.changelog.read(self.changelog.node(cset))[0]
2305 mfest = self.manifest.readdelta(mfest)
2305 mfest = self.manifest.readdelta(mfest)
2306 # store file nodes we must see
2306 # store file nodes we must see
2307 for f, n in mfest.iteritems():
2307 for f, n in mfest.iteritems():
2308 needfiles.setdefault(f, set()).add(n)
2308 needfiles.setdefault(f, set()).add(n)
2309
2309
2310 # process the files
2310 # process the files
2311 self.ui.status(_("adding file changes\n"))
2311 self.ui.status(_("adding file changes\n"))
2312 pr.step = _('files')
2312 pr.step = _('files')
2313 pr.count = 1
2313 pr.count = 1
2314 pr.total = efiles
2314 pr.total = efiles
2315 source.callback = None
2315 source.callback = None
2316
2316
2317 while True:
2317 while True:
2318 chunkdata = source.filelogheader()
2318 chunkdata = source.filelogheader()
2319 if not chunkdata:
2319 if not chunkdata:
2320 break
2320 break
2321 f = chunkdata["filename"]
2321 f = chunkdata["filename"]
2322 self.ui.debug("adding %s revisions\n" % f)
2322 self.ui.debug("adding %s revisions\n" % f)
2323 pr()
2323 pr()
2324 fl = self.file(f)
2324 fl = self.file(f)
2325 o = len(fl)
2325 o = len(fl)
2326 if not fl.addgroup(source, revmap, trp):
2326 if not fl.addgroup(source, revmap, trp):
2327 raise util.Abort(_("received file revlog group is empty"))
2327 raise util.Abort(_("received file revlog group is empty"))
2328 revisions += len(fl) - o
2328 revisions += len(fl) - o
2329 files += 1
2329 files += 1
2330 if f in needfiles:
2330 if f in needfiles:
2331 needs = needfiles[f]
2331 needs = needfiles[f]
2332 for new in xrange(o, len(fl)):
2332 for new in xrange(o, len(fl)):
2333 n = fl.node(new)
2333 n = fl.node(new)
2334 if n in needs:
2334 if n in needs:
2335 needs.remove(n)
2335 needs.remove(n)
2336 if not needs:
2336 if not needs:
2337 del needfiles[f]
2337 del needfiles[f]
2338 self.ui.progress(_('files'), None)
2338 self.ui.progress(_('files'), None)
2339
2339
2340 for f, needs in needfiles.iteritems():
2340 for f, needs in needfiles.iteritems():
2341 fl = self.file(f)
2341 fl = self.file(f)
2342 for n in needs:
2342 for n in needs:
2343 try:
2343 try:
2344 fl.rev(n)
2344 fl.rev(n)
2345 except error.LookupError:
2345 except error.LookupError:
2346 raise util.Abort(
2346 raise util.Abort(
2347 _('missing file data for %s:%s - run hg verify') %
2347 _('missing file data for %s:%s - run hg verify') %
2348 (f, hex(n)))
2348 (f, hex(n)))
2349
2349
2350 dh = 0
2350 dh = 0
2351 if oldheads:
2351 if oldheads:
2352 heads = cl.heads()
2352 heads = cl.heads()
2353 dh = len(heads) - len(oldheads)
2353 dh = len(heads) - len(oldheads)
2354 for h in heads:
2354 for h in heads:
2355 if h not in oldheads and self[h].closesbranch():
2355 if h not in oldheads and self[h].closesbranch():
2356 dh -= 1
2356 dh -= 1
2357 htext = ""
2357 htext = ""
2358 if dh:
2358 if dh:
2359 htext = _(" (%+d heads)") % dh
2359 htext = _(" (%+d heads)") % dh
2360
2360
2361 self.ui.status(_("added %d changesets"
2361 self.ui.status(_("added %d changesets"
2362 " with %d changes to %d files%s\n")
2362 " with %d changes to %d files%s\n")
2363 % (changesets, revisions, files, htext))
2363 % (changesets, revisions, files, htext))
2364 self.invalidatevolatilesets()
2364 self.invalidatevolatilesets()
2365
2365
2366 if changesets > 0:
2366 if changesets > 0:
2367 p = lambda: cl.writepending() and self.root or ""
2367 p = lambda: cl.writepending() and self.root or ""
2368 self.hook('pretxnchangegroup', throw=True,
2368 self.hook('pretxnchangegroup', throw=True,
2369 node=hex(cl.node(clstart)), source=srctype,
2369 node=hex(cl.node(clstart)), source=srctype,
2370 url=url, pending=p)
2370 url=url, pending=p)
2371
2371
2372 added = [cl.node(r) for r in xrange(clstart, clend)]
2372 added = [cl.node(r) for r in xrange(clstart, clend)]
2373 publishing = self.ui.configbool('phases', 'publish', True)
2373 publishing = self.ui.configbool('phases', 'publish', True)
2374 if srctype == 'push':
2374 if srctype == 'push':
2375 # Old server can not push the boundary themself.
2375 # Old server can not push the boundary themself.
2376 # New server won't push the boundary if changeset already
2376 # New server won't push the boundary if changeset already
2377 # existed locally as secrete
2377 # existed locally as secrete
2378 #
2378 #
2379 # We should not use added here but the list of all change in
2379 # We should not use added here but the list of all change in
2380 # the bundle
2380 # the bundle
2381 if publishing:
2381 if publishing:
2382 phases.advanceboundary(self, phases.public, srccontent)
2382 phases.advanceboundary(self, phases.public, srccontent)
2383 else:
2383 else:
2384 phases.advanceboundary(self, phases.draft, srccontent)
2384 phases.advanceboundary(self, phases.draft, srccontent)
2385 phases.retractboundary(self, phases.draft, added)
2385 phases.retractboundary(self, phases.draft, added)
2386 elif srctype != 'strip':
2386 elif srctype != 'strip':
2387 # publishing only alter behavior during push
2387 # publishing only alter behavior during push
2388 #
2388 #
2389 # strip should not touch boundary at all
2389 # strip should not touch boundary at all
2390 phases.retractboundary(self, phases.draft, added)
2390 phases.retractboundary(self, phases.draft, added)
2391
2391
2392 # make changelog see real files again
2392 # make changelog see real files again
2393 cl.finalize(trp)
2393 cl.finalize(trp)
2394
2394
2395 tr.close()
2395 tr.close()
2396
2396
2397 if changesets > 0:
2397 if changesets > 0:
2398 branchmap.updatecache(self)
2398 if srctype != 'strip':
2399 # During strip, branchcache is invalid but coming call to
2400 # `destroyed` will repair it.
2401 # In other case we can safely update cache on disk.
2402 branchmap.updatecache(self)
2399 def runhooks():
2403 def runhooks():
2400 # forcefully update the on-disk branch cache
2404 # forcefully update the on-disk branch cache
2401 self.ui.debug("updating the branch cache\n")
2405 self.ui.debug("updating the branch cache\n")
2402 self.hook("changegroup", node=hex(cl.node(clstart)),
2406 self.hook("changegroup", node=hex(cl.node(clstart)),
2403 source=srctype, url=url)
2407 source=srctype, url=url)
2404
2408
2405 for n in added:
2409 for n in added:
2406 self.hook("incoming", node=hex(n), source=srctype,
2410 self.hook("incoming", node=hex(n), source=srctype,
2407 url=url)
2411 url=url)
2408 self._afterlock(runhooks)
2412 self._afterlock(runhooks)
2409
2413
2410 finally:
2414 finally:
2411 tr.release()
2415 tr.release()
2412 # never return 0 here:
2416 # never return 0 here:
2413 if dh < 0:
2417 if dh < 0:
2414 return dh - 1
2418 return dh - 1
2415 else:
2419 else:
2416 return dh + 1
2420 return dh + 1
2417
2421
2418 def stream_in(self, remote, requirements):
2422 def stream_in(self, remote, requirements):
2419 lock = self.lock()
2423 lock = self.lock()
2420 try:
2424 try:
2421 # Save remote branchmap. We will use it later
2425 # Save remote branchmap. We will use it later
2422 # to speed up branchcache creation
2426 # to speed up branchcache creation
2423 rbranchmap = None
2427 rbranchmap = None
2424 if remote.capable("branchmap"):
2428 if remote.capable("branchmap"):
2425 rbranchmap = remote.branchmap()
2429 rbranchmap = remote.branchmap()
2426
2430
2427 fp = remote.stream_out()
2431 fp = remote.stream_out()
2428 l = fp.readline()
2432 l = fp.readline()
2429 try:
2433 try:
2430 resp = int(l)
2434 resp = int(l)
2431 except ValueError:
2435 except ValueError:
2432 raise error.ResponseError(
2436 raise error.ResponseError(
2433 _('unexpected response from remote server:'), l)
2437 _('unexpected response from remote server:'), l)
2434 if resp == 1:
2438 if resp == 1:
2435 raise util.Abort(_('operation forbidden by server'))
2439 raise util.Abort(_('operation forbidden by server'))
2436 elif resp == 2:
2440 elif resp == 2:
2437 raise util.Abort(_('locking the remote repository failed'))
2441 raise util.Abort(_('locking the remote repository failed'))
2438 elif resp != 0:
2442 elif resp != 0:
2439 raise util.Abort(_('the server sent an unknown error code'))
2443 raise util.Abort(_('the server sent an unknown error code'))
2440 self.ui.status(_('streaming all changes\n'))
2444 self.ui.status(_('streaming all changes\n'))
2441 l = fp.readline()
2445 l = fp.readline()
2442 try:
2446 try:
2443 total_files, total_bytes = map(int, l.split(' ', 1))
2447 total_files, total_bytes = map(int, l.split(' ', 1))
2444 except (ValueError, TypeError):
2448 except (ValueError, TypeError):
2445 raise error.ResponseError(
2449 raise error.ResponseError(
2446 _('unexpected response from remote server:'), l)
2450 _('unexpected response from remote server:'), l)
2447 self.ui.status(_('%d files to transfer, %s of data\n') %
2451 self.ui.status(_('%d files to transfer, %s of data\n') %
2448 (total_files, util.bytecount(total_bytes)))
2452 (total_files, util.bytecount(total_bytes)))
2449 handled_bytes = 0
2453 handled_bytes = 0
2450 self.ui.progress(_('clone'), 0, total=total_bytes)
2454 self.ui.progress(_('clone'), 0, total=total_bytes)
2451 start = time.time()
2455 start = time.time()
2452 for i in xrange(total_files):
2456 for i in xrange(total_files):
2453 # XXX doesn't support '\n' or '\r' in filenames
2457 # XXX doesn't support '\n' or '\r' in filenames
2454 l = fp.readline()
2458 l = fp.readline()
2455 try:
2459 try:
2456 name, size = l.split('\0', 1)
2460 name, size = l.split('\0', 1)
2457 size = int(size)
2461 size = int(size)
2458 except (ValueError, TypeError):
2462 except (ValueError, TypeError):
2459 raise error.ResponseError(
2463 raise error.ResponseError(
2460 _('unexpected response from remote server:'), l)
2464 _('unexpected response from remote server:'), l)
2461 if self.ui.debugflag:
2465 if self.ui.debugflag:
2462 self.ui.debug('adding %s (%s)\n' %
2466 self.ui.debug('adding %s (%s)\n' %
2463 (name, util.bytecount(size)))
2467 (name, util.bytecount(size)))
2464 # for backwards compat, name was partially encoded
2468 # for backwards compat, name was partially encoded
2465 ofp = self.sopener(store.decodedir(name), 'w')
2469 ofp = self.sopener(store.decodedir(name), 'w')
2466 for chunk in util.filechunkiter(fp, limit=size):
2470 for chunk in util.filechunkiter(fp, limit=size):
2467 handled_bytes += len(chunk)
2471 handled_bytes += len(chunk)
2468 self.ui.progress(_('clone'), handled_bytes,
2472 self.ui.progress(_('clone'), handled_bytes,
2469 total=total_bytes)
2473 total=total_bytes)
2470 ofp.write(chunk)
2474 ofp.write(chunk)
2471 ofp.close()
2475 ofp.close()
2472 elapsed = time.time() - start
2476 elapsed = time.time() - start
2473 if elapsed <= 0:
2477 if elapsed <= 0:
2474 elapsed = 0.001
2478 elapsed = 0.001
2475 self.ui.progress(_('clone'), None)
2479 self.ui.progress(_('clone'), None)
2476 self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
2480 self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
2477 (util.bytecount(total_bytes), elapsed,
2481 (util.bytecount(total_bytes), elapsed,
2478 util.bytecount(total_bytes / elapsed)))
2482 util.bytecount(total_bytes / elapsed)))
2479
2483
2480 # new requirements = old non-format requirements +
2484 # new requirements = old non-format requirements +
2481 # new format-related
2485 # new format-related
2482 # requirements from the streamed-in repository
2486 # requirements from the streamed-in repository
2483 requirements.update(set(self.requirements) - self.supportedformats)
2487 requirements.update(set(self.requirements) - self.supportedformats)
2484 self._applyrequirements(requirements)
2488 self._applyrequirements(requirements)
2485 self._writerequirements()
2489 self._writerequirements()
2486
2490
2487 if rbranchmap:
2491 if rbranchmap:
2488 rbheads = []
2492 rbheads = []
2489 for bheads in rbranchmap.itervalues():
2493 for bheads in rbranchmap.itervalues():
2490 rbheads.extend(bheads)
2494 rbheads.extend(bheads)
2491
2495
2492 if rbheads:
2496 if rbheads:
2493 rtiprev = max((int(self.changelog.rev(node))
2497 rtiprev = max((int(self.changelog.rev(node))
2494 for node in rbheads))
2498 for node in rbheads))
2495 cache = branchmap.branchcache(rbranchmap,
2499 cache = branchmap.branchcache(rbranchmap,
2496 self[rtiprev].node(),
2500 self[rtiprev].node(),
2497 rtiprev)
2501 rtiprev)
2498 self._branchcache = cache
2502 self._branchcache = cache
2499 cache.write(self)
2503 cache.write(self)
2500 self.invalidate()
2504 self.invalidate()
2501 return len(self.heads()) + 1
2505 return len(self.heads()) + 1
2502 finally:
2506 finally:
2503 lock.release()
2507 lock.release()
2504
2508
2505 def clone(self, remote, heads=[], stream=False):
2509 def clone(self, remote, heads=[], stream=False):
2506 '''clone remote repository.
2510 '''clone remote repository.
2507
2511
2508 keyword arguments:
2512 keyword arguments:
2509 heads: list of revs to clone (forces use of pull)
2513 heads: list of revs to clone (forces use of pull)
2510 stream: use streaming clone if possible'''
2514 stream: use streaming clone if possible'''
2511
2515
2512 # now, all clients that can request uncompressed clones can
2516 # now, all clients that can request uncompressed clones can
2513 # read repo formats supported by all servers that can serve
2517 # read repo formats supported by all servers that can serve
2514 # them.
2518 # them.
2515
2519
2516 # if revlog format changes, client will have to check version
2520 # if revlog format changes, client will have to check version
2517 # and format flags on "stream" capability, and use
2521 # and format flags on "stream" capability, and use
2518 # uncompressed only if compatible.
2522 # uncompressed only if compatible.
2519
2523
2520 if not stream:
2524 if not stream:
2521 # if the server explicitly prefers to stream (for fast LANs)
2525 # if the server explicitly prefers to stream (for fast LANs)
2522 stream = remote.capable('stream-preferred')
2526 stream = remote.capable('stream-preferred')
2523
2527
2524 if stream and not heads:
2528 if stream and not heads:
2525 # 'stream' means remote revlog format is revlogv1 only
2529 # 'stream' means remote revlog format is revlogv1 only
2526 if remote.capable('stream'):
2530 if remote.capable('stream'):
2527 return self.stream_in(remote, set(('revlogv1',)))
2531 return self.stream_in(remote, set(('revlogv1',)))
2528 # otherwise, 'streamreqs' contains the remote revlog format
2532 # otherwise, 'streamreqs' contains the remote revlog format
2529 streamreqs = remote.capable('streamreqs')
2533 streamreqs = remote.capable('streamreqs')
2530 if streamreqs:
2534 if streamreqs:
2531 streamreqs = set(streamreqs.split(','))
2535 streamreqs = set(streamreqs.split(','))
2532 # if we support it, stream in and adjust our requirements
2536 # if we support it, stream in and adjust our requirements
2533 if not streamreqs - self.supportedformats:
2537 if not streamreqs - self.supportedformats:
2534 return self.stream_in(remote, streamreqs)
2538 return self.stream_in(remote, streamreqs)
2535 return self.pull(remote, heads)
2539 return self.pull(remote, heads)
2536
2540
2537 def pushkey(self, namespace, key, old, new):
2541 def pushkey(self, namespace, key, old, new):
2538 self.hook('prepushkey', throw=True, namespace=namespace, key=key,
2542 self.hook('prepushkey', throw=True, namespace=namespace, key=key,
2539 old=old, new=new)
2543 old=old, new=new)
2540 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2544 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
2541 ret = pushkey.push(self, namespace, key, old, new)
2545 ret = pushkey.push(self, namespace, key, old, new)
2542 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2546 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
2543 ret=ret)
2547 ret=ret)
2544 return ret
2548 return ret
2545
2549
2546 def listkeys(self, namespace):
2550 def listkeys(self, namespace):
2547 self.hook('prelistkeys', throw=True, namespace=namespace)
2551 self.hook('prelistkeys', throw=True, namespace=namespace)
2548 self.ui.debug('listing keys for "%s"\n' % namespace)
2552 self.ui.debug('listing keys for "%s"\n' % namespace)
2549 values = pushkey.list(self, namespace)
2553 values = pushkey.list(self, namespace)
2550 self.hook('listkeys', namespace=namespace, values=values)
2554 self.hook('listkeys', namespace=namespace, values=values)
2551 return values
2555 return values
2552
2556
2553 def debugwireargs(self, one, two, three=None, four=None, five=None):
2557 def debugwireargs(self, one, two, three=None, four=None, five=None):
2554 '''used to test argument passing over the wire'''
2558 '''used to test argument passing over the wire'''
2555 return "%s %s %s %s %s" % (one, two, three, four, five)
2559 return "%s %s %s %s %s" % (one, two, three, four, five)
2556
2560
2557 def savecommitmessage(self, text):
2561 def savecommitmessage(self, text):
2558 fp = self.opener('last-message.txt', 'wb')
2562 fp = self.opener('last-message.txt', 'wb')
2559 try:
2563 try:
2560 fp.write(text)
2564 fp.write(text)
2561 finally:
2565 finally:
2562 fp.close()
2566 fp.close()
2563 return self.pathto(fp.name[len(self.root) + 1:])
2567 return self.pathto(fp.name[len(self.root) + 1:])
2564
2568
2565 # used to avoid circular references so destructors work
2569 # used to avoid circular references so destructors work
2566 def aftertrans(files):
2570 def aftertrans(files):
2567 renamefiles = [tuple(t) for t in files]
2571 renamefiles = [tuple(t) for t in files]
2568 def a():
2572 def a():
2569 for src, dest in renamefiles:
2573 for src, dest in renamefiles:
2570 try:
2574 try:
2571 util.rename(src, dest)
2575 util.rename(src, dest)
2572 except OSError: # journal file does not yet exist
2576 except OSError: # journal file does not yet exist
2573 pass
2577 pass
2574 return a
2578 return a
2575
2579
2576 def undoname(fn):
2580 def undoname(fn):
2577 base, name = os.path.split(fn)
2581 base, name = os.path.split(fn)
2578 assert name.startswith('journal')
2582 assert name.startswith('journal')
2579 return os.path.join(base, name.replace('journal', 'undo', 1))
2583 return os.path.join(base, name.replace('journal', 'undo', 1))
2580
2584
2581 def instance(ui, path, create):
2585 def instance(ui, path, create):
2582 return localrepository(ui, util.urllocalpath(path), create)
2586 return localrepository(ui, util.urllocalpath(path), create)
2583
2587
2584 def islocal(path):
2588 def islocal(path):
2585 return True
2589 return True
@@ -1,1140 +1,1139 b''
1 $ cat <<EOF >> $HGRCPATH
1 $ cat <<EOF >> $HGRCPATH
2 > [extensions]
2 > [extensions]
3 > keyword =
3 > keyword =
4 > mq =
4 > mq =
5 > notify =
5 > notify =
6 > record =
6 > record =
7 > transplant =
7 > transplant =
8 > [ui]
8 > [ui]
9 > interactive = true
9 > interactive = true
10 > EOF
10 > EOF
11
11
12 hide outer repo
12 hide outer repo
13 $ hg init
13 $ hg init
14
14
15 Run kwdemo before [keyword] files are set up
15 Run kwdemo before [keyword] files are set up
16 as it would succeed without uisetup otherwise
16 as it would succeed without uisetup otherwise
17
17
18 $ hg --quiet kwdemo
18 $ hg --quiet kwdemo
19 [extensions]
19 [extensions]
20 keyword =
20 keyword =
21 [keyword]
21 [keyword]
22 demo.txt =
22 demo.txt =
23 [keywordset]
23 [keywordset]
24 svn = False
24 svn = False
25 [keywordmaps]
25 [keywordmaps]
26 Author = {author|user}
26 Author = {author|user}
27 Date = {date|utcdate}
27 Date = {date|utcdate}
28 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
28 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
29 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
29 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
30 RCSFile = {file|basename},v
30 RCSFile = {file|basename},v
31 RCSfile = {file|basename},v
31 RCSfile = {file|basename},v
32 Revision = {node|short}
32 Revision = {node|short}
33 Source = {root}/{file},v
33 Source = {root}/{file},v
34 $Author: test $
34 $Author: test $
35 $Date: ????/??/?? ??:??:?? $ (glob)
35 $Date: ????/??/?? ??:??:?? $ (glob)
36 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
36 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
37 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
37 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
38 $RCSFile: demo.txt,v $
38 $RCSFile: demo.txt,v $
39 $RCSfile: demo.txt,v $
39 $RCSfile: demo.txt,v $
40 $Revision: ???????????? $ (glob)
40 $Revision: ???????????? $ (glob)
41 $Source: */demo.txt,v $ (glob)
41 $Source: */demo.txt,v $ (glob)
42
42
43 $ hg --quiet kwdemo "Branch = {branches}"
43 $ hg --quiet kwdemo "Branch = {branches}"
44 [extensions]
44 [extensions]
45 keyword =
45 keyword =
46 [keyword]
46 [keyword]
47 demo.txt =
47 demo.txt =
48 [keywordset]
48 [keywordset]
49 svn = False
49 svn = False
50 [keywordmaps]
50 [keywordmaps]
51 Branch = {branches}
51 Branch = {branches}
52 $Branch: demobranch $
52 $Branch: demobranch $
53
53
54 $ cat <<EOF >> $HGRCPATH
54 $ cat <<EOF >> $HGRCPATH
55 > [keyword]
55 > [keyword]
56 > ** =
56 > ** =
57 > b = ignore
57 > b = ignore
58 > i = ignore
58 > i = ignore
59 > [hooks]
59 > [hooks]
60 > EOF
60 > EOF
61 $ cp $HGRCPATH $HGRCPATH.nohooks
61 $ cp $HGRCPATH $HGRCPATH.nohooks
62 > cat <<EOF >> $HGRCPATH
62 > cat <<EOF >> $HGRCPATH
63 > commit=
63 > commit=
64 > commit.test=cp a hooktest
64 > commit.test=cp a hooktest
65 > EOF
65 > EOF
66
66
67 $ hg init Test-bndl
67 $ hg init Test-bndl
68 $ cd Test-bndl
68 $ cd Test-bndl
69
69
70 kwshrink should exit silently in empty/invalid repo
70 kwshrink should exit silently in empty/invalid repo
71
71
72 $ hg kwshrink
72 $ hg kwshrink
73
73
74 Symlinks cannot be created on Windows.
74 Symlinks cannot be created on Windows.
75 A bundle to test this was made with:
75 A bundle to test this was made with:
76 hg init t
76 hg init t
77 cd t
77 cd t
78 echo a > a
78 echo a > a
79 ln -s a sym
79 ln -s a sym
80 hg add sym
80 hg add sym
81 hg ci -m addsym -u mercurial
81 hg ci -m addsym -u mercurial
82 hg bundle --base null ../test-keyword.hg
82 hg bundle --base null ../test-keyword.hg
83
83
84 $ hg pull -u "$TESTDIR"/bundles/test-keyword.hg
84 $ hg pull -u "$TESTDIR"/bundles/test-keyword.hg
85 pulling from *test-keyword.hg (glob)
85 pulling from *test-keyword.hg (glob)
86 requesting all changes
86 requesting all changes
87 adding changesets
87 adding changesets
88 adding manifests
88 adding manifests
89 adding file changes
89 adding file changes
90 added 1 changesets with 1 changes to 1 files
90 added 1 changesets with 1 changes to 1 files
91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
92
92
93 $ echo 'expand $Id$' > a
93 $ echo 'expand $Id$' > a
94 $ echo 'do not process $Id:' >> a
94 $ echo 'do not process $Id:' >> a
95 $ echo 'xxx $' >> a
95 $ echo 'xxx $' >> a
96 $ echo 'ignore $Id$' > b
96 $ echo 'ignore $Id$' > b
97
97
98 Output files as they were created
98 Output files as they were created
99
99
100 $ cat a b
100 $ cat a b
101 expand $Id$
101 expand $Id$
102 do not process $Id:
102 do not process $Id:
103 xxx $
103 xxx $
104 ignore $Id$
104 ignore $Id$
105
105
106 no kwfiles
106 no kwfiles
107
107
108 $ hg kwfiles
108 $ hg kwfiles
109
109
110 untracked candidates
110 untracked candidates
111
111
112 $ hg -v kwfiles --unknown
112 $ hg -v kwfiles --unknown
113 k a
113 k a
114
114
115 Add files and check status
115 Add files and check status
116
116
117 $ hg addremove
117 $ hg addremove
118 adding a
118 adding a
119 adding b
119 adding b
120 $ hg status
120 $ hg status
121 A a
121 A a
122 A b
122 A b
123
123
124
124
125 Default keyword expansion including commit hook
125 Default keyword expansion including commit hook
126 Interrupted commit should not change state or run commit hook
126 Interrupted commit should not change state or run commit hook
127
127
128 $ hg --debug commit
128 $ hg --debug commit
129 abort: empty commit message
129 abort: empty commit message
130 [255]
130 [255]
131 $ hg status
131 $ hg status
132 A a
132 A a
133 A b
133 A b
134
134
135 Commit with several checks
135 Commit with several checks
136
136
137 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
137 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
138 a
138 a
139 b
139 b
140 overwriting a expanding keywords
140 overwriting a expanding keywords
141 running hook commit.test: cp a hooktest
141 running hook commit.test: cp a hooktest
142 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
142 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
143 $ hg status
143 $ hg status
144 ? hooktest
144 ? hooktest
145 $ hg debugrebuildstate
145 $ hg debugrebuildstate
146 $ hg --quiet identify
146 $ hg --quiet identify
147 ef63ca68695b
147 ef63ca68695b
148
148
149 cat files in working directory with keywords expanded
149 cat files in working directory with keywords expanded
150
150
151 $ cat a b
151 $ cat a b
152 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
152 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
153 do not process $Id:
153 do not process $Id:
154 xxx $
154 xxx $
155 ignore $Id$
155 ignore $Id$
156
156
157 hg cat files and symlink, no expansion
157 hg cat files and symlink, no expansion
158
158
159 $ hg cat sym a b && echo
159 $ hg cat sym a b && echo
160 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
160 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
161 do not process $Id:
161 do not process $Id:
162 xxx $
162 xxx $
163 ignore $Id$
163 ignore $Id$
164 a
164 a
165
165
166 $ diff a hooktest
166 $ diff a hooktest
167
167
168 $ cp $HGRCPATH.nohooks $HGRCPATH
168 $ cp $HGRCPATH.nohooks $HGRCPATH
169 $ rm hooktest
169 $ rm hooktest
170
170
171 hg status of kw-ignored binary file starting with '\1\n'
171 hg status of kw-ignored binary file starting with '\1\n'
172
172
173 >>> open("i", "wb").write("\1\nfoo")
173 >>> open("i", "wb").write("\1\nfoo")
174 $ hg -q commit -Am metasep i
174 $ hg -q commit -Am metasep i
175 $ hg status
175 $ hg status
176 >>> open("i", "wb").write("\1\nbar")
176 >>> open("i", "wb").write("\1\nbar")
177 $ hg status
177 $ hg status
178 M i
178 M i
179 $ hg -q commit -m "modify metasep" i
179 $ hg -q commit -m "modify metasep" i
180 $ hg status --rev 2:3
180 $ hg status --rev 2:3
181 M i
181 M i
182 $ touch empty
182 $ touch empty
183 $ hg -q commit -A -m "another file"
183 $ hg -q commit -A -m "another file"
184 $ hg status -A --rev 3:4 i
184 $ hg status -A --rev 3:4 i
185 C i
185 C i
186
186
187 $ hg -q strip -n 2
187 $ hg -q strip -n 2
188
188
189 Test hook execution
189 Test hook execution
190
190
191 bundle
191 bundle
192
192
193 $ hg bundle --base null ../kw.hg
193 $ hg bundle --base null ../kw.hg
194 2 changesets found
194 2 changesets found
195 $ cd ..
195 $ cd ..
196 $ hg init Test
196 $ hg init Test
197 $ cd Test
197 $ cd Test
198
198
199 Notify on pull to check whether keywords stay as is in email
199 Notify on pull to check whether keywords stay as is in email
200 ie. if patch.diff wrapper acts as it should
200 ie. if patch.diff wrapper acts as it should
201
201
202 $ cat <<EOF >> $HGRCPATH
202 $ cat <<EOF >> $HGRCPATH
203 > [hooks]
203 > [hooks]
204 > incoming.notify = python:hgext.notify.hook
204 > incoming.notify = python:hgext.notify.hook
205 > [notify]
205 > [notify]
206 > sources = pull
206 > sources = pull
207 > diffstat = False
207 > diffstat = False
208 > maxsubject = 15
208 > maxsubject = 15
209 > [reposubs]
209 > [reposubs]
210 > * = Test
210 > * = Test
211 > EOF
211 > EOF
212
212
213 Pull from bundle and trigger notify
213 Pull from bundle and trigger notify
214
214
215 $ hg pull -u ../kw.hg
215 $ hg pull -u ../kw.hg
216 pulling from ../kw.hg
216 pulling from ../kw.hg
217 requesting all changes
217 requesting all changes
218 adding changesets
218 adding changesets
219 adding manifests
219 adding manifests
220 adding file changes
220 adding file changes
221 added 2 changesets with 3 changes to 3 files
221 added 2 changesets with 3 changes to 3 files
222 Content-Type: text/plain; charset="us-ascii"
222 Content-Type: text/plain; charset="us-ascii"
223 MIME-Version: 1.0
223 MIME-Version: 1.0
224 Content-Transfer-Encoding: 7bit
224 Content-Transfer-Encoding: 7bit
225 Date: * (glob)
225 Date: * (glob)
226 Subject: changeset in...
226 Subject: changeset in...
227 From: mercurial
227 From: mercurial
228 X-Hg-Notification: changeset a2392c293916
228 X-Hg-Notification: changeset a2392c293916
229 Message-Id: <hg.a2392c293916*> (glob)
229 Message-Id: <hg.a2392c293916*> (glob)
230 To: Test
230 To: Test
231
231
232 changeset a2392c293916 in $TESTTMP/Test (glob)
232 changeset a2392c293916 in $TESTTMP/Test (glob)
233 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
233 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
234 description:
234 description:
235 addsym
235 addsym
236
236
237 diffs (6 lines):
237 diffs (6 lines):
238
238
239 diff -r 000000000000 -r a2392c293916 sym
239 diff -r 000000000000 -r a2392c293916 sym
240 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
240 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
241 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
241 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
242 @@ -0,0 +1,1 @@
242 @@ -0,0 +1,1 @@
243 +a
243 +a
244 \ No newline at end of file
244 \ No newline at end of file
245 Content-Type: text/plain; charset="us-ascii"
245 Content-Type: text/plain; charset="us-ascii"
246 MIME-Version: 1.0
246 MIME-Version: 1.0
247 Content-Transfer-Encoding: 7bit
247 Content-Transfer-Encoding: 7bit
248 Date:* (glob)
248 Date:* (glob)
249 Subject: changeset in...
249 Subject: changeset in...
250 From: User Name <user@example.com>
250 From: User Name <user@example.com>
251 X-Hg-Notification: changeset ef63ca68695b
251 X-Hg-Notification: changeset ef63ca68695b
252 Message-Id: <hg.ef63ca68695b*> (glob)
252 Message-Id: <hg.ef63ca68695b*> (glob)
253 To: Test
253 To: Test
254
254
255 changeset ef63ca68695b in $TESTTMP/Test (glob)
255 changeset ef63ca68695b in $TESTTMP/Test (glob)
256 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
256 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
257 description:
257 description:
258 absym
258 absym
259
259
260 diffs (12 lines):
260 diffs (12 lines):
261
261
262 diff -r a2392c293916 -r ef63ca68695b a
262 diff -r a2392c293916 -r ef63ca68695b a
263 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
263 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
264 +++ b/a Thu Jan 01 00:00:00 1970 +0000
264 +++ b/a Thu Jan 01 00:00:00 1970 +0000
265 @@ -0,0 +1,3 @@
265 @@ -0,0 +1,3 @@
266 +expand $Id$
266 +expand $Id$
267 +do not process $Id:
267 +do not process $Id:
268 +xxx $
268 +xxx $
269 diff -r a2392c293916 -r ef63ca68695b b
269 diff -r a2392c293916 -r ef63ca68695b b
270 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
270 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
271 +++ b/b Thu Jan 01 00:00:00 1970 +0000
271 +++ b/b Thu Jan 01 00:00:00 1970 +0000
272 @@ -0,0 +1,1 @@
272 @@ -0,0 +1,1 @@
273 +ignore $Id$
273 +ignore $Id$
274 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
274 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
275
275
276 $ cp $HGRCPATH.nohooks $HGRCPATH
276 $ cp $HGRCPATH.nohooks $HGRCPATH
277
277
278 Touch files and check with status
278 Touch files and check with status
279
279
280 $ touch a b
280 $ touch a b
281 $ hg status
281 $ hg status
282
282
283 Update and expand
283 Update and expand
284
284
285 $ rm sym a b
285 $ rm sym a b
286 $ hg update -C
286 $ hg update -C
287 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
287 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 $ cat a b
288 $ cat a b
289 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
289 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
290 do not process $Id:
290 do not process $Id:
291 xxx $
291 xxx $
292 ignore $Id$
292 ignore $Id$
293
293
294 Check whether expansion is filewise and file mode is preserved
294 Check whether expansion is filewise and file mode is preserved
295
295
296 $ echo '$Id$' > c
296 $ echo '$Id$' > c
297 $ echo 'tests for different changenodes' >> c
297 $ echo 'tests for different changenodes' >> c
298 #if unix-permissions
298 #if unix-permissions
299 $ chmod 600 c
299 $ chmod 600 c
300 $ ls -l c | cut -b 1-10
300 $ ls -l c | cut -b 1-10
301 -rw-------
301 -rw-------
302 #endif
302 #endif
303
303
304 commit file c
304 commit file c
305
305
306 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
306 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
307 adding c
307 adding c
308 #if unix-permissions
308 #if unix-permissions
309 $ ls -l c | cut -b 1-10
309 $ ls -l c | cut -b 1-10
310 -rw-------
310 -rw-------
311 #endif
311 #endif
312
312
313 force expansion
313 force expansion
314
314
315 $ hg -v kwexpand
315 $ hg -v kwexpand
316 overwriting a expanding keywords
316 overwriting a expanding keywords
317 overwriting c expanding keywords
317 overwriting c expanding keywords
318
318
319 compare changenodes in a and c
319 compare changenodes in a and c
320
320
321 $ cat a c
321 $ cat a c
322 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
322 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
323 do not process $Id:
323 do not process $Id:
324 xxx $
324 xxx $
325 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
325 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
326 tests for different changenodes
326 tests for different changenodes
327
327
328 record
328 record
329
329
330 $ echo '$Id$' > r
330 $ echo '$Id$' > r
331 $ hg add r
331 $ hg add r
332
332
333 record chunk
333 record chunk
334
334
335 >>> lines = open('a', 'rb').readlines()
335 >>> lines = open('a', 'rb').readlines()
336 >>> lines.insert(1, 'foo\n')
336 >>> lines.insert(1, 'foo\n')
337 >>> lines.append('bar\n')
337 >>> lines.append('bar\n')
338 >>> open('a', 'wb').writelines(lines)
338 >>> open('a', 'wb').writelines(lines)
339 $ hg record -d '10 1' -m rectest a<<EOF
339 $ hg record -d '10 1' -m rectest a<<EOF
340 > y
340 > y
341 > y
341 > y
342 > n
342 > n
343 > EOF
343 > EOF
344 diff --git a/a b/a
344 diff --git a/a b/a
345 2 hunks, 2 lines changed
345 2 hunks, 2 lines changed
346 examine changes to 'a'? [Ynesfdaq?]
346 examine changes to 'a'? [Ynesfdaq?]
347 @@ -1,3 +1,4 @@
347 @@ -1,3 +1,4 @@
348 expand $Id$
348 expand $Id$
349 +foo
349 +foo
350 do not process $Id:
350 do not process $Id:
351 xxx $
351 xxx $
352 record change 1/2 to 'a'? [Ynesfdaq?]
352 record change 1/2 to 'a'? [Ynesfdaq?]
353 @@ -2,2 +3,3 @@
353 @@ -2,2 +3,3 @@
354 do not process $Id:
354 do not process $Id:
355 xxx $
355 xxx $
356 +bar
356 +bar
357 record change 2/2 to 'a'? [Ynesfdaq?]
357 record change 2/2 to 'a'? [Ynesfdaq?]
358
358
359 $ hg identify
359 $ hg identify
360 5f5eb23505c3+ tip
360 5f5eb23505c3+ tip
361 $ hg status
361 $ hg status
362 M a
362 M a
363 A r
363 A r
364
364
365 Cat modified file a
365 Cat modified file a
366
366
367 $ cat a
367 $ cat a
368 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
368 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
369 foo
369 foo
370 do not process $Id:
370 do not process $Id:
371 xxx $
371 xxx $
372 bar
372 bar
373
373
374 Diff remaining chunk
374 Diff remaining chunk
375
375
376 $ hg diff a
376 $ hg diff a
377 diff -r 5f5eb23505c3 a
377 diff -r 5f5eb23505c3 a
378 --- a/a Thu Jan 01 00:00:09 1970 -0000
378 --- a/a Thu Jan 01 00:00:09 1970 -0000
379 +++ b/a * (glob)
379 +++ b/a * (glob)
380 @@ -2,3 +2,4 @@
380 @@ -2,3 +2,4 @@
381 foo
381 foo
382 do not process $Id:
382 do not process $Id:
383 xxx $
383 xxx $
384 +bar
384 +bar
385
385
386 $ hg rollback
386 $ hg rollback
387 repository tip rolled back to revision 2 (undo commit)
387 repository tip rolled back to revision 2 (undo commit)
388 working directory now based on revision 2
388 working directory now based on revision 2
389
389
390 Record all chunks in file a
390 Record all chunks in file a
391
391
392 $ echo foo > msg
392 $ echo foo > msg
393
393
394 - do not use "hg record -m" here!
394 - do not use "hg record -m" here!
395
395
396 $ hg record -l msg -d '11 1' a<<EOF
396 $ hg record -l msg -d '11 1' a<<EOF
397 > y
397 > y
398 > y
398 > y
399 > y
399 > y
400 > EOF
400 > EOF
401 diff --git a/a b/a
401 diff --git a/a b/a
402 2 hunks, 2 lines changed
402 2 hunks, 2 lines changed
403 examine changes to 'a'? [Ynesfdaq?]
403 examine changes to 'a'? [Ynesfdaq?]
404 @@ -1,3 +1,4 @@
404 @@ -1,3 +1,4 @@
405 expand $Id$
405 expand $Id$
406 +foo
406 +foo
407 do not process $Id:
407 do not process $Id:
408 xxx $
408 xxx $
409 record change 1/2 to 'a'? [Ynesfdaq?]
409 record change 1/2 to 'a'? [Ynesfdaq?]
410 @@ -2,2 +3,3 @@
410 @@ -2,2 +3,3 @@
411 do not process $Id:
411 do not process $Id:
412 xxx $
412 xxx $
413 +bar
413 +bar
414 record change 2/2 to 'a'? [Ynesfdaq?]
414 record change 2/2 to 'a'? [Ynesfdaq?]
415
415
416 File a should be clean
416 File a should be clean
417
417
418 $ hg status -A a
418 $ hg status -A a
419 C a
419 C a
420
420
421 rollback and revert expansion
421 rollback and revert expansion
422
422
423 $ cat a
423 $ cat a
424 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
424 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
425 foo
425 foo
426 do not process $Id:
426 do not process $Id:
427 xxx $
427 xxx $
428 bar
428 bar
429 $ hg --verbose rollback
429 $ hg --verbose rollback
430 repository tip rolled back to revision 2 (undo commit)
430 repository tip rolled back to revision 2 (undo commit)
431 working directory now based on revision 2
431 working directory now based on revision 2
432 overwriting a expanding keywords
432 overwriting a expanding keywords
433 $ hg status a
433 $ hg status a
434 M a
434 M a
435 $ cat a
435 $ cat a
436 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
436 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
437 foo
437 foo
438 do not process $Id:
438 do not process $Id:
439 xxx $
439 xxx $
440 bar
440 bar
441 $ echo '$Id$' > y
441 $ echo '$Id$' > y
442 $ echo '$Id$' > z
442 $ echo '$Id$' > z
443 $ hg add y
443 $ hg add y
444 $ hg commit -Am "rollback only" z
444 $ hg commit -Am "rollback only" z
445 $ cat z
445 $ cat z
446 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
446 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
447 $ hg --verbose rollback
447 $ hg --verbose rollback
448 repository tip rolled back to revision 2 (undo commit)
448 repository tip rolled back to revision 2 (undo commit)
449 working directory now based on revision 2
449 working directory now based on revision 2
450 overwriting z shrinking keywords
450 overwriting z shrinking keywords
451
451
452 Only z should be overwritten
452 Only z should be overwritten
453
453
454 $ hg status a y z
454 $ hg status a y z
455 M a
455 M a
456 A y
456 A y
457 A z
457 A z
458 $ cat z
458 $ cat z
459 $Id$
459 $Id$
460 $ hg forget y z
460 $ hg forget y z
461 $ rm y z
461 $ rm y z
462
462
463 record added file alone
463 record added file alone
464
464
465 $ hg -v record -l msg -d '12 2' r<<EOF
465 $ hg -v record -l msg -d '12 2' r<<EOF
466 > y
466 > y
467 > EOF
467 > EOF
468 diff --git a/r b/r
468 diff --git a/r b/r
469 new file mode 100644
469 new file mode 100644
470 examine changes to 'r'? [Ynesfdaq?]
470 examine changes to 'r'? [Ynesfdaq?]
471 r
471 r
472 committed changeset 3:82a2f715724d
472 committed changeset 3:82a2f715724d
473 overwriting r expanding keywords
473 overwriting r expanding keywords
474 - status call required for dirstate.normallookup() check
474 - status call required for dirstate.normallookup() check
475 $ hg status r
475 $ hg status r
476 $ hg --verbose rollback
476 $ hg --verbose rollback
477 repository tip rolled back to revision 2 (undo commit)
477 repository tip rolled back to revision 2 (undo commit)
478 working directory now based on revision 2
478 working directory now based on revision 2
479 overwriting r shrinking keywords
479 overwriting r shrinking keywords
480 $ hg forget r
480 $ hg forget r
481 $ rm msg r
481 $ rm msg r
482 $ hg update -C
482 $ hg update -C
483 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
483 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
484
484
485 record added keyword ignored file
485 record added keyword ignored file
486
486
487 $ echo '$Id$' > i
487 $ echo '$Id$' > i
488 $ hg add i
488 $ hg add i
489 $ hg --verbose record -d '13 1' -m recignored<<EOF
489 $ hg --verbose record -d '13 1' -m recignored<<EOF
490 > y
490 > y
491 > EOF
491 > EOF
492 diff --git a/i b/i
492 diff --git a/i b/i
493 new file mode 100644
493 new file mode 100644
494 examine changes to 'i'? [Ynesfdaq?]
494 examine changes to 'i'? [Ynesfdaq?]
495 i
495 i
496 committed changeset 3:9f40ceb5a072
496 committed changeset 3:9f40ceb5a072
497 $ cat i
497 $ cat i
498 $Id$
498 $Id$
499 $ hg -q rollback
499 $ hg -q rollback
500 $ hg forget i
500 $ hg forget i
501 $ rm i
501 $ rm i
502
502
503 amend
503 amend
504
504
505 $ echo amend >> a
505 $ echo amend >> a
506 $ echo amend >> b
506 $ echo amend >> b
507 $ hg -q commit -d '14 1' -m 'prepare amend'
507 $ hg -q commit -d '14 1' -m 'prepare amend'
508
508
509 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
509 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
510 invalidating branch cache (tip differs)
511 overwriting a expanding keywords
510 overwriting a expanding keywords
512 $ hg -q id
511 $ hg -q id
513 67d8c481a6be
512 67d8c481a6be
514 $ head -1 a
513 $ head -1 a
515 expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $
514 expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $
516
515
517 $ hg -q strip -n tip
516 $ hg -q strip -n tip
518
517
519 Test patch queue repo
518 Test patch queue repo
520
519
521 $ hg init --mq
520 $ hg init --mq
522 $ hg qimport -r tip -n mqtest.diff
521 $ hg qimport -r tip -n mqtest.diff
523 $ hg commit --mq -m mqtest
522 $ hg commit --mq -m mqtest
524
523
525 Keywords should not be expanded in patch
524 Keywords should not be expanded in patch
526
525
527 $ cat .hg/patches/mqtest.diff
526 $ cat .hg/patches/mqtest.diff
528 # HG changeset patch
527 # HG changeset patch
529 # User User Name <user@example.com>
528 # User User Name <user@example.com>
530 # Date 1 0
529 # Date 1 0
531 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
530 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
532 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
531 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
533 cndiff
532 cndiff
534
533
535 diff -r ef63ca68695b -r 40a904bbbe4c c
534 diff -r ef63ca68695b -r 40a904bbbe4c c
536 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
535 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
537 +++ b/c Thu Jan 01 00:00:01 1970 +0000
536 +++ b/c Thu Jan 01 00:00:01 1970 +0000
538 @@ -0,0 +1,2 @@
537 @@ -0,0 +1,2 @@
539 +$Id$
538 +$Id$
540 +tests for different changenodes
539 +tests for different changenodes
541
540
542 $ hg qpop
541 $ hg qpop
543 popping mqtest.diff
542 popping mqtest.diff
544 patch queue now empty
543 patch queue now empty
545
544
546 qgoto, implying qpush, should expand
545 qgoto, implying qpush, should expand
547
546
548 $ hg qgoto mqtest.diff
547 $ hg qgoto mqtest.diff
549 applying mqtest.diff
548 applying mqtest.diff
550 now at: mqtest.diff
549 now at: mqtest.diff
551 $ cat c
550 $ cat c
552 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
551 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
553 tests for different changenodes
552 tests for different changenodes
554 $ hg cat c
553 $ hg cat c
555 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
554 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
556 tests for different changenodes
555 tests for different changenodes
557
556
558 Keywords should not be expanded in filelog
557 Keywords should not be expanded in filelog
559
558
560 $ hg --config 'extensions.keyword=!' cat c
559 $ hg --config 'extensions.keyword=!' cat c
561 $Id$
560 $Id$
562 tests for different changenodes
561 tests for different changenodes
563
562
564 qpop and move on
563 qpop and move on
565
564
566 $ hg qpop
565 $ hg qpop
567 popping mqtest.diff
566 popping mqtest.diff
568 patch queue now empty
567 patch queue now empty
569
568
570 Copy and show added kwfiles
569 Copy and show added kwfiles
571
570
572 $ hg cp a c
571 $ hg cp a c
573 $ hg kwfiles
572 $ hg kwfiles
574 a
573 a
575 c
574 c
576
575
577 Commit and show expansion in original and copy
576 Commit and show expansion in original and copy
578
577
579 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
578 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
580 c
579 c
581 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
580 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
582 removing unknown node 40a904bbbe4c from 1-phase boundary
581 removing unknown node 40a904bbbe4c from 1-phase boundary
583 overwriting c expanding keywords
582 overwriting c expanding keywords
584 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
583 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
585 $ cat a c
584 $ cat a c
586 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
585 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
587 do not process $Id:
586 do not process $Id:
588 xxx $
587 xxx $
589 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
588 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
590 do not process $Id:
589 do not process $Id:
591 xxx $
590 xxx $
592
591
593 Touch copied c and check its status
592 Touch copied c and check its status
594
593
595 $ touch c
594 $ touch c
596 $ hg status
595 $ hg status
597
596
598 Copy kwfile to keyword ignored file unexpanding keywords
597 Copy kwfile to keyword ignored file unexpanding keywords
599
598
600 $ hg --verbose copy a i
599 $ hg --verbose copy a i
601 copying a to i
600 copying a to i
602 overwriting i shrinking keywords
601 overwriting i shrinking keywords
603 $ head -n 1 i
602 $ head -n 1 i
604 expand $Id$
603 expand $Id$
605 $ hg forget i
604 $ hg forget i
606 $ rm i
605 $ rm i
607
606
608 Copy ignored file to ignored file: no overwriting
607 Copy ignored file to ignored file: no overwriting
609
608
610 $ hg --verbose copy b i
609 $ hg --verbose copy b i
611 copying b to i
610 copying b to i
612 $ hg forget i
611 $ hg forget i
613 $ rm i
612 $ rm i
614
613
615 cp symlink file; hg cp -A symlink file (part1)
614 cp symlink file; hg cp -A symlink file (part1)
616 - copied symlink points to kwfile: overwrite
615 - copied symlink points to kwfile: overwrite
617
616
618 #if symlink
617 #if symlink
619 $ cp sym i
618 $ cp sym i
620 $ ls -l i
619 $ ls -l i
621 -rw-r--r--* (glob)
620 -rw-r--r--* (glob)
622 $ head -1 i
621 $ head -1 i
623 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
622 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
624 $ hg copy --after --verbose sym i
623 $ hg copy --after --verbose sym i
625 copying sym to i
624 copying sym to i
626 overwriting i shrinking keywords
625 overwriting i shrinking keywords
627 $ head -1 i
626 $ head -1 i
628 expand $Id$
627 expand $Id$
629 $ hg forget i
628 $ hg forget i
630 $ rm i
629 $ rm i
631 #endif
630 #endif
632
631
633 Test different options of hg kwfiles
632 Test different options of hg kwfiles
634
633
635 $ hg kwfiles
634 $ hg kwfiles
636 a
635 a
637 c
636 c
638 $ hg -v kwfiles --ignore
637 $ hg -v kwfiles --ignore
639 I b
638 I b
640 I sym
639 I sym
641 $ hg kwfiles --all
640 $ hg kwfiles --all
642 K a
641 K a
643 K c
642 K c
644 I b
643 I b
645 I sym
644 I sym
646
645
647 Diff specific revision
646 Diff specific revision
648
647
649 $ hg diff --rev 1
648 $ hg diff --rev 1
650 diff -r ef63ca68695b c
649 diff -r ef63ca68695b c
651 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
650 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
652 +++ b/c * (glob)
651 +++ b/c * (glob)
653 @@ -0,0 +1,3 @@
652 @@ -0,0 +1,3 @@
654 +expand $Id$
653 +expand $Id$
655 +do not process $Id:
654 +do not process $Id:
656 +xxx $
655 +xxx $
657
656
658 Status after rollback:
657 Status after rollback:
659
658
660 $ hg rollback
659 $ hg rollback
661 repository tip rolled back to revision 1 (undo commit)
660 repository tip rolled back to revision 1 (undo commit)
662 working directory now based on revision 1
661 working directory now based on revision 1
663 $ hg status
662 $ hg status
664 A c
663 A c
665 $ hg update --clean
664 $ hg update --clean
666 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
665 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
667
666
668 #if symlink
667 #if symlink
669
668
670 cp symlink file; hg cp -A symlink file (part2)
669 cp symlink file; hg cp -A symlink file (part2)
671 - copied symlink points to kw ignored file: do not overwrite
670 - copied symlink points to kw ignored file: do not overwrite
672
671
673 $ cat a > i
672 $ cat a > i
674 $ ln -s i symignored
673 $ ln -s i symignored
675 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
674 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
676 $ cp symignored x
675 $ cp symignored x
677 $ hg copy --after --verbose symignored x
676 $ hg copy --after --verbose symignored x
678 copying symignored to x
677 copying symignored to x
679 $ head -n 1 x
678 $ head -n 1 x
680 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
679 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
681 $ hg forget x
680 $ hg forget x
682 $ rm x
681 $ rm x
683
682
684 $ hg rollback
683 $ hg rollback
685 repository tip rolled back to revision 1 (undo commit)
684 repository tip rolled back to revision 1 (undo commit)
686 working directory now based on revision 1
685 working directory now based on revision 1
687 $ hg update --clean
686 $ hg update --clean
688 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
687 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
689 $ rm i symignored
688 $ rm i symignored
690
689
691 #endif
690 #endif
692
691
693 Custom keywordmaps as argument to kwdemo
692 Custom keywordmaps as argument to kwdemo
694
693
695 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
694 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
696 [extensions]
695 [extensions]
697 keyword =
696 keyword =
698 [keyword]
697 [keyword]
699 ** =
698 ** =
700 b = ignore
699 b = ignore
701 demo.txt =
700 demo.txt =
702 i = ignore
701 i = ignore
703 [keywordset]
702 [keywordset]
704 svn = False
703 svn = False
705 [keywordmaps]
704 [keywordmaps]
706 Xinfo = {author}: {desc}
705 Xinfo = {author}: {desc}
707 $Xinfo: test: hg keyword configuration and expansion example $
706 $Xinfo: test: hg keyword configuration and expansion example $
708
707
709 Configure custom keywordmaps
708 Configure custom keywordmaps
710
709
711 $ cat <<EOF >>$HGRCPATH
710 $ cat <<EOF >>$HGRCPATH
712 > [keywordmaps]
711 > [keywordmaps]
713 > Id = {file} {node|short} {date|rfc822date} {author|user}
712 > Id = {file} {node|short} {date|rfc822date} {author|user}
714 > Xinfo = {author}: {desc}
713 > Xinfo = {author}: {desc}
715 > EOF
714 > EOF
716
715
717 Cat and hg cat files before custom expansion
716 Cat and hg cat files before custom expansion
718
717
719 $ cat a b
718 $ cat a b
720 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
719 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
721 do not process $Id:
720 do not process $Id:
722 xxx $
721 xxx $
723 ignore $Id$
722 ignore $Id$
724 $ hg cat sym a b && echo
723 $ hg cat sym a b && echo
725 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
724 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
726 do not process $Id:
725 do not process $Id:
727 xxx $
726 xxx $
728 ignore $Id$
727 ignore $Id$
729 a
728 a
730
729
731 Write custom keyword and prepare multi-line commit message
730 Write custom keyword and prepare multi-line commit message
732
731
733 $ echo '$Xinfo$' >> a
732 $ echo '$Xinfo$' >> a
734 $ cat <<EOF >> log
733 $ cat <<EOF >> log
735 > firstline
734 > firstline
736 > secondline
735 > secondline
737 > EOF
736 > EOF
738
737
739 Interrupted commit should not change state
738 Interrupted commit should not change state
740
739
741 $ hg commit
740 $ hg commit
742 abort: empty commit message
741 abort: empty commit message
743 [255]
742 [255]
744 $ hg status
743 $ hg status
745 M a
744 M a
746 ? c
745 ? c
747 ? log
746 ? log
748
747
749 Commit with multi-line message and custom expansion
748 Commit with multi-line message and custom expansion
750
749
751 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
750 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
752 a
751 a
753 removing unknown node 40a904bbbe4c from 1-phase boundary
752 removing unknown node 40a904bbbe4c from 1-phase boundary
754 overwriting a expanding keywords
753 overwriting a expanding keywords
755 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
754 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
756 $ rm log
755 $ rm log
757
756
758 Stat, verify and show custom expansion (firstline)
757 Stat, verify and show custom expansion (firstline)
759
758
760 $ hg status
759 $ hg status
761 ? c
760 ? c
762 $ hg verify
761 $ hg verify
763 checking changesets
762 checking changesets
764 checking manifests
763 checking manifests
765 crosschecking files in changesets and manifests
764 crosschecking files in changesets and manifests
766 checking files
765 checking files
767 3 files, 3 changesets, 4 total revisions
766 3 files, 3 changesets, 4 total revisions
768 $ cat a b
767 $ cat a b
769 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
768 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
770 do not process $Id:
769 do not process $Id:
771 xxx $
770 xxx $
772 $Xinfo: User Name <user@example.com>: firstline $
771 $Xinfo: User Name <user@example.com>: firstline $
773 ignore $Id$
772 ignore $Id$
774 $ hg cat sym a b && echo
773 $ hg cat sym a b && echo
775 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
774 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
776 do not process $Id:
775 do not process $Id:
777 xxx $
776 xxx $
778 $Xinfo: User Name <user@example.com>: firstline $
777 $Xinfo: User Name <user@example.com>: firstline $
779 ignore $Id$
778 ignore $Id$
780 a
779 a
781
780
782 annotate
781 annotate
783
782
784 $ hg annotate a
783 $ hg annotate a
785 1: expand $Id$
784 1: expand $Id$
786 1: do not process $Id:
785 1: do not process $Id:
787 1: xxx $
786 1: xxx $
788 2: $Xinfo$
787 2: $Xinfo$
789
788
790 remove with status checks
789 remove with status checks
791
790
792 $ hg debugrebuildstate
791 $ hg debugrebuildstate
793 $ hg remove a
792 $ hg remove a
794 $ hg --debug commit -m rma
793 $ hg --debug commit -m rma
795 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
794 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
796 $ hg status
795 $ hg status
797 ? c
796 ? c
798
797
799 Rollback, revert, and check expansion
798 Rollback, revert, and check expansion
800
799
801 $ hg rollback
800 $ hg rollback
802 repository tip rolled back to revision 2 (undo commit)
801 repository tip rolled back to revision 2 (undo commit)
803 working directory now based on revision 2
802 working directory now based on revision 2
804 $ hg status
803 $ hg status
805 R a
804 R a
806 ? c
805 ? c
807 $ hg revert --no-backup --rev tip a
806 $ hg revert --no-backup --rev tip a
808 $ cat a
807 $ cat a
809 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
808 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
810 do not process $Id:
809 do not process $Id:
811 xxx $
810 xxx $
812 $Xinfo: User Name <user@example.com>: firstline $
811 $Xinfo: User Name <user@example.com>: firstline $
813
812
814 Clone to test global and local configurations
813 Clone to test global and local configurations
815
814
816 $ cd ..
815 $ cd ..
817
816
818 Expansion in destination with global configuration
817 Expansion in destination with global configuration
819
818
820 $ hg --quiet clone Test globalconf
819 $ hg --quiet clone Test globalconf
821 $ cat globalconf/a
820 $ cat globalconf/a
822 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
821 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
823 do not process $Id:
822 do not process $Id:
824 xxx $
823 xxx $
825 $Xinfo: User Name <user@example.com>: firstline $
824 $Xinfo: User Name <user@example.com>: firstline $
826
825
827 No expansion in destination with local configuration in origin only
826 No expansion in destination with local configuration in origin only
828
827
829 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
828 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
830 $ cat localconf/a
829 $ cat localconf/a
831 expand $Id$
830 expand $Id$
832 do not process $Id:
831 do not process $Id:
833 xxx $
832 xxx $
834 $Xinfo$
833 $Xinfo$
835
834
836 Clone to test incoming
835 Clone to test incoming
837
836
838 $ hg clone -r1 Test Test-a
837 $ hg clone -r1 Test Test-a
839 adding changesets
838 adding changesets
840 adding manifests
839 adding manifests
841 adding file changes
840 adding file changes
842 added 2 changesets with 3 changes to 3 files
841 added 2 changesets with 3 changes to 3 files
843 updating to branch default
842 updating to branch default
844 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
843 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
845 $ cd Test-a
844 $ cd Test-a
846 $ cat <<EOF >> .hg/hgrc
845 $ cat <<EOF >> .hg/hgrc
847 > [paths]
846 > [paths]
848 > default = ../Test
847 > default = ../Test
849 > EOF
848 > EOF
850 $ hg incoming
849 $ hg incoming
851 comparing with $TESTTMP/Test (glob)
850 comparing with $TESTTMP/Test (glob)
852 searching for changes
851 searching for changes
853 changeset: 2:bb948857c743
852 changeset: 2:bb948857c743
854 tag: tip
853 tag: tip
855 user: User Name <user@example.com>
854 user: User Name <user@example.com>
856 date: Thu Jan 01 00:00:02 1970 +0000
855 date: Thu Jan 01 00:00:02 1970 +0000
857 summary: firstline
856 summary: firstline
858
857
859 Imported patch should not be rejected
858 Imported patch should not be rejected
860
859
861 >>> import re
860 >>> import re
862 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
861 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
863 >>> open('a', 'wb').write(text)
862 >>> open('a', 'wb').write(text)
864 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
863 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
865 a
864 a
866 overwriting a expanding keywords
865 overwriting a expanding keywords
867 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
866 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
868 $ hg export -o ../rejecttest.diff tip
867 $ hg export -o ../rejecttest.diff tip
869 $ cd ../Test
868 $ cd ../Test
870 $ hg import ../rejecttest.diff
869 $ hg import ../rejecttest.diff
871 applying ../rejecttest.diff
870 applying ../rejecttest.diff
872 $ cat a b
871 $ cat a b
873 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
872 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
874 do not process $Id: rejecttest
873 do not process $Id: rejecttest
875 xxx $
874 xxx $
876 $Xinfo: User Name <user@example.com>: rejects? $
875 $Xinfo: User Name <user@example.com>: rejects? $
877 ignore $Id$
876 ignore $Id$
878
877
879 $ hg rollback
878 $ hg rollback
880 repository tip rolled back to revision 2 (undo import)
879 repository tip rolled back to revision 2 (undo import)
881 working directory now based on revision 2
880 working directory now based on revision 2
882 $ hg update --clean
881 $ hg update --clean
883 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
882 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
884
883
885 kwexpand/kwshrink on selected files
884 kwexpand/kwshrink on selected files
886
885
887 $ mkdir x
886 $ mkdir x
888 $ hg copy a x/a
887 $ hg copy a x/a
889 $ hg --verbose kwshrink a
888 $ hg --verbose kwshrink a
890 overwriting a shrinking keywords
889 overwriting a shrinking keywords
891 - sleep required for dirstate.normal() check
890 - sleep required for dirstate.normal() check
892 $ sleep 1
891 $ sleep 1
893 $ hg status a
892 $ hg status a
894 $ hg --verbose kwexpand a
893 $ hg --verbose kwexpand a
895 overwriting a expanding keywords
894 overwriting a expanding keywords
896 $ hg status a
895 $ hg status a
897
896
898 kwexpand x/a should abort
897 kwexpand x/a should abort
899
898
900 $ hg --verbose kwexpand x/a
899 $ hg --verbose kwexpand x/a
901 abort: outstanding uncommitted changes
900 abort: outstanding uncommitted changes
902 [255]
901 [255]
903 $ cd x
902 $ cd x
904 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
903 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
905 x/a
904 x/a
906 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
905 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
907 overwriting x/a expanding keywords
906 overwriting x/a expanding keywords
908 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
907 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
909 $ cat a
908 $ cat a
910 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
909 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
911 do not process $Id:
910 do not process $Id:
912 xxx $
911 xxx $
913 $Xinfo: User Name <user@example.com>: xa $
912 $Xinfo: User Name <user@example.com>: xa $
914
913
915 kwshrink a inside directory x
914 kwshrink a inside directory x
916
915
917 $ hg --verbose kwshrink a
916 $ hg --verbose kwshrink a
918 overwriting x/a shrinking keywords
917 overwriting x/a shrinking keywords
919 $ cat a
918 $ cat a
920 expand $Id$
919 expand $Id$
921 do not process $Id:
920 do not process $Id:
922 xxx $
921 xxx $
923 $Xinfo$
922 $Xinfo$
924 $ cd ..
923 $ cd ..
925
924
926 kwexpand nonexistent
925 kwexpand nonexistent
927
926
928 $ hg kwexpand nonexistent
927 $ hg kwexpand nonexistent
929 nonexistent:* (glob)
928 nonexistent:* (glob)
930
929
931
930
932 #if serve
931 #if serve
933 hg serve
932 hg serve
934 - expand with hgweb file
933 - expand with hgweb file
935 - no expansion with hgweb annotate/changeset/filediff
934 - no expansion with hgweb annotate/changeset/filediff
936 - check errors
935 - check errors
937
936
938 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
937 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
939 $ cat hg.pid >> $DAEMON_PIDS
938 $ cat hg.pid >> $DAEMON_PIDS
940 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/a/?style=raw'
939 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/a/?style=raw'
941 200 Script output follows
940 200 Script output follows
942
941
943 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
942 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
944 do not process $Id:
943 do not process $Id:
945 xxx $
944 xxx $
946 $Xinfo: User Name <user@example.com>: firstline $
945 $Xinfo: User Name <user@example.com>: firstline $
947 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/a/?style=raw'
946 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/a/?style=raw'
948 200 Script output follows
947 200 Script output follows
949
948
950
949
951 user@1: expand $Id$
950 user@1: expand $Id$
952 user@1: do not process $Id:
951 user@1: do not process $Id:
953 user@1: xxx $
952 user@1: xxx $
954 user@2: $Xinfo$
953 user@2: $Xinfo$
955
954
956
955
957
956
958
957
959 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'rev/tip/?style=raw'
958 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'rev/tip/?style=raw'
960 200 Script output follows
959 200 Script output follows
961
960
962
961
963 # HG changeset patch
962 # HG changeset patch
964 # User User Name <user@example.com>
963 # User User Name <user@example.com>
965 # Date 3 0
964 # Date 3 0
966 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
965 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
967 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
966 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
968 xa
967 xa
969
968
970 diff -r bb948857c743 -r b4560182a3f9 x/a
969 diff -r bb948857c743 -r b4560182a3f9 x/a
971 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
970 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
972 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
971 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
973 @@ -0,0 +1,4 @@
972 @@ -0,0 +1,4 @@
974 +expand $Id$
973 +expand $Id$
975 +do not process $Id:
974 +do not process $Id:
976 +xxx $
975 +xxx $
977 +$Xinfo$
976 +$Xinfo$
978
977
979 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
978 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
980 200 Script output follows
979 200 Script output follows
981
980
982
981
983 diff -r ef63ca68695b -r bb948857c743 a
982 diff -r ef63ca68695b -r bb948857c743 a
984 --- a/a Thu Jan 01 00:00:00 1970 +0000
983 --- a/a Thu Jan 01 00:00:00 1970 +0000
985 +++ b/a Thu Jan 01 00:00:02 1970 +0000
984 +++ b/a Thu Jan 01 00:00:02 1970 +0000
986 @@ -1,3 +1,4 @@
985 @@ -1,3 +1,4 @@
987 expand $Id$
986 expand $Id$
988 do not process $Id:
987 do not process $Id:
989 xxx $
988 xxx $
990 +$Xinfo$
989 +$Xinfo$
991
990
992
991
993
992
994
993
995 $ cat errors.log
994 $ cat errors.log
996 #endif
995 #endif
997
996
998 Prepare merge and resolve tests
997 Prepare merge and resolve tests
999
998
1000 $ echo '$Id$' > m
999 $ echo '$Id$' > m
1001 $ hg add m
1000 $ hg add m
1002 $ hg commit -m 4kw
1001 $ hg commit -m 4kw
1003 $ echo foo >> m
1002 $ echo foo >> m
1004 $ hg commit -m 5foo
1003 $ hg commit -m 5foo
1005
1004
1006 simplemerge
1005 simplemerge
1007
1006
1008 $ hg update 4
1007 $ hg update 4
1009 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1008 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1010 $ echo foo >> m
1009 $ echo foo >> m
1011 $ hg commit -m 6foo
1010 $ hg commit -m 6foo
1012 created new head
1011 created new head
1013 $ hg merge
1012 $ hg merge
1014 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1013 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1015 (branch merge, don't forget to commit)
1014 (branch merge, don't forget to commit)
1016 $ hg commit -m simplemerge
1015 $ hg commit -m simplemerge
1017 $ cat m
1016 $ cat m
1018 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1017 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1019 foo
1018 foo
1020
1019
1021 conflict: keyword should stay outside conflict zone
1020 conflict: keyword should stay outside conflict zone
1022
1021
1023 $ hg update 4
1022 $ hg update 4
1024 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1023 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1025 $ echo bar >> m
1024 $ echo bar >> m
1026 $ hg commit -m 8bar
1025 $ hg commit -m 8bar
1027 created new head
1026 created new head
1028 $ hg merge
1027 $ hg merge
1029 merging m
1028 merging m
1030 warning: conflicts during merge.
1029 warning: conflicts during merge.
1031 merging m incomplete! (edit conflicts, then use 'hg resolve --mark')
1030 merging m incomplete! (edit conflicts, then use 'hg resolve --mark')
1032 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1031 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1033 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1032 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1034 [1]
1033 [1]
1035 $ cat m
1034 $ cat m
1036 $Id$
1035 $Id$
1037 <<<<<<< local
1036 <<<<<<< local
1038 bar
1037 bar
1039 =======
1038 =======
1040 foo
1039 foo
1041 >>>>>>> other
1040 >>>>>>> other
1042
1041
1043 resolve to local
1042 resolve to local
1044
1043
1045 $ HGMERGE=internal:local hg resolve -a
1044 $ HGMERGE=internal:local hg resolve -a
1046 $ hg commit -m localresolve
1045 $ hg commit -m localresolve
1047 $ cat m
1046 $ cat m
1048 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1047 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1049 bar
1048 bar
1050
1049
1051 Test restricted mode with transplant -b
1050 Test restricted mode with transplant -b
1052
1051
1053 $ hg update 6
1052 $ hg update 6
1054 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1053 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1055 $ hg branch foo
1054 $ hg branch foo
1056 marked working directory as branch foo
1055 marked working directory as branch foo
1057 (branches are permanent and global, did you want a bookmark?)
1056 (branches are permanent and global, did you want a bookmark?)
1058 $ mv a a.bak
1057 $ mv a a.bak
1059 $ echo foobranch > a
1058 $ echo foobranch > a
1060 $ cat a.bak >> a
1059 $ cat a.bak >> a
1061 $ rm a.bak
1060 $ rm a.bak
1062 $ hg commit -m 9foobranch
1061 $ hg commit -m 9foobranch
1063 $ hg update default
1062 $ hg update default
1064 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1063 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1065 $ hg -y transplant -b foo tip
1064 $ hg -y transplant -b foo tip
1066 applying 4aa30d025d50
1065 applying 4aa30d025d50
1067 4aa30d025d50 transplanted to e00abbf63521
1066 4aa30d025d50 transplanted to e00abbf63521
1068
1067
1069 Expansion in changeset but not in file
1068 Expansion in changeset but not in file
1070
1069
1071 $ hg tip -p
1070 $ hg tip -p
1072 changeset: 11:e00abbf63521
1071 changeset: 11:e00abbf63521
1073 tag: tip
1072 tag: tip
1074 parent: 9:800511b3a22d
1073 parent: 9:800511b3a22d
1075 user: test
1074 user: test
1076 date: Thu Jan 01 00:00:00 1970 +0000
1075 date: Thu Jan 01 00:00:00 1970 +0000
1077 summary: 9foobranch
1076 summary: 9foobranch
1078
1077
1079 diff -r 800511b3a22d -r e00abbf63521 a
1078 diff -r 800511b3a22d -r e00abbf63521 a
1080 --- a/a Thu Jan 01 00:00:00 1970 +0000
1079 --- a/a Thu Jan 01 00:00:00 1970 +0000
1081 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1080 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1082 @@ -1,3 +1,4 @@
1081 @@ -1,3 +1,4 @@
1083 +foobranch
1082 +foobranch
1084 expand $Id$
1083 expand $Id$
1085 do not process $Id:
1084 do not process $Id:
1086 xxx $
1085 xxx $
1087
1086
1088 $ head -n 2 a
1087 $ head -n 2 a
1089 foobranch
1088 foobranch
1090 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1089 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1091
1090
1092 Turn off expansion
1091 Turn off expansion
1093
1092
1094 $ hg -q rollback
1093 $ hg -q rollback
1095 $ hg -q update -C
1094 $ hg -q update -C
1096
1095
1097 kwshrink with unknown file u
1096 kwshrink with unknown file u
1098
1097
1099 $ cp a u
1098 $ cp a u
1100 $ hg --verbose kwshrink
1099 $ hg --verbose kwshrink
1101 overwriting a shrinking keywords
1100 overwriting a shrinking keywords
1102 overwriting m shrinking keywords
1101 overwriting m shrinking keywords
1103 overwriting x/a shrinking keywords
1102 overwriting x/a shrinking keywords
1104
1103
1105 Keywords shrunk in working directory, but not yet disabled
1104 Keywords shrunk in working directory, but not yet disabled
1106 - cat shows unexpanded keywords
1105 - cat shows unexpanded keywords
1107 - hg cat shows expanded keywords
1106 - hg cat shows expanded keywords
1108
1107
1109 $ cat a b
1108 $ cat a b
1110 expand $Id$
1109 expand $Id$
1111 do not process $Id:
1110 do not process $Id:
1112 xxx $
1111 xxx $
1113 $Xinfo$
1112 $Xinfo$
1114 ignore $Id$
1113 ignore $Id$
1115 $ hg cat sym a b && echo
1114 $ hg cat sym a b && echo
1116 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1115 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1117 do not process $Id:
1116 do not process $Id:
1118 xxx $
1117 xxx $
1119 $Xinfo: User Name <user@example.com>: firstline $
1118 $Xinfo: User Name <user@example.com>: firstline $
1120 ignore $Id$
1119 ignore $Id$
1121 a
1120 a
1122
1121
1123 Now disable keyword expansion
1122 Now disable keyword expansion
1124
1123
1125 $ rm "$HGRCPATH"
1124 $ rm "$HGRCPATH"
1126 $ cat a b
1125 $ cat a b
1127 expand $Id$
1126 expand $Id$
1128 do not process $Id:
1127 do not process $Id:
1129 xxx $
1128 xxx $
1130 $Xinfo$
1129 $Xinfo$
1131 ignore $Id$
1130 ignore $Id$
1132 $ hg cat sym a b && echo
1131 $ hg cat sym a b && echo
1133 expand $Id$
1132 expand $Id$
1134 do not process $Id:
1133 do not process $Id:
1135 xxx $
1134 xxx $
1136 $Xinfo$
1135 $Xinfo$
1137 ignore $Id$
1136 ignore $Id$
1138 a
1137 a
1139
1138
1140 $ cd ..
1139 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now