##// END OF EJS Templates
commit: move editor outside transaction...
Matt Mackall -
r8496:a21605de default
parent child Browse files
Show More
@@ -1,2092 +1,2087 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, incorporated herein by reference.
6 # GNU General Public License version 2, incorporated herein by reference.
7
7
8 from node import bin, hex, nullid, nullrev, short
8 from node import bin, hex, nullid, nullrev, short
9 from i18n import _
9 from i18n import _
10 import repo, changegroup
10 import repo, changegroup
11 import changelog, dirstate, filelog, manifest, context
11 import changelog, dirstate, filelog, manifest, context
12 import lock, transaction, store, encoding
12 import lock, transaction, store, encoding
13 import util, extensions, hook, error
13 import util, extensions, hook, error
14 import match as match_
14 import match as match_
15 import merge as merge_
15 import merge as merge_
16 from lock import release
16 from lock import release
17 import weakref, stat, errno, os, time, inspect
17 import weakref, stat, errno, os, time, inspect
18 propertycache = util.propertycache
18 propertycache = util.propertycache
19
19
20 class localrepository(repo.repository):
20 class localrepository(repo.repository):
21 capabilities = set(('lookup', 'changegroupsubset'))
21 capabilities = set(('lookup', 'changegroupsubset'))
22 supported = set('revlogv1 store fncache'.split())
22 supported = set('revlogv1 store fncache'.split())
23
23
24 def __init__(self, baseui, path=None, create=0):
24 def __init__(self, baseui, path=None, create=0):
25 repo.repository.__init__(self)
25 repo.repository.__init__(self)
26 self.root = os.path.realpath(path)
26 self.root = os.path.realpath(path)
27 self.path = os.path.join(self.root, ".hg")
27 self.path = os.path.join(self.root, ".hg")
28 self.origroot = path
28 self.origroot = path
29 self.opener = util.opener(self.path)
29 self.opener = util.opener(self.path)
30 self.wopener = util.opener(self.root)
30 self.wopener = util.opener(self.root)
31
31
32 if not os.path.isdir(self.path):
32 if not os.path.isdir(self.path):
33 if create:
33 if create:
34 if not os.path.exists(path):
34 if not os.path.exists(path):
35 os.mkdir(path)
35 os.mkdir(path)
36 os.mkdir(self.path)
36 os.mkdir(self.path)
37 requirements = ["revlogv1"]
37 requirements = ["revlogv1"]
38 if baseui.configbool('format', 'usestore', True):
38 if baseui.configbool('format', 'usestore', True):
39 os.mkdir(os.path.join(self.path, "store"))
39 os.mkdir(os.path.join(self.path, "store"))
40 requirements.append("store")
40 requirements.append("store")
41 if baseui.configbool('format', 'usefncache', True):
41 if baseui.configbool('format', 'usefncache', True):
42 requirements.append("fncache")
42 requirements.append("fncache")
43 # create an invalid changelog
43 # create an invalid changelog
44 self.opener("00changelog.i", "a").write(
44 self.opener("00changelog.i", "a").write(
45 '\0\0\0\2' # represents revlogv2
45 '\0\0\0\2' # represents revlogv2
46 ' dummy changelog to prevent using the old repo layout'
46 ' dummy changelog to prevent using the old repo layout'
47 )
47 )
48 reqfile = self.opener("requires", "w")
48 reqfile = self.opener("requires", "w")
49 for r in requirements:
49 for r in requirements:
50 reqfile.write("%s\n" % r)
50 reqfile.write("%s\n" % r)
51 reqfile.close()
51 reqfile.close()
52 else:
52 else:
53 raise error.RepoError(_("repository %s not found") % path)
53 raise error.RepoError(_("repository %s not found") % path)
54 elif create:
54 elif create:
55 raise error.RepoError(_("repository %s already exists") % path)
55 raise error.RepoError(_("repository %s already exists") % path)
56 else:
56 else:
57 # find requirements
57 # find requirements
58 requirements = set()
58 requirements = set()
59 try:
59 try:
60 requirements = set(self.opener("requires").read().splitlines())
60 requirements = set(self.opener("requires").read().splitlines())
61 except IOError, inst:
61 except IOError, inst:
62 if inst.errno != errno.ENOENT:
62 if inst.errno != errno.ENOENT:
63 raise
63 raise
64 for r in requirements - self.supported:
64 for r in requirements - self.supported:
65 raise error.RepoError(_("requirement '%s' not supported") % r)
65 raise error.RepoError(_("requirement '%s' not supported") % r)
66
66
67 self.store = store.store(requirements, self.path, util.opener)
67 self.store = store.store(requirements, self.path, util.opener)
68 self.spath = self.store.path
68 self.spath = self.store.path
69 self.sopener = self.store.opener
69 self.sopener = self.store.opener
70 self.sjoin = self.store.join
70 self.sjoin = self.store.join
71 self.opener.createmode = self.store.createmode
71 self.opener.createmode = self.store.createmode
72
72
73 self.baseui = baseui
73 self.baseui = baseui
74 self.ui = baseui.copy()
74 self.ui = baseui.copy()
75 try:
75 try:
76 self.ui.readconfig(self.join("hgrc"), self.root)
76 self.ui.readconfig(self.join("hgrc"), self.root)
77 extensions.loadall(self.ui)
77 extensions.loadall(self.ui)
78 except IOError:
78 except IOError:
79 pass
79 pass
80
80
81 self.tagscache = None
81 self.tagscache = None
82 self._tagstypecache = None
82 self._tagstypecache = None
83 self.branchcache = None
83 self.branchcache = None
84 self._ubranchcache = None # UTF-8 version of branchcache
84 self._ubranchcache = None # UTF-8 version of branchcache
85 self._branchcachetip = None
85 self._branchcachetip = None
86 self.nodetagscache = None
86 self.nodetagscache = None
87 self.filterpats = {}
87 self.filterpats = {}
88 self._datafilters = {}
88 self._datafilters = {}
89 self._transref = self._lockref = self._wlockref = None
89 self._transref = self._lockref = self._wlockref = None
90
90
91 @propertycache
91 @propertycache
92 def changelog(self):
92 def changelog(self):
93 c = changelog.changelog(self.sopener)
93 c = changelog.changelog(self.sopener)
94 if 'HG_PENDING' in os.environ:
94 if 'HG_PENDING' in os.environ:
95 p = os.environ['HG_PENDING']
95 p = os.environ['HG_PENDING']
96 if p.startswith(self.root):
96 if p.startswith(self.root):
97 c.readpending('00changelog.i.a')
97 c.readpending('00changelog.i.a')
98 self.sopener.defversion = c.version
98 self.sopener.defversion = c.version
99 return c
99 return c
100
100
101 @propertycache
101 @propertycache
102 def manifest(self):
102 def manifest(self):
103 return manifest.manifest(self.sopener)
103 return manifest.manifest(self.sopener)
104
104
105 @propertycache
105 @propertycache
106 def dirstate(self):
106 def dirstate(self):
107 return dirstate.dirstate(self.opener, self.ui, self.root)
107 return dirstate.dirstate(self.opener, self.ui, self.root)
108
108
109 def __getitem__(self, changeid):
109 def __getitem__(self, changeid):
110 if changeid == None:
110 if changeid == None:
111 return context.workingctx(self)
111 return context.workingctx(self)
112 return context.changectx(self, changeid)
112 return context.changectx(self, changeid)
113
113
114 def __nonzero__(self):
114 def __nonzero__(self):
115 return True
115 return True
116
116
117 def __len__(self):
117 def __len__(self):
118 return len(self.changelog)
118 return len(self.changelog)
119
119
120 def __iter__(self):
120 def __iter__(self):
121 for i in xrange(len(self)):
121 for i in xrange(len(self)):
122 yield i
122 yield i
123
123
124 def url(self):
124 def url(self):
125 return 'file:' + self.root
125 return 'file:' + self.root
126
126
127 def hook(self, name, throw=False, **args):
127 def hook(self, name, throw=False, **args):
128 return hook.hook(self.ui, self, name, throw, **args)
128 return hook.hook(self.ui, self, name, throw, **args)
129
129
130 tag_disallowed = ':\r\n'
130 tag_disallowed = ':\r\n'
131
131
132 def _tag(self, names, node, message, local, user, date, extra={}):
132 def _tag(self, names, node, message, local, user, date, extra={}):
133 if isinstance(names, str):
133 if isinstance(names, str):
134 allchars = names
134 allchars = names
135 names = (names,)
135 names = (names,)
136 else:
136 else:
137 allchars = ''.join(names)
137 allchars = ''.join(names)
138 for c in self.tag_disallowed:
138 for c in self.tag_disallowed:
139 if c in allchars:
139 if c in allchars:
140 raise util.Abort(_('%r cannot be used in a tag name') % c)
140 raise util.Abort(_('%r cannot be used in a tag name') % c)
141
141
142 for name in names:
142 for name in names:
143 self.hook('pretag', throw=True, node=hex(node), tag=name,
143 self.hook('pretag', throw=True, node=hex(node), tag=name,
144 local=local)
144 local=local)
145
145
146 def writetags(fp, names, munge, prevtags):
146 def writetags(fp, names, munge, prevtags):
147 fp.seek(0, 2)
147 fp.seek(0, 2)
148 if prevtags and prevtags[-1] != '\n':
148 if prevtags and prevtags[-1] != '\n':
149 fp.write('\n')
149 fp.write('\n')
150 for name in names:
150 for name in names:
151 m = munge and munge(name) or name
151 m = munge and munge(name) or name
152 if self._tagstypecache and name in self._tagstypecache:
152 if self._tagstypecache and name in self._tagstypecache:
153 old = self.tagscache.get(name, nullid)
153 old = self.tagscache.get(name, nullid)
154 fp.write('%s %s\n' % (hex(old), m))
154 fp.write('%s %s\n' % (hex(old), m))
155 fp.write('%s %s\n' % (hex(node), m))
155 fp.write('%s %s\n' % (hex(node), m))
156 fp.close()
156 fp.close()
157
157
158 prevtags = ''
158 prevtags = ''
159 if local:
159 if local:
160 try:
160 try:
161 fp = self.opener('localtags', 'r+')
161 fp = self.opener('localtags', 'r+')
162 except IOError:
162 except IOError:
163 fp = self.opener('localtags', 'a')
163 fp = self.opener('localtags', 'a')
164 else:
164 else:
165 prevtags = fp.read()
165 prevtags = fp.read()
166
166
167 # local tags are stored in the current charset
167 # local tags are stored in the current charset
168 writetags(fp, names, None, prevtags)
168 writetags(fp, names, None, prevtags)
169 for name in names:
169 for name in names:
170 self.hook('tag', node=hex(node), tag=name, local=local)
170 self.hook('tag', node=hex(node), tag=name, local=local)
171 return
171 return
172
172
173 try:
173 try:
174 fp = self.wfile('.hgtags', 'rb+')
174 fp = self.wfile('.hgtags', 'rb+')
175 except IOError:
175 except IOError:
176 fp = self.wfile('.hgtags', 'ab')
176 fp = self.wfile('.hgtags', 'ab')
177 else:
177 else:
178 prevtags = fp.read()
178 prevtags = fp.read()
179
179
180 # committed tags are stored in UTF-8
180 # committed tags are stored in UTF-8
181 writetags(fp, names, encoding.fromlocal, prevtags)
181 writetags(fp, names, encoding.fromlocal, prevtags)
182
182
183 if '.hgtags' not in self.dirstate:
183 if '.hgtags' not in self.dirstate:
184 self.add(['.hgtags'])
184 self.add(['.hgtags'])
185
185
186 tagnode = self.commit(['.hgtags'], message, user, date, extra=extra)
186 tagnode = self.commit(['.hgtags'], message, user, date, extra=extra)
187
187
188 for name in names:
188 for name in names:
189 self.hook('tag', node=hex(node), tag=name, local=local)
189 self.hook('tag', node=hex(node), tag=name, local=local)
190
190
191 return tagnode
191 return tagnode
192
192
193 def tag(self, names, node, message, local, user, date):
193 def tag(self, names, node, message, local, user, date):
194 '''tag a revision with one or more symbolic names.
194 '''tag a revision with one or more symbolic names.
195
195
196 names is a list of strings or, when adding a single tag, names may be a
196 names is a list of strings or, when adding a single tag, names may be a
197 string.
197 string.
198
198
199 if local is True, the tags are stored in a per-repository file.
199 if local is True, the tags are stored in a per-repository file.
200 otherwise, they are stored in the .hgtags file, and a new
200 otherwise, they are stored in the .hgtags file, and a new
201 changeset is committed with the change.
201 changeset is committed with the change.
202
202
203 keyword arguments:
203 keyword arguments:
204
204
205 local: whether to store tags in non-version-controlled file
205 local: whether to store tags in non-version-controlled file
206 (default False)
206 (default False)
207
207
208 message: commit message to use if committing
208 message: commit message to use if committing
209
209
210 user: name of user to use if committing
210 user: name of user to use if committing
211
211
212 date: date tuple to use if committing'''
212 date: date tuple to use if committing'''
213
213
214 for x in self.status()[:5]:
214 for x in self.status()[:5]:
215 if '.hgtags' in x:
215 if '.hgtags' in x:
216 raise util.Abort(_('working copy of .hgtags is changed '
216 raise util.Abort(_('working copy of .hgtags is changed '
217 '(please commit .hgtags manually)'))
217 '(please commit .hgtags manually)'))
218
218
219 self.tags() # instantiate the cache
219 self.tags() # instantiate the cache
220 self._tag(names, node, message, local, user, date)
220 self._tag(names, node, message, local, user, date)
221
221
222 def tags(self):
222 def tags(self):
223 '''return a mapping of tag to node'''
223 '''return a mapping of tag to node'''
224 if self.tagscache:
224 if self.tagscache:
225 return self.tagscache
225 return self.tagscache
226
226
227 globaltags = {}
227 globaltags = {}
228 tagtypes = {}
228 tagtypes = {}
229
229
230 def readtags(lines, fn, tagtype):
230 def readtags(lines, fn, tagtype):
231 filetags = {}
231 filetags = {}
232 count = 0
232 count = 0
233
233
234 def warn(msg):
234 def warn(msg):
235 self.ui.warn(_("%s, line %s: %s\n") % (fn, count, msg))
235 self.ui.warn(_("%s, line %s: %s\n") % (fn, count, msg))
236
236
237 for l in lines:
237 for l in lines:
238 count += 1
238 count += 1
239 if not l:
239 if not l:
240 continue
240 continue
241 s = l.split(" ", 1)
241 s = l.split(" ", 1)
242 if len(s) != 2:
242 if len(s) != 2:
243 warn(_("cannot parse entry"))
243 warn(_("cannot parse entry"))
244 continue
244 continue
245 node, key = s
245 node, key = s
246 key = encoding.tolocal(key.strip()) # stored in UTF-8
246 key = encoding.tolocal(key.strip()) # stored in UTF-8
247 try:
247 try:
248 bin_n = bin(node)
248 bin_n = bin(node)
249 except TypeError:
249 except TypeError:
250 warn(_("node '%s' is not well formed") % node)
250 warn(_("node '%s' is not well formed") % node)
251 continue
251 continue
252 if bin_n not in self.changelog.nodemap:
252 if bin_n not in self.changelog.nodemap:
253 warn(_("tag '%s' refers to unknown node") % key)
253 warn(_("tag '%s' refers to unknown node") % key)
254 continue
254 continue
255
255
256 h = []
256 h = []
257 if key in filetags:
257 if key in filetags:
258 n, h = filetags[key]
258 n, h = filetags[key]
259 h.append(n)
259 h.append(n)
260 filetags[key] = (bin_n, h)
260 filetags[key] = (bin_n, h)
261
261
262 for k, nh in filetags.iteritems():
262 for k, nh in filetags.iteritems():
263 if k not in globaltags:
263 if k not in globaltags:
264 globaltags[k] = nh
264 globaltags[k] = nh
265 tagtypes[k] = tagtype
265 tagtypes[k] = tagtype
266 continue
266 continue
267
267
268 # we prefer the global tag if:
268 # we prefer the global tag if:
269 # it supercedes us OR
269 # it supercedes us OR
270 # mutual supercedes and it has a higher rank
270 # mutual supercedes and it has a higher rank
271 # otherwise we win because we're tip-most
271 # otherwise we win because we're tip-most
272 an, ah = nh
272 an, ah = nh
273 bn, bh = globaltags[k]
273 bn, bh = globaltags[k]
274 if (bn != an and an in bh and
274 if (bn != an and an in bh and
275 (bn not in ah or len(bh) > len(ah))):
275 (bn not in ah or len(bh) > len(ah))):
276 an = bn
276 an = bn
277 ah.extend([n for n in bh if n not in ah])
277 ah.extend([n for n in bh if n not in ah])
278 globaltags[k] = an, ah
278 globaltags[k] = an, ah
279 tagtypes[k] = tagtype
279 tagtypes[k] = tagtype
280
280
281 # read the tags file from each head, ending with the tip
281 # read the tags file from each head, ending with the tip
282 f = None
282 f = None
283 for rev, node, fnode in self._hgtagsnodes():
283 for rev, node, fnode in self._hgtagsnodes():
284 f = (f and f.filectx(fnode) or
284 f = (f and f.filectx(fnode) or
285 self.filectx('.hgtags', fileid=fnode))
285 self.filectx('.hgtags', fileid=fnode))
286 readtags(f.data().splitlines(), f, "global")
286 readtags(f.data().splitlines(), f, "global")
287
287
288 try:
288 try:
289 data = encoding.fromlocal(self.opener("localtags").read())
289 data = encoding.fromlocal(self.opener("localtags").read())
290 # localtags are stored in the local character set
290 # localtags are stored in the local character set
291 # while the internal tag table is stored in UTF-8
291 # while the internal tag table is stored in UTF-8
292 readtags(data.splitlines(), "localtags", "local")
292 readtags(data.splitlines(), "localtags", "local")
293 except IOError:
293 except IOError:
294 pass
294 pass
295
295
296 self.tagscache = {}
296 self.tagscache = {}
297 self._tagstypecache = {}
297 self._tagstypecache = {}
298 for k, nh in globaltags.iteritems():
298 for k, nh in globaltags.iteritems():
299 n = nh[0]
299 n = nh[0]
300 if n != nullid:
300 if n != nullid:
301 self.tagscache[k] = n
301 self.tagscache[k] = n
302 self._tagstypecache[k] = tagtypes[k]
302 self._tagstypecache[k] = tagtypes[k]
303 self.tagscache['tip'] = self.changelog.tip()
303 self.tagscache['tip'] = self.changelog.tip()
304 return self.tagscache
304 return self.tagscache
305
305
306 def tagtype(self, tagname):
306 def tagtype(self, tagname):
307 '''
307 '''
308 return the type of the given tag. result can be:
308 return the type of the given tag. result can be:
309
309
310 'local' : a local tag
310 'local' : a local tag
311 'global' : a global tag
311 'global' : a global tag
312 None : tag does not exist
312 None : tag does not exist
313 '''
313 '''
314
314
315 self.tags()
315 self.tags()
316
316
317 return self._tagstypecache.get(tagname)
317 return self._tagstypecache.get(tagname)
318
318
319 def _hgtagsnodes(self):
319 def _hgtagsnodes(self):
320 last = {}
320 last = {}
321 ret = []
321 ret = []
322 for node in reversed(self.heads()):
322 for node in reversed(self.heads()):
323 c = self[node]
323 c = self[node]
324 rev = c.rev()
324 rev = c.rev()
325 try:
325 try:
326 fnode = c.filenode('.hgtags')
326 fnode = c.filenode('.hgtags')
327 except error.LookupError:
327 except error.LookupError:
328 continue
328 continue
329 ret.append((rev, node, fnode))
329 ret.append((rev, node, fnode))
330 if fnode in last:
330 if fnode in last:
331 ret[last[fnode]] = None
331 ret[last[fnode]] = None
332 last[fnode] = len(ret) - 1
332 last[fnode] = len(ret) - 1
333 return [item for item in ret if item]
333 return [item for item in ret if item]
334
334
335 def tagslist(self):
335 def tagslist(self):
336 '''return a list of tags ordered by revision'''
336 '''return a list of tags ordered by revision'''
337 l = []
337 l = []
338 for t, n in self.tags().iteritems():
338 for t, n in self.tags().iteritems():
339 try:
339 try:
340 r = self.changelog.rev(n)
340 r = self.changelog.rev(n)
341 except:
341 except:
342 r = -2 # sort to the beginning of the list if unknown
342 r = -2 # sort to the beginning of the list if unknown
343 l.append((r, t, n))
343 l.append((r, t, n))
344 return [(t, n) for r, t, n in sorted(l)]
344 return [(t, n) for r, t, n in sorted(l)]
345
345
346 def nodetags(self, node):
346 def nodetags(self, node):
347 '''return the tags associated with a node'''
347 '''return the tags associated with a node'''
348 if not self.nodetagscache:
348 if not self.nodetagscache:
349 self.nodetagscache = {}
349 self.nodetagscache = {}
350 for t, n in self.tags().iteritems():
350 for t, n in self.tags().iteritems():
351 self.nodetagscache.setdefault(n, []).append(t)
351 self.nodetagscache.setdefault(n, []).append(t)
352 return self.nodetagscache.get(node, [])
352 return self.nodetagscache.get(node, [])
353
353
354 def _branchtags(self, partial, lrev):
354 def _branchtags(self, partial, lrev):
355 # TODO: rename this function?
355 # TODO: rename this function?
356 tiprev = len(self) - 1
356 tiprev = len(self) - 1
357 if lrev != tiprev:
357 if lrev != tiprev:
358 self._updatebranchcache(partial, lrev+1, tiprev+1)
358 self._updatebranchcache(partial, lrev+1, tiprev+1)
359 self._writebranchcache(partial, self.changelog.tip(), tiprev)
359 self._writebranchcache(partial, self.changelog.tip(), tiprev)
360
360
361 return partial
361 return partial
362
362
363 def _branchheads(self):
363 def _branchheads(self):
364 tip = self.changelog.tip()
364 tip = self.changelog.tip()
365 if self.branchcache is not None and self._branchcachetip == tip:
365 if self.branchcache is not None and self._branchcachetip == tip:
366 return self.branchcache
366 return self.branchcache
367
367
368 oldtip = self._branchcachetip
368 oldtip = self._branchcachetip
369 self._branchcachetip = tip
369 self._branchcachetip = tip
370 if self.branchcache is None:
370 if self.branchcache is None:
371 self.branchcache = {} # avoid recursion in changectx
371 self.branchcache = {} # avoid recursion in changectx
372 else:
372 else:
373 self.branchcache.clear() # keep using the same dict
373 self.branchcache.clear() # keep using the same dict
374 if oldtip is None or oldtip not in self.changelog.nodemap:
374 if oldtip is None or oldtip not in self.changelog.nodemap:
375 partial, last, lrev = self._readbranchcache()
375 partial, last, lrev = self._readbranchcache()
376 else:
376 else:
377 lrev = self.changelog.rev(oldtip)
377 lrev = self.changelog.rev(oldtip)
378 partial = self._ubranchcache
378 partial = self._ubranchcache
379
379
380 self._branchtags(partial, lrev)
380 self._branchtags(partial, lrev)
381 # this private cache holds all heads (not just tips)
381 # this private cache holds all heads (not just tips)
382 self._ubranchcache = partial
382 self._ubranchcache = partial
383
383
384 # the branch cache is stored on disk as UTF-8, but in the local
384 # the branch cache is stored on disk as UTF-8, but in the local
385 # charset internally
385 # charset internally
386 for k, v in partial.iteritems():
386 for k, v in partial.iteritems():
387 self.branchcache[encoding.tolocal(k)] = v
387 self.branchcache[encoding.tolocal(k)] = v
388 return self.branchcache
388 return self.branchcache
389
389
390
390
391 def branchtags(self):
391 def branchtags(self):
392 '''return a dict where branch names map to the tipmost head of
392 '''return a dict where branch names map to the tipmost head of
393 the branch, open heads come before closed'''
393 the branch, open heads come before closed'''
394 bt = {}
394 bt = {}
395 for bn, heads in self._branchheads().iteritems():
395 for bn, heads in self._branchheads().iteritems():
396 head = None
396 head = None
397 for i in range(len(heads)-1, -1, -1):
397 for i in range(len(heads)-1, -1, -1):
398 h = heads[i]
398 h = heads[i]
399 if 'close' not in self.changelog.read(h)[5]:
399 if 'close' not in self.changelog.read(h)[5]:
400 head = h
400 head = h
401 break
401 break
402 # no open heads were found
402 # no open heads were found
403 if head is None:
403 if head is None:
404 head = heads[-1]
404 head = heads[-1]
405 bt[bn] = head
405 bt[bn] = head
406 return bt
406 return bt
407
407
408
408
409 def _readbranchcache(self):
409 def _readbranchcache(self):
410 partial = {}
410 partial = {}
411 try:
411 try:
412 f = self.opener("branchheads.cache")
412 f = self.opener("branchheads.cache")
413 lines = f.read().split('\n')
413 lines = f.read().split('\n')
414 f.close()
414 f.close()
415 except (IOError, OSError):
415 except (IOError, OSError):
416 return {}, nullid, nullrev
416 return {}, nullid, nullrev
417
417
418 try:
418 try:
419 last, lrev = lines.pop(0).split(" ", 1)
419 last, lrev = lines.pop(0).split(" ", 1)
420 last, lrev = bin(last), int(lrev)
420 last, lrev = bin(last), int(lrev)
421 if lrev >= len(self) or self[lrev].node() != last:
421 if lrev >= len(self) or self[lrev].node() != last:
422 # invalidate the cache
422 # invalidate the cache
423 raise ValueError('invalidating branch cache (tip differs)')
423 raise ValueError('invalidating branch cache (tip differs)')
424 for l in lines:
424 for l in lines:
425 if not l: continue
425 if not l: continue
426 node, label = l.split(" ", 1)
426 node, label = l.split(" ", 1)
427 partial.setdefault(label.strip(), []).append(bin(node))
427 partial.setdefault(label.strip(), []).append(bin(node))
428 except KeyboardInterrupt:
428 except KeyboardInterrupt:
429 raise
429 raise
430 except Exception, inst:
430 except Exception, inst:
431 if self.ui.debugflag:
431 if self.ui.debugflag:
432 self.ui.warn(str(inst), '\n')
432 self.ui.warn(str(inst), '\n')
433 partial, last, lrev = {}, nullid, nullrev
433 partial, last, lrev = {}, nullid, nullrev
434 return partial, last, lrev
434 return partial, last, lrev
435
435
436 def _writebranchcache(self, branches, tip, tiprev):
436 def _writebranchcache(self, branches, tip, tiprev):
437 try:
437 try:
438 f = self.opener("branchheads.cache", "w", atomictemp=True)
438 f = self.opener("branchheads.cache", "w", atomictemp=True)
439 f.write("%s %s\n" % (hex(tip), tiprev))
439 f.write("%s %s\n" % (hex(tip), tiprev))
440 for label, nodes in branches.iteritems():
440 for label, nodes in branches.iteritems():
441 for node in nodes:
441 for node in nodes:
442 f.write("%s %s\n" % (hex(node), label))
442 f.write("%s %s\n" % (hex(node), label))
443 f.rename()
443 f.rename()
444 except (IOError, OSError):
444 except (IOError, OSError):
445 pass
445 pass
446
446
447 def _updatebranchcache(self, partial, start, end):
447 def _updatebranchcache(self, partial, start, end):
448 for r in xrange(start, end):
448 for r in xrange(start, end):
449 c = self[r]
449 c = self[r]
450 b = c.branch()
450 b = c.branch()
451 bheads = partial.setdefault(b, [])
451 bheads = partial.setdefault(b, [])
452 bheads.append(c.node())
452 bheads.append(c.node())
453 for p in c.parents():
453 for p in c.parents():
454 pn = p.node()
454 pn = p.node()
455 if pn in bheads:
455 if pn in bheads:
456 bheads.remove(pn)
456 bheads.remove(pn)
457
457
458 def lookup(self, key):
458 def lookup(self, key):
459 if isinstance(key, int):
459 if isinstance(key, int):
460 return self.changelog.node(key)
460 return self.changelog.node(key)
461 elif key == '.':
461 elif key == '.':
462 return self.dirstate.parents()[0]
462 return self.dirstate.parents()[0]
463 elif key == 'null':
463 elif key == 'null':
464 return nullid
464 return nullid
465 elif key == 'tip':
465 elif key == 'tip':
466 return self.changelog.tip()
466 return self.changelog.tip()
467 n = self.changelog._match(key)
467 n = self.changelog._match(key)
468 if n:
468 if n:
469 return n
469 return n
470 if key in self.tags():
470 if key in self.tags():
471 return self.tags()[key]
471 return self.tags()[key]
472 if key in self.branchtags():
472 if key in self.branchtags():
473 return self.branchtags()[key]
473 return self.branchtags()[key]
474 n = self.changelog._partialmatch(key)
474 n = self.changelog._partialmatch(key)
475 if n:
475 if n:
476 return n
476 return n
477 try:
477 try:
478 if len(key) == 20:
478 if len(key) == 20:
479 key = hex(key)
479 key = hex(key)
480 except:
480 except:
481 pass
481 pass
482 raise error.RepoError(_("unknown revision '%s'") % key)
482 raise error.RepoError(_("unknown revision '%s'") % key)
483
483
484 def local(self):
484 def local(self):
485 return True
485 return True
486
486
487 def join(self, f):
487 def join(self, f):
488 return os.path.join(self.path, f)
488 return os.path.join(self.path, f)
489
489
490 def wjoin(self, f):
490 def wjoin(self, f):
491 return os.path.join(self.root, f)
491 return os.path.join(self.root, f)
492
492
493 def rjoin(self, f):
493 def rjoin(self, f):
494 return os.path.join(self.root, util.pconvert(f))
494 return os.path.join(self.root, util.pconvert(f))
495
495
496 def file(self, f):
496 def file(self, f):
497 if f[0] == '/':
497 if f[0] == '/':
498 f = f[1:]
498 f = f[1:]
499 return filelog.filelog(self.sopener, f)
499 return filelog.filelog(self.sopener, f)
500
500
501 def changectx(self, changeid):
501 def changectx(self, changeid):
502 return self[changeid]
502 return self[changeid]
503
503
504 def parents(self, changeid=None):
504 def parents(self, changeid=None):
505 '''get list of changectxs for parents of changeid'''
505 '''get list of changectxs for parents of changeid'''
506 return self[changeid].parents()
506 return self[changeid].parents()
507
507
508 def filectx(self, path, changeid=None, fileid=None):
508 def filectx(self, path, changeid=None, fileid=None):
509 """changeid can be a changeset revision, node, or tag.
509 """changeid can be a changeset revision, node, or tag.
510 fileid can be a file revision or node."""
510 fileid can be a file revision or node."""
511 return context.filectx(self, path, changeid, fileid)
511 return context.filectx(self, path, changeid, fileid)
512
512
513 def getcwd(self):
513 def getcwd(self):
514 return self.dirstate.getcwd()
514 return self.dirstate.getcwd()
515
515
516 def pathto(self, f, cwd=None):
516 def pathto(self, f, cwd=None):
517 return self.dirstate.pathto(f, cwd)
517 return self.dirstate.pathto(f, cwd)
518
518
519 def wfile(self, f, mode='r'):
519 def wfile(self, f, mode='r'):
520 return self.wopener(f, mode)
520 return self.wopener(f, mode)
521
521
522 def _link(self, f):
522 def _link(self, f):
523 return os.path.islink(self.wjoin(f))
523 return os.path.islink(self.wjoin(f))
524
524
525 def _filter(self, filter, filename, data):
525 def _filter(self, filter, filename, data):
526 if filter not in self.filterpats:
526 if filter not in self.filterpats:
527 l = []
527 l = []
528 for pat, cmd in self.ui.configitems(filter):
528 for pat, cmd in self.ui.configitems(filter):
529 if cmd == '!':
529 if cmd == '!':
530 continue
530 continue
531 mf = util.matcher(self.root, "", [pat], [], [])[1]
531 mf = util.matcher(self.root, "", [pat], [], [])[1]
532 fn = None
532 fn = None
533 params = cmd
533 params = cmd
534 for name, filterfn in self._datafilters.iteritems():
534 for name, filterfn in self._datafilters.iteritems():
535 if cmd.startswith(name):
535 if cmd.startswith(name):
536 fn = filterfn
536 fn = filterfn
537 params = cmd[len(name):].lstrip()
537 params = cmd[len(name):].lstrip()
538 break
538 break
539 if not fn:
539 if not fn:
540 fn = lambda s, c, **kwargs: util.filter(s, c)
540 fn = lambda s, c, **kwargs: util.filter(s, c)
541 # Wrap old filters not supporting keyword arguments
541 # Wrap old filters not supporting keyword arguments
542 if not inspect.getargspec(fn)[2]:
542 if not inspect.getargspec(fn)[2]:
543 oldfn = fn
543 oldfn = fn
544 fn = lambda s, c, **kwargs: oldfn(s, c)
544 fn = lambda s, c, **kwargs: oldfn(s, c)
545 l.append((mf, fn, params))
545 l.append((mf, fn, params))
546 self.filterpats[filter] = l
546 self.filterpats[filter] = l
547
547
548 for mf, fn, cmd in self.filterpats[filter]:
548 for mf, fn, cmd in self.filterpats[filter]:
549 if mf(filename):
549 if mf(filename):
550 self.ui.debug(_("filtering %s through %s\n") % (filename, cmd))
550 self.ui.debug(_("filtering %s through %s\n") % (filename, cmd))
551 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
551 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
552 break
552 break
553
553
554 return data
554 return data
555
555
556 def adddatafilter(self, name, filter):
556 def adddatafilter(self, name, filter):
557 self._datafilters[name] = filter
557 self._datafilters[name] = filter
558
558
559 def wread(self, filename):
559 def wread(self, filename):
560 if self._link(filename):
560 if self._link(filename):
561 data = os.readlink(self.wjoin(filename))
561 data = os.readlink(self.wjoin(filename))
562 else:
562 else:
563 data = self.wopener(filename, 'r').read()
563 data = self.wopener(filename, 'r').read()
564 return self._filter("encode", filename, data)
564 return self._filter("encode", filename, data)
565
565
566 def wwrite(self, filename, data, flags):
566 def wwrite(self, filename, data, flags):
567 data = self._filter("decode", filename, data)
567 data = self._filter("decode", filename, data)
568 try:
568 try:
569 os.unlink(self.wjoin(filename))
569 os.unlink(self.wjoin(filename))
570 except OSError:
570 except OSError:
571 pass
571 pass
572 if 'l' in flags:
572 if 'l' in flags:
573 self.wopener.symlink(data, filename)
573 self.wopener.symlink(data, filename)
574 else:
574 else:
575 self.wopener(filename, 'w').write(data)
575 self.wopener(filename, 'w').write(data)
576 if 'x' in flags:
576 if 'x' in flags:
577 util.set_flags(self.wjoin(filename), False, True)
577 util.set_flags(self.wjoin(filename), False, True)
578
578
579 def wwritedata(self, filename, data):
579 def wwritedata(self, filename, data):
580 return self._filter("decode", filename, data)
580 return self._filter("decode", filename, data)
581
581
582 def transaction(self):
582 def transaction(self):
583 tr = self._transref and self._transref() or None
583 tr = self._transref and self._transref() or None
584 if tr and tr.running():
584 if tr and tr.running():
585 return tr.nest()
585 return tr.nest()
586
586
587 # abort here if the journal already exists
587 # abort here if the journal already exists
588 if os.path.exists(self.sjoin("journal")):
588 if os.path.exists(self.sjoin("journal")):
589 raise error.RepoError(_("journal already exists - run hg recover"))
589 raise error.RepoError(_("journal already exists - run hg recover"))
590
590
591 # save dirstate for rollback
591 # save dirstate for rollback
592 try:
592 try:
593 ds = self.opener("dirstate").read()
593 ds = self.opener("dirstate").read()
594 except IOError:
594 except IOError:
595 ds = ""
595 ds = ""
596 self.opener("journal.dirstate", "w").write(ds)
596 self.opener("journal.dirstate", "w").write(ds)
597 self.opener("journal.branch", "w").write(self.dirstate.branch())
597 self.opener("journal.branch", "w").write(self.dirstate.branch())
598
598
599 renames = [(self.sjoin("journal"), self.sjoin("undo")),
599 renames = [(self.sjoin("journal"), self.sjoin("undo")),
600 (self.join("journal.dirstate"), self.join("undo.dirstate")),
600 (self.join("journal.dirstate"), self.join("undo.dirstate")),
601 (self.join("journal.branch"), self.join("undo.branch"))]
601 (self.join("journal.branch"), self.join("undo.branch"))]
602 tr = transaction.transaction(self.ui.warn, self.sopener,
602 tr = transaction.transaction(self.ui.warn, self.sopener,
603 self.sjoin("journal"),
603 self.sjoin("journal"),
604 aftertrans(renames),
604 aftertrans(renames),
605 self.store.createmode)
605 self.store.createmode)
606 self._transref = weakref.ref(tr)
606 self._transref = weakref.ref(tr)
607 return tr
607 return tr
608
608
609 def recover(self):
609 def recover(self):
610 lock = self.lock()
610 lock = self.lock()
611 try:
611 try:
612 if os.path.exists(self.sjoin("journal")):
612 if os.path.exists(self.sjoin("journal")):
613 self.ui.status(_("rolling back interrupted transaction\n"))
613 self.ui.status(_("rolling back interrupted transaction\n"))
614 transaction.rollback(self.sopener, self.sjoin("journal"), self.ui.warn)
614 transaction.rollback(self.sopener, self.sjoin("journal"), self.ui.warn)
615 self.invalidate()
615 self.invalidate()
616 return True
616 return True
617 else:
617 else:
618 self.ui.warn(_("no interrupted transaction available\n"))
618 self.ui.warn(_("no interrupted transaction available\n"))
619 return False
619 return False
620 finally:
620 finally:
621 lock.release()
621 lock.release()
622
622
623 def rollback(self):
623 def rollback(self):
624 wlock = lock = None
624 wlock = lock = None
625 try:
625 try:
626 wlock = self.wlock()
626 wlock = self.wlock()
627 lock = self.lock()
627 lock = self.lock()
628 if os.path.exists(self.sjoin("undo")):
628 if os.path.exists(self.sjoin("undo")):
629 self.ui.status(_("rolling back last transaction\n"))
629 self.ui.status(_("rolling back last transaction\n"))
630 transaction.rollback(self.sopener, self.sjoin("undo"), self.ui.warn)
630 transaction.rollback(self.sopener, self.sjoin("undo"), self.ui.warn)
631 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
631 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
632 try:
632 try:
633 branch = self.opener("undo.branch").read()
633 branch = self.opener("undo.branch").read()
634 self.dirstate.setbranch(branch)
634 self.dirstate.setbranch(branch)
635 except IOError:
635 except IOError:
636 self.ui.warn(_("Named branch could not be reset, "
636 self.ui.warn(_("Named branch could not be reset, "
637 "current branch still is: %s\n")
637 "current branch still is: %s\n")
638 % encoding.tolocal(self.dirstate.branch()))
638 % encoding.tolocal(self.dirstate.branch()))
639 self.invalidate()
639 self.invalidate()
640 self.dirstate.invalidate()
640 self.dirstate.invalidate()
641 else:
641 else:
642 self.ui.warn(_("no rollback information available\n"))
642 self.ui.warn(_("no rollback information available\n"))
643 finally:
643 finally:
644 release(lock, wlock)
644 release(lock, wlock)
645
645
646 def invalidate(self):
646 def invalidate(self):
647 for a in "changelog manifest".split():
647 for a in "changelog manifest".split():
648 if a in self.__dict__:
648 if a in self.__dict__:
649 delattr(self, a)
649 delattr(self, a)
650 self.tagscache = None
650 self.tagscache = None
651 self._tagstypecache = None
651 self._tagstypecache = None
652 self.nodetagscache = None
652 self.nodetagscache = None
653 self.branchcache = None
653 self.branchcache = None
654 self._ubranchcache = None
654 self._ubranchcache = None
655 self._branchcachetip = None
655 self._branchcachetip = None
656
656
657 def _lock(self, lockname, wait, releasefn, acquirefn, desc):
657 def _lock(self, lockname, wait, releasefn, acquirefn, desc):
658 try:
658 try:
659 l = lock.lock(lockname, 0, releasefn, desc=desc)
659 l = lock.lock(lockname, 0, releasefn, desc=desc)
660 except error.LockHeld, inst:
660 except error.LockHeld, inst:
661 if not wait:
661 if not wait:
662 raise
662 raise
663 self.ui.warn(_("waiting for lock on %s held by %r\n") %
663 self.ui.warn(_("waiting for lock on %s held by %r\n") %
664 (desc, inst.locker))
664 (desc, inst.locker))
665 # default to 600 seconds timeout
665 # default to 600 seconds timeout
666 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
666 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
667 releasefn, desc=desc)
667 releasefn, desc=desc)
668 if acquirefn:
668 if acquirefn:
669 acquirefn()
669 acquirefn()
670 return l
670 return l
671
671
672 def lock(self, wait=True):
672 def lock(self, wait=True):
673 l = self._lockref and self._lockref()
673 l = self._lockref and self._lockref()
674 if l is not None and l.held:
674 if l is not None and l.held:
675 l.lock()
675 l.lock()
676 return l
676 return l
677
677
678 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate,
678 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate,
679 _('repository %s') % self.origroot)
679 _('repository %s') % self.origroot)
680 self._lockref = weakref.ref(l)
680 self._lockref = weakref.ref(l)
681 return l
681 return l
682
682
683 def wlock(self, wait=True):
683 def wlock(self, wait=True):
684 l = self._wlockref and self._wlockref()
684 l = self._wlockref and self._wlockref()
685 if l is not None and l.held:
685 if l is not None and l.held:
686 l.lock()
686 l.lock()
687 return l
687 return l
688
688
689 l = self._lock(self.join("wlock"), wait, self.dirstate.write,
689 l = self._lock(self.join("wlock"), wait, self.dirstate.write,
690 self.dirstate.invalidate, _('working directory of %s') %
690 self.dirstate.invalidate, _('working directory of %s') %
691 self.origroot)
691 self.origroot)
692 self._wlockref = weakref.ref(l)
692 self._wlockref = weakref.ref(l)
693 return l
693 return l
694
694
695 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
695 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
696 """
696 """
697 commit an individual file as part of a larger transaction
697 commit an individual file as part of a larger transaction
698 """
698 """
699
699
700 fname = fctx.path()
700 fname = fctx.path()
701 text = fctx.data()
701 text = fctx.data()
702 flog = self.file(fname)
702 flog = self.file(fname)
703 fparent1 = manifest1.get(fname, nullid)
703 fparent1 = manifest1.get(fname, nullid)
704 fparent2 = fparent2o = manifest2.get(fname, nullid)
704 fparent2 = fparent2o = manifest2.get(fname, nullid)
705
705
706 meta = {}
706 meta = {}
707 copy = fctx.renamed()
707 copy = fctx.renamed()
708 if copy and copy[0] != fname:
708 if copy and copy[0] != fname:
709 # Mark the new revision of this file as a copy of another
709 # Mark the new revision of this file as a copy of another
710 # file. This copy data will effectively act as a parent
710 # file. This copy data will effectively act as a parent
711 # of this new revision. If this is a merge, the first
711 # of this new revision. If this is a merge, the first
712 # parent will be the nullid (meaning "look up the copy data")
712 # parent will be the nullid (meaning "look up the copy data")
713 # and the second one will be the other parent. For example:
713 # and the second one will be the other parent. For example:
714 #
714 #
715 # 0 --- 1 --- 3 rev1 changes file foo
715 # 0 --- 1 --- 3 rev1 changes file foo
716 # \ / rev2 renames foo to bar and changes it
716 # \ / rev2 renames foo to bar and changes it
717 # \- 2 -/ rev3 should have bar with all changes and
717 # \- 2 -/ rev3 should have bar with all changes and
718 # should record that bar descends from
718 # should record that bar descends from
719 # bar in rev2 and foo in rev1
719 # bar in rev2 and foo in rev1
720 #
720 #
721 # this allows this merge to succeed:
721 # this allows this merge to succeed:
722 #
722 #
723 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
723 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
724 # \ / merging rev3 and rev4 should use bar@rev2
724 # \ / merging rev3 and rev4 should use bar@rev2
725 # \- 2 --- 4 as the merge base
725 # \- 2 --- 4 as the merge base
726 #
726 #
727
727
728 cfname = copy[0]
728 cfname = copy[0]
729 crev = manifest1.get(cfname)
729 crev = manifest1.get(cfname)
730 newfparent = fparent2
730 newfparent = fparent2
731
731
732 if manifest2: # branch merge
732 if manifest2: # branch merge
733 if fparent2 == nullid or crev is None: # copied on remote side
733 if fparent2 == nullid or crev is None: # copied on remote side
734 if cfname in manifest2:
734 if cfname in manifest2:
735 crev = manifest2[cfname]
735 crev = manifest2[cfname]
736 newfparent = fparent1
736 newfparent = fparent1
737
737
738 # find source in nearest ancestor if we've lost track
738 # find source in nearest ancestor if we've lost track
739 if not crev:
739 if not crev:
740 self.ui.debug(_(" %s: searching for copy revision for %s\n") %
740 self.ui.debug(_(" %s: searching for copy revision for %s\n") %
741 (fname, cfname))
741 (fname, cfname))
742 for ancestor in self['.'].ancestors():
742 for ancestor in self['.'].ancestors():
743 if cfname in ancestor:
743 if cfname in ancestor:
744 crev = ancestor[cfname].filenode()
744 crev = ancestor[cfname].filenode()
745 break
745 break
746
746
747 self.ui.debug(_(" %s: copy %s:%s\n") % (fname, cfname, hex(crev)))
747 self.ui.debug(_(" %s: copy %s:%s\n") % (fname, cfname, hex(crev)))
748 meta["copy"] = cfname
748 meta["copy"] = cfname
749 meta["copyrev"] = hex(crev)
749 meta["copyrev"] = hex(crev)
750 fparent1, fparent2 = nullid, newfparent
750 fparent1, fparent2 = nullid, newfparent
751 elif fparent2 != nullid:
751 elif fparent2 != nullid:
752 # is one parent an ancestor of the other?
752 # is one parent an ancestor of the other?
753 fparentancestor = flog.ancestor(fparent1, fparent2)
753 fparentancestor = flog.ancestor(fparent1, fparent2)
754 if fparentancestor == fparent1:
754 if fparentancestor == fparent1:
755 fparent1, fparent2 = fparent2, nullid
755 fparent1, fparent2 = fparent2, nullid
756 elif fparentancestor == fparent2:
756 elif fparentancestor == fparent2:
757 fparent2 = nullid
757 fparent2 = nullid
758
758
759 # is the file changed?
759 # is the file changed?
760 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
760 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
761 changelist.append(fname)
761 changelist.append(fname)
762 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
762 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
763
763
764 # are just the flags changed during merge?
764 # are just the flags changed during merge?
765 if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags():
765 if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags():
766 changelist.append(fname)
766 changelist.append(fname)
767
767
768 return fparent1
768 return fparent1
769
769
770 def commit(self, files=None, text="", user=None, date=None, match=None,
770 def commit(self, files=None, text="", user=None, date=None, match=None,
771 force=False, editor=False, extra={}):
771 force=False, editor=False, extra={}):
772 wlock = lock = None
772 wlock = lock = None
773 if extra.get("close"):
773 if extra.get("close"):
774 force = True
774 force = True
775 if files:
775 if files:
776 files = list(set(files))
776 files = list(set(files))
777
777
778 ret = None
778 ret = None
779 wlock = self.wlock()
779 wlock = self.wlock()
780 try:
780 try:
781 p1, p2 = self.dirstate.parents()
781 p1, p2 = self.dirstate.parents()
782
782
783 if (not force and p2 != nullid and
783 if (not force and p2 != nullid and
784 (match and (match.files() or match.anypats()))):
784 (match and (match.files() or match.anypats()))):
785 raise util.Abort(_('cannot partially commit a merge '
785 raise util.Abort(_('cannot partially commit a merge '
786 '(do not specify files or patterns)'))
786 '(do not specify files or patterns)'))
787
787
788 if files:
788 if files:
789 modified, removed = [], []
789 modified, removed = [], []
790 for f in files:
790 for f in files:
791 s = self.dirstate[f]
791 s = self.dirstate[f]
792 if s in 'nma':
792 if s in 'nma':
793 modified.append(f)
793 modified.append(f)
794 elif s == 'r':
794 elif s == 'r':
795 removed.append(f)
795 removed.append(f)
796 else:
796 else:
797 self.ui.warn(_("%s not tracked!\n") % f)
797 self.ui.warn(_("%s not tracked!\n") % f)
798 changes = [modified, [], removed, [], []]
798 changes = [modified, [], removed, [], []]
799 else:
799 else:
800 changes = self.status(match=match)
800 changes = self.status(match=match)
801
801
802 if (not (changes[0] or changes[1] or changes[2])
802 if (not (changes[0] or changes[1] or changes[2])
803 and not force and p2 == nullid and
803 and not force and p2 == nullid and
804 self[None].branch() == self['.'].branch()):
804 self[None].branch() == self['.'].branch()):
805 self.ui.status(_("nothing changed\n"))
805 self.ui.status(_("nothing changed\n"))
806 return None
806 return None
807
807
808 ms = merge_.mergestate(self)
808 ms = merge_.mergestate(self)
809 for f in changes[0]:
809 for f in changes[0]:
810 if f in ms and ms[f] == 'u':
810 if f in ms and ms[f] == 'u':
811 raise util.Abort(_("unresolved merge conflicts "
811 raise util.Abort(_("unresolved merge conflicts "
812 "(see hg resolve)"))
812 "(see hg resolve)"))
813
813 wctx = context.workingctx(self, (p1, p2), text, user, date,
814 wctx = context.workingctx(self, (p1, p2), text, user, date,
814 extra, changes)
815 extra, changes)
815 ret = self.commitctx(wctx, editor, True)
816 if editor:
817 wctx._text = editor(self, wctx,
818 changes[1], changes[0], changes[2])
819
820 ret = self.commitctx(wctx, True)
816 ms.reset()
821 ms.reset()
817
822
818 # update dirstate
823 # update dirstate
819 for f in changes[0] + changes[1]:
824 for f in changes[0] + changes[1]:
820 self.dirstate.normal(f)
825 self.dirstate.normal(f)
821 for f in changes[2]:
826 for f in changes[2]:
822 self.dirstate.forget(f)
827 self.dirstate.forget(f)
823 self.dirstate.setparents(ret)
828 self.dirstate.setparents(ret)
824
829
825 return ret
830 return ret
826
831
827 finally:
832 finally:
828 if ret == None:
833 if ret == None:
829 self.dirstate.invalidate() # didn't successfully commit
834 self.dirstate.invalidate() # didn't successfully commit
830 wlock.release()
835 wlock.release()
831
836
832 def commitctx(self, ctx, editor=None, error=False):
837 def commitctx(self, ctx, error=False):
833 """Add a new revision to current repository.
838 """Add a new revision to current repository.
834
839
835 Revision information is passed via the context argument.
840 Revision information is passed via the context argument.
836 If editor is supplied, it is called to get a commit message.
841 If editor is supplied, it is called to get a commit message.
837 If working is set, the working directory is affected.
842 If working is set, the working directory is affected.
838 """
843 """
839
844
840 tr = lock = None
845 tr = lock = None
841 remove = ctx.removed()
846 remove = ctx.removed()
842 p1, p2 = ctx.p1(), ctx.p2()
847 p1, p2 = ctx.p1(), ctx.p2()
843 m1 = p1.manifest().copy()
848 m1 = p1.manifest().copy()
844 m2 = p2.manifest()
849 m2 = p2.manifest()
845 user = ctx.user()
850 user = ctx.user()
846
851
847 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
852 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
848 self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
853 self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
849
854
850 lock = self.lock()
855 lock = self.lock()
851 try:
856 try:
852 tr = self.transaction()
857 tr = self.transaction()
853 trp = weakref.proxy(tr)
858 trp = weakref.proxy(tr)
854
859
855 # check in files
860 # check in files
856 new = {}
861 new = {}
857 changed = []
862 changed = []
858 linkrev = len(self)
863 linkrev = len(self)
859 for f in sorted(ctx.modified() + ctx.added()):
864 for f in sorted(ctx.modified() + ctx.added()):
860 self.ui.note(f + "\n")
865 self.ui.note(f + "\n")
861 try:
866 try:
862 fctx = ctx[f]
867 fctx = ctx[f]
863 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
868 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
864 changed)
869 changed)
865 m1.set(f, fctx.flags())
870 m1.set(f, fctx.flags())
866 except (OSError, IOError):
871 except (OSError, IOError):
867 if error:
872 if error:
868 self.ui.warn(_("trouble committing %s!\n") % f)
873 self.ui.warn(_("trouble committing %s!\n") % f)
869 raise
874 raise
870 else:
875 else:
871 remove.append(f)
876 remove.append(f)
872
877
873 updated, added = [], []
874 for f in sorted(changed):
875 if f in m1 or f in m2:
876 updated.append(f)
877 else:
878 added.append(f)
879
880 # update manifest
878 # update manifest
881 m1.update(new)
879 m1.update(new)
882 removed = [f for f in sorted(remove) if f in m1 or f in m2]
880 removed = [f for f in sorted(remove) if f in m1 or f in m2]
883 removed1 = []
881 removed1 = []
884
882
885 for f in removed:
883 for f in removed:
886 if f in m1:
884 if f in m1:
887 del m1[f]
885 del m1[f]
888 removed1.append(f)
886 removed1.append(f)
889 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
887 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
890 p2.manifestnode(), (new, removed1))
888 p2.manifestnode(), (new, removed1))
891
889
892 text = ctx.description()
890 text = ctx.description()
893 if editor:
894 text = editor(self, ctx, added, updated, removed)
895
896 lines = [line.rstrip() for line in text.rstrip().splitlines()]
891 lines = [line.rstrip() for line in text.rstrip().splitlines()]
897 while lines and not lines[0]:
892 while lines and not lines[0]:
898 del lines[0]
893 del lines[0]
899 text = '\n'.join(lines)
894 text = '\n'.join(lines)
900
895
901 self.changelog.delayupdate()
896 self.changelog.delayupdate()
902 n = self.changelog.add(mn, changed + removed, text, trp,
897 n = self.changelog.add(mn, changed + removed, text, trp,
903 p1.node(), p2.node(),
898 p1.node(), p2.node(),
904 user, ctx.date(), ctx.extra().copy())
899 user, ctx.date(), ctx.extra().copy())
905 p = lambda: self.changelog.writepending() and self.root or ""
900 p = lambda: self.changelog.writepending() and self.root or ""
906 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
901 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
907 parent2=xp2, pending=p)
902 parent2=xp2, pending=p)
908 self.changelog.finalize(trp)
903 self.changelog.finalize(trp)
909 tr.close()
904 tr.close()
910
905
911 if self.branchcache:
906 if self.branchcache:
912 self.branchtags()
907 self.branchtags()
913
908
914 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
909 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
915 return n
910 return n
916 finally:
911 finally:
917 del tr
912 del tr
918 lock.release()
913 lock.release()
919
914
920 def walk(self, match, node=None):
915 def walk(self, match, node=None):
921 '''
916 '''
922 walk recursively through the directory tree or a given
917 walk recursively through the directory tree or a given
923 changeset, finding all files matched by the match
918 changeset, finding all files matched by the match
924 function
919 function
925 '''
920 '''
926 return self[node].walk(match)
921 return self[node].walk(match)
927
922
928 def status(self, node1='.', node2=None, match=None,
923 def status(self, node1='.', node2=None, match=None,
929 ignored=False, clean=False, unknown=False):
924 ignored=False, clean=False, unknown=False):
930 """return status of files between two nodes or node and working directory
925 """return status of files between two nodes or node and working directory
931
926
932 If node1 is None, use the first dirstate parent instead.
927 If node1 is None, use the first dirstate parent instead.
933 If node2 is None, compare node1 with working directory.
928 If node2 is None, compare node1 with working directory.
934 """
929 """
935
930
936 def mfmatches(ctx):
931 def mfmatches(ctx):
937 mf = ctx.manifest().copy()
932 mf = ctx.manifest().copy()
938 for fn in mf.keys():
933 for fn in mf.keys():
939 if not match(fn):
934 if not match(fn):
940 del mf[fn]
935 del mf[fn]
941 return mf
936 return mf
942
937
943 if isinstance(node1, context.changectx):
938 if isinstance(node1, context.changectx):
944 ctx1 = node1
939 ctx1 = node1
945 else:
940 else:
946 ctx1 = self[node1]
941 ctx1 = self[node1]
947 if isinstance(node2, context.changectx):
942 if isinstance(node2, context.changectx):
948 ctx2 = node2
943 ctx2 = node2
949 else:
944 else:
950 ctx2 = self[node2]
945 ctx2 = self[node2]
951
946
952 working = ctx2.rev() is None
947 working = ctx2.rev() is None
953 parentworking = working and ctx1 == self['.']
948 parentworking = working and ctx1 == self['.']
954 match = match or match_.always(self.root, self.getcwd())
949 match = match or match_.always(self.root, self.getcwd())
955 listignored, listclean, listunknown = ignored, clean, unknown
950 listignored, listclean, listunknown = ignored, clean, unknown
956
951
957 # load earliest manifest first for caching reasons
952 # load earliest manifest first for caching reasons
958 if not working and ctx2.rev() < ctx1.rev():
953 if not working and ctx2.rev() < ctx1.rev():
959 ctx2.manifest()
954 ctx2.manifest()
960
955
961 if not parentworking:
956 if not parentworking:
962 def bad(f, msg):
957 def bad(f, msg):
963 if f not in ctx1:
958 if f not in ctx1:
964 self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
959 self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
965 return False
960 return False
966 match.bad = bad
961 match.bad = bad
967
962
968 if working: # we need to scan the working dir
963 if working: # we need to scan the working dir
969 s = self.dirstate.status(match, listignored, listclean, listunknown)
964 s = self.dirstate.status(match, listignored, listclean, listunknown)
970 cmp, modified, added, removed, deleted, unknown, ignored, clean = s
965 cmp, modified, added, removed, deleted, unknown, ignored, clean = s
971
966
972 # check for any possibly clean files
967 # check for any possibly clean files
973 if parentworking and cmp:
968 if parentworking and cmp:
974 fixup = []
969 fixup = []
975 # do a full compare of any files that might have changed
970 # do a full compare of any files that might have changed
976 for f in sorted(cmp):
971 for f in sorted(cmp):
977 if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f)
972 if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f)
978 or ctx1[f].cmp(ctx2[f].data())):
973 or ctx1[f].cmp(ctx2[f].data())):
979 modified.append(f)
974 modified.append(f)
980 else:
975 else:
981 fixup.append(f)
976 fixup.append(f)
982
977
983 if listclean:
978 if listclean:
984 clean += fixup
979 clean += fixup
985
980
986 # update dirstate for files that are actually clean
981 # update dirstate for files that are actually clean
987 if fixup:
982 if fixup:
988 wlock = None
983 wlock = None
989 try:
984 try:
990 try:
985 try:
991 # updating the dirstate is optional
986 # updating the dirstate is optional
992 # so we don't wait on the lock
987 # so we don't wait on the lock
993 wlock = self.wlock(False)
988 wlock = self.wlock(False)
994 for f in fixup:
989 for f in fixup:
995 self.dirstate.normal(f)
990 self.dirstate.normal(f)
996 except error.LockError:
991 except error.LockError:
997 pass
992 pass
998 finally:
993 finally:
999 release(wlock)
994 release(wlock)
1000
995
1001 if not parentworking:
996 if not parentworking:
1002 mf1 = mfmatches(ctx1)
997 mf1 = mfmatches(ctx1)
1003 if working:
998 if working:
1004 # we are comparing working dir against non-parent
999 # we are comparing working dir against non-parent
1005 # generate a pseudo-manifest for the working dir
1000 # generate a pseudo-manifest for the working dir
1006 mf2 = mfmatches(self['.'])
1001 mf2 = mfmatches(self['.'])
1007 for f in cmp + modified + added:
1002 for f in cmp + modified + added:
1008 mf2[f] = None
1003 mf2[f] = None
1009 mf2.set(f, ctx2.flags(f))
1004 mf2.set(f, ctx2.flags(f))
1010 for f in removed:
1005 for f in removed:
1011 if f in mf2:
1006 if f in mf2:
1012 del mf2[f]
1007 del mf2[f]
1013 else:
1008 else:
1014 # we are comparing two revisions
1009 # we are comparing two revisions
1015 deleted, unknown, ignored = [], [], []
1010 deleted, unknown, ignored = [], [], []
1016 mf2 = mfmatches(ctx2)
1011 mf2 = mfmatches(ctx2)
1017
1012
1018 modified, added, clean = [], [], []
1013 modified, added, clean = [], [], []
1019 for fn in mf2:
1014 for fn in mf2:
1020 if fn in mf1:
1015 if fn in mf1:
1021 if (mf1.flags(fn) != mf2.flags(fn) or
1016 if (mf1.flags(fn) != mf2.flags(fn) or
1022 (mf1[fn] != mf2[fn] and
1017 (mf1[fn] != mf2[fn] and
1023 (mf2[fn] or ctx1[fn].cmp(ctx2[fn].data())))):
1018 (mf2[fn] or ctx1[fn].cmp(ctx2[fn].data())))):
1024 modified.append(fn)
1019 modified.append(fn)
1025 elif listclean:
1020 elif listclean:
1026 clean.append(fn)
1021 clean.append(fn)
1027 del mf1[fn]
1022 del mf1[fn]
1028 else:
1023 else:
1029 added.append(fn)
1024 added.append(fn)
1030 removed = mf1.keys()
1025 removed = mf1.keys()
1031
1026
1032 r = modified, added, removed, deleted, unknown, ignored, clean
1027 r = modified, added, removed, deleted, unknown, ignored, clean
1033 [l.sort() for l in r]
1028 [l.sort() for l in r]
1034 return r
1029 return r
1035
1030
1036 def add(self, list):
1031 def add(self, list):
1037 wlock = self.wlock()
1032 wlock = self.wlock()
1038 try:
1033 try:
1039 rejected = []
1034 rejected = []
1040 for f in list:
1035 for f in list:
1041 p = self.wjoin(f)
1036 p = self.wjoin(f)
1042 try:
1037 try:
1043 st = os.lstat(p)
1038 st = os.lstat(p)
1044 except:
1039 except:
1045 self.ui.warn(_("%s does not exist!\n") % f)
1040 self.ui.warn(_("%s does not exist!\n") % f)
1046 rejected.append(f)
1041 rejected.append(f)
1047 continue
1042 continue
1048 if st.st_size > 10000000:
1043 if st.st_size > 10000000:
1049 self.ui.warn(_("%s: files over 10MB may cause memory and"
1044 self.ui.warn(_("%s: files over 10MB may cause memory and"
1050 " performance problems\n"
1045 " performance problems\n"
1051 "(use 'hg revert %s' to unadd the file)\n")
1046 "(use 'hg revert %s' to unadd the file)\n")
1052 % (f, f))
1047 % (f, f))
1053 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1048 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1054 self.ui.warn(_("%s not added: only files and symlinks "
1049 self.ui.warn(_("%s not added: only files and symlinks "
1055 "supported currently\n") % f)
1050 "supported currently\n") % f)
1056 rejected.append(p)
1051 rejected.append(p)
1057 elif self.dirstate[f] in 'amn':
1052 elif self.dirstate[f] in 'amn':
1058 self.ui.warn(_("%s already tracked!\n") % f)
1053 self.ui.warn(_("%s already tracked!\n") % f)
1059 elif self.dirstate[f] == 'r':
1054 elif self.dirstate[f] == 'r':
1060 self.dirstate.normallookup(f)
1055 self.dirstate.normallookup(f)
1061 else:
1056 else:
1062 self.dirstate.add(f)
1057 self.dirstate.add(f)
1063 return rejected
1058 return rejected
1064 finally:
1059 finally:
1065 wlock.release()
1060 wlock.release()
1066
1061
1067 def forget(self, list):
1062 def forget(self, list):
1068 wlock = self.wlock()
1063 wlock = self.wlock()
1069 try:
1064 try:
1070 for f in list:
1065 for f in list:
1071 if self.dirstate[f] != 'a':
1066 if self.dirstate[f] != 'a':
1072 self.ui.warn(_("%s not added!\n") % f)
1067 self.ui.warn(_("%s not added!\n") % f)
1073 else:
1068 else:
1074 self.dirstate.forget(f)
1069 self.dirstate.forget(f)
1075 finally:
1070 finally:
1076 wlock.release()
1071 wlock.release()
1077
1072
1078 def remove(self, list, unlink=False):
1073 def remove(self, list, unlink=False):
1079 wlock = None
1074 wlock = None
1080 try:
1075 try:
1081 if unlink:
1076 if unlink:
1082 for f in list:
1077 for f in list:
1083 try:
1078 try:
1084 util.unlink(self.wjoin(f))
1079 util.unlink(self.wjoin(f))
1085 except OSError, inst:
1080 except OSError, inst:
1086 if inst.errno != errno.ENOENT:
1081 if inst.errno != errno.ENOENT:
1087 raise
1082 raise
1088 wlock = self.wlock()
1083 wlock = self.wlock()
1089 for f in list:
1084 for f in list:
1090 if unlink and os.path.exists(self.wjoin(f)):
1085 if unlink and os.path.exists(self.wjoin(f)):
1091 self.ui.warn(_("%s still exists!\n") % f)
1086 self.ui.warn(_("%s still exists!\n") % f)
1092 elif self.dirstate[f] == 'a':
1087 elif self.dirstate[f] == 'a':
1093 self.dirstate.forget(f)
1088 self.dirstate.forget(f)
1094 elif f not in self.dirstate:
1089 elif f not in self.dirstate:
1095 self.ui.warn(_("%s not tracked!\n") % f)
1090 self.ui.warn(_("%s not tracked!\n") % f)
1096 else:
1091 else:
1097 self.dirstate.remove(f)
1092 self.dirstate.remove(f)
1098 finally:
1093 finally:
1099 release(wlock)
1094 release(wlock)
1100
1095
1101 def undelete(self, list):
1096 def undelete(self, list):
1102 manifests = [self.manifest.read(self.changelog.read(p)[0])
1097 manifests = [self.manifest.read(self.changelog.read(p)[0])
1103 for p in self.dirstate.parents() if p != nullid]
1098 for p in self.dirstate.parents() if p != nullid]
1104 wlock = self.wlock()
1099 wlock = self.wlock()
1105 try:
1100 try:
1106 for f in list:
1101 for f in list:
1107 if self.dirstate[f] != 'r':
1102 if self.dirstate[f] != 'r':
1108 self.ui.warn(_("%s not removed!\n") % f)
1103 self.ui.warn(_("%s not removed!\n") % f)
1109 else:
1104 else:
1110 m = f in manifests[0] and manifests[0] or manifests[1]
1105 m = f in manifests[0] and manifests[0] or manifests[1]
1111 t = self.file(f).read(m[f])
1106 t = self.file(f).read(m[f])
1112 self.wwrite(f, t, m.flags(f))
1107 self.wwrite(f, t, m.flags(f))
1113 self.dirstate.normal(f)
1108 self.dirstate.normal(f)
1114 finally:
1109 finally:
1115 wlock.release()
1110 wlock.release()
1116
1111
1117 def copy(self, source, dest):
1112 def copy(self, source, dest):
1118 p = self.wjoin(dest)
1113 p = self.wjoin(dest)
1119 if not (os.path.exists(p) or os.path.islink(p)):
1114 if not (os.path.exists(p) or os.path.islink(p)):
1120 self.ui.warn(_("%s does not exist!\n") % dest)
1115 self.ui.warn(_("%s does not exist!\n") % dest)
1121 elif not (os.path.isfile(p) or os.path.islink(p)):
1116 elif not (os.path.isfile(p) or os.path.islink(p)):
1122 self.ui.warn(_("copy failed: %s is not a file or a "
1117 self.ui.warn(_("copy failed: %s is not a file or a "
1123 "symbolic link\n") % dest)
1118 "symbolic link\n") % dest)
1124 else:
1119 else:
1125 wlock = self.wlock()
1120 wlock = self.wlock()
1126 try:
1121 try:
1127 if self.dirstate[dest] in '?r':
1122 if self.dirstate[dest] in '?r':
1128 self.dirstate.add(dest)
1123 self.dirstate.add(dest)
1129 self.dirstate.copy(source, dest)
1124 self.dirstate.copy(source, dest)
1130 finally:
1125 finally:
1131 wlock.release()
1126 wlock.release()
1132
1127
1133 def heads(self, start=None, closed=True):
1128 def heads(self, start=None, closed=True):
1134 heads = self.changelog.heads(start)
1129 heads = self.changelog.heads(start)
1135 def display(head):
1130 def display(head):
1136 if closed:
1131 if closed:
1137 return True
1132 return True
1138 extras = self.changelog.read(head)[5]
1133 extras = self.changelog.read(head)[5]
1139 return ('close' not in extras)
1134 return ('close' not in extras)
1140 # sort the output in rev descending order
1135 # sort the output in rev descending order
1141 heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
1136 heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
1142 return [n for (r, n) in sorted(heads)]
1137 return [n for (r, n) in sorted(heads)]
1143
1138
1144 def branchheads(self, branch=None, start=None, closed=True):
1139 def branchheads(self, branch=None, start=None, closed=True):
1145 if branch is None:
1140 if branch is None:
1146 branch = self[None].branch()
1141 branch = self[None].branch()
1147 branches = self._branchheads()
1142 branches = self._branchheads()
1148 if branch not in branches:
1143 if branch not in branches:
1149 return []
1144 return []
1150 bheads = branches[branch]
1145 bheads = branches[branch]
1151 # the cache returns heads ordered lowest to highest
1146 # the cache returns heads ordered lowest to highest
1152 bheads.reverse()
1147 bheads.reverse()
1153 if start is not None:
1148 if start is not None:
1154 # filter out the heads that cannot be reached from startrev
1149 # filter out the heads that cannot be reached from startrev
1155 bheads = self.changelog.nodesbetween([start], bheads)[2]
1150 bheads = self.changelog.nodesbetween([start], bheads)[2]
1156 if not closed:
1151 if not closed:
1157 bheads = [h for h in bheads if
1152 bheads = [h for h in bheads if
1158 ('close' not in self.changelog.read(h)[5])]
1153 ('close' not in self.changelog.read(h)[5])]
1159 return bheads
1154 return bheads
1160
1155
1161 def branches(self, nodes):
1156 def branches(self, nodes):
1162 if not nodes:
1157 if not nodes:
1163 nodes = [self.changelog.tip()]
1158 nodes = [self.changelog.tip()]
1164 b = []
1159 b = []
1165 for n in nodes:
1160 for n in nodes:
1166 t = n
1161 t = n
1167 while 1:
1162 while 1:
1168 p = self.changelog.parents(n)
1163 p = self.changelog.parents(n)
1169 if p[1] != nullid or p[0] == nullid:
1164 if p[1] != nullid or p[0] == nullid:
1170 b.append((t, n, p[0], p[1]))
1165 b.append((t, n, p[0], p[1]))
1171 break
1166 break
1172 n = p[0]
1167 n = p[0]
1173 return b
1168 return b
1174
1169
1175 def between(self, pairs):
1170 def between(self, pairs):
1176 r = []
1171 r = []
1177
1172
1178 for top, bottom in pairs:
1173 for top, bottom in pairs:
1179 n, l, i = top, [], 0
1174 n, l, i = top, [], 0
1180 f = 1
1175 f = 1
1181
1176
1182 while n != bottom and n != nullid:
1177 while n != bottom and n != nullid:
1183 p = self.changelog.parents(n)[0]
1178 p = self.changelog.parents(n)[0]
1184 if i == f:
1179 if i == f:
1185 l.append(n)
1180 l.append(n)
1186 f = f * 2
1181 f = f * 2
1187 n = p
1182 n = p
1188 i += 1
1183 i += 1
1189
1184
1190 r.append(l)
1185 r.append(l)
1191
1186
1192 return r
1187 return r
1193
1188
1194 def findincoming(self, remote, base=None, heads=None, force=False):
1189 def findincoming(self, remote, base=None, heads=None, force=False):
1195 """Return list of roots of the subsets of missing nodes from remote
1190 """Return list of roots of the subsets of missing nodes from remote
1196
1191
1197 If base dict is specified, assume that these nodes and their parents
1192 If base dict is specified, assume that these nodes and their parents
1198 exist on the remote side and that no child of a node of base exists
1193 exist on the remote side and that no child of a node of base exists
1199 in both remote and self.
1194 in both remote and self.
1200 Furthermore base will be updated to include the nodes that exists
1195 Furthermore base will be updated to include the nodes that exists
1201 in self and remote but no children exists in self and remote.
1196 in self and remote but no children exists in self and remote.
1202 If a list of heads is specified, return only nodes which are heads
1197 If a list of heads is specified, return only nodes which are heads
1203 or ancestors of these heads.
1198 or ancestors of these heads.
1204
1199
1205 All the ancestors of base are in self and in remote.
1200 All the ancestors of base are in self and in remote.
1206 All the descendants of the list returned are missing in self.
1201 All the descendants of the list returned are missing in self.
1207 (and so we know that the rest of the nodes are missing in remote, see
1202 (and so we know that the rest of the nodes are missing in remote, see
1208 outgoing)
1203 outgoing)
1209 """
1204 """
1210 return self.findcommonincoming(remote, base, heads, force)[1]
1205 return self.findcommonincoming(remote, base, heads, force)[1]
1211
1206
1212 def findcommonincoming(self, remote, base=None, heads=None, force=False):
1207 def findcommonincoming(self, remote, base=None, heads=None, force=False):
1213 """Return a tuple (common, missing roots, heads) used to identify
1208 """Return a tuple (common, missing roots, heads) used to identify
1214 missing nodes from remote.
1209 missing nodes from remote.
1215
1210
1216 If base dict is specified, assume that these nodes and their parents
1211 If base dict is specified, assume that these nodes and their parents
1217 exist on the remote side and that no child of a node of base exists
1212 exist on the remote side and that no child of a node of base exists
1218 in both remote and self.
1213 in both remote and self.
1219 Furthermore base will be updated to include the nodes that exists
1214 Furthermore base will be updated to include the nodes that exists
1220 in self and remote but no children exists in self and remote.
1215 in self and remote but no children exists in self and remote.
1221 If a list of heads is specified, return only nodes which are heads
1216 If a list of heads is specified, return only nodes which are heads
1222 or ancestors of these heads.
1217 or ancestors of these heads.
1223
1218
1224 All the ancestors of base are in self and in remote.
1219 All the ancestors of base are in self and in remote.
1225 """
1220 """
1226 m = self.changelog.nodemap
1221 m = self.changelog.nodemap
1227 search = []
1222 search = []
1228 fetch = set()
1223 fetch = set()
1229 seen = set()
1224 seen = set()
1230 seenbranch = set()
1225 seenbranch = set()
1231 if base == None:
1226 if base == None:
1232 base = {}
1227 base = {}
1233
1228
1234 if not heads:
1229 if not heads:
1235 heads = remote.heads()
1230 heads = remote.heads()
1236
1231
1237 if self.changelog.tip() == nullid:
1232 if self.changelog.tip() == nullid:
1238 base[nullid] = 1
1233 base[nullid] = 1
1239 if heads != [nullid]:
1234 if heads != [nullid]:
1240 return [nullid], [nullid], list(heads)
1235 return [nullid], [nullid], list(heads)
1241 return [nullid], [], []
1236 return [nullid], [], []
1242
1237
1243 # assume we're closer to the tip than the root
1238 # assume we're closer to the tip than the root
1244 # and start by examining the heads
1239 # and start by examining the heads
1245 self.ui.status(_("searching for changes\n"))
1240 self.ui.status(_("searching for changes\n"))
1246
1241
1247 unknown = []
1242 unknown = []
1248 for h in heads:
1243 for h in heads:
1249 if h not in m:
1244 if h not in m:
1250 unknown.append(h)
1245 unknown.append(h)
1251 else:
1246 else:
1252 base[h] = 1
1247 base[h] = 1
1253
1248
1254 heads = unknown
1249 heads = unknown
1255 if not unknown:
1250 if not unknown:
1256 return base.keys(), [], []
1251 return base.keys(), [], []
1257
1252
1258 req = set(unknown)
1253 req = set(unknown)
1259 reqcnt = 0
1254 reqcnt = 0
1260
1255
1261 # search through remote branches
1256 # search through remote branches
1262 # a 'branch' here is a linear segment of history, with four parts:
1257 # a 'branch' here is a linear segment of history, with four parts:
1263 # head, root, first parent, second parent
1258 # head, root, first parent, second parent
1264 # (a branch always has two parents (or none) by definition)
1259 # (a branch always has two parents (or none) by definition)
1265 unknown = remote.branches(unknown)
1260 unknown = remote.branches(unknown)
1266 while unknown:
1261 while unknown:
1267 r = []
1262 r = []
1268 while unknown:
1263 while unknown:
1269 n = unknown.pop(0)
1264 n = unknown.pop(0)
1270 if n[0] in seen:
1265 if n[0] in seen:
1271 continue
1266 continue
1272
1267
1273 self.ui.debug(_("examining %s:%s\n")
1268 self.ui.debug(_("examining %s:%s\n")
1274 % (short(n[0]), short(n[1])))
1269 % (short(n[0]), short(n[1])))
1275 if n[0] == nullid: # found the end of the branch
1270 if n[0] == nullid: # found the end of the branch
1276 pass
1271 pass
1277 elif n in seenbranch:
1272 elif n in seenbranch:
1278 self.ui.debug(_("branch already found\n"))
1273 self.ui.debug(_("branch already found\n"))
1279 continue
1274 continue
1280 elif n[1] and n[1] in m: # do we know the base?
1275 elif n[1] and n[1] in m: # do we know the base?
1281 self.ui.debug(_("found incomplete branch %s:%s\n")
1276 self.ui.debug(_("found incomplete branch %s:%s\n")
1282 % (short(n[0]), short(n[1])))
1277 % (short(n[0]), short(n[1])))
1283 search.append(n[0:2]) # schedule branch range for scanning
1278 search.append(n[0:2]) # schedule branch range for scanning
1284 seenbranch.add(n)
1279 seenbranch.add(n)
1285 else:
1280 else:
1286 if n[1] not in seen and n[1] not in fetch:
1281 if n[1] not in seen and n[1] not in fetch:
1287 if n[2] in m and n[3] in m:
1282 if n[2] in m and n[3] in m:
1288 self.ui.debug(_("found new changeset %s\n") %
1283 self.ui.debug(_("found new changeset %s\n") %
1289 short(n[1]))
1284 short(n[1]))
1290 fetch.add(n[1]) # earliest unknown
1285 fetch.add(n[1]) # earliest unknown
1291 for p in n[2:4]:
1286 for p in n[2:4]:
1292 if p in m:
1287 if p in m:
1293 base[p] = 1 # latest known
1288 base[p] = 1 # latest known
1294
1289
1295 for p in n[2:4]:
1290 for p in n[2:4]:
1296 if p not in req and p not in m:
1291 if p not in req and p not in m:
1297 r.append(p)
1292 r.append(p)
1298 req.add(p)
1293 req.add(p)
1299 seen.add(n[0])
1294 seen.add(n[0])
1300
1295
1301 if r:
1296 if r:
1302 reqcnt += 1
1297 reqcnt += 1
1303 self.ui.debug(_("request %d: %s\n") %
1298 self.ui.debug(_("request %d: %s\n") %
1304 (reqcnt, " ".join(map(short, r))))
1299 (reqcnt, " ".join(map(short, r))))
1305 for p in xrange(0, len(r), 10):
1300 for p in xrange(0, len(r), 10):
1306 for b in remote.branches(r[p:p+10]):
1301 for b in remote.branches(r[p:p+10]):
1307 self.ui.debug(_("received %s:%s\n") %
1302 self.ui.debug(_("received %s:%s\n") %
1308 (short(b[0]), short(b[1])))
1303 (short(b[0]), short(b[1])))
1309 unknown.append(b)
1304 unknown.append(b)
1310
1305
1311 # do binary search on the branches we found
1306 # do binary search on the branches we found
1312 while search:
1307 while search:
1313 newsearch = []
1308 newsearch = []
1314 reqcnt += 1
1309 reqcnt += 1
1315 for n, l in zip(search, remote.between(search)):
1310 for n, l in zip(search, remote.between(search)):
1316 l.append(n[1])
1311 l.append(n[1])
1317 p = n[0]
1312 p = n[0]
1318 f = 1
1313 f = 1
1319 for i in l:
1314 for i in l:
1320 self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i)))
1315 self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i)))
1321 if i in m:
1316 if i in m:
1322 if f <= 2:
1317 if f <= 2:
1323 self.ui.debug(_("found new branch changeset %s\n") %
1318 self.ui.debug(_("found new branch changeset %s\n") %
1324 short(p))
1319 short(p))
1325 fetch.add(p)
1320 fetch.add(p)
1326 base[i] = 1
1321 base[i] = 1
1327 else:
1322 else:
1328 self.ui.debug(_("narrowed branch search to %s:%s\n")
1323 self.ui.debug(_("narrowed branch search to %s:%s\n")
1329 % (short(p), short(i)))
1324 % (short(p), short(i)))
1330 newsearch.append((p, i))
1325 newsearch.append((p, i))
1331 break
1326 break
1332 p, f = i, f * 2
1327 p, f = i, f * 2
1333 search = newsearch
1328 search = newsearch
1334
1329
1335 # sanity check our fetch list
1330 # sanity check our fetch list
1336 for f in fetch:
1331 for f in fetch:
1337 if f in m:
1332 if f in m:
1338 raise error.RepoError(_("already have changeset ")
1333 raise error.RepoError(_("already have changeset ")
1339 + short(f[:4]))
1334 + short(f[:4]))
1340
1335
1341 if base.keys() == [nullid]:
1336 if base.keys() == [nullid]:
1342 if force:
1337 if force:
1343 self.ui.warn(_("warning: repository is unrelated\n"))
1338 self.ui.warn(_("warning: repository is unrelated\n"))
1344 else:
1339 else:
1345 raise util.Abort(_("repository is unrelated"))
1340 raise util.Abort(_("repository is unrelated"))
1346
1341
1347 self.ui.debug(_("found new changesets starting at ") +
1342 self.ui.debug(_("found new changesets starting at ") +
1348 " ".join([short(f) for f in fetch]) + "\n")
1343 " ".join([short(f) for f in fetch]) + "\n")
1349
1344
1350 self.ui.debug(_("%d total queries\n") % reqcnt)
1345 self.ui.debug(_("%d total queries\n") % reqcnt)
1351
1346
1352 return base.keys(), list(fetch), heads
1347 return base.keys(), list(fetch), heads
1353
1348
1354 def findoutgoing(self, remote, base=None, heads=None, force=False):
1349 def findoutgoing(self, remote, base=None, heads=None, force=False):
1355 """Return list of nodes that are roots of subsets not in remote
1350 """Return list of nodes that are roots of subsets not in remote
1356
1351
1357 If base dict is specified, assume that these nodes and their parents
1352 If base dict is specified, assume that these nodes and their parents
1358 exist on the remote side.
1353 exist on the remote side.
1359 If a list of heads is specified, return only nodes which are heads
1354 If a list of heads is specified, return only nodes which are heads
1360 or ancestors of these heads, and return a second element which
1355 or ancestors of these heads, and return a second element which
1361 contains all remote heads which get new children.
1356 contains all remote heads which get new children.
1362 """
1357 """
1363 if base == None:
1358 if base == None:
1364 base = {}
1359 base = {}
1365 self.findincoming(remote, base, heads, force=force)
1360 self.findincoming(remote, base, heads, force=force)
1366
1361
1367 self.ui.debug(_("common changesets up to ")
1362 self.ui.debug(_("common changesets up to ")
1368 + " ".join(map(short, base.keys())) + "\n")
1363 + " ".join(map(short, base.keys())) + "\n")
1369
1364
1370 remain = set(self.changelog.nodemap)
1365 remain = set(self.changelog.nodemap)
1371
1366
1372 # prune everything remote has from the tree
1367 # prune everything remote has from the tree
1373 remain.remove(nullid)
1368 remain.remove(nullid)
1374 remove = base.keys()
1369 remove = base.keys()
1375 while remove:
1370 while remove:
1376 n = remove.pop(0)
1371 n = remove.pop(0)
1377 if n in remain:
1372 if n in remain:
1378 remain.remove(n)
1373 remain.remove(n)
1379 for p in self.changelog.parents(n):
1374 for p in self.changelog.parents(n):
1380 remove.append(p)
1375 remove.append(p)
1381
1376
1382 # find every node whose parents have been pruned
1377 # find every node whose parents have been pruned
1383 subset = []
1378 subset = []
1384 # find every remote head that will get new children
1379 # find every remote head that will get new children
1385 updated_heads = set()
1380 updated_heads = set()
1386 for n in remain:
1381 for n in remain:
1387 p1, p2 = self.changelog.parents(n)
1382 p1, p2 = self.changelog.parents(n)
1388 if p1 not in remain and p2 not in remain:
1383 if p1 not in remain and p2 not in remain:
1389 subset.append(n)
1384 subset.append(n)
1390 if heads:
1385 if heads:
1391 if p1 in heads:
1386 if p1 in heads:
1392 updated_heads.add(p1)
1387 updated_heads.add(p1)
1393 if p2 in heads:
1388 if p2 in heads:
1394 updated_heads.add(p2)
1389 updated_heads.add(p2)
1395
1390
1396 # this is the set of all roots we have to push
1391 # this is the set of all roots we have to push
1397 if heads:
1392 if heads:
1398 return subset, list(updated_heads)
1393 return subset, list(updated_heads)
1399 else:
1394 else:
1400 return subset
1395 return subset
1401
1396
1402 def pull(self, remote, heads=None, force=False):
1397 def pull(self, remote, heads=None, force=False):
1403 lock = self.lock()
1398 lock = self.lock()
1404 try:
1399 try:
1405 common, fetch, rheads = self.findcommonincoming(remote, heads=heads,
1400 common, fetch, rheads = self.findcommonincoming(remote, heads=heads,
1406 force=force)
1401 force=force)
1407 if fetch == [nullid]:
1402 if fetch == [nullid]:
1408 self.ui.status(_("requesting all changes\n"))
1403 self.ui.status(_("requesting all changes\n"))
1409
1404
1410 if not fetch:
1405 if not fetch:
1411 self.ui.status(_("no changes found\n"))
1406 self.ui.status(_("no changes found\n"))
1412 return 0
1407 return 0
1413
1408
1414 if heads is None and remote.capable('changegroupsubset'):
1409 if heads is None and remote.capable('changegroupsubset'):
1415 heads = rheads
1410 heads = rheads
1416
1411
1417 if heads is None:
1412 if heads is None:
1418 cg = remote.changegroup(fetch, 'pull')
1413 cg = remote.changegroup(fetch, 'pull')
1419 else:
1414 else:
1420 if not remote.capable('changegroupsubset'):
1415 if not remote.capable('changegroupsubset'):
1421 raise util.Abort(_("Partial pull cannot be done because other repository doesn't support changegroupsubset."))
1416 raise util.Abort(_("Partial pull cannot be done because other repository doesn't support changegroupsubset."))
1422 cg = remote.changegroupsubset(fetch, heads, 'pull')
1417 cg = remote.changegroupsubset(fetch, heads, 'pull')
1423 return self.addchangegroup(cg, 'pull', remote.url())
1418 return self.addchangegroup(cg, 'pull', remote.url())
1424 finally:
1419 finally:
1425 lock.release()
1420 lock.release()
1426
1421
1427 def push(self, remote, force=False, revs=None):
1422 def push(self, remote, force=False, revs=None):
1428 # there are two ways to push to remote repo:
1423 # there are two ways to push to remote repo:
1429 #
1424 #
1430 # addchangegroup assumes local user can lock remote
1425 # addchangegroup assumes local user can lock remote
1431 # repo (local filesystem, old ssh servers).
1426 # repo (local filesystem, old ssh servers).
1432 #
1427 #
1433 # unbundle assumes local user cannot lock remote repo (new ssh
1428 # unbundle assumes local user cannot lock remote repo (new ssh
1434 # servers, http servers).
1429 # servers, http servers).
1435
1430
1436 if remote.capable('unbundle'):
1431 if remote.capable('unbundle'):
1437 return self.push_unbundle(remote, force, revs)
1432 return self.push_unbundle(remote, force, revs)
1438 return self.push_addchangegroup(remote, force, revs)
1433 return self.push_addchangegroup(remote, force, revs)
1439
1434
1440 def prepush(self, remote, force, revs):
1435 def prepush(self, remote, force, revs):
1441 common = {}
1436 common = {}
1442 remote_heads = remote.heads()
1437 remote_heads = remote.heads()
1443 inc = self.findincoming(remote, common, remote_heads, force=force)
1438 inc = self.findincoming(remote, common, remote_heads, force=force)
1444
1439
1445 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1440 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1446 if revs is not None:
1441 if revs is not None:
1447 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1442 msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
1448 else:
1443 else:
1449 bases, heads = update, self.changelog.heads()
1444 bases, heads = update, self.changelog.heads()
1450
1445
1451 if not bases:
1446 if not bases:
1452 self.ui.status(_("no changes found\n"))
1447 self.ui.status(_("no changes found\n"))
1453 return None, 1
1448 return None, 1
1454 elif not force:
1449 elif not force:
1455 # check if we're creating new remote heads
1450 # check if we're creating new remote heads
1456 # to be a remote head after push, node must be either
1451 # to be a remote head after push, node must be either
1457 # - unknown locally
1452 # - unknown locally
1458 # - a local outgoing head descended from update
1453 # - a local outgoing head descended from update
1459 # - a remote head that's known locally and not
1454 # - a remote head that's known locally and not
1460 # ancestral to an outgoing head
1455 # ancestral to an outgoing head
1461
1456
1462 warn = 0
1457 warn = 0
1463
1458
1464 if remote_heads == [nullid]:
1459 if remote_heads == [nullid]:
1465 warn = 0
1460 warn = 0
1466 elif not revs and len(heads) > len(remote_heads):
1461 elif not revs and len(heads) > len(remote_heads):
1467 warn = 1
1462 warn = 1
1468 else:
1463 else:
1469 newheads = list(heads)
1464 newheads = list(heads)
1470 for r in remote_heads:
1465 for r in remote_heads:
1471 if r in self.changelog.nodemap:
1466 if r in self.changelog.nodemap:
1472 desc = self.changelog.heads(r, heads)
1467 desc = self.changelog.heads(r, heads)
1473 l = [h for h in heads if h in desc]
1468 l = [h for h in heads if h in desc]
1474 if not l:
1469 if not l:
1475 newheads.append(r)
1470 newheads.append(r)
1476 else:
1471 else:
1477 newheads.append(r)
1472 newheads.append(r)
1478 if len(newheads) > len(remote_heads):
1473 if len(newheads) > len(remote_heads):
1479 warn = 1
1474 warn = 1
1480
1475
1481 if warn:
1476 if warn:
1482 self.ui.warn(_("abort: push creates new remote heads!\n"))
1477 self.ui.warn(_("abort: push creates new remote heads!\n"))
1483 self.ui.status(_("(did you forget to merge?"
1478 self.ui.status(_("(did you forget to merge?"
1484 " use push -f to force)\n"))
1479 " use push -f to force)\n"))
1485 return None, 0
1480 return None, 0
1486 elif inc:
1481 elif inc:
1487 self.ui.warn(_("note: unsynced remote changes!\n"))
1482 self.ui.warn(_("note: unsynced remote changes!\n"))
1488
1483
1489
1484
1490 if revs is None:
1485 if revs is None:
1491 # use the fast path, no race possible on push
1486 # use the fast path, no race possible on push
1492 cg = self._changegroup(common.keys(), 'push')
1487 cg = self._changegroup(common.keys(), 'push')
1493 else:
1488 else:
1494 cg = self.changegroupsubset(update, revs, 'push')
1489 cg = self.changegroupsubset(update, revs, 'push')
1495 return cg, remote_heads
1490 return cg, remote_heads
1496
1491
1497 def push_addchangegroup(self, remote, force, revs):
1492 def push_addchangegroup(self, remote, force, revs):
1498 lock = remote.lock()
1493 lock = remote.lock()
1499 try:
1494 try:
1500 ret = self.prepush(remote, force, revs)
1495 ret = self.prepush(remote, force, revs)
1501 if ret[0] is not None:
1496 if ret[0] is not None:
1502 cg, remote_heads = ret
1497 cg, remote_heads = ret
1503 return remote.addchangegroup(cg, 'push', self.url())
1498 return remote.addchangegroup(cg, 'push', self.url())
1504 return ret[1]
1499 return ret[1]
1505 finally:
1500 finally:
1506 lock.release()
1501 lock.release()
1507
1502
1508 def push_unbundle(self, remote, force, revs):
1503 def push_unbundle(self, remote, force, revs):
1509 # local repo finds heads on server, finds out what revs it
1504 # local repo finds heads on server, finds out what revs it
1510 # must push. once revs transferred, if server finds it has
1505 # must push. once revs transferred, if server finds it has
1511 # different heads (someone else won commit/push race), server
1506 # different heads (someone else won commit/push race), server
1512 # aborts.
1507 # aborts.
1513
1508
1514 ret = self.prepush(remote, force, revs)
1509 ret = self.prepush(remote, force, revs)
1515 if ret[0] is not None:
1510 if ret[0] is not None:
1516 cg, remote_heads = ret
1511 cg, remote_heads = ret
1517 if force: remote_heads = ['force']
1512 if force: remote_heads = ['force']
1518 return remote.unbundle(cg, remote_heads, 'push')
1513 return remote.unbundle(cg, remote_heads, 'push')
1519 return ret[1]
1514 return ret[1]
1520
1515
1521 def changegroupinfo(self, nodes, source):
1516 def changegroupinfo(self, nodes, source):
1522 if self.ui.verbose or source == 'bundle':
1517 if self.ui.verbose or source == 'bundle':
1523 self.ui.status(_("%d changesets found\n") % len(nodes))
1518 self.ui.status(_("%d changesets found\n") % len(nodes))
1524 if self.ui.debugflag:
1519 if self.ui.debugflag:
1525 self.ui.debug(_("list of changesets:\n"))
1520 self.ui.debug(_("list of changesets:\n"))
1526 for node in nodes:
1521 for node in nodes:
1527 self.ui.debug("%s\n" % hex(node))
1522 self.ui.debug("%s\n" % hex(node))
1528
1523
1529 def changegroupsubset(self, bases, heads, source, extranodes=None):
1524 def changegroupsubset(self, bases, heads, source, extranodes=None):
1530 """This function generates a changegroup consisting of all the nodes
1525 """This function generates a changegroup consisting of all the nodes
1531 that are descendents of any of the bases, and ancestors of any of
1526 that are descendents of any of the bases, and ancestors of any of
1532 the heads.
1527 the heads.
1533
1528
1534 It is fairly complex as determining which filenodes and which
1529 It is fairly complex as determining which filenodes and which
1535 manifest nodes need to be included for the changeset to be complete
1530 manifest nodes need to be included for the changeset to be complete
1536 is non-trivial.
1531 is non-trivial.
1537
1532
1538 Another wrinkle is doing the reverse, figuring out which changeset in
1533 Another wrinkle is doing the reverse, figuring out which changeset in
1539 the changegroup a particular filenode or manifestnode belongs to.
1534 the changegroup a particular filenode or manifestnode belongs to.
1540
1535
1541 The caller can specify some nodes that must be included in the
1536 The caller can specify some nodes that must be included in the
1542 changegroup using the extranodes argument. It should be a dict
1537 changegroup using the extranodes argument. It should be a dict
1543 where the keys are the filenames (or 1 for the manifest), and the
1538 where the keys are the filenames (or 1 for the manifest), and the
1544 values are lists of (node, linknode) tuples, where node is a wanted
1539 values are lists of (node, linknode) tuples, where node is a wanted
1545 node and linknode is the changelog node that should be transmitted as
1540 node and linknode is the changelog node that should be transmitted as
1546 the linkrev.
1541 the linkrev.
1547 """
1542 """
1548
1543
1549 if extranodes is None:
1544 if extranodes is None:
1550 # can we go through the fast path ?
1545 # can we go through the fast path ?
1551 heads.sort()
1546 heads.sort()
1552 allheads = self.heads()
1547 allheads = self.heads()
1553 allheads.sort()
1548 allheads.sort()
1554 if heads == allheads:
1549 if heads == allheads:
1555 common = []
1550 common = []
1556 # parents of bases are known from both sides
1551 # parents of bases are known from both sides
1557 for n in bases:
1552 for n in bases:
1558 for p in self.changelog.parents(n):
1553 for p in self.changelog.parents(n):
1559 if p != nullid:
1554 if p != nullid:
1560 common.append(p)
1555 common.append(p)
1561 return self._changegroup(common, source)
1556 return self._changegroup(common, source)
1562
1557
1563 self.hook('preoutgoing', throw=True, source=source)
1558 self.hook('preoutgoing', throw=True, source=source)
1564
1559
1565 # Set up some initial variables
1560 # Set up some initial variables
1566 # Make it easy to refer to self.changelog
1561 # Make it easy to refer to self.changelog
1567 cl = self.changelog
1562 cl = self.changelog
1568 # msng is short for missing - compute the list of changesets in this
1563 # msng is short for missing - compute the list of changesets in this
1569 # changegroup.
1564 # changegroup.
1570 msng_cl_lst, bases, heads = cl.nodesbetween(bases, heads)
1565 msng_cl_lst, bases, heads = cl.nodesbetween(bases, heads)
1571 self.changegroupinfo(msng_cl_lst, source)
1566 self.changegroupinfo(msng_cl_lst, source)
1572 # Some bases may turn out to be superfluous, and some heads may be
1567 # Some bases may turn out to be superfluous, and some heads may be
1573 # too. nodesbetween will return the minimal set of bases and heads
1568 # too. nodesbetween will return the minimal set of bases and heads
1574 # necessary to re-create the changegroup.
1569 # necessary to re-create the changegroup.
1575
1570
1576 # Known heads are the list of heads that it is assumed the recipient
1571 # Known heads are the list of heads that it is assumed the recipient
1577 # of this changegroup will know about.
1572 # of this changegroup will know about.
1578 knownheads = set()
1573 knownheads = set()
1579 # We assume that all parents of bases are known heads.
1574 # We assume that all parents of bases are known heads.
1580 for n in bases:
1575 for n in bases:
1581 knownheads.update(cl.parents(n))
1576 knownheads.update(cl.parents(n))
1582 knownheads.discard(nullid)
1577 knownheads.discard(nullid)
1583 knownheads = list(knownheads)
1578 knownheads = list(knownheads)
1584 if knownheads:
1579 if knownheads:
1585 # Now that we know what heads are known, we can compute which
1580 # Now that we know what heads are known, we can compute which
1586 # changesets are known. The recipient must know about all
1581 # changesets are known. The recipient must know about all
1587 # changesets required to reach the known heads from the null
1582 # changesets required to reach the known heads from the null
1588 # changeset.
1583 # changeset.
1589 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
1584 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
1590 junk = None
1585 junk = None
1591 # Transform the list into a set.
1586 # Transform the list into a set.
1592 has_cl_set = set(has_cl_set)
1587 has_cl_set = set(has_cl_set)
1593 else:
1588 else:
1594 # If there were no known heads, the recipient cannot be assumed to
1589 # If there were no known heads, the recipient cannot be assumed to
1595 # know about any changesets.
1590 # know about any changesets.
1596 has_cl_set = set()
1591 has_cl_set = set()
1597
1592
1598 # Make it easy to refer to self.manifest
1593 # Make it easy to refer to self.manifest
1599 mnfst = self.manifest
1594 mnfst = self.manifest
1600 # We don't know which manifests are missing yet
1595 # We don't know which manifests are missing yet
1601 msng_mnfst_set = {}
1596 msng_mnfst_set = {}
1602 # Nor do we know which filenodes are missing.
1597 # Nor do we know which filenodes are missing.
1603 msng_filenode_set = {}
1598 msng_filenode_set = {}
1604
1599
1605 junk = mnfst.index[len(mnfst) - 1] # Get around a bug in lazyindex
1600 junk = mnfst.index[len(mnfst) - 1] # Get around a bug in lazyindex
1606 junk = None
1601 junk = None
1607
1602
1608 # A changeset always belongs to itself, so the changenode lookup
1603 # A changeset always belongs to itself, so the changenode lookup
1609 # function for a changenode is identity.
1604 # function for a changenode is identity.
1610 def identity(x):
1605 def identity(x):
1611 return x
1606 return x
1612
1607
1613 # A function generating function. Sets up an environment for the
1608 # A function generating function. Sets up an environment for the
1614 # inner function.
1609 # inner function.
1615 def cmp_by_rev_func(revlog):
1610 def cmp_by_rev_func(revlog):
1616 # Compare two nodes by their revision number in the environment's
1611 # Compare two nodes by their revision number in the environment's
1617 # revision history. Since the revision number both represents the
1612 # revision history. Since the revision number both represents the
1618 # most efficient order to read the nodes in, and represents a
1613 # most efficient order to read the nodes in, and represents a
1619 # topological sorting of the nodes, this function is often useful.
1614 # topological sorting of the nodes, this function is often useful.
1620 def cmp_by_rev(a, b):
1615 def cmp_by_rev(a, b):
1621 return cmp(revlog.rev(a), revlog.rev(b))
1616 return cmp(revlog.rev(a), revlog.rev(b))
1622 return cmp_by_rev
1617 return cmp_by_rev
1623
1618
1624 # If we determine that a particular file or manifest node must be a
1619 # If we determine that a particular file or manifest node must be a
1625 # node that the recipient of the changegroup will already have, we can
1620 # node that the recipient of the changegroup will already have, we can
1626 # also assume the recipient will have all the parents. This function
1621 # also assume the recipient will have all the parents. This function
1627 # prunes them from the set of missing nodes.
1622 # prunes them from the set of missing nodes.
1628 def prune_parents(revlog, hasset, msngset):
1623 def prune_parents(revlog, hasset, msngset):
1629 haslst = list(hasset)
1624 haslst = list(hasset)
1630 haslst.sort(cmp_by_rev_func(revlog))
1625 haslst.sort(cmp_by_rev_func(revlog))
1631 for node in haslst:
1626 for node in haslst:
1632 parentlst = [p for p in revlog.parents(node) if p != nullid]
1627 parentlst = [p for p in revlog.parents(node) if p != nullid]
1633 while parentlst:
1628 while parentlst:
1634 n = parentlst.pop()
1629 n = parentlst.pop()
1635 if n not in hasset:
1630 if n not in hasset:
1636 hasset.add(n)
1631 hasset.add(n)
1637 p = [p for p in revlog.parents(n) if p != nullid]
1632 p = [p for p in revlog.parents(n) if p != nullid]
1638 parentlst.extend(p)
1633 parentlst.extend(p)
1639 for n in hasset:
1634 for n in hasset:
1640 msngset.pop(n, None)
1635 msngset.pop(n, None)
1641
1636
1642 # This is a function generating function used to set up an environment
1637 # This is a function generating function used to set up an environment
1643 # for the inner function to execute in.
1638 # for the inner function to execute in.
1644 def manifest_and_file_collector(changedfileset):
1639 def manifest_and_file_collector(changedfileset):
1645 # This is an information gathering function that gathers
1640 # This is an information gathering function that gathers
1646 # information from each changeset node that goes out as part of
1641 # information from each changeset node that goes out as part of
1647 # the changegroup. The information gathered is a list of which
1642 # the changegroup. The information gathered is a list of which
1648 # manifest nodes are potentially required (the recipient may
1643 # manifest nodes are potentially required (the recipient may
1649 # already have them) and total list of all files which were
1644 # already have them) and total list of all files which were
1650 # changed in any changeset in the changegroup.
1645 # changed in any changeset in the changegroup.
1651 #
1646 #
1652 # We also remember the first changenode we saw any manifest
1647 # We also remember the first changenode we saw any manifest
1653 # referenced by so we can later determine which changenode 'owns'
1648 # referenced by so we can later determine which changenode 'owns'
1654 # the manifest.
1649 # the manifest.
1655 def collect_manifests_and_files(clnode):
1650 def collect_manifests_and_files(clnode):
1656 c = cl.read(clnode)
1651 c = cl.read(clnode)
1657 for f in c[3]:
1652 for f in c[3]:
1658 # This is to make sure we only have one instance of each
1653 # This is to make sure we only have one instance of each
1659 # filename string for each filename.
1654 # filename string for each filename.
1660 changedfileset.setdefault(f, f)
1655 changedfileset.setdefault(f, f)
1661 msng_mnfst_set.setdefault(c[0], clnode)
1656 msng_mnfst_set.setdefault(c[0], clnode)
1662 return collect_manifests_and_files
1657 return collect_manifests_and_files
1663
1658
1664 # Figure out which manifest nodes (of the ones we think might be part
1659 # Figure out which manifest nodes (of the ones we think might be part
1665 # of the changegroup) the recipient must know about and remove them
1660 # of the changegroup) the recipient must know about and remove them
1666 # from the changegroup.
1661 # from the changegroup.
1667 def prune_manifests():
1662 def prune_manifests():
1668 has_mnfst_set = set()
1663 has_mnfst_set = set()
1669 for n in msng_mnfst_set:
1664 for n in msng_mnfst_set:
1670 # If a 'missing' manifest thinks it belongs to a changenode
1665 # If a 'missing' manifest thinks it belongs to a changenode
1671 # the recipient is assumed to have, obviously the recipient
1666 # the recipient is assumed to have, obviously the recipient
1672 # must have that manifest.
1667 # must have that manifest.
1673 linknode = cl.node(mnfst.linkrev(mnfst.rev(n)))
1668 linknode = cl.node(mnfst.linkrev(mnfst.rev(n)))
1674 if linknode in has_cl_set:
1669 if linknode in has_cl_set:
1675 has_mnfst_set.add(n)
1670 has_mnfst_set.add(n)
1676 prune_parents(mnfst, has_mnfst_set, msng_mnfst_set)
1671 prune_parents(mnfst, has_mnfst_set, msng_mnfst_set)
1677
1672
1678 # Use the information collected in collect_manifests_and_files to say
1673 # Use the information collected in collect_manifests_and_files to say
1679 # which changenode any manifestnode belongs to.
1674 # which changenode any manifestnode belongs to.
1680 def lookup_manifest_link(mnfstnode):
1675 def lookup_manifest_link(mnfstnode):
1681 return msng_mnfst_set[mnfstnode]
1676 return msng_mnfst_set[mnfstnode]
1682
1677
1683 # A function generating function that sets up the initial environment
1678 # A function generating function that sets up the initial environment
1684 # the inner function.
1679 # the inner function.
1685 def filenode_collector(changedfiles):
1680 def filenode_collector(changedfiles):
1686 next_rev = [0]
1681 next_rev = [0]
1687 # This gathers information from each manifestnode included in the
1682 # This gathers information from each manifestnode included in the
1688 # changegroup about which filenodes the manifest node references
1683 # changegroup about which filenodes the manifest node references
1689 # so we can include those in the changegroup too.
1684 # so we can include those in the changegroup too.
1690 #
1685 #
1691 # It also remembers which changenode each filenode belongs to. It
1686 # It also remembers which changenode each filenode belongs to. It
1692 # does this by assuming the a filenode belongs to the changenode
1687 # does this by assuming the a filenode belongs to the changenode
1693 # the first manifest that references it belongs to.
1688 # the first manifest that references it belongs to.
1694 def collect_msng_filenodes(mnfstnode):
1689 def collect_msng_filenodes(mnfstnode):
1695 r = mnfst.rev(mnfstnode)
1690 r = mnfst.rev(mnfstnode)
1696 if r == next_rev[0]:
1691 if r == next_rev[0]:
1697 # If the last rev we looked at was the one just previous,
1692 # If the last rev we looked at was the one just previous,
1698 # we only need to see a diff.
1693 # we only need to see a diff.
1699 deltamf = mnfst.readdelta(mnfstnode)
1694 deltamf = mnfst.readdelta(mnfstnode)
1700 # For each line in the delta
1695 # For each line in the delta
1701 for f, fnode in deltamf.iteritems():
1696 for f, fnode in deltamf.iteritems():
1702 f = changedfiles.get(f, None)
1697 f = changedfiles.get(f, None)
1703 # And if the file is in the list of files we care
1698 # And if the file is in the list of files we care
1704 # about.
1699 # about.
1705 if f is not None:
1700 if f is not None:
1706 # Get the changenode this manifest belongs to
1701 # Get the changenode this manifest belongs to
1707 clnode = msng_mnfst_set[mnfstnode]
1702 clnode = msng_mnfst_set[mnfstnode]
1708 # Create the set of filenodes for the file if
1703 # Create the set of filenodes for the file if
1709 # there isn't one already.
1704 # there isn't one already.
1710 ndset = msng_filenode_set.setdefault(f, {})
1705 ndset = msng_filenode_set.setdefault(f, {})
1711 # And set the filenode's changelog node to the
1706 # And set the filenode's changelog node to the
1712 # manifest's if it hasn't been set already.
1707 # manifest's if it hasn't been set already.
1713 ndset.setdefault(fnode, clnode)
1708 ndset.setdefault(fnode, clnode)
1714 else:
1709 else:
1715 # Otherwise we need a full manifest.
1710 # Otherwise we need a full manifest.
1716 m = mnfst.read(mnfstnode)
1711 m = mnfst.read(mnfstnode)
1717 # For every file in we care about.
1712 # For every file in we care about.
1718 for f in changedfiles:
1713 for f in changedfiles:
1719 fnode = m.get(f, None)
1714 fnode = m.get(f, None)
1720 # If it's in the manifest
1715 # If it's in the manifest
1721 if fnode is not None:
1716 if fnode is not None:
1722 # See comments above.
1717 # See comments above.
1723 clnode = msng_mnfst_set[mnfstnode]
1718 clnode = msng_mnfst_set[mnfstnode]
1724 ndset = msng_filenode_set.setdefault(f, {})
1719 ndset = msng_filenode_set.setdefault(f, {})
1725 ndset.setdefault(fnode, clnode)
1720 ndset.setdefault(fnode, clnode)
1726 # Remember the revision we hope to see next.
1721 # Remember the revision we hope to see next.
1727 next_rev[0] = r + 1
1722 next_rev[0] = r + 1
1728 return collect_msng_filenodes
1723 return collect_msng_filenodes
1729
1724
1730 # We have a list of filenodes we think we need for a file, lets remove
1725 # We have a list of filenodes we think we need for a file, lets remove
1731 # all those we know the recipient must have.
1726 # all those we know the recipient must have.
1732 def prune_filenodes(f, filerevlog):
1727 def prune_filenodes(f, filerevlog):
1733 msngset = msng_filenode_set[f]
1728 msngset = msng_filenode_set[f]
1734 hasset = set()
1729 hasset = set()
1735 # If a 'missing' filenode thinks it belongs to a changenode we
1730 # If a 'missing' filenode thinks it belongs to a changenode we
1736 # assume the recipient must have, then the recipient must have
1731 # assume the recipient must have, then the recipient must have
1737 # that filenode.
1732 # that filenode.
1738 for n in msngset:
1733 for n in msngset:
1739 clnode = cl.node(filerevlog.linkrev(filerevlog.rev(n)))
1734 clnode = cl.node(filerevlog.linkrev(filerevlog.rev(n)))
1740 if clnode in has_cl_set:
1735 if clnode in has_cl_set:
1741 hasset.add(n)
1736 hasset.add(n)
1742 prune_parents(filerevlog, hasset, msngset)
1737 prune_parents(filerevlog, hasset, msngset)
1743
1738
1744 # A function generator function that sets up the a context for the
1739 # A function generator function that sets up the a context for the
1745 # inner function.
1740 # inner function.
1746 def lookup_filenode_link_func(fname):
1741 def lookup_filenode_link_func(fname):
1747 msngset = msng_filenode_set[fname]
1742 msngset = msng_filenode_set[fname]
1748 # Lookup the changenode the filenode belongs to.
1743 # Lookup the changenode the filenode belongs to.
1749 def lookup_filenode_link(fnode):
1744 def lookup_filenode_link(fnode):
1750 return msngset[fnode]
1745 return msngset[fnode]
1751 return lookup_filenode_link
1746 return lookup_filenode_link
1752
1747
1753 # Add the nodes that were explicitly requested.
1748 # Add the nodes that were explicitly requested.
1754 def add_extra_nodes(name, nodes):
1749 def add_extra_nodes(name, nodes):
1755 if not extranodes or name not in extranodes:
1750 if not extranodes or name not in extranodes:
1756 return
1751 return
1757
1752
1758 for node, linknode in extranodes[name]:
1753 for node, linknode in extranodes[name]:
1759 if node not in nodes:
1754 if node not in nodes:
1760 nodes[node] = linknode
1755 nodes[node] = linknode
1761
1756
1762 # Now that we have all theses utility functions to help out and
1757 # Now that we have all theses utility functions to help out and
1763 # logically divide up the task, generate the group.
1758 # logically divide up the task, generate the group.
1764 def gengroup():
1759 def gengroup():
1765 # The set of changed files starts empty.
1760 # The set of changed files starts empty.
1766 changedfiles = {}
1761 changedfiles = {}
1767 # Create a changenode group generator that will call our functions
1762 # Create a changenode group generator that will call our functions
1768 # back to lookup the owning changenode and collect information.
1763 # back to lookup the owning changenode and collect information.
1769 group = cl.group(msng_cl_lst, identity,
1764 group = cl.group(msng_cl_lst, identity,
1770 manifest_and_file_collector(changedfiles))
1765 manifest_and_file_collector(changedfiles))
1771 for chnk in group:
1766 for chnk in group:
1772 yield chnk
1767 yield chnk
1773
1768
1774 # The list of manifests has been collected by the generator
1769 # The list of manifests has been collected by the generator
1775 # calling our functions back.
1770 # calling our functions back.
1776 prune_manifests()
1771 prune_manifests()
1777 add_extra_nodes(1, msng_mnfst_set)
1772 add_extra_nodes(1, msng_mnfst_set)
1778 msng_mnfst_lst = msng_mnfst_set.keys()
1773 msng_mnfst_lst = msng_mnfst_set.keys()
1779 # Sort the manifestnodes by revision number.
1774 # Sort the manifestnodes by revision number.
1780 msng_mnfst_lst.sort(cmp_by_rev_func(mnfst))
1775 msng_mnfst_lst.sort(cmp_by_rev_func(mnfst))
1781 # Create a generator for the manifestnodes that calls our lookup
1776 # Create a generator for the manifestnodes that calls our lookup
1782 # and data collection functions back.
1777 # and data collection functions back.
1783 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link,
1778 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link,
1784 filenode_collector(changedfiles))
1779 filenode_collector(changedfiles))
1785 for chnk in group:
1780 for chnk in group:
1786 yield chnk
1781 yield chnk
1787
1782
1788 # These are no longer needed, dereference and toss the memory for
1783 # These are no longer needed, dereference and toss the memory for
1789 # them.
1784 # them.
1790 msng_mnfst_lst = None
1785 msng_mnfst_lst = None
1791 msng_mnfst_set.clear()
1786 msng_mnfst_set.clear()
1792
1787
1793 if extranodes:
1788 if extranodes:
1794 for fname in extranodes:
1789 for fname in extranodes:
1795 if isinstance(fname, int):
1790 if isinstance(fname, int):
1796 continue
1791 continue
1797 msng_filenode_set.setdefault(fname, {})
1792 msng_filenode_set.setdefault(fname, {})
1798 changedfiles[fname] = 1
1793 changedfiles[fname] = 1
1799 # Go through all our files in order sorted by name.
1794 # Go through all our files in order sorted by name.
1800 for fname in sorted(changedfiles):
1795 for fname in sorted(changedfiles):
1801 filerevlog = self.file(fname)
1796 filerevlog = self.file(fname)
1802 if not len(filerevlog):
1797 if not len(filerevlog):
1803 raise util.Abort(_("empty or missing revlog for %s") % fname)
1798 raise util.Abort(_("empty or missing revlog for %s") % fname)
1804 # Toss out the filenodes that the recipient isn't really
1799 # Toss out the filenodes that the recipient isn't really
1805 # missing.
1800 # missing.
1806 if fname in msng_filenode_set:
1801 if fname in msng_filenode_set:
1807 prune_filenodes(fname, filerevlog)
1802 prune_filenodes(fname, filerevlog)
1808 add_extra_nodes(fname, msng_filenode_set[fname])
1803 add_extra_nodes(fname, msng_filenode_set[fname])
1809 msng_filenode_lst = msng_filenode_set[fname].keys()
1804 msng_filenode_lst = msng_filenode_set[fname].keys()
1810 else:
1805 else:
1811 msng_filenode_lst = []
1806 msng_filenode_lst = []
1812 # If any filenodes are left, generate the group for them,
1807 # If any filenodes are left, generate the group for them,
1813 # otherwise don't bother.
1808 # otherwise don't bother.
1814 if len(msng_filenode_lst) > 0:
1809 if len(msng_filenode_lst) > 0:
1815 yield changegroup.chunkheader(len(fname))
1810 yield changegroup.chunkheader(len(fname))
1816 yield fname
1811 yield fname
1817 # Sort the filenodes by their revision #
1812 # Sort the filenodes by their revision #
1818 msng_filenode_lst.sort(cmp_by_rev_func(filerevlog))
1813 msng_filenode_lst.sort(cmp_by_rev_func(filerevlog))
1819 # Create a group generator and only pass in a changenode
1814 # Create a group generator and only pass in a changenode
1820 # lookup function as we need to collect no information
1815 # lookup function as we need to collect no information
1821 # from filenodes.
1816 # from filenodes.
1822 group = filerevlog.group(msng_filenode_lst,
1817 group = filerevlog.group(msng_filenode_lst,
1823 lookup_filenode_link_func(fname))
1818 lookup_filenode_link_func(fname))
1824 for chnk in group:
1819 for chnk in group:
1825 yield chnk
1820 yield chnk
1826 if fname in msng_filenode_set:
1821 if fname in msng_filenode_set:
1827 # Don't need this anymore, toss it to free memory.
1822 # Don't need this anymore, toss it to free memory.
1828 del msng_filenode_set[fname]
1823 del msng_filenode_set[fname]
1829 # Signal that no more groups are left.
1824 # Signal that no more groups are left.
1830 yield changegroup.closechunk()
1825 yield changegroup.closechunk()
1831
1826
1832 if msng_cl_lst:
1827 if msng_cl_lst:
1833 self.hook('outgoing', node=hex(msng_cl_lst[0]), source=source)
1828 self.hook('outgoing', node=hex(msng_cl_lst[0]), source=source)
1834
1829
1835 return util.chunkbuffer(gengroup())
1830 return util.chunkbuffer(gengroup())
1836
1831
1837 def changegroup(self, basenodes, source):
1832 def changegroup(self, basenodes, source):
1838 # to avoid a race we use changegroupsubset() (issue1320)
1833 # to avoid a race we use changegroupsubset() (issue1320)
1839 return self.changegroupsubset(basenodes, self.heads(), source)
1834 return self.changegroupsubset(basenodes, self.heads(), source)
1840
1835
1841 def _changegroup(self, common, source):
1836 def _changegroup(self, common, source):
1842 """Generate a changegroup of all nodes that we have that a recipient
1837 """Generate a changegroup of all nodes that we have that a recipient
1843 doesn't.
1838 doesn't.
1844
1839
1845 This is much easier than the previous function as we can assume that
1840 This is much easier than the previous function as we can assume that
1846 the recipient has any changenode we aren't sending them.
1841 the recipient has any changenode we aren't sending them.
1847
1842
1848 common is the set of common nodes between remote and self"""
1843 common is the set of common nodes between remote and self"""
1849
1844
1850 self.hook('preoutgoing', throw=True, source=source)
1845 self.hook('preoutgoing', throw=True, source=source)
1851
1846
1852 cl = self.changelog
1847 cl = self.changelog
1853 nodes = cl.findmissing(common)
1848 nodes = cl.findmissing(common)
1854 revset = set([cl.rev(n) for n in nodes])
1849 revset = set([cl.rev(n) for n in nodes])
1855 self.changegroupinfo(nodes, source)
1850 self.changegroupinfo(nodes, source)
1856
1851
1857 def identity(x):
1852 def identity(x):
1858 return x
1853 return x
1859
1854
1860 def gennodelst(log):
1855 def gennodelst(log):
1861 for r in log:
1856 for r in log:
1862 if log.linkrev(r) in revset:
1857 if log.linkrev(r) in revset:
1863 yield log.node(r)
1858 yield log.node(r)
1864
1859
1865 def changed_file_collector(changedfileset):
1860 def changed_file_collector(changedfileset):
1866 def collect_changed_files(clnode):
1861 def collect_changed_files(clnode):
1867 c = cl.read(clnode)
1862 c = cl.read(clnode)
1868 changedfileset.update(c[3])
1863 changedfileset.update(c[3])
1869 return collect_changed_files
1864 return collect_changed_files
1870
1865
1871 def lookuprevlink_func(revlog):
1866 def lookuprevlink_func(revlog):
1872 def lookuprevlink(n):
1867 def lookuprevlink(n):
1873 return cl.node(revlog.linkrev(revlog.rev(n)))
1868 return cl.node(revlog.linkrev(revlog.rev(n)))
1874 return lookuprevlink
1869 return lookuprevlink
1875
1870
1876 def gengroup():
1871 def gengroup():
1877 # construct a list of all changed files
1872 # construct a list of all changed files
1878 changedfiles = set()
1873 changedfiles = set()
1879
1874
1880 for chnk in cl.group(nodes, identity,
1875 for chnk in cl.group(nodes, identity,
1881 changed_file_collector(changedfiles)):
1876 changed_file_collector(changedfiles)):
1882 yield chnk
1877 yield chnk
1883
1878
1884 mnfst = self.manifest
1879 mnfst = self.manifest
1885 nodeiter = gennodelst(mnfst)
1880 nodeiter = gennodelst(mnfst)
1886 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1881 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1887 yield chnk
1882 yield chnk
1888
1883
1889 for fname in sorted(changedfiles):
1884 for fname in sorted(changedfiles):
1890 filerevlog = self.file(fname)
1885 filerevlog = self.file(fname)
1891 if not len(filerevlog):
1886 if not len(filerevlog):
1892 raise util.Abort(_("empty or missing revlog for %s") % fname)
1887 raise util.Abort(_("empty or missing revlog for %s") % fname)
1893 nodeiter = gennodelst(filerevlog)
1888 nodeiter = gennodelst(filerevlog)
1894 nodeiter = list(nodeiter)
1889 nodeiter = list(nodeiter)
1895 if nodeiter:
1890 if nodeiter:
1896 yield changegroup.chunkheader(len(fname))
1891 yield changegroup.chunkheader(len(fname))
1897 yield fname
1892 yield fname
1898 lookup = lookuprevlink_func(filerevlog)
1893 lookup = lookuprevlink_func(filerevlog)
1899 for chnk in filerevlog.group(nodeiter, lookup):
1894 for chnk in filerevlog.group(nodeiter, lookup):
1900 yield chnk
1895 yield chnk
1901
1896
1902 yield changegroup.closechunk()
1897 yield changegroup.closechunk()
1903
1898
1904 if nodes:
1899 if nodes:
1905 self.hook('outgoing', node=hex(nodes[0]), source=source)
1900 self.hook('outgoing', node=hex(nodes[0]), source=source)
1906
1901
1907 return util.chunkbuffer(gengroup())
1902 return util.chunkbuffer(gengroup())
1908
1903
1909 def addchangegroup(self, source, srctype, url, emptyok=False):
1904 def addchangegroup(self, source, srctype, url, emptyok=False):
1910 """add changegroup to repo.
1905 """add changegroup to repo.
1911
1906
1912 return values:
1907 return values:
1913 - nothing changed or no source: 0
1908 - nothing changed or no source: 0
1914 - more heads than before: 1+added heads (2..n)
1909 - more heads than before: 1+added heads (2..n)
1915 - less heads than before: -1-removed heads (-2..-n)
1910 - less heads than before: -1-removed heads (-2..-n)
1916 - number of heads stays the same: 1
1911 - number of heads stays the same: 1
1917 """
1912 """
1918 def csmap(x):
1913 def csmap(x):
1919 self.ui.debug(_("add changeset %s\n") % short(x))
1914 self.ui.debug(_("add changeset %s\n") % short(x))
1920 return len(cl)
1915 return len(cl)
1921
1916
1922 def revmap(x):
1917 def revmap(x):
1923 return cl.rev(x)
1918 return cl.rev(x)
1924
1919
1925 if not source:
1920 if not source:
1926 return 0
1921 return 0
1927
1922
1928 self.hook('prechangegroup', throw=True, source=srctype, url=url)
1923 self.hook('prechangegroup', throw=True, source=srctype, url=url)
1929
1924
1930 changesets = files = revisions = 0
1925 changesets = files = revisions = 0
1931
1926
1932 # write changelog data to temp files so concurrent readers will not see
1927 # write changelog data to temp files so concurrent readers will not see
1933 # inconsistent view
1928 # inconsistent view
1934 cl = self.changelog
1929 cl = self.changelog
1935 cl.delayupdate()
1930 cl.delayupdate()
1936 oldheads = len(cl.heads())
1931 oldheads = len(cl.heads())
1937
1932
1938 tr = self.transaction()
1933 tr = self.transaction()
1939 try:
1934 try:
1940 trp = weakref.proxy(tr)
1935 trp = weakref.proxy(tr)
1941 # pull off the changeset group
1936 # pull off the changeset group
1942 self.ui.status(_("adding changesets\n"))
1937 self.ui.status(_("adding changesets\n"))
1943 clstart = len(cl)
1938 clstart = len(cl)
1944 chunkiter = changegroup.chunkiter(source)
1939 chunkiter = changegroup.chunkiter(source)
1945 if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok:
1940 if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok:
1946 raise util.Abort(_("received changelog group is empty"))
1941 raise util.Abort(_("received changelog group is empty"))
1947 clend = len(cl)
1942 clend = len(cl)
1948 changesets = clend - clstart
1943 changesets = clend - clstart
1949
1944
1950 # pull off the manifest group
1945 # pull off the manifest group
1951 self.ui.status(_("adding manifests\n"))
1946 self.ui.status(_("adding manifests\n"))
1952 chunkiter = changegroup.chunkiter(source)
1947 chunkiter = changegroup.chunkiter(source)
1953 # no need to check for empty manifest group here:
1948 # no need to check for empty manifest group here:
1954 # if the result of the merge of 1 and 2 is the same in 3 and 4,
1949 # if the result of the merge of 1 and 2 is the same in 3 and 4,
1955 # no new manifest will be created and the manifest group will
1950 # no new manifest will be created and the manifest group will
1956 # be empty during the pull
1951 # be empty during the pull
1957 self.manifest.addgroup(chunkiter, revmap, trp)
1952 self.manifest.addgroup(chunkiter, revmap, trp)
1958
1953
1959 # process the files
1954 # process the files
1960 self.ui.status(_("adding file changes\n"))
1955 self.ui.status(_("adding file changes\n"))
1961 while 1:
1956 while 1:
1962 f = changegroup.getchunk(source)
1957 f = changegroup.getchunk(source)
1963 if not f:
1958 if not f:
1964 break
1959 break
1965 self.ui.debug(_("adding %s revisions\n") % f)
1960 self.ui.debug(_("adding %s revisions\n") % f)
1966 fl = self.file(f)
1961 fl = self.file(f)
1967 o = len(fl)
1962 o = len(fl)
1968 chunkiter = changegroup.chunkiter(source)
1963 chunkiter = changegroup.chunkiter(source)
1969 if fl.addgroup(chunkiter, revmap, trp) is None:
1964 if fl.addgroup(chunkiter, revmap, trp) is None:
1970 raise util.Abort(_("received file revlog group is empty"))
1965 raise util.Abort(_("received file revlog group is empty"))
1971 revisions += len(fl) - o
1966 revisions += len(fl) - o
1972 files += 1
1967 files += 1
1973
1968
1974 newheads = len(cl.heads())
1969 newheads = len(cl.heads())
1975 heads = ""
1970 heads = ""
1976 if oldheads and newheads != oldheads:
1971 if oldheads and newheads != oldheads:
1977 heads = _(" (%+d heads)") % (newheads - oldheads)
1972 heads = _(" (%+d heads)") % (newheads - oldheads)
1978
1973
1979 self.ui.status(_("added %d changesets"
1974 self.ui.status(_("added %d changesets"
1980 " with %d changes to %d files%s\n")
1975 " with %d changes to %d files%s\n")
1981 % (changesets, revisions, files, heads))
1976 % (changesets, revisions, files, heads))
1982
1977
1983 if changesets > 0:
1978 if changesets > 0:
1984 p = lambda: cl.writepending() and self.root or ""
1979 p = lambda: cl.writepending() and self.root or ""
1985 self.hook('pretxnchangegroup', throw=True,
1980 self.hook('pretxnchangegroup', throw=True,
1986 node=hex(cl.node(clstart)), source=srctype,
1981 node=hex(cl.node(clstart)), source=srctype,
1987 url=url, pending=p)
1982 url=url, pending=p)
1988
1983
1989 # make changelog see real files again
1984 # make changelog see real files again
1990 cl.finalize(trp)
1985 cl.finalize(trp)
1991
1986
1992 tr.close()
1987 tr.close()
1993 finally:
1988 finally:
1994 del tr
1989 del tr
1995
1990
1996 if changesets > 0:
1991 if changesets > 0:
1997 # forcefully update the on-disk branch cache
1992 # forcefully update the on-disk branch cache
1998 self.ui.debug(_("updating the branch cache\n"))
1993 self.ui.debug(_("updating the branch cache\n"))
1999 self.branchtags()
1994 self.branchtags()
2000 self.hook("changegroup", node=hex(cl.node(clstart)),
1995 self.hook("changegroup", node=hex(cl.node(clstart)),
2001 source=srctype, url=url)
1996 source=srctype, url=url)
2002
1997
2003 for i in xrange(clstart, clend):
1998 for i in xrange(clstart, clend):
2004 self.hook("incoming", node=hex(cl.node(i)),
1999 self.hook("incoming", node=hex(cl.node(i)),
2005 source=srctype, url=url)
2000 source=srctype, url=url)
2006
2001
2007 # never return 0 here:
2002 # never return 0 here:
2008 if newheads < oldheads:
2003 if newheads < oldheads:
2009 return newheads - oldheads - 1
2004 return newheads - oldheads - 1
2010 else:
2005 else:
2011 return newheads - oldheads + 1
2006 return newheads - oldheads + 1
2012
2007
2013
2008
2014 def stream_in(self, remote):
2009 def stream_in(self, remote):
2015 fp = remote.stream_out()
2010 fp = remote.stream_out()
2016 l = fp.readline()
2011 l = fp.readline()
2017 try:
2012 try:
2018 resp = int(l)
2013 resp = int(l)
2019 except ValueError:
2014 except ValueError:
2020 raise error.ResponseError(
2015 raise error.ResponseError(
2021 _('Unexpected response from remote server:'), l)
2016 _('Unexpected response from remote server:'), l)
2022 if resp == 1:
2017 if resp == 1:
2023 raise util.Abort(_('operation forbidden by server'))
2018 raise util.Abort(_('operation forbidden by server'))
2024 elif resp == 2:
2019 elif resp == 2:
2025 raise util.Abort(_('locking the remote repository failed'))
2020 raise util.Abort(_('locking the remote repository failed'))
2026 elif resp != 0:
2021 elif resp != 0:
2027 raise util.Abort(_('the server sent an unknown error code'))
2022 raise util.Abort(_('the server sent an unknown error code'))
2028 self.ui.status(_('streaming all changes\n'))
2023 self.ui.status(_('streaming all changes\n'))
2029 l = fp.readline()
2024 l = fp.readline()
2030 try:
2025 try:
2031 total_files, total_bytes = map(int, l.split(' ', 1))
2026 total_files, total_bytes = map(int, l.split(' ', 1))
2032 except (ValueError, TypeError):
2027 except (ValueError, TypeError):
2033 raise error.ResponseError(
2028 raise error.ResponseError(
2034 _('Unexpected response from remote server:'), l)
2029 _('Unexpected response from remote server:'), l)
2035 self.ui.status(_('%d files to transfer, %s of data\n') %
2030 self.ui.status(_('%d files to transfer, %s of data\n') %
2036 (total_files, util.bytecount(total_bytes)))
2031 (total_files, util.bytecount(total_bytes)))
2037 start = time.time()
2032 start = time.time()
2038 for i in xrange(total_files):
2033 for i in xrange(total_files):
2039 # XXX doesn't support '\n' or '\r' in filenames
2034 # XXX doesn't support '\n' or '\r' in filenames
2040 l = fp.readline()
2035 l = fp.readline()
2041 try:
2036 try:
2042 name, size = l.split('\0', 1)
2037 name, size = l.split('\0', 1)
2043 size = int(size)
2038 size = int(size)
2044 except (ValueError, TypeError):
2039 except (ValueError, TypeError):
2045 raise error.ResponseError(
2040 raise error.ResponseError(
2046 _('Unexpected response from remote server:'), l)
2041 _('Unexpected response from remote server:'), l)
2047 self.ui.debug(_('adding %s (%s)\n') % (name, util.bytecount(size)))
2042 self.ui.debug(_('adding %s (%s)\n') % (name, util.bytecount(size)))
2048 ofp = self.sopener(name, 'w')
2043 ofp = self.sopener(name, 'w')
2049 for chunk in util.filechunkiter(fp, limit=size):
2044 for chunk in util.filechunkiter(fp, limit=size):
2050 ofp.write(chunk)
2045 ofp.write(chunk)
2051 ofp.close()
2046 ofp.close()
2052 elapsed = time.time() - start
2047 elapsed = time.time() - start
2053 if elapsed <= 0:
2048 if elapsed <= 0:
2054 elapsed = 0.001
2049 elapsed = 0.001
2055 self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
2050 self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
2056 (util.bytecount(total_bytes), elapsed,
2051 (util.bytecount(total_bytes), elapsed,
2057 util.bytecount(total_bytes / elapsed)))
2052 util.bytecount(total_bytes / elapsed)))
2058 self.invalidate()
2053 self.invalidate()
2059 return len(self.heads()) + 1
2054 return len(self.heads()) + 1
2060
2055
2061 def clone(self, remote, heads=[], stream=False):
2056 def clone(self, remote, heads=[], stream=False):
2062 '''clone remote repository.
2057 '''clone remote repository.
2063
2058
2064 keyword arguments:
2059 keyword arguments:
2065 heads: list of revs to clone (forces use of pull)
2060 heads: list of revs to clone (forces use of pull)
2066 stream: use streaming clone if possible'''
2061 stream: use streaming clone if possible'''
2067
2062
2068 # now, all clients that can request uncompressed clones can
2063 # now, all clients that can request uncompressed clones can
2069 # read repo formats supported by all servers that can serve
2064 # read repo formats supported by all servers that can serve
2070 # them.
2065 # them.
2071
2066
2072 # if revlog format changes, client will have to check version
2067 # if revlog format changes, client will have to check version
2073 # and format flags on "stream" capability, and use
2068 # and format flags on "stream" capability, and use
2074 # uncompressed only if compatible.
2069 # uncompressed only if compatible.
2075
2070
2076 if stream and not heads and remote.capable('stream'):
2071 if stream and not heads and remote.capable('stream'):
2077 return self.stream_in(remote)
2072 return self.stream_in(remote)
2078 return self.pull(remote, heads)
2073 return self.pull(remote, heads)
2079
2074
2080 # used to avoid circular references so destructors work
2075 # used to avoid circular references so destructors work
2081 def aftertrans(files):
2076 def aftertrans(files):
2082 renamefiles = [tuple(t) for t in files]
2077 renamefiles = [tuple(t) for t in files]
2083 def a():
2078 def a():
2084 for src, dest in renamefiles:
2079 for src, dest in renamefiles:
2085 util.rename(src, dest)
2080 util.rename(src, dest)
2086 return a
2081 return a
2087
2082
2088 def instance(ui, path, create):
2083 def instance(ui, path, create):
2089 return localrepository(ui, util.drop_scheme('file', path), create)
2084 return localrepository(ui, util.drop_scheme('file', path), create)
2090
2085
2091 def islocal(path):
2086 def islocal(path):
2092 return True
2087 return True
@@ -1,121 +1,117 b''
1 % commit date test
1 % commit date test
2 transaction abort!
3 rollback completed
4 abort: empty commit message
2 abort: empty commit message
5 abort: impossible time zone offset: 4444444
3 abort: impossible time zone offset: 4444444
6 abort: invalid date: '1\t15.1'
4 abort: invalid date: '1\t15.1'
7 abort: invalid date: 'foo bar'
5 abort: invalid date: 'foo bar'
8 abort: date exceeds 32 bits: 111111111111
6 abort: date exceeds 32 bits: 111111111111
9 % commit added file that has been deleted
7 % commit added file that has been deleted
10 nothing changed
8 nothing changed
11 abort: file bar not found!
9 abort: file bar not found!
12 adding dir/file
10 adding dir/file
13 dir/file
11 dir/file
14 committed changeset 2:d2a76177cb42
12 committed changeset 2:d2a76177cb42
15 adding dir.file
13 adding dir.file
16 abort: no match under directory dir!
14 abort: no match under directory dir!
17 abort: no match under directory .!
15 abort: no match under directory .!
18 abort: no match under directory ../dir2!
16 abort: no match under directory ../dir2!
19 dir/file
17 dir/file
20 committed changeset 3:1cd62a2d8db5
18 committed changeset 3:1cd62a2d8db5
21 does-not-exist: No such file or directory
19 does-not-exist: No such file or directory
22 abort: file does-not-exist not found!
20 abort: file does-not-exist not found!
23 abort: file baz not tracked!
21 abort: file baz not tracked!
24 abort: file quux not tracked!
22 abort: file quux not tracked!
25 dir/file
23 dir/file
26 committed changeset 4:49176991390e
24 committed changeset 4:49176991390e
27 % partial subdir commit test
25 % partial subdir commit test
28 adding bar/bar
26 adding bar/bar
29 adding foo/foo
27 adding foo/foo
30 % subdir log 1
28 % subdir log 1
31 changeset: 0:6ef3cb06bb80
29 changeset: 0:6ef3cb06bb80
32 user: test
30 user: test
33 date: Mon Jan 12 13:46:40 1970 +0000
31 date: Mon Jan 12 13:46:40 1970 +0000
34 files: foo/foo
32 files: foo/foo
35 description:
33 description:
36 commit-subdir-1
34 commit-subdir-1
37
35
38
36
39 % subdir log 2
37 % subdir log 2
40 changeset: 1:f2e51572cf5a
38 changeset: 1:f2e51572cf5a
41 tag: tip
39 tag: tip
42 user: test
40 user: test
43 date: Mon Jan 12 13:46:41 1970 +0000
41 date: Mon Jan 12 13:46:41 1970 +0000
44 files: bar/bar
42 files: bar/bar
45 description:
43 description:
46 commit-subdir-2
44 commit-subdir-2
47
45
48
46
49 % full log
47 % full log
50 changeset: 1:f2e51572cf5a
48 changeset: 1:f2e51572cf5a
51 tag: tip
49 tag: tip
52 user: test
50 user: test
53 date: Mon Jan 12 13:46:41 1970 +0000
51 date: Mon Jan 12 13:46:41 1970 +0000
54 files: bar/bar
52 files: bar/bar
55 description:
53 description:
56 commit-subdir-2
54 commit-subdir-2
57
55
58
56
59 changeset: 0:6ef3cb06bb80
57 changeset: 0:6ef3cb06bb80
60 user: test
58 user: test
61 date: Mon Jan 12 13:46:40 1970 +0000
59 date: Mon Jan 12 13:46:40 1970 +0000
62 files: foo/foo
60 files: foo/foo
63 description:
61 description:
64 commit-subdir-1
62 commit-subdir-1
65
63
66
64
67 % dot and subdir commit test
65 % dot and subdir commit test
68 % full log
66 % full log
69 changeset: 1:d9180e04fa8a
67 changeset: 1:d9180e04fa8a
70 tag: tip
68 tag: tip
71 user: test
69 user: test
72 date: Sat Jan 24 03:33:20 1970 +0000
70 date: Sat Jan 24 03:33:20 1970 +0000
73 files: foo/plain-file
71 files: foo/plain-file
74 description:
72 description:
75 commit-foo-dot
73 commit-foo-dot
76
74
77
75
78 changeset: 0:80b572aaf098
76 changeset: 0:80b572aaf098
79 user: test
77 user: test
80 date: Mon Jan 12 13:46:40 1970 +0000
78 date: Mon Jan 12 13:46:40 1970 +0000
81 files: foo/plain-file
79 files: foo/plain-file
82 description:
80 description:
83 commit-foo-subdir
81 commit-foo-subdir
84
82
85
83
86 % subdir log
84 % subdir log
87 changeset: 1:d9180e04fa8a
85 changeset: 1:d9180e04fa8a
88 tag: tip
86 tag: tip
89 user: test
87 user: test
90 date: Sat Jan 24 03:33:20 1970 +0000
88 date: Sat Jan 24 03:33:20 1970 +0000
91 summary: commit-foo-dot
89 summary: commit-foo-dot
92
90
93 changeset: 0:80b572aaf098
91 changeset: 0:80b572aaf098
94 user: test
92 user: test
95 date: Mon Jan 12 13:46:40 1970 +0000
93 date: Mon Jan 12 13:46:40 1970 +0000
96 summary: commit-foo-subdir
94 summary: commit-foo-subdir
97
95
98 adding a
96 adding a
99 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 created new head
98 created new head
101 merging a
99 merging a
102 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
100 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
103 (branch merge, don't forget to commit)
101 (branch merge, don't forget to commit)
104 % should fail because we are specifying a file name
102 % should fail because we are specifying a file name
105 abort: cannot partially commit a merge (do not specify files or patterns)
103 abort: cannot partially commit a merge (do not specify files or patterns)
106 % should fail because we are specifying a pattern
104 % should fail because we are specifying a pattern
107 abort: cannot partially commit a merge (do not specify files or patterns)
105 abort: cannot partially commit a merge (do not specify files or patterns)
108 % should succeed
106 % should succeed
109 % test commit message content
107 % test commit message content
110
108
111
109
112 HG: Enter commit message. Lines beginning with 'HG:' are removed.
110 HG: Enter commit message. Lines beginning with 'HG:' are removed.
113 HG: --
111 HG: --
114 HG: user: test
112 HG: user: test
115 HG: branch 'default'
113 HG: branch 'default'
116 HG: added added
114 HG: added added
117 HG: changed changed
115 HG: changed changed
118 HG: removed removed
116 HG: removed removed
119 transaction abort!
120 rollback completed
121 abort: empty commit message
117 abort: empty commit message
@@ -1,298 +1,294 b''
1 adding a
1 adding a
2 adding d1/d2/a
2 adding d1/d2/a
3 % import exported patch
3 % import exported patch
4 requesting all changes
4 requesting all changes
5 adding changesets
5 adding changesets
6 adding manifests
6 adding manifests
7 adding file changes
7 adding file changes
8 added 1 changesets with 2 changes to 2 files
8 added 1 changesets with 2 changes to 2 files
9 updating working directory
9 updating working directory
10 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
10 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
11 applying ../tip.patch
11 applying ../tip.patch
12 % message should be same
12 % message should be same
13 summary: second change
13 summary: second change
14 % committer should be same
14 % committer should be same
15 user: someone
15 user: someone
16 % import exported patch with external patcher
16 % import exported patch with external patcher
17 requesting all changes
17 requesting all changes
18 adding changesets
18 adding changesets
19 adding manifests
19 adding manifests
20 adding file changes
20 adding file changes
21 added 1 changesets with 2 changes to 2 files
21 added 1 changesets with 2 changes to 2 files
22 updating working directory
22 updating working directory
23 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
24 applying ../tip.patch
24 applying ../tip.patch
25 line2
25 line2
26 % import of plain diff should fail without message
26 % import of plain diff should fail without message
27 requesting all changes
27 requesting all changes
28 adding changesets
28 adding changesets
29 adding manifests
29 adding manifests
30 adding file changes
30 adding file changes
31 added 1 changesets with 2 changes to 2 files
31 added 1 changesets with 2 changes to 2 files
32 updating working directory
32 updating working directory
33 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
33 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 applying ../tip.patch
34 applying ../tip.patch
35 transaction abort!
36 rollback completed
37 abort: empty commit message
35 abort: empty commit message
38 % import of plain diff should be ok with message
36 % import of plain diff should be ok with message
39 requesting all changes
37 requesting all changes
40 adding changesets
38 adding changesets
41 adding manifests
39 adding manifests
42 adding file changes
40 adding file changes
43 added 1 changesets with 2 changes to 2 files
41 added 1 changesets with 2 changes to 2 files
44 updating working directory
42 updating working directory
45 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 applying ../tip.patch
44 applying ../tip.patch
47 % import of plain diff with specific date and user
45 % import of plain diff with specific date and user
48 requesting all changes
46 requesting all changes
49 adding changesets
47 adding changesets
50 adding manifests
48 adding manifests
51 adding file changes
49 adding file changes
52 added 1 changesets with 2 changes to 2 files
50 added 1 changesets with 2 changes to 2 files
53 updating working directory
51 updating working directory
54 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
52 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 applying ../tip.patch
53 applying ../tip.patch
56 changeset: 1:ca68f19f3a40
54 changeset: 1:ca68f19f3a40
57 tag: tip
55 tag: tip
58 user: user@nowhere.net
56 user: user@nowhere.net
59 date: Thu Jan 01 00:00:01 1970 +0000
57 date: Thu Jan 01 00:00:01 1970 +0000
60 files: a
58 files: a
61 description:
59 description:
62 patch
60 patch
63
61
64
62
65 diff -r 80971e65b431 -r ca68f19f3a40 a
63 diff -r 80971e65b431 -r ca68f19f3a40 a
66 --- a/a Thu Jan 01 00:00:00 1970 +0000
64 --- a/a Thu Jan 01 00:00:00 1970 +0000
67 +++ b/a Thu Jan 01 00:00:01 1970 +0000
65 +++ b/a Thu Jan 01 00:00:01 1970 +0000
68 @@ -1,1 +1,2 @@
66 @@ -1,1 +1,2 @@
69 line 1
67 line 1
70 +line 2
68 +line 2
71
69
72 % import of plain diff should be ok with --no-commit
70 % import of plain diff should be ok with --no-commit
73 requesting all changes
71 requesting all changes
74 adding changesets
72 adding changesets
75 adding manifests
73 adding manifests
76 adding file changes
74 adding file changes
77 added 1 changesets with 2 changes to 2 files
75 added 1 changesets with 2 changes to 2 files
78 updating working directory
76 updating working directory
79 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 applying ../tip.patch
78 applying ../tip.patch
81 diff -r 80971e65b431 a
79 diff -r 80971e65b431 a
82 --- a/a
80 --- a/a
83 +++ b/a
81 +++ b/a
84 @@ -1,1 +1,2 @@
82 @@ -1,1 +1,2 @@
85 line 1
83 line 1
86 +line 2
84 +line 2
87 % hg -R repo import
85 % hg -R repo import
88 requesting all changes
86 requesting all changes
89 adding changesets
87 adding changesets
90 adding manifests
88 adding manifests
91 adding file changes
89 adding file changes
92 added 1 changesets with 2 changes to 2 files
90 added 1 changesets with 2 changes to 2 files
93 updating working directory
91 updating working directory
94 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
95 applying tip.patch
93 applying tip.patch
96 % import from stdin
94 % import from stdin
97 requesting all changes
95 requesting all changes
98 adding changesets
96 adding changesets
99 adding manifests
97 adding manifests
100 adding file changes
98 adding file changes
101 added 1 changesets with 2 changes to 2 files
99 added 1 changesets with 2 changes to 2 files
102 updating working directory
100 updating working directory
103 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 applying patch from stdin
102 applying patch from stdin
105 % override commit message
103 % override commit message
106 requesting all changes
104 requesting all changes
107 adding changesets
105 adding changesets
108 adding manifests
106 adding manifests
109 adding file changes
107 adding file changes
110 added 1 changesets with 2 changes to 2 files
108 added 1 changesets with 2 changes to 2 files
111 updating working directory
109 updating working directory
112 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
113 applying patch from stdin
111 applying patch from stdin
114 summary: override
112 summary: override
115 % plain diff in email, subject, message body
113 % plain diff in email, subject, message body
116 requesting all changes
114 requesting all changes
117 adding changesets
115 adding changesets
118 adding manifests
116 adding manifests
119 adding file changes
117 adding file changes
120 added 1 changesets with 2 changes to 2 files
118 added 1 changesets with 2 changes to 2 files
121 updating working directory
119 updating working directory
122 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
120 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
123 applying ../msg.patch
121 applying ../msg.patch
124 user: email patcher
122 user: email patcher
125 summary: email patch
123 summary: email patch
126 % plain diff in email, no subject, message body
124 % plain diff in email, no subject, message body
127 requesting all changes
125 requesting all changes
128 adding changesets
126 adding changesets
129 adding manifests
127 adding manifests
130 adding file changes
128 adding file changes
131 added 1 changesets with 2 changes to 2 files
129 added 1 changesets with 2 changes to 2 files
132 updating working directory
130 updating working directory
133 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
131 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
134 applying patch from stdin
132 applying patch from stdin
135 % plain diff in email, subject, no message body
133 % plain diff in email, subject, no message body
136 requesting all changes
134 requesting all changes
137 adding changesets
135 adding changesets
138 adding manifests
136 adding manifests
139 adding file changes
137 adding file changes
140 added 1 changesets with 2 changes to 2 files
138 added 1 changesets with 2 changes to 2 files
141 updating working directory
139 updating working directory
142 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
143 applying patch from stdin
141 applying patch from stdin
144 % plain diff in email, no subject, no message body, should fail
142 % plain diff in email, no subject, no message body, should fail
145 requesting all changes
143 requesting all changes
146 adding changesets
144 adding changesets
147 adding manifests
145 adding manifests
148 adding file changes
146 adding file changes
149 added 1 changesets with 2 changes to 2 files
147 added 1 changesets with 2 changes to 2 files
150 updating working directory
148 updating working directory
151 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
149 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
152 applying patch from stdin
150 applying patch from stdin
153 transaction abort!
154 rollback completed
155 abort: empty commit message
151 abort: empty commit message
156 % hg export in email, should use patch header
152 % hg export in email, should use patch header
157 requesting all changes
153 requesting all changes
158 adding changesets
154 adding changesets
159 adding manifests
155 adding manifests
160 adding file changes
156 adding file changes
161 added 1 changesets with 2 changes to 2 files
157 added 1 changesets with 2 changes to 2 files
162 updating working directory
158 updating working directory
163 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
159 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
164 applying patch from stdin
160 applying patch from stdin
165 summary: second change
161 summary: second change
166 % plain diff in email, [PATCH] subject, message body with subject
162 % plain diff in email, [PATCH] subject, message body with subject
167 requesting all changes
163 requesting all changes
168 adding changesets
164 adding changesets
169 adding manifests
165 adding manifests
170 adding file changes
166 adding file changes
171 added 1 changesets with 2 changes to 2 files
167 added 1 changesets with 2 changes to 2 files
172 updating working directory
168 updating working directory
173 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
169 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
174 applying patch from stdin
170 applying patch from stdin
175 email patch
171 email patch
176
172
177 next line
173 next line
178 ---
174 ---
179 % import patch1 patch2; rollback
175 % import patch1 patch2; rollback
180 parent: 0
176 parent: 0
181 applying ../patch1
177 applying ../patch1
182 applying ../patch2
178 applying ../patch2
183 rolling back last transaction
179 rolling back last transaction
184 parent: 1
180 parent: 1
185 % hg import in a subdirectory
181 % hg import in a subdirectory
186 requesting all changes
182 requesting all changes
187 adding changesets
183 adding changesets
188 adding manifests
184 adding manifests
189 adding file changes
185 adding file changes
190 added 1 changesets with 2 changes to 2 files
186 added 1 changesets with 2 changes to 2 files
191 updating working directory
187 updating working directory
192 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
188 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 applying ../../../tip.patch
189 applying ../../../tip.patch
194 % message should be 'subdir change'
190 % message should be 'subdir change'
195 summary: subdir change
191 summary: subdir change
196 % committer should be 'someoneelse'
192 % committer should be 'someoneelse'
197 user: someoneelse
193 user: someoneelse
198 % should be empty
194 % should be empty
199 % test fuzziness
195 % test fuzziness
200 adding a
196 adding a
201 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
202 created new head
198 created new head
203 applying tip.patch
199 applying tip.patch
204 patching file a
200 patching file a
205 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
201 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
206 a
202 a
207 adding a
203 adding a
208 adding b1
204 adding b1
209 adding c1
205 adding c1
210 adding d
206 adding d
211 diff --git a/a b/a
207 diff --git a/a b/a
212 --- a/a
208 --- a/a
213 +++ b/a
209 +++ b/a
214 @@ -0,0 +1,1 @@
210 @@ -0,0 +1,1 @@
215 +a
211 +a
216 diff --git a/b1 b/b2
212 diff --git a/b1 b/b2
217 rename from b1
213 rename from b1
218 rename to b2
214 rename to b2
219 --- a/b1
215 --- a/b1
220 +++ b/b2
216 +++ b/b2
221 @@ -0,0 +1,1 @@
217 @@ -0,0 +1,1 @@
222 +b
218 +b
223 diff --git a/c1 b/c1
219 diff --git a/c1 b/c1
224 --- a/c1
220 --- a/c1
225 +++ b/c1
221 +++ b/c1
226 @@ -0,0 +1,1 @@
222 @@ -0,0 +1,1 @@
227 +c
223 +c
228 diff --git a/c1 b/c2
224 diff --git a/c1 b/c2
229 copy from c1
225 copy from c1
230 copy to c2
226 copy to c2
231 --- a/c1
227 --- a/c1
232 +++ b/c2
228 +++ b/c2
233 @@ -0,0 +1,1 @@
229 @@ -0,0 +1,1 @@
234 +c
230 +c
235 diff --git a/d b/d
231 diff --git a/d b/d
236 --- a/d
232 --- a/d
237 +++ b/d
233 +++ b/d
238 @@ -1,1 +0,0 @@
234 @@ -1,1 +0,0 @@
239 -d
235 -d
240 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
236 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
241 applying empty.diff
237 applying empty.diff
242 % a file
238 % a file
243 a
239 a
244 % b1 file
240 % b1 file
245 % b2 file
241 % b2 file
246 b
242 b
247 % c1 file
243 % c1 file
248 c
244 c
249 % c2 file
245 % c2 file
250 c
246 c
251 % d file
247 % d file
252 % test trailing binary removal
248 % test trailing binary removal
253 adding a
249 adding a
254 adding b
250 adding b
255 R a
251 R a
256 R b
252 R b
257 diff --git a/a b/a
253 diff --git a/a b/a
258 diff --git a/b b/b
254 diff --git a/b b/b
259 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
255 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
260 applying remove.diff
256 applying remove.diff
261 % test update+rename with common name (issue 927)
257 % test update+rename with common name (issue 927)
262 adding a
258 adding a
263 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
259 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
264 applying copy.diff
260 applying copy.diff
265 % view a
261 % view a
266 a
262 a
267 % view a2
263 % view a2
268 a
264 a
269 % test -p0
265 % test -p0
270 adding a
266 adding a
271 applying patch from stdin
267 applying patch from stdin
272 bb
268 bb
273 % test paths outside repo root
269 % test paths outside repo root
274 applying patch from stdin
270 applying patch from stdin
275 abort: ../outside/foo not under root
271 abort: ../outside/foo not under root
276 % test import with similarity (issue295)
272 % test import with similarity (issue295)
277 adding a
273 adding a
278 applying ../rename.diff
274 applying ../rename.diff
279 patching file a
275 patching file a
280 patching file b
276 patching file b
281 removing a
277 removing a
282 adding b
278 adding b
283 recording removal of a as rename to b (88% similar)
279 recording removal of a as rename to b (88% similar)
284 A b
280 A b
285 a
281 a
286 R a
282 R a
287 undeleting a
283 undeleting a
288 forgetting b
284 forgetting b
289 applying ../rename.diff
285 applying ../rename.diff
290 patching file a
286 patching file a
291 patching file b
287 patching file b
292 removing a
288 removing a
293 adding b
289 adding b
294 A b
290 A b
295 R a
291 R a
296 % add empty file from the end of patch (issue 1495)
292 % add empty file from the end of patch (issue 1495)
297 adding a
293 adding a
298 applying a.patch
294 applying a.patch
@@ -1,504 +1,498 b''
1 % help
1 % help
2 keyword extension - keyword expansion in local repositories
2 keyword extension - keyword expansion in local repositories
3
3
4 This extension expands RCS/CVS-like or self-customized $Keywords$ in
4 This extension expands RCS/CVS-like or self-customized $Keywords$ in
5 tracked text files selected by your configuration.
5 tracked text files selected by your configuration.
6
6
7 Keywords are only expanded in local repositories and not stored in the
7 Keywords are only expanded in local repositories and not stored in the
8 change history. The mechanism can be regarded as a convenience for the
8 change history. The mechanism can be regarded as a convenience for the
9 current user or for archive distribution.
9 current user or for archive distribution.
10
10
11 Configuration is done in the [keyword] and [keywordmaps] sections of
11 Configuration is done in the [keyword] and [keywordmaps] sections of
12 hgrc files.
12 hgrc files.
13
13
14 Example:
14 Example:
15
15
16 [keyword]
16 [keyword]
17 # expand keywords in every python file except those matching "x*"
17 # expand keywords in every python file except those matching "x*"
18 **.py =
18 **.py =
19 x* = ignore
19 x* = ignore
20
20
21 Note: the more specific you are in your filename patterns
21 Note: the more specific you are in your filename patterns
22 the less you lose speed in huge repositories.
22 the less you lose speed in huge repositories.
23
23
24 For [keywordmaps] template mapping and expansion demonstration and
24 For [keywordmaps] template mapping and expansion demonstration and
25 control run "hg kwdemo".
25 control run "hg kwdemo".
26
26
27 An additional date template filter {date|utcdate} is provided.
27 An additional date template filter {date|utcdate} is provided.
28
28
29 The default template mappings (view with "hg kwdemo -d") can be
29 The default template mappings (view with "hg kwdemo -d") can be
30 replaced with customized keywords and templates. Again, run "hg
30 replaced with customized keywords and templates. Again, run "hg
31 kwdemo" to control the results of your config changes.
31 kwdemo" to control the results of your config changes.
32
32
33 Before changing/disabling active keywords, run "hg kwshrink" to avoid
33 Before changing/disabling active keywords, run "hg kwshrink" to avoid
34 the risk of inadvertedly storing expanded keywords in the change
34 the risk of inadvertedly storing expanded keywords in the change
35 history.
35 history.
36
36
37 To force expansion after enabling it, or a configuration change, run
37 To force expansion after enabling it, or a configuration change, run
38 "hg kwexpand".
38 "hg kwexpand".
39
39
40 Also, when committing with the record extension or using mq's qrecord,
40 Also, when committing with the record extension or using mq's qrecord,
41 be aware that keywords cannot be updated. Again, run "hg kwexpand" on
41 be aware that keywords cannot be updated. Again, run "hg kwexpand" on
42 the files in question to update keyword expansions after all changes
42 the files in question to update keyword expansions after all changes
43 have been checked in.
43 have been checked in.
44
44
45 Expansions spanning more than one line and incremental expansions,
45 Expansions spanning more than one line and incremental expansions,
46 like CVS' $Log$, are not supported. A keyword template map
46 like CVS' $Log$, are not supported. A keyword template map
47 "Log = {desc}" expands to the first line of the changeset description.
47 "Log = {desc}" expands to the first line of the changeset description.
48
48
49 list of commands:
49 list of commands:
50
50
51 kwdemo print [keywordmaps] configuration and an expansion example
51 kwdemo print [keywordmaps] configuration and an expansion example
52 kwexpand expand keywords in working directory
52 kwexpand expand keywords in working directory
53 kwfiles print files currently configured for keyword expansion
53 kwfiles print files currently configured for keyword expansion
54 kwshrink revert expanded keywords in working directory
54 kwshrink revert expanded keywords in working directory
55
55
56 enabled extensions:
56 enabled extensions:
57
57
58 keyword keyword expansion in local repositories
58 keyword keyword expansion in local repositories
59 mq patch management and development
59 mq patch management and development
60 notify hook extension to email notifications on commits/pushes
60 notify hook extension to email notifications on commits/pushes
61
61
62 use "hg -v help keyword" to show aliases and global options
62 use "hg -v help keyword" to show aliases and global options
63 % hg kwdemo
63 % hg kwdemo
64 [extensions]
64 [extensions]
65 hgext.keyword =
65 hgext.keyword =
66 [keyword]
66 [keyword]
67 * =
67 * =
68 b = ignore
68 b = ignore
69 demo.txt =
69 demo.txt =
70 [keywordmaps]
70 [keywordmaps]
71 RCSFile = {file|basename},v
71 RCSFile = {file|basename},v
72 Author = {author|user}
72 Author = {author|user}
73 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
73 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
74 Source = {root}/{file},v
74 Source = {root}/{file},v
75 Date = {date|utcdate}
75 Date = {date|utcdate}
76 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
76 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
77 Revision = {node|short}
77 Revision = {node|short}
78 $RCSFile: demo.txt,v $
78 $RCSFile: demo.txt,v $
79 $Author: test $
79 $Author: test $
80 $Header: /TMP/demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $
80 $Header: /TMP/demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $
81 $Source: /TMP/demo.txt,v $
81 $Source: /TMP/demo.txt,v $
82 $Date: 2000/00/00 00:00:00 $
82 $Date: 2000/00/00 00:00:00 $
83 $Id: demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $
83 $Id: demo.txt,v xxxxxxxxxxxx 2000/00/00 00:00:00 test $
84 $Revision: xxxxxxxxxxxx $
84 $Revision: xxxxxxxxxxxx $
85 [extensions]
85 [extensions]
86 hgext.keyword =
86 hgext.keyword =
87 [keyword]
87 [keyword]
88 * =
88 * =
89 b = ignore
89 b = ignore
90 demo.txt =
90 demo.txt =
91 [keywordmaps]
91 [keywordmaps]
92 Branch = {branches}
92 Branch = {branches}
93 $Branch: demobranch $
93 $Branch: demobranch $
94 % kwshrink should exit silently in empty/invalid repo
94 % kwshrink should exit silently in empty/invalid repo
95 pulling from test-keyword.hg
95 pulling from test-keyword.hg
96 requesting all changes
96 requesting all changes
97 adding changesets
97 adding changesets
98 adding manifests
98 adding manifests
99 adding file changes
99 adding file changes
100 added 1 changesets with 1 changes to 1 files
100 added 1 changesets with 1 changes to 1 files
101 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 % cat
102 % cat
103 expand $Id$
103 expand $Id$
104 do not process $Id:
104 do not process $Id:
105 xxx $
105 xxx $
106 ignore $Id$
106 ignore $Id$
107 % addremove
107 % addremove
108 adding a
108 adding a
109 adding b
109 adding b
110 % status
110 % status
111 A a
111 A a
112 A b
112 A b
113 % default keyword expansion including commit hook
113 % default keyword expansion including commit hook
114 % interrupted commit should not change state or run commit hook
114 % interrupted commit should not change state or run commit hook
115 a
116 b
117 transaction abort!
118 rollback completed
119 abort: empty commit message
115 abort: empty commit message
120 % status
116 % status
121 A a
117 A a
122 A b
118 A b
123 % commit
119 % commit
124 a
120 a
125 b
121 b
126 overwriting a expanding keywords
122 overwriting a expanding keywords
127 running hook commit.test: cp a hooktest
123 running hook commit.test: cp a hooktest
128 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
124 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
129 % status
125 % status
130 ? hooktest
126 ? hooktest
131 % identify
127 % identify
132 ef63ca68695b
128 ef63ca68695b
133 % cat
129 % cat
134 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
130 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
135 do not process $Id:
131 do not process $Id:
136 xxx $
132 xxx $
137 ignore $Id$
133 ignore $Id$
138 % hg cat
134 % hg cat
139 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
135 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
140 do not process $Id:
136 do not process $Id:
141 xxx $
137 xxx $
142 ignore $Id$
138 ignore $Id$
143 a
139 a
144 % diff a hooktest
140 % diff a hooktest
145 % removing commit hook from config
141 % removing commit hook from config
146 % bundle
142 % bundle
147 2 changesets found
143 2 changesets found
148 % notify on pull to check whether keywords stay as is in email
144 % notify on pull to check whether keywords stay as is in email
149 % ie. if patch.diff wrapper acts as it should
145 % ie. if patch.diff wrapper acts as it should
150 % pull from bundle
146 % pull from bundle
151 pulling from ../kw.hg
147 pulling from ../kw.hg
152 requesting all changes
148 requesting all changes
153 adding changesets
149 adding changesets
154 adding manifests
150 adding manifests
155 adding file changes
151 adding file changes
156 added 2 changesets with 3 changes to 3 files
152 added 2 changesets with 3 changes to 3 files
157
153
158 diff -r 000000000000 -r a2392c293916 sym
154 diff -r 000000000000 -r a2392c293916 sym
159 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
155 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
160 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
156 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
161 @@ -0,0 +1,1 @@
157 @@ -0,0 +1,1 @@
162 +a
158 +a
163 \ No newline at end of file
159 \ No newline at end of file
164
160
165 diff -r a2392c293916 -r ef63ca68695b a
161 diff -r a2392c293916 -r ef63ca68695b a
166 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
162 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
167 +++ b/a Thu Jan 01 00:00:00 1970 +0000
163 +++ b/a Thu Jan 01 00:00:00 1970 +0000
168 @@ -0,0 +1,3 @@
164 @@ -0,0 +1,3 @@
169 +expand $Id$
165 +expand $Id$
170 +do not process $Id:
166 +do not process $Id:
171 +xxx $
167 +xxx $
172 diff -r a2392c293916 -r ef63ca68695b b
168 diff -r a2392c293916 -r ef63ca68695b b
173 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
169 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
174 +++ b/b Thu Jan 01 00:00:00 1970 +0000
170 +++ b/b Thu Jan 01 00:00:00 1970 +0000
175 @@ -0,0 +1,1 @@
171 @@ -0,0 +1,1 @@
176 +ignore $Id$
172 +ignore $Id$
177 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
173 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
178 % remove notify config
174 % remove notify config
179 % touch
175 % touch
180 % status
176 % status
181 % update
177 % update
182 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
178 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
183 % cat
179 % cat
184 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
180 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
185 do not process $Id:
181 do not process $Id:
186 xxx $
182 xxx $
187 ignore $Id$
183 ignore $Id$
188 % check whether expansion is filewise
184 % check whether expansion is filewise
189 % commit c
185 % commit c
190 adding c
186 adding c
191 % force expansion
187 % force expansion
192 overwriting a expanding keywords
188 overwriting a expanding keywords
193 overwriting c expanding keywords
189 overwriting c expanding keywords
194 % compare changenodes in a c
190 % compare changenodes in a c
195 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
191 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
196 do not process $Id:
192 do not process $Id:
197 xxx $
193 xxx $
198 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
194 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
199 tests for different changenodes
195 tests for different changenodes
200 % qinit -c
196 % qinit -c
201 % qimport
197 % qimport
202 % qcommit
198 % qcommit
203 % keywords should not be expanded in patch
199 % keywords should not be expanded in patch
204 # HG changeset patch
200 # HG changeset patch
205 # User User Name <user@example.com>
201 # User User Name <user@example.com>
206 # Date 1 0
202 # Date 1 0
207 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
203 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
208 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
204 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
209 cndiff
205 cndiff
210
206
211 diff -r ef63ca68695b -r 40a904bbbe4c c
207 diff -r ef63ca68695b -r 40a904bbbe4c c
212 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
208 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
213 +++ b/c Thu Jan 01 00:00:01 1970 +0000
209 +++ b/c Thu Jan 01 00:00:01 1970 +0000
214 @@ -0,0 +1,2 @@
210 @@ -0,0 +1,2 @@
215 +$Id$
211 +$Id$
216 +tests for different changenodes
212 +tests for different changenodes
217 % qpop
213 % qpop
218 patch queue now empty
214 patch queue now empty
219 % qgoto - should imply qpush
215 % qgoto - should imply qpush
220 applying mqtest.diff
216 applying mqtest.diff
221 now at: mqtest.diff
217 now at: mqtest.diff
222 % cat
218 % cat
223 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
219 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
224 tests for different changenodes
220 tests for different changenodes
225 % qpop and move on
221 % qpop and move on
226 patch queue now empty
222 patch queue now empty
227 % copy
223 % copy
228 % kwfiles added
224 % kwfiles added
229 a
225 a
230 c
226 c
231 % commit
227 % commit
232 c
228 c
233 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
229 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
234 overwriting c expanding keywords
230 overwriting c expanding keywords
235 committed changeset 2:e22d299ac0c2bd8897b3df5114374b9e4d4ca62f
231 committed changeset 2:e22d299ac0c2bd8897b3df5114374b9e4d4ca62f
236 % cat a c
232 % cat a c
237 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
233 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
238 do not process $Id:
234 do not process $Id:
239 xxx $
235 xxx $
240 expand $Id: c,v e22d299ac0c2 1970/01/01 00:00:01 user $
236 expand $Id: c,v e22d299ac0c2 1970/01/01 00:00:01 user $
241 do not process $Id:
237 do not process $Id:
242 xxx $
238 xxx $
243 % touch copied c
239 % touch copied c
244 % status
240 % status
245 % kwfiles
241 % kwfiles
246 a
242 a
247 c
243 c
248 % diff --rev
244 % diff --rev
249 diff -r ef63ca68695b c
245 diff -r ef63ca68695b c
250 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
246 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
251 @@ -0,0 +1,3 @@
247 @@ -0,0 +1,3 @@
252 +expand $Id$
248 +expand $Id$
253 +do not process $Id:
249 +do not process $Id:
254 +xxx $
250 +xxx $
255 % rollback
251 % rollback
256 rolling back last transaction
252 rolling back last transaction
257 % status
253 % status
258 A c
254 A c
259 % update -C
255 % update -C
260 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
256 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
261 % custom keyword expansion
257 % custom keyword expansion
262 % try with kwdemo
258 % try with kwdemo
263 [extensions]
259 [extensions]
264 hgext.keyword =
260 hgext.keyword =
265 [keyword]
261 [keyword]
266 * =
262 * =
267 b = ignore
263 b = ignore
268 demo.txt =
264 demo.txt =
269 [keywordmaps]
265 [keywordmaps]
270 Xinfo = {author}: {desc}
266 Xinfo = {author}: {desc}
271 $Xinfo: test: hg keyword config and expansion example $
267 $Xinfo: test: hg keyword config and expansion example $
272 % cat
268 % cat
273 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
269 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
274 do not process $Id:
270 do not process $Id:
275 xxx $
271 xxx $
276 ignore $Id$
272 ignore $Id$
277 % hg cat
273 % hg cat
278 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
274 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
279 do not process $Id:
275 do not process $Id:
280 xxx $
276 xxx $
281 ignore $Id$
277 ignore $Id$
282 a
278 a
283 % interrupted commit should not change state
279 % interrupted commit should not change state
284 transaction abort!
285 rollback completed
286 abort: empty commit message
280 abort: empty commit message
287 % status
281 % status
288 M a
282 M a
289 ? log
283 ? log
290 % commit
284 % commit
291 a
285 a
292 overwriting a expanding keywords
286 overwriting a expanding keywords
293 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
287 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
294 % status
288 % status
295 % verify
289 % verify
296 checking changesets
290 checking changesets
297 checking manifests
291 checking manifests
298 crosschecking files in changesets and manifests
292 crosschecking files in changesets and manifests
299 checking files
293 checking files
300 3 files, 3 changesets, 4 total revisions
294 3 files, 3 changesets, 4 total revisions
301 % cat
295 % cat
302 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
296 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
303 do not process $Id:
297 do not process $Id:
304 xxx $
298 xxx $
305 $Xinfo: User Name <user@example.com>: firstline $
299 $Xinfo: User Name <user@example.com>: firstline $
306 ignore $Id$
300 ignore $Id$
307 % hg cat
301 % hg cat
308 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
302 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
309 do not process $Id:
303 do not process $Id:
310 xxx $
304 xxx $
311 $Xinfo: User Name <user@example.com>: firstline $
305 $Xinfo: User Name <user@example.com>: firstline $
312 ignore $Id$
306 ignore $Id$
313 a
307 a
314 % annotate
308 % annotate
315 1: expand $Id$
309 1: expand $Id$
316 1: do not process $Id:
310 1: do not process $Id:
317 1: xxx $
311 1: xxx $
318 2: $Xinfo$
312 2: $Xinfo$
319 % remove
313 % remove
320 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
314 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
321 % status
315 % status
322 % rollback
316 % rollback
323 rolling back last transaction
317 rolling back last transaction
324 % status
318 % status
325 R a
319 R a
326 % revert a
320 % revert a
327 % cat a
321 % cat a
328 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
322 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
329 do not process $Id:
323 do not process $Id:
330 xxx $
324 xxx $
331 $Xinfo: User Name <user@example.com>: firstline $
325 $Xinfo: User Name <user@example.com>: firstline $
332 % clone to test incoming
326 % clone to test incoming
333 requesting all changes
327 requesting all changes
334 adding changesets
328 adding changesets
335 adding manifests
329 adding manifests
336 adding file changes
330 adding file changes
337 added 2 changesets with 3 changes to 3 files
331 added 2 changesets with 3 changes to 3 files
338 updating working directory
332 updating working directory
339 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
333 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
340 % incoming
334 % incoming
341 comparing with test-keyword/Test
335 comparing with test-keyword/Test
342 searching for changes
336 searching for changes
343 changeset: 2:bb948857c743
337 changeset: 2:bb948857c743
344 tag: tip
338 tag: tip
345 user: User Name <user@example.com>
339 user: User Name <user@example.com>
346 date: Thu Jan 01 00:00:02 1970 +0000
340 date: Thu Jan 01 00:00:02 1970 +0000
347 summary: firstline
341 summary: firstline
348
342
349 % commit rejecttest
343 % commit rejecttest
350 a
344 a
351 overwriting a expanding keywords
345 overwriting a expanding keywords
352 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
346 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
353 % export
347 % export
354 % import
348 % import
355 applying ../rejecttest.diff
349 applying ../rejecttest.diff
356 % cat
350 % cat
357 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
351 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
358 do not process $Id: rejecttest
352 do not process $Id: rejecttest
359 xxx $
353 xxx $
360 $Xinfo: User Name <user@example.com>: rejects? $
354 $Xinfo: User Name <user@example.com>: rejects? $
361 ignore $Id$
355 ignore $Id$
362
356
363 % rollback
357 % rollback
364 rolling back last transaction
358 rolling back last transaction
365 % clean update
359 % clean update
366 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
360 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
367 % kwexpand/kwshrink on selected files
361 % kwexpand/kwshrink on selected files
368 % copy a x/a
362 % copy a x/a
369 % kwexpand a
363 % kwexpand a
370 overwriting a expanding keywords
364 overwriting a expanding keywords
371 % kwexpand x/a should abort
365 % kwexpand x/a should abort
372 abort: outstanding uncommitted changes
366 abort: outstanding uncommitted changes
373 x/a
367 x/a
374 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
368 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
375 overwriting x/a expanding keywords
369 overwriting x/a expanding keywords
376 committed changeset 3:cfa68229c1167443337266ebac453c73b1d5d16e
370 committed changeset 3:cfa68229c1167443337266ebac453c73b1d5d16e
377 % cat a
371 % cat a
378 expand $Id: x/a cfa68229c116 Thu, 01 Jan 1970 00:00:03 +0000 user $
372 expand $Id: x/a cfa68229c116 Thu, 01 Jan 1970 00:00:03 +0000 user $
379 do not process $Id:
373 do not process $Id:
380 xxx $
374 xxx $
381 $Xinfo: User Name <user@example.com>: xa $
375 $Xinfo: User Name <user@example.com>: xa $
382 % kwshrink a inside directory x
376 % kwshrink a inside directory x
383 overwriting x/a shrinking keywords
377 overwriting x/a shrinking keywords
384 % cat a
378 % cat a
385 expand $Id$
379 expand $Id$
386 do not process $Id:
380 do not process $Id:
387 xxx $
381 xxx $
388 $Xinfo$
382 $Xinfo$
389 % kwexpand nonexistent
383 % kwexpand nonexistent
390 nonexistent:
384 nonexistent:
391 % hg serve
385 % hg serve
392 % expansion
386 % expansion
393 % hgweb file
387 % hgweb file
394 200 Script output follows
388 200 Script output follows
395
389
396 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
390 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
397 do not process $Id:
391 do not process $Id:
398 xxx $
392 xxx $
399 $Xinfo: User Name <user@example.com>: firstline $
393 $Xinfo: User Name <user@example.com>: firstline $
400 % no expansion
394 % no expansion
401 % hgweb annotate
395 % hgweb annotate
402 200 Script output follows
396 200 Script output follows
403
397
404
398
405 user@1: expand $Id$
399 user@1: expand $Id$
406 user@1: do not process $Id:
400 user@1: do not process $Id:
407 user@1: xxx $
401 user@1: xxx $
408 user@2: $Xinfo$
402 user@2: $Xinfo$
409
403
410
404
411
405
412
406
413 % hgweb changeset
407 % hgweb changeset
414 200 Script output follows
408 200 Script output follows
415
409
416
410
417 # HG changeset patch
411 # HG changeset patch
418 # User User Name <user@example.com>
412 # User User Name <user@example.com>
419 # Date 3 0
413 # Date 3 0
420 # Node ID cfa68229c1167443337266ebac453c73b1d5d16e
414 # Node ID cfa68229c1167443337266ebac453c73b1d5d16e
421 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
415 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
422 xa
416 xa
423
417
424 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
418 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
425 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
419 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
426 @@ -0,0 +1,4 @@
420 @@ -0,0 +1,4 @@
427 +expand $Id$
421 +expand $Id$
428 +do not process $Id:
422 +do not process $Id:
429 +xxx $
423 +xxx $
430 +$Xinfo$
424 +$Xinfo$
431
425
432 % hgweb filediff
426 % hgweb filediff
433 200 Script output follows
427 200 Script output follows
434
428
435
429
436 --- a/a Thu Jan 01 00:00:00 1970 +0000
430 --- a/a Thu Jan 01 00:00:00 1970 +0000
437 +++ b/a Thu Jan 01 00:00:02 1970 +0000
431 +++ b/a Thu Jan 01 00:00:02 1970 +0000
438 @@ -1,3 +1,4 @@
432 @@ -1,3 +1,4 @@
439 expand $Id$
433 expand $Id$
440 do not process $Id:
434 do not process $Id:
441 xxx $
435 xxx $
442 +$Xinfo$
436 +$Xinfo$
443
437
444
438
445
439
446
440
447 % errors encountered
441 % errors encountered
448 % merge/resolve
442 % merge/resolve
449 % simplemerge
443 % simplemerge
450 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
444 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
451 created new head
445 created new head
452 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
446 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
453 (branch merge, don't forget to commit)
447 (branch merge, don't forget to commit)
454 $Id: m 8731e1dadc99 Thu, 01 Jan 1970 00:00:00 +0000 test $
448 $Id: m 8731e1dadc99 Thu, 01 Jan 1970 00:00:00 +0000 test $
455 foo
449 foo
456 % conflict
450 % conflict
457 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
451 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
458 created new head
452 created new head
459 merging m
453 merging m
460 warning: conflicts during merge.
454 warning: conflicts during merge.
461 merging m failed!
455 merging m failed!
462 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
456 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
463 use 'hg resolve' to retry unresolved file merges or 'hg up --clean' to abandon
457 use 'hg resolve' to retry unresolved file merges or 'hg up --clean' to abandon
464 % keyword stays outside conflict zone
458 % keyword stays outside conflict zone
465 $Id$
459 $Id$
466 <<<<<<< local
460 <<<<<<< local
467 bar
461 bar
468 =======
462 =======
469 foo
463 foo
470 >>>>>>> other
464 >>>>>>> other
471 % resolve to local
465 % resolve to local
472 $Id: m 43dfd2854b5b Thu, 01 Jan 1970 00:00:00 +0000 test $
466 $Id: m 43dfd2854b5b Thu, 01 Jan 1970 00:00:00 +0000 test $
473 bar
467 bar
474 % switch off expansion
468 % switch off expansion
475 % kwshrink with unknown file u
469 % kwshrink with unknown file u
476 overwriting a shrinking keywords
470 overwriting a shrinking keywords
477 overwriting m shrinking keywords
471 overwriting m shrinking keywords
478 overwriting x/a shrinking keywords
472 overwriting x/a shrinking keywords
479 % cat
473 % cat
480 expand $Id$
474 expand $Id$
481 do not process $Id:
475 do not process $Id:
482 xxx $
476 xxx $
483 $Xinfo$
477 $Xinfo$
484 ignore $Id$
478 ignore $Id$
485 % hg cat
479 % hg cat
486 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
480 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
487 do not process $Id:
481 do not process $Id:
488 xxx $
482 xxx $
489 $Xinfo: User Name <user@example.com>: firstline $
483 $Xinfo: User Name <user@example.com>: firstline $
490 ignore $Id$
484 ignore $Id$
491 a
485 a
492 % cat
486 % cat
493 expand $Id$
487 expand $Id$
494 do not process $Id:
488 do not process $Id:
495 xxx $
489 xxx $
496 $Xinfo$
490 $Xinfo$
497 ignore $Id$
491 ignore $Id$
498 % hg cat
492 % hg cat
499 expand $Id$
493 expand $Id$
500 do not process $Id:
494 do not process $Id:
501 xxx $
495 xxx $
502 $Xinfo$
496 $Xinfo$
503 ignore $Id$
497 ignore $Id$
504 a
498 a
@@ -1,576 +1,574 b''
1 % help
1 % help
2 hg record [OPTION]... [FILE]...
2 hg record [OPTION]... [FILE]...
3
3
4 interactively select changes to commit
4 interactively select changes to commit
5
5
6 If a list of files is omitted, all changes reported by "hg status"
6 If a list of files is omitted, all changes reported by "hg status"
7 will be candidates for recording.
7 will be candidates for recording.
8
8
9 See 'hg help dates' for a list of formats valid for -d/--date.
9 See 'hg help dates' for a list of formats valid for -d/--date.
10
10
11 You will be prompted for whether to record changes to each
11 You will be prompted for whether to record changes to each
12 modified file, and for files with multiple changes, for each
12 modified file, and for files with multiple changes, for each
13 change to use. For each query, the following responses are
13 change to use. For each query, the following responses are
14 possible:
14 possible:
15
15
16 y - record this change
16 y - record this change
17 n - skip this change
17 n - skip this change
18
18
19 s - skip remaining changes to this file
19 s - skip remaining changes to this file
20 f - record remaining changes to this file
20 f - record remaining changes to this file
21
21
22 d - done, skip remaining changes and files
22 d - done, skip remaining changes and files
23 a - record all changes to all remaining files
23 a - record all changes to all remaining files
24 q - quit, recording no changes
24 q - quit, recording no changes
25
25
26 ? - display help
26 ? - display help
27
27
28 options:
28 options:
29
29
30 -A --addremove mark new/missing files as added/removed before
30 -A --addremove mark new/missing files as added/removed before
31 committing
31 committing
32 --close-branch mark a branch as closed, hiding it from the branch
32 --close-branch mark a branch as closed, hiding it from the branch
33 list
33 list
34 -I --include include names matching the given patterns
34 -I --include include names matching the given patterns
35 -X --exclude exclude names matching the given patterns
35 -X --exclude exclude names matching the given patterns
36 -m --message use <text> as commit message
36 -m --message use <text> as commit message
37 -l --logfile read commit message from <file>
37 -l --logfile read commit message from <file>
38 -d --date record datecode as commit date
38 -d --date record datecode as commit date
39 -u --user record the specified user as committer
39 -u --user record the specified user as committer
40
40
41 use "hg -v help record" to show global options
41 use "hg -v help record" to show global options
42 % select no files
42 % select no files
43 diff --git a/empty-rw b/empty-rw
43 diff --git a/empty-rw b/empty-rw
44 new file mode 100644
44 new file mode 100644
45 examine changes to 'empty-rw'? [Ynsfdaq?] no changes to record
45 examine changes to 'empty-rw'? [Ynsfdaq?] no changes to record
46
46
47 changeset: -1:000000000000
47 changeset: -1:000000000000
48 tag: tip
48 tag: tip
49 user:
49 user:
50 date: Thu Jan 01 00:00:00 1970 +0000
50 date: Thu Jan 01 00:00:00 1970 +0000
51
51
52
52
53 % select files but no hunks
53 % select files but no hunks
54 diff --git a/empty-rw b/empty-rw
54 diff --git a/empty-rw b/empty-rw
55 new file mode 100644
55 new file mode 100644
56 examine changes to 'empty-rw'? [Ynsfdaq?] transaction abort!
56 examine changes to 'empty-rw'? [Ynsfdaq?] abort: empty commit message
57 rollback completed
58 abort: empty commit message
59
57
60 changeset: -1:000000000000
58 changeset: -1:000000000000
61 tag: tip
59 tag: tip
62 user:
60 user:
63 date: Thu Jan 01 00:00:00 1970 +0000
61 date: Thu Jan 01 00:00:00 1970 +0000
64
62
65
63
66 % record empty file
64 % record empty file
67 diff --git a/empty-rw b/empty-rw
65 diff --git a/empty-rw b/empty-rw
68 new file mode 100644
66 new file mode 100644
69 examine changes to 'empty-rw'? [Ynsfdaq?]
67 examine changes to 'empty-rw'? [Ynsfdaq?]
70 changeset: 0:c0708cf4e46e
68 changeset: 0:c0708cf4e46e
71 tag: tip
69 tag: tip
72 user: test
70 user: test
73 date: Thu Jan 01 00:00:00 1970 +0000
71 date: Thu Jan 01 00:00:00 1970 +0000
74 summary: empty
72 summary: empty
75
73
76
74
77 % rename empty file
75 % rename empty file
78 diff --git a/empty-rw b/empty-rename
76 diff --git a/empty-rw b/empty-rename
79 rename from empty-rw
77 rename from empty-rw
80 rename to empty-rename
78 rename to empty-rename
81 examine changes to 'empty-rw' and 'empty-rename'? [Ynsfdaq?]
79 examine changes to 'empty-rw' and 'empty-rename'? [Ynsfdaq?]
82 changeset: 1:df251d174da3
80 changeset: 1:df251d174da3
83 tag: tip
81 tag: tip
84 user: test
82 user: test
85 date: Thu Jan 01 00:00:01 1970 +0000
83 date: Thu Jan 01 00:00:01 1970 +0000
86 summary: rename
84 summary: rename
87
85
88
86
89 % copy empty file
87 % copy empty file
90 diff --git a/empty-rename b/empty-copy
88 diff --git a/empty-rename b/empty-copy
91 copy from empty-rename
89 copy from empty-rename
92 copy to empty-copy
90 copy to empty-copy
93 examine changes to 'empty-rename' and 'empty-copy'? [Ynsfdaq?]
91 examine changes to 'empty-rename' and 'empty-copy'? [Ynsfdaq?]
94 changeset: 2:b63ea3939f8d
92 changeset: 2:b63ea3939f8d
95 tag: tip
93 tag: tip
96 user: test
94 user: test
97 date: Thu Jan 01 00:00:02 1970 +0000
95 date: Thu Jan 01 00:00:02 1970 +0000
98 summary: copy
96 summary: copy
99
97
100
98
101 % delete empty file
99 % delete empty file
102 diff --git a/empty-copy b/empty-copy
100 diff --git a/empty-copy b/empty-copy
103 deleted file mode 100644
101 deleted file mode 100644
104 examine changes to 'empty-copy'? [Ynsfdaq?]
102 examine changes to 'empty-copy'? [Ynsfdaq?]
105 changeset: 3:a2546574bce9
103 changeset: 3:a2546574bce9
106 tag: tip
104 tag: tip
107 user: test
105 user: test
108 date: Thu Jan 01 00:00:03 1970 +0000
106 date: Thu Jan 01 00:00:03 1970 +0000
109 summary: delete
107 summary: delete
110
108
111
109
112 % add binary file
110 % add binary file
113 1 changesets found
111 1 changesets found
114 diff --git a/tip.bundle b/tip.bundle
112 diff --git a/tip.bundle b/tip.bundle
115 new file mode 100644
113 new file mode 100644
116 this is a binary file
114 this is a binary file
117 examine changes to 'tip.bundle'? [Ynsfdaq?]
115 examine changes to 'tip.bundle'? [Ynsfdaq?]
118 changeset: 4:9e998a545a8b
116 changeset: 4:9e998a545a8b
119 tag: tip
117 tag: tip
120 user: test
118 user: test
121 date: Thu Jan 01 00:00:04 1970 +0000
119 date: Thu Jan 01 00:00:04 1970 +0000
122 summary: binary
120 summary: binary
123
121
124 diff -r a2546574bce9 -r 9e998a545a8b tip.bundle
122 diff -r a2546574bce9 -r 9e998a545a8b tip.bundle
125 Binary file tip.bundle has changed
123 Binary file tip.bundle has changed
126
124
127 % change binary file
125 % change binary file
128 1 changesets found
126 1 changesets found
129 diff --git a/tip.bundle b/tip.bundle
127 diff --git a/tip.bundle b/tip.bundle
130 this modifies a binary file (all or nothing)
128 this modifies a binary file (all or nothing)
131 examine changes to 'tip.bundle'? [Ynsfdaq?]
129 examine changes to 'tip.bundle'? [Ynsfdaq?]
132 changeset: 5:93d05561507d
130 changeset: 5:93d05561507d
133 tag: tip
131 tag: tip
134 user: test
132 user: test
135 date: Thu Jan 01 00:00:05 1970 +0000
133 date: Thu Jan 01 00:00:05 1970 +0000
136 summary: binary-change
134 summary: binary-change
137
135
138 diff -r 9e998a545a8b -r 93d05561507d tip.bundle
136 diff -r 9e998a545a8b -r 93d05561507d tip.bundle
139 Binary file tip.bundle has changed
137 Binary file tip.bundle has changed
140
138
141 % rename and change binary file
139 % rename and change binary file
142 1 changesets found
140 1 changesets found
143 diff --git a/tip.bundle b/top.bundle
141 diff --git a/tip.bundle b/top.bundle
144 rename from tip.bundle
142 rename from tip.bundle
145 rename to top.bundle
143 rename to top.bundle
146 this modifies a binary file (all or nothing)
144 this modifies a binary file (all or nothing)
147 examine changes to 'tip.bundle' and 'top.bundle'? [Ynsfdaq?]
145 examine changes to 'tip.bundle' and 'top.bundle'? [Ynsfdaq?]
148 changeset: 6:699cc1bea9aa
146 changeset: 6:699cc1bea9aa
149 tag: tip
147 tag: tip
150 user: test
148 user: test
151 date: Thu Jan 01 00:00:06 1970 +0000
149 date: Thu Jan 01 00:00:06 1970 +0000
152 summary: binary-change-rename
150 summary: binary-change-rename
153
151
154 diff -r 93d05561507d -r 699cc1bea9aa tip.bundle
152 diff -r 93d05561507d -r 699cc1bea9aa tip.bundle
155 Binary file tip.bundle has changed
153 Binary file tip.bundle has changed
156 diff -r 93d05561507d -r 699cc1bea9aa top.bundle
154 diff -r 93d05561507d -r 699cc1bea9aa top.bundle
157 Binary file top.bundle has changed
155 Binary file top.bundle has changed
158
156
159 % add plain file
157 % add plain file
160 diff --git a/plain b/plain
158 diff --git a/plain b/plain
161 new file mode 100644
159 new file mode 100644
162 examine changes to 'plain'? [Ynsfdaq?]
160 examine changes to 'plain'? [Ynsfdaq?]
163 changeset: 7:118ed744216b
161 changeset: 7:118ed744216b
164 tag: tip
162 tag: tip
165 user: test
163 user: test
166 date: Thu Jan 01 00:00:07 1970 +0000
164 date: Thu Jan 01 00:00:07 1970 +0000
167 summary: plain
165 summary: plain
168
166
169 diff -r 699cc1bea9aa -r 118ed744216b plain
167 diff -r 699cc1bea9aa -r 118ed744216b plain
170 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
168 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
171 +++ b/plain Thu Jan 01 00:00:07 1970 +0000
169 +++ b/plain Thu Jan 01 00:00:07 1970 +0000
172 @@ -0,0 +1,10 @@
170 @@ -0,0 +1,10 @@
173 +1
171 +1
174 +2
172 +2
175 +3
173 +3
176 +4
174 +4
177 +5
175 +5
178 +6
176 +6
179 +7
177 +7
180 +8
178 +8
181 +9
179 +9
182 +10
180 +10
183
181
184 % modify end of plain file
182 % modify end of plain file
185 diff --git a/plain b/plain
183 diff --git a/plain b/plain
186 1 hunks, 1 lines changed
184 1 hunks, 1 lines changed
187 examine changes to 'plain'? [Ynsfdaq?] @@ -8,3 +8,4 @@
185 examine changes to 'plain'? [Ynsfdaq?] @@ -8,3 +8,4 @@
188 8
186 8
189 9
187 9
190 10
188 10
191 +11
189 +11
192 record this change to 'plain'? [Ynsfdaq?] % modify end of plain file, no EOL
190 record this change to 'plain'? [Ynsfdaq?] % modify end of plain file, no EOL
193 diff --git a/plain b/plain
191 diff --git a/plain b/plain
194 1 hunks, 1 lines changed
192 1 hunks, 1 lines changed
195 examine changes to 'plain'? [Ynsfdaq?] @@ -9,3 +9,4 @@
193 examine changes to 'plain'? [Ynsfdaq?] @@ -9,3 +9,4 @@
196 9
194 9
197 10
195 10
198 11
196 11
199 +cf81a2760718a74d44c0c2eecb72f659e63a69c5
197 +cf81a2760718a74d44c0c2eecb72f659e63a69c5
200 \ No newline at end of file
198 \ No newline at end of file
201 record this change to 'plain'? [Ynsfdaq?] % modify end of plain file, add EOL
199 record this change to 'plain'? [Ynsfdaq?] % modify end of plain file, add EOL
202 diff --git a/plain b/plain
200 diff --git a/plain b/plain
203 1 hunks, 2 lines changed
201 1 hunks, 2 lines changed
204 examine changes to 'plain'? [Ynsfdaq?] @@ -9,4 +9,4 @@
202 examine changes to 'plain'? [Ynsfdaq?] @@ -9,4 +9,4 @@
205 9
203 9
206 10
204 10
207 11
205 11
208 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
206 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
209 \ No newline at end of file
207 \ No newline at end of file
210 +cf81a2760718a74d44c0c2eecb72f659e63a69c5
208 +cf81a2760718a74d44c0c2eecb72f659e63a69c5
211 record this change to 'plain'? [Ynsfdaq?] % modify beginning, trim end, record both
209 record this change to 'plain'? [Ynsfdaq?] % modify beginning, trim end, record both
212 diff --git a/plain b/plain
210 diff --git a/plain b/plain
213 2 hunks, 4 lines changed
211 2 hunks, 4 lines changed
214 examine changes to 'plain'? [Ynsfdaq?] @@ -1,4 +1,4 @@
212 examine changes to 'plain'? [Ynsfdaq?] @@ -1,4 +1,4 @@
215 -1
213 -1
216 +2
214 +2
217 2
215 2
218 3
216 3
219 4
217 4
220 record change 1/2 to 'plain'? [Ynsfdaq?] @@ -8,5 +8,3 @@
218 record change 1/2 to 'plain'? [Ynsfdaq?] @@ -8,5 +8,3 @@
221 8
219 8
222 9
220 9
223 10
221 10
224 -11
222 -11
225 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
223 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
226 record change 2/2 to 'plain'? [Ynsfdaq?]
224 record change 2/2 to 'plain'? [Ynsfdaq?]
227 changeset: 11:d09ab1967dab
225 changeset: 11:d09ab1967dab
228 tag: tip
226 tag: tip
229 user: test
227 user: test
230 date: Thu Jan 01 00:00:10 1970 +0000
228 date: Thu Jan 01 00:00:10 1970 +0000
231 summary: begin-and-end
229 summary: begin-and-end
232
230
233 diff -r e2ecd9b0b78d -r d09ab1967dab plain
231 diff -r e2ecd9b0b78d -r d09ab1967dab plain
234 --- a/plain Thu Jan 01 00:00:10 1970 +0000
232 --- a/plain Thu Jan 01 00:00:10 1970 +0000
235 +++ b/plain Thu Jan 01 00:00:10 1970 +0000
233 +++ b/plain Thu Jan 01 00:00:10 1970 +0000
236 @@ -1,4 +1,4 @@
234 @@ -1,4 +1,4 @@
237 -1
235 -1
238 +2
236 +2
239 2
237 2
240 3
238 3
241 4
239 4
242 @@ -8,5 +8,3 @@
240 @@ -8,5 +8,3 @@
243 8
241 8
244 9
242 9
245 10
243 10
246 -11
244 -11
247 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
245 -cf81a2760718a74d44c0c2eecb72f659e63a69c5
248
246
249 % trim beginning, modify end
247 % trim beginning, modify end
250 % record end
248 % record end
251 diff --git a/plain b/plain
249 diff --git a/plain b/plain
252 2 hunks, 5 lines changed
250 2 hunks, 5 lines changed
253 examine changes to 'plain'? [Ynsfdaq?] @@ -1,9 +1,6 @@
251 examine changes to 'plain'? [Ynsfdaq?] @@ -1,9 +1,6 @@
254 -2
252 -2
255 -2
253 -2
256 -3
254 -3
257 4
255 4
258 5
256 5
259 6
257 6
260 7
258 7
261 8
259 8
262 9
260 9
263 record change 1/2 to 'plain'? [Ynsfdaq?] @@ -4,7 +1,7 @@
261 record change 1/2 to 'plain'? [Ynsfdaq?] @@ -4,7 +1,7 @@
264 4
262 4
265 5
263 5
266 6
264 6
267 7
265 7
268 8
266 8
269 9
267 9
270 -10
268 -10
271 +10.new
269 +10.new
272 record change 2/2 to 'plain'? [Ynsfdaq?]
270 record change 2/2 to 'plain'? [Ynsfdaq?]
273 changeset: 12:44516c9708ae
271 changeset: 12:44516c9708ae
274 tag: tip
272 tag: tip
275 user: test
273 user: test
276 date: Thu Jan 01 00:00:11 1970 +0000
274 date: Thu Jan 01 00:00:11 1970 +0000
277 summary: end-only
275 summary: end-only
278
276
279 diff -r d09ab1967dab -r 44516c9708ae plain
277 diff -r d09ab1967dab -r 44516c9708ae plain
280 --- a/plain Thu Jan 01 00:00:10 1970 +0000
278 --- a/plain Thu Jan 01 00:00:10 1970 +0000
281 +++ b/plain Thu Jan 01 00:00:11 1970 +0000
279 +++ b/plain Thu Jan 01 00:00:11 1970 +0000
282 @@ -7,4 +7,4 @@
280 @@ -7,4 +7,4 @@
283 7
281 7
284 8
282 8
285 9
283 9
286 -10
284 -10
287 +10.new
285 +10.new
288
286
289 % record beginning
287 % record beginning
290 diff --git a/plain b/plain
288 diff --git a/plain b/plain
291 1 hunks, 3 lines changed
289 1 hunks, 3 lines changed
292 examine changes to 'plain'? [Ynsfdaq?] @@ -1,6 +1,3 @@
290 examine changes to 'plain'? [Ynsfdaq?] @@ -1,6 +1,3 @@
293 -2
291 -2
294 -2
292 -2
295 -3
293 -3
296 4
294 4
297 5
295 5
298 6
296 6
299 record this change to 'plain'? [Ynsfdaq?]
297 record this change to 'plain'? [Ynsfdaq?]
300 changeset: 13:3ebbace64a8d
298 changeset: 13:3ebbace64a8d
301 tag: tip
299 tag: tip
302 user: test
300 user: test
303 date: Thu Jan 01 00:00:12 1970 +0000
301 date: Thu Jan 01 00:00:12 1970 +0000
304 summary: begin-only
302 summary: begin-only
305
303
306 diff -r 44516c9708ae -r 3ebbace64a8d plain
304 diff -r 44516c9708ae -r 3ebbace64a8d plain
307 --- a/plain Thu Jan 01 00:00:11 1970 +0000
305 --- a/plain Thu Jan 01 00:00:11 1970 +0000
308 +++ b/plain Thu Jan 01 00:00:12 1970 +0000
306 +++ b/plain Thu Jan 01 00:00:12 1970 +0000
309 @@ -1,6 +1,3 @@
307 @@ -1,6 +1,3 @@
310 -2
308 -2
311 -2
309 -2
312 -3
310 -3
313 4
311 4
314 5
312 5
315 6
313 6
316
314
317 % add to beginning, trim from end
315 % add to beginning, trim from end
318 % record end
316 % record end
319 diff --git a/plain b/plain
317 diff --git a/plain b/plain
320 2 hunks, 4 lines changed
318 2 hunks, 4 lines changed
321 examine changes to 'plain'? [Ynsfdaq?] @@ -1,6 +1,9 @@
319 examine changes to 'plain'? [Ynsfdaq?] @@ -1,6 +1,9 @@
322 +1
320 +1
323 +2
321 +2
324 +3
322 +3
325 4
323 4
326 5
324 5
327 6
325 6
328 7
326 7
329 8
327 8
330 9
328 9
331 record change 1/2 to 'plain'? [Ynsfdaq?] @@ -1,7 +4,6 @@
329 record change 1/2 to 'plain'? [Ynsfdaq?] @@ -1,7 +4,6 @@
332 4
330 4
333 5
331 5
334 6
332 6
335 7
333 7
336 8
334 8
337 9
335 9
338 -10.new
336 -10.new
339 record change 2/2 to 'plain'? [Ynsfdaq?] % add to beginning, middle, end
337 record change 2/2 to 'plain'? [Ynsfdaq?] % add to beginning, middle, end
340 % record beginning, middle
338 % record beginning, middle
341 diff --git a/plain b/plain
339 diff --git a/plain b/plain
342 3 hunks, 7 lines changed
340 3 hunks, 7 lines changed
343 examine changes to 'plain'? [Ynsfdaq?] @@ -1,2 +1,5 @@
341 examine changes to 'plain'? [Ynsfdaq?] @@ -1,2 +1,5 @@
344 +1
342 +1
345 +2
343 +2
346 +3
344 +3
347 4
345 4
348 5
346 5
349 record change 1/3 to 'plain'? [Ynsfdaq?] @@ -1,6 +4,8 @@
347 record change 1/3 to 'plain'? [Ynsfdaq?] @@ -1,6 +4,8 @@
350 4
348 4
351 5
349 5
352 +5.new
350 +5.new
353 +5.reallynew
351 +5.reallynew
354 6
352 6
355 7
353 7
356 8
354 8
357 9
355 9
358 record change 2/3 to 'plain'? [Ynsfdaq?] @@ -3,4 +8,6 @@
356 record change 2/3 to 'plain'? [Ynsfdaq?] @@ -3,4 +8,6 @@
359 6
357 6
360 7
358 7
361 8
359 8
362 9
360 9
363 +10
361 +10
364 +11
362 +11
365 record change 3/3 to 'plain'? [Ynsfdaq?]
363 record change 3/3 to 'plain'? [Ynsfdaq?]
366 changeset: 15:c1c639d8b268
364 changeset: 15:c1c639d8b268
367 tag: tip
365 tag: tip
368 user: test
366 user: test
369 date: Thu Jan 01 00:00:14 1970 +0000
367 date: Thu Jan 01 00:00:14 1970 +0000
370 summary: middle-only
368 summary: middle-only
371
369
372 diff -r efc0dad7bd9f -r c1c639d8b268 plain
370 diff -r efc0dad7bd9f -r c1c639d8b268 plain
373 --- a/plain Thu Jan 01 00:00:13 1970 +0000
371 --- a/plain Thu Jan 01 00:00:13 1970 +0000
374 +++ b/plain Thu Jan 01 00:00:14 1970 +0000
372 +++ b/plain Thu Jan 01 00:00:14 1970 +0000
375 @@ -1,5 +1,10 @@
373 @@ -1,5 +1,10 @@
376 +1
374 +1
377 +2
375 +2
378 +3
376 +3
379 4
377 4
380 5
378 5
381 +5.new
379 +5.new
382 +5.reallynew
380 +5.reallynew
383 6
381 6
384 7
382 7
385 8
383 8
386
384
387 % record end
385 % record end
388 diff --git a/plain b/plain
386 diff --git a/plain b/plain
389 1 hunks, 2 lines changed
387 1 hunks, 2 lines changed
390 examine changes to 'plain'? [Ynsfdaq?] @@ -9,3 +9,5 @@
388 examine changes to 'plain'? [Ynsfdaq?] @@ -9,3 +9,5 @@
391 7
389 7
392 8
390 8
393 9
391 9
394 +10
392 +10
395 +11
393 +11
396 record this change to 'plain'? [Ynsfdaq?]
394 record this change to 'plain'? [Ynsfdaq?]
397 changeset: 16:80b74bbc7808
395 changeset: 16:80b74bbc7808
398 tag: tip
396 tag: tip
399 user: test
397 user: test
400 date: Thu Jan 01 00:00:15 1970 +0000
398 date: Thu Jan 01 00:00:15 1970 +0000
401 summary: end-only
399 summary: end-only
402
400
403 diff -r c1c639d8b268 -r 80b74bbc7808 plain
401 diff -r c1c639d8b268 -r 80b74bbc7808 plain
404 --- a/plain Thu Jan 01 00:00:14 1970 +0000
402 --- a/plain Thu Jan 01 00:00:14 1970 +0000
405 +++ b/plain Thu Jan 01 00:00:15 1970 +0000
403 +++ b/plain Thu Jan 01 00:00:15 1970 +0000
406 @@ -9,3 +9,5 @@
404 @@ -9,3 +9,5 @@
407 7
405 7
408 8
406 8
409 9
407 9
410 +10
408 +10
411 +11
409 +11
412
410
413 adding subdir/a
411 adding subdir/a
414 diff --git a/subdir/a b/subdir/a
412 diff --git a/subdir/a b/subdir/a
415 1 hunks, 1 lines changed
413 1 hunks, 1 lines changed
416 examine changes to 'subdir/a'? [Ynsfdaq?] @@ -1,1 +1,2 @@
414 examine changes to 'subdir/a'? [Ynsfdaq?] @@ -1,1 +1,2 @@
417 a
415 a
418 +a
416 +a
419 record this change to 'subdir/a'? [Ynsfdaq?]
417 record this change to 'subdir/a'? [Ynsfdaq?]
420 changeset: 18:33ff5c4fb017
418 changeset: 18:33ff5c4fb017
421 tag: tip
419 tag: tip
422 user: test
420 user: test
423 date: Thu Jan 01 00:00:16 1970 +0000
421 date: Thu Jan 01 00:00:16 1970 +0000
424 summary: subdir-change
422 summary: subdir-change
425
423
426 diff -r aecf2b2ea83c -r 33ff5c4fb017 subdir/a
424 diff -r aecf2b2ea83c -r 33ff5c4fb017 subdir/a
427 --- a/subdir/a Thu Jan 01 00:00:16 1970 +0000
425 --- a/subdir/a Thu Jan 01 00:00:16 1970 +0000
428 +++ b/subdir/a Thu Jan 01 00:00:16 1970 +0000
426 +++ b/subdir/a Thu Jan 01 00:00:16 1970 +0000
429 @@ -1,1 +1,2 @@
427 @@ -1,1 +1,2 @@
430 a
428 a
431 +a
429 +a
432
430
433 % help, quit
431 % help, quit
434 diff --git a/subdir/f1 b/subdir/f1
432 diff --git a/subdir/f1 b/subdir/f1
435 1 hunks, 1 lines changed
433 1 hunks, 1 lines changed
436 examine changes to 'subdir/f1'? [Ynsfdaq?] y - record this change
434 examine changes to 'subdir/f1'? [Ynsfdaq?] y - record this change
437 n - skip this change
435 n - skip this change
438 s - skip remaining changes to this file
436 s - skip remaining changes to this file
439 f - record remaining changes to this file
437 f - record remaining changes to this file
440 d - done, skip remaining changes and files
438 d - done, skip remaining changes and files
441 a - record all changes to all remaining files
439 a - record all changes to all remaining files
442 q - quit, recording no changes
440 q - quit, recording no changes
443 ? - display help
441 ? - display help
444 examine changes to 'subdir/f1'? [Ynsfdaq?] abort: user quit
442 examine changes to 'subdir/f1'? [Ynsfdaq?] abort: user quit
445 % skip
443 % skip
446 diff --git a/subdir/f1 b/subdir/f1
444 diff --git a/subdir/f1 b/subdir/f1
447 1 hunks, 1 lines changed
445 1 hunks, 1 lines changed
448 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
446 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
449 1 hunks, 1 lines changed
447 1 hunks, 1 lines changed
450 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: response expected
448 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: response expected
451 % no
449 % no
452 diff --git a/subdir/f1 b/subdir/f1
450 diff --git a/subdir/f1 b/subdir/f1
453 1 hunks, 1 lines changed
451 1 hunks, 1 lines changed
454 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
452 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
455 1 hunks, 1 lines changed
453 1 hunks, 1 lines changed
456 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: response expected
454 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: response expected
457 % f, quit
455 % f, quit
458 diff --git a/subdir/f1 b/subdir/f1
456 diff --git a/subdir/f1 b/subdir/f1
459 1 hunks, 1 lines changed
457 1 hunks, 1 lines changed
460 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
458 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
461 1 hunks, 1 lines changed
459 1 hunks, 1 lines changed
462 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: user quit
460 examine changes to 'subdir/f2'? [Ynsfdaq?] abort: user quit
463 % s, all
461 % s, all
464 diff --git a/subdir/f1 b/subdir/f1
462 diff --git a/subdir/f1 b/subdir/f1
465 1 hunks, 1 lines changed
463 1 hunks, 1 lines changed
466 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
464 examine changes to 'subdir/f1'? [Ynsfdaq?] diff --git a/subdir/f2 b/subdir/f2
467 1 hunks, 1 lines changed
465 1 hunks, 1 lines changed
468 examine changes to 'subdir/f2'? [Ynsfdaq?]
466 examine changes to 'subdir/f2'? [Ynsfdaq?]
469 changeset: 20:094183e04b7c
467 changeset: 20:094183e04b7c
470 tag: tip
468 tag: tip
471 user: test
469 user: test
472 date: Thu Jan 01 00:00:18 1970 +0000
470 date: Thu Jan 01 00:00:18 1970 +0000
473 summary: x
471 summary: x
474
472
475 diff -r f9e855cd9374 -r 094183e04b7c subdir/f2
473 diff -r f9e855cd9374 -r 094183e04b7c subdir/f2
476 --- a/subdir/f2 Thu Jan 01 00:00:17 1970 +0000
474 --- a/subdir/f2 Thu Jan 01 00:00:17 1970 +0000
477 +++ b/subdir/f2 Thu Jan 01 00:00:18 1970 +0000
475 +++ b/subdir/f2 Thu Jan 01 00:00:18 1970 +0000
478 @@ -1,1 +1,2 @@
476 @@ -1,1 +1,2 @@
479 b
477 b
480 +b
478 +b
481
479
482 % f
480 % f
483 diff --git a/subdir/f1 b/subdir/f1
481 diff --git a/subdir/f1 b/subdir/f1
484 1 hunks, 1 lines changed
482 1 hunks, 1 lines changed
485 examine changes to 'subdir/f1'? [Ynsfdaq?]
483 examine changes to 'subdir/f1'? [Ynsfdaq?]
486 changeset: 21:38164785b0ef
484 changeset: 21:38164785b0ef
487 tag: tip
485 tag: tip
488 user: test
486 user: test
489 date: Thu Jan 01 00:00:19 1970 +0000
487 date: Thu Jan 01 00:00:19 1970 +0000
490 summary: y
488 summary: y
491
489
492 diff -r 094183e04b7c -r 38164785b0ef subdir/f1
490 diff -r 094183e04b7c -r 38164785b0ef subdir/f1
493 --- a/subdir/f1 Thu Jan 01 00:00:18 1970 +0000
491 --- a/subdir/f1 Thu Jan 01 00:00:18 1970 +0000
494 +++ b/subdir/f1 Thu Jan 01 00:00:19 1970 +0000
492 +++ b/subdir/f1 Thu Jan 01 00:00:19 1970 +0000
495 @@ -1,1 +1,2 @@
493 @@ -1,1 +1,2 @@
496 a
494 a
497 +a
495 +a
498
496
499 % preserve chmod +x
497 % preserve chmod +x
500 diff --git a/subdir/f1 b/subdir/f1
498 diff --git a/subdir/f1 b/subdir/f1
501 old mode 100644
499 old mode 100644
502 new mode 100755
500 new mode 100755
503 1 hunks, 1 lines changed
501 1 hunks, 1 lines changed
504 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -1,2 +1,3 @@
502 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -1,2 +1,3 @@
505 a
503 a
506 a
504 a
507 +a
505 +a
508 record this change to 'subdir/f1'? [Ynsfdaq?]
506 record this change to 'subdir/f1'? [Ynsfdaq?]
509 changeset: 22:a891589cb933
507 changeset: 22:a891589cb933
510 tag: tip
508 tag: tip
511 user: test
509 user: test
512 date: Thu Jan 01 00:00:20 1970 +0000
510 date: Thu Jan 01 00:00:20 1970 +0000
513 summary: z
511 summary: z
514
512
515 diff --git a/subdir/f1 b/subdir/f1
513 diff --git a/subdir/f1 b/subdir/f1
516 old mode 100644
514 old mode 100644
517 new mode 100755
515 new mode 100755
518 --- a/subdir/f1
516 --- a/subdir/f1
519 +++ b/subdir/f1
517 +++ b/subdir/f1
520 @@ -1,2 +1,3 @@
518 @@ -1,2 +1,3 @@
521 a
519 a
522 a
520 a
523 +a
521 +a
524
522
525 % preserve execute permission on original
523 % preserve execute permission on original
526 diff --git a/subdir/f1 b/subdir/f1
524 diff --git a/subdir/f1 b/subdir/f1
527 1 hunks, 1 lines changed
525 1 hunks, 1 lines changed
528 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -1,3 +1,4 @@
526 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -1,3 +1,4 @@
529 a
527 a
530 a
528 a
531 a
529 a
532 +b
530 +b
533 record this change to 'subdir/f1'? [Ynsfdaq?]
531 record this change to 'subdir/f1'? [Ynsfdaq?]
534 changeset: 23:befa0dae6201
532 changeset: 23:befa0dae6201
535 tag: tip
533 tag: tip
536 user: test
534 user: test
537 date: Thu Jan 01 00:00:21 1970 +0000
535 date: Thu Jan 01 00:00:21 1970 +0000
538 summary: aa
536 summary: aa
539
537
540 diff --git a/subdir/f1 b/subdir/f1
538 diff --git a/subdir/f1 b/subdir/f1
541 --- a/subdir/f1
539 --- a/subdir/f1
542 +++ b/subdir/f1
540 +++ b/subdir/f1
543 @@ -1,3 +1,4 @@
541 @@ -1,3 +1,4 @@
544 a
542 a
545 a
543 a
546 a
544 a
547 +b
545 +b
548
546
549 % preserve chmod -x
547 % preserve chmod -x
550 diff --git a/subdir/f1 b/subdir/f1
548 diff --git a/subdir/f1 b/subdir/f1
551 old mode 100755
549 old mode 100755
552 new mode 100644
550 new mode 100644
553 1 hunks, 1 lines changed
551 1 hunks, 1 lines changed
554 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -2,3 +2,4 @@
552 examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -2,3 +2,4 @@
555 a
553 a
556 a
554 a
557 b
555 b
558 +c
556 +c
559 record this change to 'subdir/f1'? [Ynsfdaq?]
557 record this change to 'subdir/f1'? [Ynsfdaq?]
560 changeset: 24:8fd83ff53ce6
558 changeset: 24:8fd83ff53ce6
561 tag: tip
559 tag: tip
562 user: test
560 user: test
563 date: Thu Jan 01 00:00:22 1970 +0000
561 date: Thu Jan 01 00:00:22 1970 +0000
564 summary: ab
562 summary: ab
565
563
566 diff --git a/subdir/f1 b/subdir/f1
564 diff --git a/subdir/f1 b/subdir/f1
567 old mode 100755
565 old mode 100755
568 new mode 100644
566 new mode 100644
569 --- a/subdir/f1
567 --- a/subdir/f1
570 +++ b/subdir/f1
568 +++ b/subdir/f1
571 @@ -2,3 +2,4 @@
569 @@ -2,3 +2,4 @@
572 a
570 a
573 a
571 a
574 b
572 b
575 +c
573 +c
576
574
General Comments 0
You need to be logged in to leave comments. Login now