##// END OF EJS Templates
subrepo: print paths relative to upper repo root for push/pull/commit...
Edouard Gomez -
r11112:4a9bee61 default
parent child Browse files
Show More
@@ -1,2261 +1,2263 b''
1 1 # localrepo.py - read/write repository class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from node import bin, hex, nullid, nullrev, short
9 9 from i18n import _
10 10 import repo, changegroup, subrepo
11 11 import changelog, dirstate, filelog, manifest, context
12 12 import lock, transaction, store, encoding
13 13 import util, extensions, hook, error
14 14 import match as matchmod
15 15 import merge as mergemod
16 16 import tags as tagsmod
17 17 import url as urlmod
18 18 from lock import release
19 19 import weakref, stat, errno, os, time, inspect
20 20 propertycache = util.propertycache
21 21
22 22 class localrepository(repo.repository):
23 23 capabilities = set(('lookup', 'changegroupsubset', 'branchmap'))
24 24 supported = set('revlogv1 store fncache shared'.split())
25 25
26 26 def __init__(self, baseui, path=None, create=0):
27 27 repo.repository.__init__(self)
28 28 self.root = os.path.realpath(path)
29 29 self.path = os.path.join(self.root, ".hg")
30 30 self.origroot = path
31 31 self.opener = util.opener(self.path)
32 32 self.wopener = util.opener(self.root)
33 33 self.baseui = baseui
34 34 self.ui = baseui.copy()
35 35
36 36 try:
37 37 self.ui.readconfig(self.join("hgrc"), self.root)
38 38 extensions.loadall(self.ui)
39 39 except IOError:
40 40 pass
41 41
42 42 if not os.path.isdir(self.path):
43 43 if create:
44 44 if not os.path.exists(path):
45 45 os.mkdir(path)
46 46 os.mkdir(self.path)
47 47 requirements = ["revlogv1"]
48 48 if self.ui.configbool('format', 'usestore', True):
49 49 os.mkdir(os.path.join(self.path, "store"))
50 50 requirements.append("store")
51 51 if self.ui.configbool('format', 'usefncache', True):
52 52 requirements.append("fncache")
53 53 # create an invalid changelog
54 54 self.opener("00changelog.i", "a").write(
55 55 '\0\0\0\2' # represents revlogv2
56 56 ' dummy changelog to prevent using the old repo layout'
57 57 )
58 58 reqfile = self.opener("requires", "w")
59 59 for r in requirements:
60 60 reqfile.write("%s\n" % r)
61 61 reqfile.close()
62 62 else:
63 63 raise error.RepoError(_("repository %s not found") % path)
64 64 elif create:
65 65 raise error.RepoError(_("repository %s already exists") % path)
66 66 else:
67 67 # find requirements
68 68 requirements = set()
69 69 try:
70 70 requirements = set(self.opener("requires").read().splitlines())
71 71 except IOError, inst:
72 72 if inst.errno != errno.ENOENT:
73 73 raise
74 74 for r in requirements - self.supported:
75 75 raise error.RepoError(_("requirement '%s' not supported") % r)
76 76
77 77 self.sharedpath = self.path
78 78 try:
79 79 s = os.path.realpath(self.opener("sharedpath").read())
80 80 if not os.path.exists(s):
81 81 raise error.RepoError(
82 82 _('.hg/sharedpath points to nonexistent directory %s') % s)
83 83 self.sharedpath = s
84 84 except IOError, inst:
85 85 if inst.errno != errno.ENOENT:
86 86 raise
87 87
88 88 self.store = store.store(requirements, self.sharedpath, util.opener)
89 89 self.spath = self.store.path
90 90 self.sopener = self.store.opener
91 91 self.sjoin = self.store.join
92 92 self.opener.createmode = self.store.createmode
93 93 self.sopener.options = {}
94 94
95 95 # These two define the set of tags for this repository. _tags
96 96 # maps tag name to node; _tagtypes maps tag name to 'global' or
97 97 # 'local'. (Global tags are defined by .hgtags across all
98 98 # heads, and local tags are defined in .hg/localtags.) They
99 99 # constitute the in-memory cache of tags.
100 100 self._tags = None
101 101 self._tagtypes = None
102 102
103 103 self._branchcache = None # in UTF-8
104 104 self._branchcachetip = None
105 105 self.nodetagscache = None
106 106 self.filterpats = {}
107 107 self._datafilters = {}
108 108 self._transref = self._lockref = self._wlockref = None
109 109
110 110 @propertycache
111 111 def changelog(self):
112 112 c = changelog.changelog(self.sopener)
113 113 if 'HG_PENDING' in os.environ:
114 114 p = os.environ['HG_PENDING']
115 115 if p.startswith(self.root):
116 116 c.readpending('00changelog.i.a')
117 117 self.sopener.options['defversion'] = c.version
118 118 return c
119 119
120 120 @propertycache
121 121 def manifest(self):
122 122 return manifest.manifest(self.sopener)
123 123
124 124 @propertycache
125 125 def dirstate(self):
126 126 return dirstate.dirstate(self.opener, self.ui, self.root)
127 127
128 128 def __getitem__(self, changeid):
129 129 if changeid is None:
130 130 return context.workingctx(self)
131 131 return context.changectx(self, changeid)
132 132
133 133 def __contains__(self, changeid):
134 134 try:
135 135 return bool(self.lookup(changeid))
136 136 except error.RepoLookupError:
137 137 return False
138 138
139 139 def __nonzero__(self):
140 140 return True
141 141
142 142 def __len__(self):
143 143 return len(self.changelog)
144 144
145 145 def __iter__(self):
146 146 for i in xrange(len(self)):
147 147 yield i
148 148
149 149 def url(self):
150 150 return 'file:' + self.root
151 151
152 152 def hook(self, name, throw=False, **args):
153 153 return hook.hook(self.ui, self, name, throw, **args)
154 154
155 155 tag_disallowed = ':\r\n'
156 156
157 157 def _tag(self, names, node, message, local, user, date, extra={}):
158 158 if isinstance(names, str):
159 159 allchars = names
160 160 names = (names,)
161 161 else:
162 162 allchars = ''.join(names)
163 163 for c in self.tag_disallowed:
164 164 if c in allchars:
165 165 raise util.Abort(_('%r cannot be used in a tag name') % c)
166 166
167 167 branches = self.branchmap()
168 168 for name in names:
169 169 self.hook('pretag', throw=True, node=hex(node), tag=name,
170 170 local=local)
171 171 if name in branches:
172 172 self.ui.warn(_("warning: tag %s conflicts with existing"
173 173 " branch name\n") % name)
174 174
175 175 def writetags(fp, names, munge, prevtags):
176 176 fp.seek(0, 2)
177 177 if prevtags and prevtags[-1] != '\n':
178 178 fp.write('\n')
179 179 for name in names:
180 180 m = munge and munge(name) or name
181 181 if self._tagtypes and name in self._tagtypes:
182 182 old = self._tags.get(name, nullid)
183 183 fp.write('%s %s\n' % (hex(old), m))
184 184 fp.write('%s %s\n' % (hex(node), m))
185 185 fp.close()
186 186
187 187 prevtags = ''
188 188 if local:
189 189 try:
190 190 fp = self.opener('localtags', 'r+')
191 191 except IOError:
192 192 fp = self.opener('localtags', 'a')
193 193 else:
194 194 prevtags = fp.read()
195 195
196 196 # local tags are stored in the current charset
197 197 writetags(fp, names, None, prevtags)
198 198 for name in names:
199 199 self.hook('tag', node=hex(node), tag=name, local=local)
200 200 return
201 201
202 202 try:
203 203 fp = self.wfile('.hgtags', 'rb+')
204 204 except IOError:
205 205 fp = self.wfile('.hgtags', 'ab')
206 206 else:
207 207 prevtags = fp.read()
208 208
209 209 # committed tags are stored in UTF-8
210 210 writetags(fp, names, encoding.fromlocal, prevtags)
211 211
212 212 if '.hgtags' not in self.dirstate:
213 213 self.add(['.hgtags'])
214 214
215 215 m = matchmod.exact(self.root, '', ['.hgtags'])
216 216 tagnode = self.commit(message, user, date, extra=extra, match=m)
217 217
218 218 for name in names:
219 219 self.hook('tag', node=hex(node), tag=name, local=local)
220 220
221 221 return tagnode
222 222
223 223 def tag(self, names, node, message, local, user, date):
224 224 '''tag a revision with one or more symbolic names.
225 225
226 226 names is a list of strings or, when adding a single tag, names may be a
227 227 string.
228 228
229 229 if local is True, the tags are stored in a per-repository file.
230 230 otherwise, they are stored in the .hgtags file, and a new
231 231 changeset is committed with the change.
232 232
233 233 keyword arguments:
234 234
235 235 local: whether to store tags in non-version-controlled file
236 236 (default False)
237 237
238 238 message: commit message to use if committing
239 239
240 240 user: name of user to use if committing
241 241
242 242 date: date tuple to use if committing'''
243 243
244 244 for x in self.status()[:5]:
245 245 if '.hgtags' in x:
246 246 raise util.Abort(_('working copy of .hgtags is changed '
247 247 '(please commit .hgtags manually)'))
248 248
249 249 self.tags() # instantiate the cache
250 250 self._tag(names, node, message, local, user, date)
251 251
252 252 def tags(self):
253 253 '''return a mapping of tag to node'''
254 254 if self._tags is None:
255 255 (self._tags, self._tagtypes) = self._findtags()
256 256
257 257 return self._tags
258 258
259 259 def _findtags(self):
260 260 '''Do the hard work of finding tags. Return a pair of dicts
261 261 (tags, tagtypes) where tags maps tag name to node, and tagtypes
262 262 maps tag name to a string like \'global\' or \'local\'.
263 263 Subclasses or extensions are free to add their own tags, but
264 264 should be aware that the returned dicts will be retained for the
265 265 duration of the localrepo object.'''
266 266
267 267 # XXX what tagtype should subclasses/extensions use? Currently
268 268 # mq and bookmarks add tags, but do not set the tagtype at all.
269 269 # Should each extension invent its own tag type? Should there
270 270 # be one tagtype for all such "virtual" tags? Or is the status
271 271 # quo fine?
272 272
273 273 alltags = {} # map tag name to (node, hist)
274 274 tagtypes = {}
275 275
276 276 tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
277 277 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
278 278
279 279 # Build the return dicts. Have to re-encode tag names because
280 280 # the tags module always uses UTF-8 (in order not to lose info
281 281 # writing to the cache), but the rest of Mercurial wants them in
282 282 # local encoding.
283 283 tags = {}
284 284 for (name, (node, hist)) in alltags.iteritems():
285 285 if node != nullid:
286 286 tags[encoding.tolocal(name)] = node
287 287 tags['tip'] = self.changelog.tip()
288 288 tagtypes = dict([(encoding.tolocal(name), value)
289 289 for (name, value) in tagtypes.iteritems()])
290 290 return (tags, tagtypes)
291 291
292 292 def tagtype(self, tagname):
293 293 '''
294 294 return the type of the given tag. result can be:
295 295
296 296 'local' : a local tag
297 297 'global' : a global tag
298 298 None : tag does not exist
299 299 '''
300 300
301 301 self.tags()
302 302
303 303 return self._tagtypes.get(tagname)
304 304
305 305 def tagslist(self):
306 306 '''return a list of tags ordered by revision'''
307 307 l = []
308 308 for t, n in self.tags().iteritems():
309 309 try:
310 310 r = self.changelog.rev(n)
311 311 except:
312 312 r = -2 # sort to the beginning of the list if unknown
313 313 l.append((r, t, n))
314 314 return [(t, n) for r, t, n in sorted(l)]
315 315
316 316 def nodetags(self, node):
317 317 '''return the tags associated with a node'''
318 318 if not self.nodetagscache:
319 319 self.nodetagscache = {}
320 320 for t, n in self.tags().iteritems():
321 321 self.nodetagscache.setdefault(n, []).append(t)
322 322 for tags in self.nodetagscache.itervalues():
323 323 tags.sort()
324 324 return self.nodetagscache.get(node, [])
325 325
326 326 def _branchtags(self, partial, lrev):
327 327 # TODO: rename this function?
328 328 tiprev = len(self) - 1
329 329 if lrev != tiprev:
330 330 ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1))
331 331 self._updatebranchcache(partial, ctxgen)
332 332 self._writebranchcache(partial, self.changelog.tip(), tiprev)
333 333
334 334 return partial
335 335
336 336 def branchmap(self):
337 337 '''returns a dictionary {branch: [branchheads]}'''
338 338 tip = self.changelog.tip()
339 339 if self._branchcache is not None and self._branchcachetip == tip:
340 340 return self._branchcache
341 341
342 342 oldtip = self._branchcachetip
343 343 self._branchcachetip = tip
344 344 if oldtip is None or oldtip not in self.changelog.nodemap:
345 345 partial, last, lrev = self._readbranchcache()
346 346 else:
347 347 lrev = self.changelog.rev(oldtip)
348 348 partial = self._branchcache
349 349
350 350 self._branchtags(partial, lrev)
351 351 # this private cache holds all heads (not just tips)
352 352 self._branchcache = partial
353 353
354 354 return self._branchcache
355 355
356 356 def branchtags(self):
357 357 '''return a dict where branch names map to the tipmost head of
358 358 the branch, open heads come before closed'''
359 359 bt = {}
360 360 for bn, heads in self.branchmap().iteritems():
361 361 tip = heads[-1]
362 362 for h in reversed(heads):
363 363 if 'close' not in self.changelog.read(h)[5]:
364 364 tip = h
365 365 break
366 366 bt[bn] = tip
367 367 return bt
368 368
369 369
370 370 def _readbranchcache(self):
371 371 partial = {}
372 372 try:
373 373 f = self.opener("branchheads.cache")
374 374 lines = f.read().split('\n')
375 375 f.close()
376 376 except (IOError, OSError):
377 377 return {}, nullid, nullrev
378 378
379 379 try:
380 380 last, lrev = lines.pop(0).split(" ", 1)
381 381 last, lrev = bin(last), int(lrev)
382 382 if lrev >= len(self) or self[lrev].node() != last:
383 383 # invalidate the cache
384 384 raise ValueError('invalidating branch cache (tip differs)')
385 385 for l in lines:
386 386 if not l:
387 387 continue
388 388 node, label = l.split(" ", 1)
389 389 partial.setdefault(label.strip(), []).append(bin(node))
390 390 except KeyboardInterrupt:
391 391 raise
392 392 except Exception, inst:
393 393 if self.ui.debugflag:
394 394 self.ui.warn(str(inst), '\n')
395 395 partial, last, lrev = {}, nullid, nullrev
396 396 return partial, last, lrev
397 397
398 398 def _writebranchcache(self, branches, tip, tiprev):
399 399 try:
400 400 f = self.opener("branchheads.cache", "w", atomictemp=True)
401 401 f.write("%s %s\n" % (hex(tip), tiprev))
402 402 for label, nodes in branches.iteritems():
403 403 for node in nodes:
404 404 f.write("%s %s\n" % (hex(node), label))
405 405 f.rename()
406 406 except (IOError, OSError):
407 407 pass
408 408
409 409 def _updatebranchcache(self, partial, ctxgen):
410 410 # collect new branch entries
411 411 newbranches = {}
412 412 for c in ctxgen:
413 413 newbranches.setdefault(c.branch(), []).append(c.node())
414 414 # if older branchheads are reachable from new ones, they aren't
415 415 # really branchheads. Note checking parents is insufficient:
416 416 # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
417 417 for branch, newnodes in newbranches.iteritems():
418 418 bheads = partial.setdefault(branch, [])
419 419 bheads.extend(newnodes)
420 420 if len(bheads) <= 1:
421 421 continue
422 422 # starting from tip means fewer passes over reachable
423 423 while newnodes:
424 424 latest = newnodes.pop()
425 425 if latest not in bheads:
426 426 continue
427 427 minbhrev = self[min([self[bh].rev() for bh in bheads])].node()
428 428 reachable = self.changelog.reachable(latest, minbhrev)
429 429 reachable.remove(latest)
430 430 bheads = [b for b in bheads if b not in reachable]
431 431 partial[branch] = bheads
432 432
433 433 def lookup(self, key):
434 434 if isinstance(key, int):
435 435 return self.changelog.node(key)
436 436 elif key == '.':
437 437 return self.dirstate.parents()[0]
438 438 elif key == 'null':
439 439 return nullid
440 440 elif key == 'tip':
441 441 return self.changelog.tip()
442 442 n = self.changelog._match(key)
443 443 if n:
444 444 return n
445 445 if key in self.tags():
446 446 return self.tags()[key]
447 447 if key in self.branchtags():
448 448 return self.branchtags()[key]
449 449 n = self.changelog._partialmatch(key)
450 450 if n:
451 451 return n
452 452
453 453 # can't find key, check if it might have come from damaged dirstate
454 454 if key in self.dirstate.parents():
455 455 raise error.Abort(_("working directory has unknown parent '%s'!")
456 456 % short(key))
457 457 try:
458 458 if len(key) == 20:
459 459 key = hex(key)
460 460 except:
461 461 pass
462 462 raise error.RepoLookupError(_("unknown revision '%s'") % key)
463 463
464 464 def lookupbranch(self, key, remote=None):
465 465 repo = remote or self
466 466 if key in repo.branchmap():
467 467 return key
468 468
469 469 repo = (remote and remote.local()) and remote or self
470 470 return repo[key].branch()
471 471
472 472 def local(self):
473 473 return True
474 474
475 475 def join(self, f):
476 476 return os.path.join(self.path, f)
477 477
478 478 def wjoin(self, f):
479 479 return os.path.join(self.root, f)
480 480
481 481 def rjoin(self, f):
482 482 return os.path.join(self.root, util.pconvert(f))
483 483
484 484 def file(self, f):
485 485 if f[0] == '/':
486 486 f = f[1:]
487 487 return filelog.filelog(self.sopener, f)
488 488
489 489 def changectx(self, changeid):
490 490 return self[changeid]
491 491
492 492 def parents(self, changeid=None):
493 493 '''get list of changectxs for parents of changeid'''
494 494 return self[changeid].parents()
495 495
496 496 def filectx(self, path, changeid=None, fileid=None):
497 497 """changeid can be a changeset revision, node, or tag.
498 498 fileid can be a file revision or node."""
499 499 return context.filectx(self, path, changeid, fileid)
500 500
501 501 def getcwd(self):
502 502 return self.dirstate.getcwd()
503 503
504 504 def pathto(self, f, cwd=None):
505 505 return self.dirstate.pathto(f, cwd)
506 506
507 507 def wfile(self, f, mode='r'):
508 508 return self.wopener(f, mode)
509 509
510 510 def _link(self, f):
511 511 return os.path.islink(self.wjoin(f))
512 512
513 513 def _filter(self, filter, filename, data):
514 514 if filter not in self.filterpats:
515 515 l = []
516 516 for pat, cmd in self.ui.configitems(filter):
517 517 if cmd == '!':
518 518 continue
519 519 mf = matchmod.match(self.root, '', [pat])
520 520 fn = None
521 521 params = cmd
522 522 for name, filterfn in self._datafilters.iteritems():
523 523 if cmd.startswith(name):
524 524 fn = filterfn
525 525 params = cmd[len(name):].lstrip()
526 526 break
527 527 if not fn:
528 528 fn = lambda s, c, **kwargs: util.filter(s, c)
529 529 # Wrap old filters not supporting keyword arguments
530 530 if not inspect.getargspec(fn)[2]:
531 531 oldfn = fn
532 532 fn = lambda s, c, **kwargs: oldfn(s, c)
533 533 l.append((mf, fn, params))
534 534 self.filterpats[filter] = l
535 535
536 536 for mf, fn, cmd in self.filterpats[filter]:
537 537 if mf(filename):
538 538 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
539 539 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
540 540 break
541 541
542 542 return data
543 543
544 544 def adddatafilter(self, name, filter):
545 545 self._datafilters[name] = filter
546 546
547 547 def wread(self, filename):
548 548 if self._link(filename):
549 549 data = os.readlink(self.wjoin(filename))
550 550 else:
551 551 data = self.wopener(filename, 'r').read()
552 552 return self._filter("encode", filename, data)
553 553
554 554 def wwrite(self, filename, data, flags):
555 555 data = self._filter("decode", filename, data)
556 556 try:
557 557 os.unlink(self.wjoin(filename))
558 558 except OSError:
559 559 pass
560 560 if 'l' in flags:
561 561 self.wopener.symlink(data, filename)
562 562 else:
563 563 self.wopener(filename, 'w').write(data)
564 564 if 'x' in flags:
565 565 util.set_flags(self.wjoin(filename), False, True)
566 566
567 567 def wwritedata(self, filename, data):
568 568 return self._filter("decode", filename, data)
569 569
570 570 def transaction(self, desc):
571 571 tr = self._transref and self._transref() or None
572 572 if tr and tr.running():
573 573 return tr.nest()
574 574
575 575 # abort here if the journal already exists
576 576 if os.path.exists(self.sjoin("journal")):
577 577 raise error.RepoError(
578 578 _("abandoned transaction found - run hg recover"))
579 579
580 580 # save dirstate for rollback
581 581 try:
582 582 ds = self.opener("dirstate").read()
583 583 except IOError:
584 584 ds = ""
585 585 self.opener("journal.dirstate", "w").write(ds)
586 586 self.opener("journal.branch", "w").write(self.dirstate.branch())
587 587 self.opener("journal.desc", "w").write("%d\n%s\n" % (len(self), desc))
588 588
589 589 renames = [(self.sjoin("journal"), self.sjoin("undo")),
590 590 (self.join("journal.dirstate"), self.join("undo.dirstate")),
591 591 (self.join("journal.branch"), self.join("undo.branch")),
592 592 (self.join("journal.desc"), self.join("undo.desc"))]
593 593 tr = transaction.transaction(self.ui.warn, self.sopener,
594 594 self.sjoin("journal"),
595 595 aftertrans(renames),
596 596 self.store.createmode)
597 597 self._transref = weakref.ref(tr)
598 598 return tr
599 599
600 600 def recover(self):
601 601 lock = self.lock()
602 602 try:
603 603 if os.path.exists(self.sjoin("journal")):
604 604 self.ui.status(_("rolling back interrupted transaction\n"))
605 605 transaction.rollback(self.sopener, self.sjoin("journal"),
606 606 self.ui.warn)
607 607 self.invalidate()
608 608 return True
609 609 else:
610 610 self.ui.warn(_("no interrupted transaction available\n"))
611 611 return False
612 612 finally:
613 613 lock.release()
614 614
615 615 def rollback(self, dryrun=False):
616 616 wlock = lock = None
617 617 try:
618 618 wlock = self.wlock()
619 619 lock = self.lock()
620 620 if os.path.exists(self.sjoin("undo")):
621 621 try:
622 622 args = self.opener("undo.desc", "r").read().splitlines()
623 623 if len(args) >= 3 and self.ui.verbose:
624 624 desc = _("rolling back to revision %s"
625 625 " (undo %s: %s)\n") % (
626 626 args[0], args[1], args[2])
627 627 elif len(args) >= 2:
628 628 desc = _("rolling back to revision %s (undo %s)\n") % (
629 629 args[0], args[1])
630 630 except IOError:
631 631 desc = _("rolling back unknown transaction\n")
632 632 self.ui.status(desc)
633 633 if dryrun:
634 634 return
635 635 transaction.rollback(self.sopener, self.sjoin("undo"),
636 636 self.ui.warn)
637 637 util.rename(self.join("undo.dirstate"), self.join("dirstate"))
638 638 try:
639 639 branch = self.opener("undo.branch").read()
640 640 self.dirstate.setbranch(branch)
641 641 except IOError:
642 642 self.ui.warn(_("Named branch could not be reset, "
643 643 "current branch still is: %s\n")
644 644 % encoding.tolocal(self.dirstate.branch()))
645 645 self.invalidate()
646 646 self.dirstate.invalidate()
647 647 self.destroyed()
648 648 else:
649 649 self.ui.warn(_("no rollback information available\n"))
650 650 finally:
651 651 release(lock, wlock)
652 652
653 653 def invalidatecaches(self):
654 654 self._tags = None
655 655 self._tagtypes = None
656 656 self.nodetagscache = None
657 657 self._branchcache = None # in UTF-8
658 658 self._branchcachetip = None
659 659
660 660 def invalidate(self):
661 661 for a in "changelog manifest".split():
662 662 if a in self.__dict__:
663 663 delattr(self, a)
664 664 self.invalidatecaches()
665 665
666 666 def _lock(self, lockname, wait, releasefn, acquirefn, desc):
667 667 try:
668 668 l = lock.lock(lockname, 0, releasefn, desc=desc)
669 669 except error.LockHeld, inst:
670 670 if not wait:
671 671 raise
672 672 self.ui.warn(_("waiting for lock on %s held by %r\n") %
673 673 (desc, inst.locker))
674 674 # default to 600 seconds timeout
675 675 l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")),
676 676 releasefn, desc=desc)
677 677 if acquirefn:
678 678 acquirefn()
679 679 return l
680 680
681 681 def lock(self, wait=True):
682 682 '''Lock the repository store (.hg/store) and return a weak reference
683 683 to the lock. Use this before modifying the store (e.g. committing or
684 684 stripping). If you are opening a transaction, get a lock as well.)'''
685 685 l = self._lockref and self._lockref()
686 686 if l is not None and l.held:
687 687 l.lock()
688 688 return l
689 689
690 690 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate,
691 691 _('repository %s') % self.origroot)
692 692 self._lockref = weakref.ref(l)
693 693 return l
694 694
695 695 def wlock(self, wait=True):
696 696 '''Lock the non-store parts of the repository (everything under
697 697 .hg except .hg/store) and return a weak reference to the lock.
698 698 Use this before modifying files in .hg.'''
699 699 l = self._wlockref and self._wlockref()
700 700 if l is not None and l.held:
701 701 l.lock()
702 702 return l
703 703
704 704 l = self._lock(self.join("wlock"), wait, self.dirstate.write,
705 705 self.dirstate.invalidate, _('working directory of %s') %
706 706 self.origroot)
707 707 self._wlockref = weakref.ref(l)
708 708 return l
709 709
710 710 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
711 711 """
712 712 commit an individual file as part of a larger transaction
713 713 """
714 714
715 715 fname = fctx.path()
716 716 text = fctx.data()
717 717 flog = self.file(fname)
718 718 fparent1 = manifest1.get(fname, nullid)
719 719 fparent2 = fparent2o = manifest2.get(fname, nullid)
720 720
721 721 meta = {}
722 722 copy = fctx.renamed()
723 723 if copy and copy[0] != fname:
724 724 # Mark the new revision of this file as a copy of another
725 725 # file. This copy data will effectively act as a parent
726 726 # of this new revision. If this is a merge, the first
727 727 # parent will be the nullid (meaning "look up the copy data")
728 728 # and the second one will be the other parent. For example:
729 729 #
730 730 # 0 --- 1 --- 3 rev1 changes file foo
731 731 # \ / rev2 renames foo to bar and changes it
732 732 # \- 2 -/ rev3 should have bar with all changes and
733 733 # should record that bar descends from
734 734 # bar in rev2 and foo in rev1
735 735 #
736 736 # this allows this merge to succeed:
737 737 #
738 738 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
739 739 # \ / merging rev3 and rev4 should use bar@rev2
740 740 # \- 2 --- 4 as the merge base
741 741 #
742 742
743 743 cfname = copy[0]
744 744 crev = manifest1.get(cfname)
745 745 newfparent = fparent2
746 746
747 747 if manifest2: # branch merge
748 748 if fparent2 == nullid or crev is None: # copied on remote side
749 749 if cfname in manifest2:
750 750 crev = manifest2[cfname]
751 751 newfparent = fparent1
752 752
753 753 # find source in nearest ancestor if we've lost track
754 754 if not crev:
755 755 self.ui.debug(" %s: searching for copy revision for %s\n" %
756 756 (fname, cfname))
757 757 for ancestor in self['.'].ancestors():
758 758 if cfname in ancestor:
759 759 crev = ancestor[cfname].filenode()
760 760 break
761 761
762 762 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
763 763 meta["copy"] = cfname
764 764 meta["copyrev"] = hex(crev)
765 765 fparent1, fparent2 = nullid, newfparent
766 766 elif fparent2 != nullid:
767 767 # is one parent an ancestor of the other?
768 768 fparentancestor = flog.ancestor(fparent1, fparent2)
769 769 if fparentancestor == fparent1:
770 770 fparent1, fparent2 = fparent2, nullid
771 771 elif fparentancestor == fparent2:
772 772 fparent2 = nullid
773 773
774 774 # is the file changed?
775 775 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
776 776 changelist.append(fname)
777 777 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
778 778
779 779 # are just the flags changed during merge?
780 780 if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags():
781 781 changelist.append(fname)
782 782
783 783 return fparent1
784 784
785 785 def commit(self, text="", user=None, date=None, match=None, force=False,
786 786 editor=False, extra={}):
787 787 """Add a new revision to current repository.
788 788
789 789 Revision information is gathered from the working directory,
790 790 match can be used to filter the committed files. If editor is
791 791 supplied, it is called to get a commit message.
792 792 """
793 793
794 794 def fail(f, msg):
795 795 raise util.Abort('%s: %s' % (f, msg))
796 796
797 797 if not match:
798 798 match = matchmod.always(self.root, '')
799 799
800 800 if not force:
801 801 vdirs = []
802 802 match.dir = vdirs.append
803 803 match.bad = fail
804 804
805 805 wlock = self.wlock()
806 806 try:
807 807 wctx = self[None]
808 808 merge = len(wctx.parents()) > 1
809 809
810 810 if (not force and merge and match and
811 811 (match.files() or match.anypats())):
812 812 raise util.Abort(_('cannot partially commit a merge '
813 813 '(do not specify files or patterns)'))
814 814
815 815 changes = self.status(match=match, clean=force)
816 816 if force:
817 817 changes[0].extend(changes[6]) # mq may commit unchanged files
818 818
819 819 # check subrepos
820 820 subs = []
821 821 removedsubs = set()
822 822 for p in wctx.parents():
823 823 removedsubs.update(s for s in p.substate if match(s))
824 824 for s in wctx.substate:
825 825 removedsubs.discard(s)
826 826 if match(s) and wctx.sub(s).dirty():
827 827 subs.append(s)
828 828 if (subs or removedsubs) and '.hgsubstate' not in changes[0]:
829 829 changes[0].insert(0, '.hgsubstate')
830 830
831 831 # make sure all explicit patterns are matched
832 832 if not force and match.files():
833 833 matched = set(changes[0] + changes[1] + changes[2])
834 834
835 835 for f in match.files():
836 836 if f == '.' or f in matched or f in wctx.substate:
837 837 continue
838 838 if f in changes[3]: # missing
839 839 fail(f, _('file not found!'))
840 840 if f in vdirs: # visited directory
841 841 d = f + '/'
842 842 for mf in matched:
843 843 if mf.startswith(d):
844 844 break
845 845 else:
846 846 fail(f, _("no match under directory!"))
847 847 elif f not in self.dirstate:
848 848 fail(f, _("file not tracked!"))
849 849
850 850 if (not force and not extra.get("close") and not merge
851 851 and not (changes[0] or changes[1] or changes[2])
852 852 and wctx.branch() == wctx.p1().branch()):
853 853 return None
854 854
855 855 ms = mergemod.mergestate(self)
856 856 for f in changes[0]:
857 857 if f in ms and ms[f] == 'u':
858 858 raise util.Abort(_("unresolved merge conflicts "
859 859 "(see hg resolve)"))
860 860
861 861 cctx = context.workingctx(self, text, user, date, extra, changes)
862 862 if editor:
863 863 cctx._text = editor(self, cctx, subs)
864 864 edited = (text != cctx._text)
865 865
866 866 # commit subs
867 867 if subs or removedsubs:
868 868 state = wctx.substate.copy()
869 869 for s in subs:
870 self.ui.status(_('committing subrepository %s\n') % s)
871 sr = wctx.sub(s).commit(cctx._text, user, date)
870 sub = wctx.sub(s)
871 self.ui.status(_('committing subrepository %s\n') %
872 subrepo.relpath(sub))
873 sr = sub.commit(cctx._text, user, date)
872 874 state[s] = (state[s][0], sr)
873 875 subrepo.writestate(self, state)
874 876
875 877 # Save commit message in case this transaction gets rolled back
876 878 # (e.g. by a pretxncommit hook). Leave the content alone on
877 879 # the assumption that the user will use the same editor again.
878 880 msgfile = self.opener('last-message.txt', 'wb')
879 881 msgfile.write(cctx._text)
880 882 msgfile.close()
881 883
882 884 p1, p2 = self.dirstate.parents()
883 885 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
884 886 try:
885 887 self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2)
886 888 ret = self.commitctx(cctx, True)
887 889 except:
888 890 if edited:
889 891 msgfn = self.pathto(msgfile.name[len(self.root)+1:])
890 892 self.ui.write(
891 893 _('note: commit message saved in %s\n') % msgfn)
892 894 raise
893 895
894 896 # update dirstate and mergestate
895 897 for f in changes[0] + changes[1]:
896 898 self.dirstate.normal(f)
897 899 for f in changes[2]:
898 900 self.dirstate.forget(f)
899 901 self.dirstate.setparents(ret)
900 902 ms.reset()
901 903 finally:
902 904 wlock.release()
903 905
904 906 self.hook("commit", node=hex(ret), parent1=hookp1, parent2=hookp2)
905 907 return ret
906 908
907 909 def commitctx(self, ctx, error=False):
908 910 """Add a new revision to current repository.
909 911 Revision information is passed via the context argument.
910 912 """
911 913
912 914 tr = lock = None
913 915 removed = ctx.removed()
914 916 p1, p2 = ctx.p1(), ctx.p2()
915 917 m1 = p1.manifest().copy()
916 918 m2 = p2.manifest()
917 919 user = ctx.user()
918 920
919 921 lock = self.lock()
920 922 try:
921 923 tr = self.transaction("commit")
922 924 trp = weakref.proxy(tr)
923 925
924 926 # check in files
925 927 new = {}
926 928 changed = []
927 929 linkrev = len(self)
928 930 for f in sorted(ctx.modified() + ctx.added()):
929 931 self.ui.note(f + "\n")
930 932 try:
931 933 fctx = ctx[f]
932 934 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
933 935 changed)
934 936 m1.set(f, fctx.flags())
935 937 except OSError, inst:
936 938 self.ui.warn(_("trouble committing %s!\n") % f)
937 939 raise
938 940 except IOError, inst:
939 941 errcode = getattr(inst, 'errno', errno.ENOENT)
940 942 if error or errcode and errcode != errno.ENOENT:
941 943 self.ui.warn(_("trouble committing %s!\n") % f)
942 944 raise
943 945 else:
944 946 removed.append(f)
945 947
946 948 # update manifest
947 949 m1.update(new)
948 950 removed = [f for f in sorted(removed) if f in m1 or f in m2]
949 951 drop = [f for f in removed if f in m1]
950 952 for f in drop:
951 953 del m1[f]
952 954 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
953 955 p2.manifestnode(), (new, drop))
954 956
955 957 # update changelog
956 958 self.changelog.delayupdate()
957 959 n = self.changelog.add(mn, changed + removed, ctx.description(),
958 960 trp, p1.node(), p2.node(),
959 961 user, ctx.date(), ctx.extra().copy())
960 962 p = lambda: self.changelog.writepending() and self.root or ""
961 963 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
962 964 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
963 965 parent2=xp2, pending=p)
964 966 self.changelog.finalize(trp)
965 967 tr.close()
966 968
967 969 if self._branchcache:
968 970 self.branchtags()
969 971 return n
970 972 finally:
971 973 del tr
972 974 lock.release()
973 975
974 976 def destroyed(self):
975 977 '''Inform the repository that nodes have been destroyed.
976 978 Intended for use by strip and rollback, so there's a common
977 979 place for anything that has to be done after destroying history.'''
978 980 # XXX it might be nice if we could take the list of destroyed
979 981 # nodes, but I don't see an easy way for rollback() to do that
980 982
981 983 # Ensure the persistent tag cache is updated. Doing it now
982 984 # means that the tag cache only has to worry about destroyed
983 985 # heads immediately after a strip/rollback. That in turn
984 986 # guarantees that "cachetip == currenttip" (comparing both rev
985 987 # and node) always means no nodes have been added or destroyed.
986 988
987 989 # XXX this is suboptimal when qrefresh'ing: we strip the current
988 990 # head, refresh the tag cache, then immediately add a new head.
989 991 # But I think doing it this way is necessary for the "instant
990 992 # tag cache retrieval" case to work.
991 993 self.invalidatecaches()
992 994
993 995 def walk(self, match, node=None):
994 996 '''
995 997 walk recursively through the directory tree or a given
996 998 changeset, finding all files matched by the match
997 999 function
998 1000 '''
999 1001 return self[node].walk(match)
1000 1002
1001 1003 def status(self, node1='.', node2=None, match=None,
1002 1004 ignored=False, clean=False, unknown=False):
1003 1005 """return status of files between two nodes or node and working directory
1004 1006
1005 1007 If node1 is None, use the first dirstate parent instead.
1006 1008 If node2 is None, compare node1 with working directory.
1007 1009 """
1008 1010
1009 1011 def mfmatches(ctx):
1010 1012 mf = ctx.manifest().copy()
1011 1013 for fn in mf.keys():
1012 1014 if not match(fn):
1013 1015 del mf[fn]
1014 1016 return mf
1015 1017
1016 1018 if isinstance(node1, context.changectx):
1017 1019 ctx1 = node1
1018 1020 else:
1019 1021 ctx1 = self[node1]
1020 1022 if isinstance(node2, context.changectx):
1021 1023 ctx2 = node2
1022 1024 else:
1023 1025 ctx2 = self[node2]
1024 1026
1025 1027 working = ctx2.rev() is None
1026 1028 parentworking = working and ctx1 == self['.']
1027 1029 match = match or matchmod.always(self.root, self.getcwd())
1028 1030 listignored, listclean, listunknown = ignored, clean, unknown
1029 1031
1030 1032 # load earliest manifest first for caching reasons
1031 1033 if not working and ctx2.rev() < ctx1.rev():
1032 1034 ctx2.manifest()
1033 1035
1034 1036 if not parentworking:
1035 1037 def bad(f, msg):
1036 1038 if f not in ctx1:
1037 1039 self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg))
1038 1040 match.bad = bad
1039 1041
1040 1042 if working: # we need to scan the working dir
1041 1043 subrepos = ctx1.substate.keys()
1042 1044 s = self.dirstate.status(match, subrepos, listignored,
1043 1045 listclean, listunknown)
1044 1046 cmp, modified, added, removed, deleted, unknown, ignored, clean = s
1045 1047
1046 1048 # check for any possibly clean files
1047 1049 if parentworking and cmp:
1048 1050 fixup = []
1049 1051 # do a full compare of any files that might have changed
1050 1052 for f in sorted(cmp):
1051 1053 if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f)
1052 1054 or ctx1[f].cmp(ctx2[f].data())):
1053 1055 modified.append(f)
1054 1056 else:
1055 1057 fixup.append(f)
1056 1058
1057 1059 if listclean:
1058 1060 clean += fixup
1059 1061
1060 1062 # update dirstate for files that are actually clean
1061 1063 if fixup:
1062 1064 try:
1063 1065 # updating the dirstate is optional
1064 1066 # so we don't wait on the lock
1065 1067 wlock = self.wlock(False)
1066 1068 try:
1067 1069 for f in fixup:
1068 1070 self.dirstate.normal(f)
1069 1071 finally:
1070 1072 wlock.release()
1071 1073 except error.LockError:
1072 1074 pass
1073 1075
1074 1076 if not parentworking:
1075 1077 mf1 = mfmatches(ctx1)
1076 1078 if working:
1077 1079 # we are comparing working dir against non-parent
1078 1080 # generate a pseudo-manifest for the working dir
1079 1081 mf2 = mfmatches(self['.'])
1080 1082 for f in cmp + modified + added:
1081 1083 mf2[f] = None
1082 1084 mf2.set(f, ctx2.flags(f))
1083 1085 for f in removed:
1084 1086 if f in mf2:
1085 1087 del mf2[f]
1086 1088 else:
1087 1089 # we are comparing two revisions
1088 1090 deleted, unknown, ignored = [], [], []
1089 1091 mf2 = mfmatches(ctx2)
1090 1092
1091 1093 modified, added, clean = [], [], []
1092 1094 for fn in mf2:
1093 1095 if fn in mf1:
1094 1096 if (mf1.flags(fn) != mf2.flags(fn) or
1095 1097 (mf1[fn] != mf2[fn] and
1096 1098 (mf2[fn] or ctx1[fn].cmp(ctx2[fn].data())))):
1097 1099 modified.append(fn)
1098 1100 elif listclean:
1099 1101 clean.append(fn)
1100 1102 del mf1[fn]
1101 1103 else:
1102 1104 added.append(fn)
1103 1105 removed = mf1.keys()
1104 1106
1105 1107 r = modified, added, removed, deleted, unknown, ignored, clean
1106 1108 [l.sort() for l in r]
1107 1109 return r
1108 1110
1109 1111 def add(self, list):
1110 1112 wlock = self.wlock()
1111 1113 try:
1112 1114 rejected = []
1113 1115 for f in list:
1114 1116 p = self.wjoin(f)
1115 1117 try:
1116 1118 st = os.lstat(p)
1117 1119 except:
1118 1120 self.ui.warn(_("%s does not exist!\n") % f)
1119 1121 rejected.append(f)
1120 1122 continue
1121 1123 if st.st_size > 10000000:
1122 1124 self.ui.warn(_("%s: up to %d MB of RAM may be required "
1123 1125 "to manage this file\n"
1124 1126 "(use 'hg revert %s' to cancel the "
1125 1127 "pending addition)\n")
1126 1128 % (f, 3 * st.st_size // 1000000, f))
1127 1129 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
1128 1130 self.ui.warn(_("%s not added: only files and symlinks "
1129 1131 "supported currently\n") % f)
1130 1132 rejected.append(p)
1131 1133 elif self.dirstate[f] in 'amn':
1132 1134 self.ui.warn(_("%s already tracked!\n") % f)
1133 1135 elif self.dirstate[f] == 'r':
1134 1136 self.dirstate.normallookup(f)
1135 1137 else:
1136 1138 self.dirstate.add(f)
1137 1139 return rejected
1138 1140 finally:
1139 1141 wlock.release()
1140 1142
1141 1143 def forget(self, list):
1142 1144 wlock = self.wlock()
1143 1145 try:
1144 1146 for f in list:
1145 1147 if self.dirstate[f] != 'a':
1146 1148 self.ui.warn(_("%s not added!\n") % f)
1147 1149 else:
1148 1150 self.dirstate.forget(f)
1149 1151 finally:
1150 1152 wlock.release()
1151 1153
1152 1154 def remove(self, list, unlink=False):
1153 1155 if unlink:
1154 1156 for f in list:
1155 1157 try:
1156 1158 util.unlink(self.wjoin(f))
1157 1159 except OSError, inst:
1158 1160 if inst.errno != errno.ENOENT:
1159 1161 raise
1160 1162 wlock = self.wlock()
1161 1163 try:
1162 1164 for f in list:
1163 1165 if unlink and os.path.exists(self.wjoin(f)):
1164 1166 self.ui.warn(_("%s still exists!\n") % f)
1165 1167 elif self.dirstate[f] == 'a':
1166 1168 self.dirstate.forget(f)
1167 1169 elif f not in self.dirstate:
1168 1170 self.ui.warn(_("%s not tracked!\n") % f)
1169 1171 else:
1170 1172 self.dirstate.remove(f)
1171 1173 finally:
1172 1174 wlock.release()
1173 1175
1174 1176 def undelete(self, list):
1175 1177 manifests = [self.manifest.read(self.changelog.read(p)[0])
1176 1178 for p in self.dirstate.parents() if p != nullid]
1177 1179 wlock = self.wlock()
1178 1180 try:
1179 1181 for f in list:
1180 1182 if self.dirstate[f] != 'r':
1181 1183 self.ui.warn(_("%s not removed!\n") % f)
1182 1184 else:
1183 1185 m = f in manifests[0] and manifests[0] or manifests[1]
1184 1186 t = self.file(f).read(m[f])
1185 1187 self.wwrite(f, t, m.flags(f))
1186 1188 self.dirstate.normal(f)
1187 1189 finally:
1188 1190 wlock.release()
1189 1191
1190 1192 def copy(self, source, dest):
1191 1193 p = self.wjoin(dest)
1192 1194 if not (os.path.exists(p) or os.path.islink(p)):
1193 1195 self.ui.warn(_("%s does not exist!\n") % dest)
1194 1196 elif not (os.path.isfile(p) or os.path.islink(p)):
1195 1197 self.ui.warn(_("copy failed: %s is not a file or a "
1196 1198 "symbolic link\n") % dest)
1197 1199 else:
1198 1200 wlock = self.wlock()
1199 1201 try:
1200 1202 if self.dirstate[dest] in '?r':
1201 1203 self.dirstate.add(dest)
1202 1204 self.dirstate.copy(source, dest)
1203 1205 finally:
1204 1206 wlock.release()
1205 1207
1206 1208 def heads(self, start=None):
1207 1209 heads = self.changelog.heads(start)
1208 1210 # sort the output in rev descending order
1209 1211 heads = [(-self.changelog.rev(h), h) for h in heads]
1210 1212 return [n for (r, n) in sorted(heads)]
1211 1213
1212 1214 def branchheads(self, branch=None, start=None, closed=False):
1213 1215 '''return a (possibly filtered) list of heads for the given branch
1214 1216
1215 1217 Heads are returned in topological order, from newest to oldest.
1216 1218 If branch is None, use the dirstate branch.
1217 1219 If start is not None, return only heads reachable from start.
1218 1220 If closed is True, return heads that are marked as closed as well.
1219 1221 '''
1220 1222 if branch is None:
1221 1223 branch = self[None].branch()
1222 1224 branches = self.branchmap()
1223 1225 if branch not in branches:
1224 1226 return []
1225 1227 # the cache returns heads ordered lowest to highest
1226 1228 bheads = list(reversed(branches[branch]))
1227 1229 if start is not None:
1228 1230 # filter out the heads that cannot be reached from startrev
1229 1231 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
1230 1232 bheads = [h for h in bheads if h in fbheads]
1231 1233 if not closed:
1232 1234 bheads = [h for h in bheads if
1233 1235 ('close' not in self.changelog.read(h)[5])]
1234 1236 return bheads
1235 1237
1236 1238 def branches(self, nodes):
1237 1239 if not nodes:
1238 1240 nodes = [self.changelog.tip()]
1239 1241 b = []
1240 1242 for n in nodes:
1241 1243 t = n
1242 1244 while 1:
1243 1245 p = self.changelog.parents(n)
1244 1246 if p[1] != nullid or p[0] == nullid:
1245 1247 b.append((t, n, p[0], p[1]))
1246 1248 break
1247 1249 n = p[0]
1248 1250 return b
1249 1251
1250 1252 def between(self, pairs):
1251 1253 r = []
1252 1254
1253 1255 for top, bottom in pairs:
1254 1256 n, l, i = top, [], 0
1255 1257 f = 1
1256 1258
1257 1259 while n != bottom and n != nullid:
1258 1260 p = self.changelog.parents(n)[0]
1259 1261 if i == f:
1260 1262 l.append(n)
1261 1263 f = f * 2
1262 1264 n = p
1263 1265 i += 1
1264 1266
1265 1267 r.append(l)
1266 1268
1267 1269 return r
1268 1270
1269 1271 def findincoming(self, remote, base=None, heads=None, force=False):
1270 1272 """Return list of roots of the subsets of missing nodes from remote
1271 1273
1272 1274 If base dict is specified, assume that these nodes and their parents
1273 1275 exist on the remote side and that no child of a node of base exists
1274 1276 in both remote and self.
1275 1277 Furthermore base will be updated to include the nodes that exists
1276 1278 in self and remote but no children exists in self and remote.
1277 1279 If a list of heads is specified, return only nodes which are heads
1278 1280 or ancestors of these heads.
1279 1281
1280 1282 All the ancestors of base are in self and in remote.
1281 1283 All the descendants of the list returned are missing in self.
1282 1284 (and so we know that the rest of the nodes are missing in remote, see
1283 1285 outgoing)
1284 1286 """
1285 1287 return self.findcommonincoming(remote, base, heads, force)[1]
1286 1288
1287 1289 def findcommonincoming(self, remote, base=None, heads=None, force=False):
1288 1290 """Return a tuple (common, missing roots, heads) used to identify
1289 1291 missing nodes from remote.
1290 1292
1291 1293 If base dict is specified, assume that these nodes and their parents
1292 1294 exist on the remote side and that no child of a node of base exists
1293 1295 in both remote and self.
1294 1296 Furthermore base will be updated to include the nodes that exists
1295 1297 in self and remote but no children exists in self and remote.
1296 1298 If a list of heads is specified, return only nodes which are heads
1297 1299 or ancestors of these heads.
1298 1300
1299 1301 All the ancestors of base are in self and in remote.
1300 1302 """
1301 1303 m = self.changelog.nodemap
1302 1304 search = []
1303 1305 fetch = set()
1304 1306 seen = set()
1305 1307 seenbranch = set()
1306 1308 if base is None:
1307 1309 base = {}
1308 1310
1309 1311 if not heads:
1310 1312 heads = remote.heads()
1311 1313
1312 1314 if self.changelog.tip() == nullid:
1313 1315 base[nullid] = 1
1314 1316 if heads != [nullid]:
1315 1317 return [nullid], [nullid], list(heads)
1316 1318 return [nullid], [], []
1317 1319
1318 1320 # assume we're closer to the tip than the root
1319 1321 # and start by examining the heads
1320 1322 self.ui.status(_("searching for changes\n"))
1321 1323
1322 1324 unknown = []
1323 1325 for h in heads:
1324 1326 if h not in m:
1325 1327 unknown.append(h)
1326 1328 else:
1327 1329 base[h] = 1
1328 1330
1329 1331 heads = unknown
1330 1332 if not unknown:
1331 1333 return base.keys(), [], []
1332 1334
1333 1335 req = set(unknown)
1334 1336 reqcnt = 0
1335 1337
1336 1338 # search through remote branches
1337 1339 # a 'branch' here is a linear segment of history, with four parts:
1338 1340 # head, root, first parent, second parent
1339 1341 # (a branch always has two parents (or none) by definition)
1340 1342 unknown = remote.branches(unknown)
1341 1343 while unknown:
1342 1344 r = []
1343 1345 while unknown:
1344 1346 n = unknown.pop(0)
1345 1347 if n[0] in seen:
1346 1348 continue
1347 1349
1348 1350 self.ui.debug("examining %s:%s\n"
1349 1351 % (short(n[0]), short(n[1])))
1350 1352 if n[0] == nullid: # found the end of the branch
1351 1353 pass
1352 1354 elif n in seenbranch:
1353 1355 self.ui.debug("branch already found\n")
1354 1356 continue
1355 1357 elif n[1] and n[1] in m: # do we know the base?
1356 1358 self.ui.debug("found incomplete branch %s:%s\n"
1357 1359 % (short(n[0]), short(n[1])))
1358 1360 search.append(n[0:2]) # schedule branch range for scanning
1359 1361 seenbranch.add(n)
1360 1362 else:
1361 1363 if n[1] not in seen and n[1] not in fetch:
1362 1364 if n[2] in m and n[3] in m:
1363 1365 self.ui.debug("found new changeset %s\n" %
1364 1366 short(n[1]))
1365 1367 fetch.add(n[1]) # earliest unknown
1366 1368 for p in n[2:4]:
1367 1369 if p in m:
1368 1370 base[p] = 1 # latest known
1369 1371
1370 1372 for p in n[2:4]:
1371 1373 if p not in req and p not in m:
1372 1374 r.append(p)
1373 1375 req.add(p)
1374 1376 seen.add(n[0])
1375 1377
1376 1378 if r:
1377 1379 reqcnt += 1
1378 1380 self.ui.progress(_('searching'), reqcnt, unit=_('queries'))
1379 1381 self.ui.debug("request %d: %s\n" %
1380 1382 (reqcnt, " ".join(map(short, r))))
1381 1383 for p in xrange(0, len(r), 10):
1382 1384 for b in remote.branches(r[p:p + 10]):
1383 1385 self.ui.debug("received %s:%s\n" %
1384 1386 (short(b[0]), short(b[1])))
1385 1387 unknown.append(b)
1386 1388
1387 1389 # do binary search on the branches we found
1388 1390 while search:
1389 1391 newsearch = []
1390 1392 reqcnt += 1
1391 1393 self.ui.progress(_('searching'), reqcnt, unit=_('queries'))
1392 1394 for n, l in zip(search, remote.between(search)):
1393 1395 l.append(n[1])
1394 1396 p = n[0]
1395 1397 f = 1
1396 1398 for i in l:
1397 1399 self.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i)))
1398 1400 if i in m:
1399 1401 if f <= 2:
1400 1402 self.ui.debug("found new branch changeset %s\n" %
1401 1403 short(p))
1402 1404 fetch.add(p)
1403 1405 base[i] = 1
1404 1406 else:
1405 1407 self.ui.debug("narrowed branch search to %s:%s\n"
1406 1408 % (short(p), short(i)))
1407 1409 newsearch.append((p, i))
1408 1410 break
1409 1411 p, f = i, f * 2
1410 1412 search = newsearch
1411 1413
1412 1414 # sanity check our fetch list
1413 1415 for f in fetch:
1414 1416 if f in m:
1415 1417 raise error.RepoError(_("already have changeset ")
1416 1418 + short(f[:4]))
1417 1419
1418 1420 if base.keys() == [nullid]:
1419 1421 if force:
1420 1422 self.ui.warn(_("warning: repository is unrelated\n"))
1421 1423 else:
1422 1424 raise util.Abort(_("repository is unrelated"))
1423 1425
1424 1426 self.ui.debug("found new changesets starting at " +
1425 1427 " ".join([short(f) for f in fetch]) + "\n")
1426 1428
1427 1429 self.ui.progress(_('searching'), None)
1428 1430 self.ui.debug("%d total queries\n" % reqcnt)
1429 1431
1430 1432 return base.keys(), list(fetch), heads
1431 1433
1432 1434 def findoutgoing(self, remote, base=None, heads=None, force=False):
1433 1435 """Return list of nodes that are roots of subsets not in remote
1434 1436
1435 1437 If base dict is specified, assume that these nodes and their parents
1436 1438 exist on the remote side.
1437 1439 If a list of heads is specified, return only nodes which are heads
1438 1440 or ancestors of these heads, and return a second element which
1439 1441 contains all remote heads which get new children.
1440 1442 """
1441 1443 if base is None:
1442 1444 base = {}
1443 1445 self.findincoming(remote, base, heads, force=force)
1444 1446
1445 1447 self.ui.debug("common changesets up to "
1446 1448 + " ".join(map(short, base.keys())) + "\n")
1447 1449
1448 1450 remain = set(self.changelog.nodemap)
1449 1451
1450 1452 # prune everything remote has from the tree
1451 1453 remain.remove(nullid)
1452 1454 remove = base.keys()
1453 1455 while remove:
1454 1456 n = remove.pop(0)
1455 1457 if n in remain:
1456 1458 remain.remove(n)
1457 1459 for p in self.changelog.parents(n):
1458 1460 remove.append(p)
1459 1461
1460 1462 # find every node whose parents have been pruned
1461 1463 subset = []
1462 1464 # find every remote head that will get new children
1463 1465 updated_heads = set()
1464 1466 for n in remain:
1465 1467 p1, p2 = self.changelog.parents(n)
1466 1468 if p1 not in remain and p2 not in remain:
1467 1469 subset.append(n)
1468 1470 if heads:
1469 1471 if p1 in heads:
1470 1472 updated_heads.add(p1)
1471 1473 if p2 in heads:
1472 1474 updated_heads.add(p2)
1473 1475
1474 1476 # this is the set of all roots we have to push
1475 1477 if heads:
1476 1478 return subset, list(updated_heads)
1477 1479 else:
1478 1480 return subset
1479 1481
1480 1482 def pull(self, remote, heads=None, force=False):
1481 1483 lock = self.lock()
1482 1484 try:
1483 1485 common, fetch, rheads = self.findcommonincoming(remote, heads=heads,
1484 1486 force=force)
1485 1487 if not fetch:
1486 1488 self.ui.status(_("no changes found\n"))
1487 1489 return 0
1488 1490
1489 1491 if fetch == [nullid]:
1490 1492 self.ui.status(_("requesting all changes\n"))
1491 1493 elif heads is None and remote.capable('changegroupsubset'):
1492 1494 # issue1320, avoid a race if remote changed after discovery
1493 1495 heads = rheads
1494 1496
1495 1497 if heads is None:
1496 1498 cg = remote.changegroup(fetch, 'pull')
1497 1499 else:
1498 1500 if not remote.capable('changegroupsubset'):
1499 1501 raise util.Abort(_("Partial pull cannot be done because "
1500 1502 "other repository doesn't support "
1501 1503 "changegroupsubset."))
1502 1504 cg = remote.changegroupsubset(fetch, heads, 'pull')
1503 1505 return self.addchangegroup(cg, 'pull', remote.url())
1504 1506 finally:
1505 1507 lock.release()
1506 1508
1507 1509 def push(self, remote, force=False, revs=None):
1508 1510 # there are two ways to push to remote repo:
1509 1511 #
1510 1512 # addchangegroup assumes local user can lock remote
1511 1513 # repo (local filesystem, old ssh servers).
1512 1514 #
1513 1515 # unbundle assumes local user cannot lock remote repo (new ssh
1514 1516 # servers, http servers).
1515 1517
1516 1518 if remote.capable('unbundle'):
1517 1519 return self.push_unbundle(remote, force, revs)
1518 1520 return self.push_addchangegroup(remote, force, revs)
1519 1521
1520 1522 def prepush(self, remote, force, revs):
1521 1523 '''Analyze the local and remote repositories and determine which
1522 1524 changesets need to be pushed to the remote. Return a tuple
1523 1525 (changegroup, remoteheads). changegroup is a readable file-like
1524 1526 object whose read() returns successive changegroup chunks ready to
1525 1527 be sent over the wire. remoteheads is the list of remote heads.
1526 1528 '''
1527 1529 common = {}
1528 1530 remote_heads = remote.heads()
1529 1531 inc = self.findincoming(remote, common, remote_heads, force=force)
1530 1532
1531 1533 cl = self.changelog
1532 1534 update, updated_heads = self.findoutgoing(remote, common, remote_heads)
1533 1535 outg, bases, heads = cl.nodesbetween(update, revs)
1534 1536
1535 1537 if not bases:
1536 1538 self.ui.status(_("no changes found\n"))
1537 1539 return None, 1
1538 1540
1539 1541 if not force and remote_heads != [nullid]:
1540 1542
1541 1543 def fail_multiple_heads(unsynced, branch=None):
1542 1544 if branch:
1543 1545 msg = _("abort: push creates new remote heads"
1544 1546 " on branch '%s'!\n") % branch
1545 1547 else:
1546 1548 msg = _("abort: push creates new remote heads!\n")
1547 1549 self.ui.warn(msg)
1548 1550 if unsynced:
1549 1551 self.ui.status(_("(you should pull and merge or"
1550 1552 " use push -f to force)\n"))
1551 1553 else:
1552 1554 self.ui.status(_("(did you forget to merge?"
1553 1555 " use push -f to force)\n"))
1554 1556 return None, 0
1555 1557
1556 1558 if remote.capable('branchmap'):
1557 1559 # Check for each named branch if we're creating new remote heads.
1558 1560 # To be a remote head after push, node must be either:
1559 1561 # - unknown locally
1560 1562 # - a local outgoing head descended from update
1561 1563 # - a remote head that's known locally and not
1562 1564 # ancestral to an outgoing head
1563 1565 #
1564 1566 # New named branches cannot be created without --force.
1565 1567
1566 1568 # 1. Create set of branches involved in the push.
1567 1569 branches = set(self[n].branch() for n in outg)
1568 1570
1569 1571 # 2. Check for new branches on the remote.
1570 1572 remotemap = remote.branchmap()
1571 1573 newbranches = branches - set(remotemap)
1572 1574 if newbranches: # new branch requires --force
1573 1575 branchnames = ', '.join("%s" % b for b in newbranches)
1574 1576 self.ui.warn(_("abort: push creates "
1575 1577 "new remote branches: %s!\n")
1576 1578 % branchnames)
1577 1579 self.ui.status(_("(use 'hg push -f' to force)\n"))
1578 1580 return None, 0
1579 1581
1580 1582 # 3. Construct the initial oldmap and newmap dicts.
1581 1583 # They contain information about the remote heads before and
1582 1584 # after the push, respectively.
1583 1585 # Heads not found locally are not included in either dict,
1584 1586 # since they won't be affected by the push.
1585 1587 # unsynced contains all branches with incoming changesets.
1586 1588 oldmap = {}
1587 1589 newmap = {}
1588 1590 unsynced = set()
1589 1591 for branch in branches:
1590 1592 remoteheads = remotemap[branch]
1591 1593 prunedheads = [h for h in remoteheads if h in cl.nodemap]
1592 1594 oldmap[branch] = prunedheads
1593 1595 newmap[branch] = list(prunedheads)
1594 1596 if len(remoteheads) > len(prunedheads):
1595 1597 unsynced.add(branch)
1596 1598
1597 1599 # 4. Update newmap with outgoing changes.
1598 1600 # This will possibly add new heads and remove existing ones.
1599 1601 ctxgen = (self[n] for n in outg)
1600 1602 self._updatebranchcache(newmap, ctxgen)
1601 1603
1602 1604 # 5. Check for new heads.
1603 1605 # If there are more heads after the push than before, a suitable
1604 1606 # warning, depending on unsynced status, is displayed.
1605 1607 for branch in branches:
1606 1608 if len(newmap[branch]) > len(oldmap[branch]):
1607 1609 return fail_multiple_heads(branch in unsynced, branch)
1608 1610
1609 1611 # 6. Check for unsynced changes on involved branches.
1610 1612 if unsynced:
1611 1613 self.ui.warn(_("note: unsynced remote changes!\n"))
1612 1614
1613 1615 else:
1614 1616 # Old servers: Check for new topological heads.
1615 1617 # Code based on _updatebranchcache.
1616 1618 newheads = set(h for h in remote_heads if h in cl.nodemap)
1617 1619 oldheadcnt = len(newheads)
1618 1620 newheads.update(outg)
1619 1621 if len(newheads) > 1:
1620 1622 for latest in reversed(outg):
1621 1623 if latest not in newheads:
1622 1624 continue
1623 1625 minhrev = min(cl.rev(h) for h in newheads)
1624 1626 reachable = cl.reachable(latest, cl.node(minhrev))
1625 1627 reachable.remove(latest)
1626 1628 newheads.difference_update(reachable)
1627 1629 if len(newheads) > oldheadcnt:
1628 1630 return fail_multiple_heads(inc)
1629 1631 if inc:
1630 1632 self.ui.warn(_("note: unsynced remote changes!\n"))
1631 1633
1632 1634 if revs is None:
1633 1635 # use the fast path, no race possible on push
1634 1636 nodes = self.changelog.findmissing(common.keys())
1635 1637 cg = self._changegroup(nodes, 'push')
1636 1638 else:
1637 1639 cg = self.changegroupsubset(update, revs, 'push')
1638 1640 return cg, remote_heads
1639 1641
1640 1642 def push_addchangegroup(self, remote, force, revs):
1641 1643 lock = remote.lock()
1642 1644 try:
1643 1645 ret = self.prepush(remote, force, revs)
1644 1646 if ret[0] is not None:
1645 1647 cg, remote_heads = ret
1646 1648 return remote.addchangegroup(cg, 'push', self.url())
1647 1649 return ret[1]
1648 1650 finally:
1649 1651 lock.release()
1650 1652
1651 1653 def push_unbundle(self, remote, force, revs):
1652 1654 # local repo finds heads on server, finds out what revs it
1653 1655 # must push. once revs transferred, if server finds it has
1654 1656 # different heads (someone else won commit/push race), server
1655 1657 # aborts.
1656 1658
1657 1659 ret = self.prepush(remote, force, revs)
1658 1660 if ret[0] is not None:
1659 1661 cg, remote_heads = ret
1660 1662 if force:
1661 1663 remote_heads = ['force']
1662 1664 return remote.unbundle(cg, remote_heads, 'push')
1663 1665 return ret[1]
1664 1666
1665 1667 def changegroupinfo(self, nodes, source):
1666 1668 if self.ui.verbose or source == 'bundle':
1667 1669 self.ui.status(_("%d changesets found\n") % len(nodes))
1668 1670 if self.ui.debugflag:
1669 1671 self.ui.debug("list of changesets:\n")
1670 1672 for node in nodes:
1671 1673 self.ui.debug("%s\n" % hex(node))
1672 1674
1673 1675 def changegroupsubset(self, bases, heads, source, extranodes=None):
1674 1676 """Compute a changegroup consisting of all the nodes that are
1675 1677 descendents of any of the bases and ancestors of any of the heads.
1676 1678 Return a chunkbuffer object whose read() method will return
1677 1679 successive changegroup chunks.
1678 1680
1679 1681 It is fairly complex as determining which filenodes and which
1680 1682 manifest nodes need to be included for the changeset to be complete
1681 1683 is non-trivial.
1682 1684
1683 1685 Another wrinkle is doing the reverse, figuring out which changeset in
1684 1686 the changegroup a particular filenode or manifestnode belongs to.
1685 1687
1686 1688 The caller can specify some nodes that must be included in the
1687 1689 changegroup using the extranodes argument. It should be a dict
1688 1690 where the keys are the filenames (or 1 for the manifest), and the
1689 1691 values are lists of (node, linknode) tuples, where node is a wanted
1690 1692 node and linknode is the changelog node that should be transmitted as
1691 1693 the linkrev.
1692 1694 """
1693 1695
1694 1696 # Set up some initial variables
1695 1697 # Make it easy to refer to self.changelog
1696 1698 cl = self.changelog
1697 1699 # msng is short for missing - compute the list of changesets in this
1698 1700 # changegroup.
1699 1701 if not bases:
1700 1702 bases = [nullid]
1701 1703 msng_cl_lst, bases, heads = cl.nodesbetween(bases, heads)
1702 1704
1703 1705 if extranodes is None:
1704 1706 # can we go through the fast path ?
1705 1707 heads.sort()
1706 1708 allheads = self.heads()
1707 1709 allheads.sort()
1708 1710 if heads == allheads:
1709 1711 return self._changegroup(msng_cl_lst, source)
1710 1712
1711 1713 # slow path
1712 1714 self.hook('preoutgoing', throw=True, source=source)
1713 1715
1714 1716 self.changegroupinfo(msng_cl_lst, source)
1715 1717 # Some bases may turn out to be superfluous, and some heads may be
1716 1718 # too. nodesbetween will return the minimal set of bases and heads
1717 1719 # necessary to re-create the changegroup.
1718 1720
1719 1721 # Known heads are the list of heads that it is assumed the recipient
1720 1722 # of this changegroup will know about.
1721 1723 knownheads = set()
1722 1724 # We assume that all parents of bases are known heads.
1723 1725 for n in bases:
1724 1726 knownheads.update(cl.parents(n))
1725 1727 knownheads.discard(nullid)
1726 1728 knownheads = list(knownheads)
1727 1729 if knownheads:
1728 1730 # Now that we know what heads are known, we can compute which
1729 1731 # changesets are known. The recipient must know about all
1730 1732 # changesets required to reach the known heads from the null
1731 1733 # changeset.
1732 1734 has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
1733 1735 junk = None
1734 1736 # Transform the list into a set.
1735 1737 has_cl_set = set(has_cl_set)
1736 1738 else:
1737 1739 # If there were no known heads, the recipient cannot be assumed to
1738 1740 # know about any changesets.
1739 1741 has_cl_set = set()
1740 1742
1741 1743 # Make it easy to refer to self.manifest
1742 1744 mnfst = self.manifest
1743 1745 # We don't know which manifests are missing yet
1744 1746 msng_mnfst_set = {}
1745 1747 # Nor do we know which filenodes are missing.
1746 1748 msng_filenode_set = {}
1747 1749
1748 1750 junk = mnfst.index[len(mnfst) - 1] # Get around a bug in lazyindex
1749 1751 junk = None
1750 1752
1751 1753 # A changeset always belongs to itself, so the changenode lookup
1752 1754 # function for a changenode is identity.
1753 1755 def identity(x):
1754 1756 return x
1755 1757
1756 1758 # If we determine that a particular file or manifest node must be a
1757 1759 # node that the recipient of the changegroup will already have, we can
1758 1760 # also assume the recipient will have all the parents. This function
1759 1761 # prunes them from the set of missing nodes.
1760 1762 def prune_parents(revlog, hasset, msngset):
1761 1763 for r in revlog.ancestors(*[revlog.rev(n) for n in hasset]):
1762 1764 msngset.pop(revlog.node(r), None)
1763 1765
1764 1766 # Use the information collected in collect_manifests_and_files to say
1765 1767 # which changenode any manifestnode belongs to.
1766 1768 def lookup_manifest_link(mnfstnode):
1767 1769 return msng_mnfst_set[mnfstnode]
1768 1770
1769 1771 # A function generating function that sets up the initial environment
1770 1772 # the inner function.
1771 1773 def filenode_collector(changedfiles):
1772 1774 # This gathers information from each manifestnode included in the
1773 1775 # changegroup about which filenodes the manifest node references
1774 1776 # so we can include those in the changegroup too.
1775 1777 #
1776 1778 # It also remembers which changenode each filenode belongs to. It
1777 1779 # does this by assuming the a filenode belongs to the changenode
1778 1780 # the first manifest that references it belongs to.
1779 1781 def collect_msng_filenodes(mnfstnode):
1780 1782 r = mnfst.rev(mnfstnode)
1781 1783 if r - 1 in mnfst.parentrevs(r):
1782 1784 # If the previous rev is one of the parents,
1783 1785 # we only need to see a diff.
1784 1786 deltamf = mnfst.readdelta(mnfstnode)
1785 1787 # For each line in the delta
1786 1788 for f, fnode in deltamf.iteritems():
1787 1789 f = changedfiles.get(f, None)
1788 1790 # And if the file is in the list of files we care
1789 1791 # about.
1790 1792 if f is not None:
1791 1793 # Get the changenode this manifest belongs to
1792 1794 clnode = msng_mnfst_set[mnfstnode]
1793 1795 # Create the set of filenodes for the file if
1794 1796 # there isn't one already.
1795 1797 ndset = msng_filenode_set.setdefault(f, {})
1796 1798 # And set the filenode's changelog node to the
1797 1799 # manifest's if it hasn't been set already.
1798 1800 ndset.setdefault(fnode, clnode)
1799 1801 else:
1800 1802 # Otherwise we need a full manifest.
1801 1803 m = mnfst.read(mnfstnode)
1802 1804 # For every file in we care about.
1803 1805 for f in changedfiles:
1804 1806 fnode = m.get(f, None)
1805 1807 # If it's in the manifest
1806 1808 if fnode is not None:
1807 1809 # See comments above.
1808 1810 clnode = msng_mnfst_set[mnfstnode]
1809 1811 ndset = msng_filenode_set.setdefault(f, {})
1810 1812 ndset.setdefault(fnode, clnode)
1811 1813 return collect_msng_filenodes
1812 1814
1813 1815 # We have a list of filenodes we think we need for a file, lets remove
1814 1816 # all those we know the recipient must have.
1815 1817 def prune_filenodes(f, filerevlog):
1816 1818 msngset = msng_filenode_set[f]
1817 1819 hasset = set()
1818 1820 # If a 'missing' filenode thinks it belongs to a changenode we
1819 1821 # assume the recipient must have, then the recipient must have
1820 1822 # that filenode.
1821 1823 for n in msngset:
1822 1824 clnode = cl.node(filerevlog.linkrev(filerevlog.rev(n)))
1823 1825 if clnode in has_cl_set:
1824 1826 hasset.add(n)
1825 1827 prune_parents(filerevlog, hasset, msngset)
1826 1828
1827 1829 # A function generator function that sets up the a context for the
1828 1830 # inner function.
1829 1831 def lookup_filenode_link_func(fname):
1830 1832 msngset = msng_filenode_set[fname]
1831 1833 # Lookup the changenode the filenode belongs to.
1832 1834 def lookup_filenode_link(fnode):
1833 1835 return msngset[fnode]
1834 1836 return lookup_filenode_link
1835 1837
1836 1838 # Add the nodes that were explicitly requested.
1837 1839 def add_extra_nodes(name, nodes):
1838 1840 if not extranodes or name not in extranodes:
1839 1841 return
1840 1842
1841 1843 for node, linknode in extranodes[name]:
1842 1844 if node not in nodes:
1843 1845 nodes[node] = linknode
1844 1846
1845 1847 # Now that we have all theses utility functions to help out and
1846 1848 # logically divide up the task, generate the group.
1847 1849 def gengroup():
1848 1850 # The set of changed files starts empty.
1849 1851 changedfiles = {}
1850 1852 collect = changegroup.collector(cl, msng_mnfst_set, changedfiles)
1851 1853
1852 1854 # Create a changenode group generator that will call our functions
1853 1855 # back to lookup the owning changenode and collect information.
1854 1856 group = cl.group(msng_cl_lst, identity, collect)
1855 1857 cnt = 0
1856 1858 for chnk in group:
1857 1859 yield chnk
1858 1860 self.ui.progress(_('bundling changes'), cnt, unit=_('chunks'))
1859 1861 cnt += 1
1860 1862 self.ui.progress(_('bundling changes'), None)
1861 1863
1862 1864
1863 1865 # Figure out which manifest nodes (of the ones we think might be
1864 1866 # part of the changegroup) the recipient must know about and
1865 1867 # remove them from the changegroup.
1866 1868 has_mnfst_set = set()
1867 1869 for n in msng_mnfst_set:
1868 1870 # If a 'missing' manifest thinks it belongs to a changenode
1869 1871 # the recipient is assumed to have, obviously the recipient
1870 1872 # must have that manifest.
1871 1873 linknode = cl.node(mnfst.linkrev(mnfst.rev(n)))
1872 1874 if linknode in has_cl_set:
1873 1875 has_mnfst_set.add(n)
1874 1876 prune_parents(mnfst, has_mnfst_set, msng_mnfst_set)
1875 1877 add_extra_nodes(1, msng_mnfst_set)
1876 1878 msng_mnfst_lst = msng_mnfst_set.keys()
1877 1879 # Sort the manifestnodes by revision number.
1878 1880 msng_mnfst_lst.sort(key=mnfst.rev)
1879 1881 # Create a generator for the manifestnodes that calls our lookup
1880 1882 # and data collection functions back.
1881 1883 group = mnfst.group(msng_mnfst_lst, lookup_manifest_link,
1882 1884 filenode_collector(changedfiles))
1883 1885 cnt = 0
1884 1886 for chnk in group:
1885 1887 yield chnk
1886 1888 self.ui.progress(_('bundling manifests'), cnt, unit=_('chunks'))
1887 1889 cnt += 1
1888 1890 self.ui.progress(_('bundling manifests'), None)
1889 1891
1890 1892 # These are no longer needed, dereference and toss the memory for
1891 1893 # them.
1892 1894 msng_mnfst_lst = None
1893 1895 msng_mnfst_set.clear()
1894 1896
1895 1897 if extranodes:
1896 1898 for fname in extranodes:
1897 1899 if isinstance(fname, int):
1898 1900 continue
1899 1901 msng_filenode_set.setdefault(fname, {})
1900 1902 changedfiles[fname] = 1
1901 1903 # Go through all our files in order sorted by name.
1902 1904 cnt = 0
1903 1905 for fname in sorted(changedfiles):
1904 1906 filerevlog = self.file(fname)
1905 1907 if not len(filerevlog):
1906 1908 raise util.Abort(_("empty or missing revlog for %s") % fname)
1907 1909 # Toss out the filenodes that the recipient isn't really
1908 1910 # missing.
1909 1911 if fname in msng_filenode_set:
1910 1912 prune_filenodes(fname, filerevlog)
1911 1913 add_extra_nodes(fname, msng_filenode_set[fname])
1912 1914 msng_filenode_lst = msng_filenode_set[fname].keys()
1913 1915 else:
1914 1916 msng_filenode_lst = []
1915 1917 # If any filenodes are left, generate the group for them,
1916 1918 # otherwise don't bother.
1917 1919 if len(msng_filenode_lst) > 0:
1918 1920 yield changegroup.chunkheader(len(fname))
1919 1921 yield fname
1920 1922 # Sort the filenodes by their revision #
1921 1923 msng_filenode_lst.sort(key=filerevlog.rev)
1922 1924 # Create a group generator and only pass in a changenode
1923 1925 # lookup function as we need to collect no information
1924 1926 # from filenodes.
1925 1927 group = filerevlog.group(msng_filenode_lst,
1926 1928 lookup_filenode_link_func(fname))
1927 1929 for chnk in group:
1928 1930 self.ui.progress(
1929 1931 _('bundling files'), cnt, item=fname, unit=_('chunks'))
1930 1932 cnt += 1
1931 1933 yield chnk
1932 1934 if fname in msng_filenode_set:
1933 1935 # Don't need this anymore, toss it to free memory.
1934 1936 del msng_filenode_set[fname]
1935 1937 # Signal that no more groups are left.
1936 1938 yield changegroup.closechunk()
1937 1939 self.ui.progress(_('bundling files'), None)
1938 1940
1939 1941 if msng_cl_lst:
1940 1942 self.hook('outgoing', node=hex(msng_cl_lst[0]), source=source)
1941 1943
1942 1944 return util.chunkbuffer(gengroup())
1943 1945
1944 1946 def changegroup(self, basenodes, source):
1945 1947 # to avoid a race we use changegroupsubset() (issue1320)
1946 1948 return self.changegroupsubset(basenodes, self.heads(), source)
1947 1949
1948 1950 def _changegroup(self, nodes, source):
1949 1951 """Compute the changegroup of all nodes that we have that a recipient
1950 1952 doesn't. Return a chunkbuffer object whose read() method will return
1951 1953 successive changegroup chunks.
1952 1954
1953 1955 This is much easier than the previous function as we can assume that
1954 1956 the recipient has any changenode we aren't sending them.
1955 1957
1956 1958 nodes is the set of nodes to send"""
1957 1959
1958 1960 self.hook('preoutgoing', throw=True, source=source)
1959 1961
1960 1962 cl = self.changelog
1961 1963 revset = set([cl.rev(n) for n in nodes])
1962 1964 self.changegroupinfo(nodes, source)
1963 1965
1964 1966 def identity(x):
1965 1967 return x
1966 1968
1967 1969 def gennodelst(log):
1968 1970 for r in log:
1969 1971 if log.linkrev(r) in revset:
1970 1972 yield log.node(r)
1971 1973
1972 1974 def lookuprevlink_func(revlog):
1973 1975 def lookuprevlink(n):
1974 1976 return cl.node(revlog.linkrev(revlog.rev(n)))
1975 1977 return lookuprevlink
1976 1978
1977 1979 def gengroup():
1978 1980 '''yield a sequence of changegroup chunks (strings)'''
1979 1981 # construct a list of all changed files
1980 1982 changedfiles = {}
1981 1983 mmfs = {}
1982 1984 collect = changegroup.collector(cl, mmfs, changedfiles)
1983 1985
1984 1986 cnt = 0
1985 1987 for chnk in cl.group(nodes, identity, collect):
1986 1988 self.ui.progress(_('bundling changes'), cnt, unit=_('chunks'))
1987 1989 cnt += 1
1988 1990 yield chnk
1989 1991 self.ui.progress(_('bundling changes'), None)
1990 1992
1991 1993 mnfst = self.manifest
1992 1994 nodeiter = gennodelst(mnfst)
1993 1995 cnt = 0
1994 1996 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1995 1997 self.ui.progress(_('bundling manifests'), cnt, unit=_('chunks'))
1996 1998 cnt += 1
1997 1999 yield chnk
1998 2000 self.ui.progress(_('bundling manifests'), None)
1999 2001
2000 2002 cnt = 0
2001 2003 for fname in sorted(changedfiles):
2002 2004 filerevlog = self.file(fname)
2003 2005 if not len(filerevlog):
2004 2006 raise util.Abort(_("empty or missing revlog for %s") % fname)
2005 2007 nodeiter = gennodelst(filerevlog)
2006 2008 nodeiter = list(nodeiter)
2007 2009 if nodeiter:
2008 2010 yield changegroup.chunkheader(len(fname))
2009 2011 yield fname
2010 2012 lookup = lookuprevlink_func(filerevlog)
2011 2013 for chnk in filerevlog.group(nodeiter, lookup):
2012 2014 self.ui.progress(
2013 2015 _('bundling files'), cnt, item=fname, unit=_('chunks'))
2014 2016 cnt += 1
2015 2017 yield chnk
2016 2018 self.ui.progress(_('bundling files'), None)
2017 2019
2018 2020 yield changegroup.closechunk()
2019 2021
2020 2022 if nodes:
2021 2023 self.hook('outgoing', node=hex(nodes[0]), source=source)
2022 2024
2023 2025 return util.chunkbuffer(gengroup())
2024 2026
2025 2027 def addchangegroup(self, source, srctype, url, emptyok=False):
2026 2028 """add changegroup to repo.
2027 2029
2028 2030 return values:
2029 2031 - nothing changed or no source: 0
2030 2032 - more heads than before: 1+added heads (2..n)
2031 2033 - less heads than before: -1-removed heads (-2..-n)
2032 2034 - number of heads stays the same: 1
2033 2035 """
2034 2036 def csmap(x):
2035 2037 self.ui.debug("add changeset %s\n" % short(x))
2036 2038 return len(cl)
2037 2039
2038 2040 def revmap(x):
2039 2041 return cl.rev(x)
2040 2042
2041 2043 if not source:
2042 2044 return 0
2043 2045
2044 2046 self.hook('prechangegroup', throw=True, source=srctype, url=url)
2045 2047
2046 2048 changesets = files = revisions = 0
2047 2049 efiles = set()
2048 2050
2049 2051 # write changelog data to temp files so concurrent readers will not see
2050 2052 # inconsistent view
2051 2053 cl = self.changelog
2052 2054 cl.delayupdate()
2053 2055 oldheads = len(cl.heads())
2054 2056
2055 2057 tr = self.transaction("\n".join([srctype, urlmod.hidepassword(url)]))
2056 2058 try:
2057 2059 trp = weakref.proxy(tr)
2058 2060 # pull off the changeset group
2059 2061 self.ui.status(_("adding changesets\n"))
2060 2062 clstart = len(cl)
2061 2063 class prog(object):
2062 2064 step = _('changesets')
2063 2065 count = 1
2064 2066 ui = self.ui
2065 2067 total = None
2066 2068 def __call__(self):
2067 2069 self.ui.progress(self.step, self.count, unit=_('chunks'),
2068 2070 total=self.total)
2069 2071 self.count += 1
2070 2072 pr = prog()
2071 2073 chunkiter = changegroup.chunkiter(source, progress=pr)
2072 2074 if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok:
2073 2075 raise util.Abort(_("received changelog group is empty"))
2074 2076 clend = len(cl)
2075 2077 changesets = clend - clstart
2076 2078 for c in xrange(clstart, clend):
2077 2079 efiles.update(self[c].files())
2078 2080 efiles = len(efiles)
2079 2081 self.ui.progress(_('changesets'), None)
2080 2082
2081 2083 # pull off the manifest group
2082 2084 self.ui.status(_("adding manifests\n"))
2083 2085 pr.step = _('manifests')
2084 2086 pr.count = 1
2085 2087 pr.total = changesets # manifests <= changesets
2086 2088 chunkiter = changegroup.chunkiter(source, progress=pr)
2087 2089 # no need to check for empty manifest group here:
2088 2090 # if the result of the merge of 1 and 2 is the same in 3 and 4,
2089 2091 # no new manifest will be created and the manifest group will
2090 2092 # be empty during the pull
2091 2093 self.manifest.addgroup(chunkiter, revmap, trp)
2092 2094 self.ui.progress(_('manifests'), None)
2093 2095
2094 2096 needfiles = {}
2095 2097 if self.ui.configbool('server', 'validate', default=False):
2096 2098 # validate incoming csets have their manifests
2097 2099 for cset in xrange(clstart, clend):
2098 2100 mfest = self.changelog.read(self.changelog.node(cset))[0]
2099 2101 mfest = self.manifest.readdelta(mfest)
2100 2102 # store file nodes we must see
2101 2103 for f, n in mfest.iteritems():
2102 2104 needfiles.setdefault(f, set()).add(n)
2103 2105
2104 2106 # process the files
2105 2107 self.ui.status(_("adding file changes\n"))
2106 2108 pr.step = 'files'
2107 2109 pr.count = 1
2108 2110 pr.total = efiles
2109 2111 while 1:
2110 2112 f = changegroup.getchunk(source)
2111 2113 if not f:
2112 2114 break
2113 2115 self.ui.debug("adding %s revisions\n" % f)
2114 2116 pr()
2115 2117 fl = self.file(f)
2116 2118 o = len(fl)
2117 2119 chunkiter = changegroup.chunkiter(source)
2118 2120 if fl.addgroup(chunkiter, revmap, trp) is None:
2119 2121 raise util.Abort(_("received file revlog group is empty"))
2120 2122 revisions += len(fl) - o
2121 2123 files += 1
2122 2124 if f in needfiles:
2123 2125 needs = needfiles[f]
2124 2126 for new in xrange(o, len(fl)):
2125 2127 n = fl.node(new)
2126 2128 if n in needs:
2127 2129 needs.remove(n)
2128 2130 if not needs:
2129 2131 del needfiles[f]
2130 2132 self.ui.progress(_('files'), None)
2131 2133
2132 2134 for f, needs in needfiles.iteritems():
2133 2135 fl = self.file(f)
2134 2136 for n in needs:
2135 2137 try:
2136 2138 fl.rev(n)
2137 2139 except error.LookupError:
2138 2140 raise util.Abort(
2139 2141 _('missing file data for %s:%s - run hg verify') %
2140 2142 (f, hex(n)))
2141 2143
2142 2144 newheads = len(cl.heads())
2143 2145 heads = ""
2144 2146 if oldheads and newheads != oldheads:
2145 2147 heads = _(" (%+d heads)") % (newheads - oldheads)
2146 2148
2147 2149 self.ui.status(_("added %d changesets"
2148 2150 " with %d changes to %d files%s\n")
2149 2151 % (changesets, revisions, files, heads))
2150 2152
2151 2153 if changesets > 0:
2152 2154 p = lambda: cl.writepending() and self.root or ""
2153 2155 self.hook('pretxnchangegroup', throw=True,
2154 2156 node=hex(cl.node(clstart)), source=srctype,
2155 2157 url=url, pending=p)
2156 2158
2157 2159 # make changelog see real files again
2158 2160 cl.finalize(trp)
2159 2161
2160 2162 tr.close()
2161 2163 finally:
2162 2164 del tr
2163 2165
2164 2166 if changesets > 0:
2165 2167 # forcefully update the on-disk branch cache
2166 2168 self.ui.debug("updating the branch cache\n")
2167 2169 self.branchtags()
2168 2170 self.hook("changegroup", node=hex(cl.node(clstart)),
2169 2171 source=srctype, url=url)
2170 2172
2171 2173 for i in xrange(clstart, clend):
2172 2174 self.hook("incoming", node=hex(cl.node(i)),
2173 2175 source=srctype, url=url)
2174 2176
2175 2177 # never return 0 here:
2176 2178 if newheads < oldheads:
2177 2179 return newheads - oldheads - 1
2178 2180 else:
2179 2181 return newheads - oldheads + 1
2180 2182
2181 2183
2182 2184 def stream_in(self, remote):
2183 2185 fp = remote.stream_out()
2184 2186 l = fp.readline()
2185 2187 try:
2186 2188 resp = int(l)
2187 2189 except ValueError:
2188 2190 raise error.ResponseError(
2189 2191 _('Unexpected response from remote server:'), l)
2190 2192 if resp == 1:
2191 2193 raise util.Abort(_('operation forbidden by server'))
2192 2194 elif resp == 2:
2193 2195 raise util.Abort(_('locking the remote repository failed'))
2194 2196 elif resp != 0:
2195 2197 raise util.Abort(_('the server sent an unknown error code'))
2196 2198 self.ui.status(_('streaming all changes\n'))
2197 2199 l = fp.readline()
2198 2200 try:
2199 2201 total_files, total_bytes = map(int, l.split(' ', 1))
2200 2202 except (ValueError, TypeError):
2201 2203 raise error.ResponseError(
2202 2204 _('Unexpected response from remote server:'), l)
2203 2205 self.ui.status(_('%d files to transfer, %s of data\n') %
2204 2206 (total_files, util.bytecount(total_bytes)))
2205 2207 start = time.time()
2206 2208 for i in xrange(total_files):
2207 2209 # XXX doesn't support '\n' or '\r' in filenames
2208 2210 l = fp.readline()
2209 2211 try:
2210 2212 name, size = l.split('\0', 1)
2211 2213 size = int(size)
2212 2214 except (ValueError, TypeError):
2213 2215 raise error.ResponseError(
2214 2216 _('Unexpected response from remote server:'), l)
2215 2217 self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size)))
2216 2218 # for backwards compat, name was partially encoded
2217 2219 ofp = self.sopener(store.decodedir(name), 'w')
2218 2220 for chunk in util.filechunkiter(fp, limit=size):
2219 2221 ofp.write(chunk)
2220 2222 ofp.close()
2221 2223 elapsed = time.time() - start
2222 2224 if elapsed <= 0:
2223 2225 elapsed = 0.001
2224 2226 self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
2225 2227 (util.bytecount(total_bytes), elapsed,
2226 2228 util.bytecount(total_bytes / elapsed)))
2227 2229 self.invalidate()
2228 2230 return len(self.heads()) + 1
2229 2231
2230 2232 def clone(self, remote, heads=[], stream=False):
2231 2233 '''clone remote repository.
2232 2234
2233 2235 keyword arguments:
2234 2236 heads: list of revs to clone (forces use of pull)
2235 2237 stream: use streaming clone if possible'''
2236 2238
2237 2239 # now, all clients that can request uncompressed clones can
2238 2240 # read repo formats supported by all servers that can serve
2239 2241 # them.
2240 2242
2241 2243 # if revlog format changes, client will have to check version
2242 2244 # and format flags on "stream" capability, and use
2243 2245 # uncompressed only if compatible.
2244 2246
2245 2247 if stream and not heads and remote.capable('stream'):
2246 2248 return self.stream_in(remote)
2247 2249 return self.pull(remote, heads)
2248 2250
2249 2251 # used to avoid circular references so destructors work
2250 2252 def aftertrans(files):
2251 2253 renamefiles = [tuple(t) for t in files]
2252 2254 def a():
2253 2255 for src, dest in renamefiles:
2254 2256 util.rename(src, dest)
2255 2257 return a
2256 2258
2257 2259 def instance(ui, path, create):
2258 2260 return localrepository(ui, util.drop_scheme('file', path), create)
2259 2261
2260 2262 def islocal(path):
2261 2263 return True
@@ -1,380 +1,388 b''
1 1 # subrepo.py - sub-repository handling for Mercurial
2 2 #
3 3 # Copyright 2009-2010 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 import errno, os, re, xml.dom.minidom, shutil, urlparse, posixpath
9 9 from i18n import _
10 10 import config, util, node, error
11 11 hg = None
12 12
13 13 nullstate = ('', '', 'empty')
14 14
15 15 def state(ctx):
16 16 p = config.config()
17 17 def read(f, sections=None, remap=None):
18 18 if f in ctx:
19 19 p.parse(f, ctx[f].data(), sections, remap, read)
20 20 else:
21 21 raise util.Abort(_("subrepo spec file %s not found") % f)
22 22
23 23 if '.hgsub' in ctx:
24 24 read('.hgsub')
25 25
26 26 rev = {}
27 27 if '.hgsubstate' in ctx:
28 28 try:
29 29 for l in ctx['.hgsubstate'].data().splitlines():
30 30 revision, path = l.split(" ", 1)
31 31 rev[path] = revision
32 32 except IOError, err:
33 33 if err.errno != errno.ENOENT:
34 34 raise
35 35
36 36 state = {}
37 37 for path, src in p[''].items():
38 38 kind = 'hg'
39 39 if src.startswith('['):
40 40 if ']' not in src:
41 41 raise util.Abort(_('missing ] in subrepo source'))
42 42 kind, src = src.split(']', 1)
43 43 kind = kind[1:]
44 44 state[path] = (src.strip(), rev.get(path, ''), kind)
45 45
46 46 return state
47 47
48 48 def writestate(repo, state):
49 49 repo.wwrite('.hgsubstate',
50 50 ''.join(['%s %s\n' % (state[s][1], s)
51 51 for s in sorted(state)]), '')
52 52
53 53 def submerge(repo, wctx, mctx, actx):
54 54 # working context, merging context, ancestor context
55 55 if mctx == actx: # backwards?
56 56 actx = wctx.p1()
57 57 s1 = wctx.substate
58 58 s2 = mctx.substate
59 59 sa = actx.substate
60 60 sm = {}
61 61
62 62 repo.ui.debug("subrepo merge %s %s %s\n" % (wctx, mctx, actx))
63 63
64 64 def debug(s, msg, r=""):
65 65 if r:
66 66 r = "%s:%s:%s" % r
67 67 repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r))
68 68
69 69 for s, l in s1.items():
70 70 if wctx != actx and wctx.sub(s).dirty():
71 71 l = (l[0], l[1] + "+")
72 72 a = sa.get(s, nullstate)
73 73 if s in s2:
74 74 r = s2[s]
75 75 if l == r or r == a: # no change or local is newer
76 76 sm[s] = l
77 77 continue
78 78 elif l == a: # other side changed
79 79 debug(s, "other changed, get", r)
80 80 wctx.sub(s).get(r)
81 81 sm[s] = r
82 82 elif l[0] != r[0]: # sources differ
83 83 if repo.ui.promptchoice(
84 84 _(' subrepository sources for %s differ\n'
85 85 'use (l)ocal source (%s) or (r)emote source (%s)?')
86 86 % (s, l[0], r[0]),
87 87 (_('&Local'), _('&Remote')), 0):
88 88 debug(s, "prompt changed, get", r)
89 89 wctx.sub(s).get(r)
90 90 sm[s] = r
91 91 elif l[1] == a[1]: # local side is unchanged
92 92 debug(s, "other side changed, get", r)
93 93 wctx.sub(s).get(r)
94 94 sm[s] = r
95 95 else:
96 96 debug(s, "both sides changed, merge with", r)
97 97 wctx.sub(s).merge(r)
98 98 sm[s] = l
99 99 elif l == a: # remote removed, local unchanged
100 100 debug(s, "remote removed, remove")
101 101 wctx.sub(s).remove()
102 102 else:
103 103 if repo.ui.promptchoice(
104 104 _(' local changed subrepository %s which remote removed\n'
105 105 'use (c)hanged version or (d)elete?') % s,
106 106 (_('&Changed'), _('&Delete')), 0):
107 107 debug(s, "prompt remove")
108 108 wctx.sub(s).remove()
109 109
110 110 for s, r in s2.items():
111 111 if s in s1:
112 112 continue
113 113 elif s not in sa:
114 114 debug(s, "remote added, get", r)
115 115 mctx.sub(s).get(r)
116 116 sm[s] = r
117 117 elif r != sa[s]:
118 118 if repo.ui.promptchoice(
119 119 _(' remote changed subrepository %s which local removed\n'
120 120 'use (c)hanged version or (d)elete?') % s,
121 121 (_('&Changed'), _('&Delete')), 0) == 0:
122 122 debug(s, "prompt recreate", r)
123 123 wctx.sub(s).get(r)
124 124 sm[s] = r
125 125
126 126 # record merged .hgsubstate
127 127 writestate(repo, sm)
128 128
129 def relpath(sub):
130 if not hasattr(sub, '_repo'):
131 return sub._path
132 parent = sub._repo
133 while hasattr(parent, '_subparent'):
134 parent = parent._subparent
135 return sub._repo.root[len(parent.root)+1:]
136
129 137 def _abssource(repo, push=False):
130 138 if hasattr(repo, '_subparent'):
131 139 source = repo._subsource
132 140 if source.startswith('/') or '://' in source:
133 141 return source
134 142 parent = _abssource(repo._subparent, push)
135 143 if '://' in parent:
136 144 if parent[-1] == '/':
137 145 parent = parent[:-1]
138 146 r = urlparse.urlparse(parent + '/' + source)
139 147 r = urlparse.urlunparse((r[0], r[1],
140 148 posixpath.normpath(r.path),
141 149 r[3], r[4], r[5]))
142 150 return r
143 151 return posixpath.normpath(os.path.join(parent, repo._subsource))
144 152 if push and repo.ui.config('paths', 'default-push'):
145 153 return repo.ui.config('paths', 'default-push', repo.root)
146 154 return repo.ui.config('paths', 'default', repo.root)
147 155
148 156 def subrepo(ctx, path):
149 157 # subrepo inherently violates our import layering rules
150 158 # because it wants to make repo objects from deep inside the stack
151 159 # so we manually delay the circular imports to not break
152 160 # scripts that don't use our demand-loading
153 161 global hg
154 162 import hg as h
155 163 hg = h
156 164
157 165 util.path_auditor(ctx._repo.root)(path)
158 166 state = ctx.substate.get(path, nullstate)
159 167 if state[2] not in types:
160 168 raise util.Abort(_('unknown subrepo type %s') % state[2])
161 169 return types[state[2]](ctx, path, state[:2])
162 170
163 171 # subrepo classes need to implement the following methods:
164 172 # __init__(self, ctx, path, state)
165 173 # dirty(self): returns true if the dirstate of the subrepo
166 174 # does not match current stored state
167 175 # commit(self, text, user, date): commit the current changes
168 176 # to the subrepo with the given log message. Use given
169 177 # user and date if possible. Return the new state of the subrepo.
170 178 # remove(self): remove the subrepo (should verify the dirstate
171 179 # is not dirty first)
172 180 # get(self, state): run whatever commands are needed to put the
173 181 # subrepo into this state
174 182 # merge(self, state): merge currently-saved state with the new state.
175 183 # push(self, force): perform whatever action is analagous to 'hg push'
176 184 # This may be a no-op on some systems.
177 185
178 186 class hgsubrepo(object):
179 187 def __init__(self, ctx, path, state):
180 188 self._path = path
181 189 self._state = state
182 190 r = ctx._repo
183 191 root = r.wjoin(path)
184 192 create = False
185 193 if not os.path.exists(os.path.join(root, '.hg')):
186 194 create = True
187 195 util.makedirs(root)
188 196 self._repo = hg.repository(r.ui, root, create=create)
189 197 self._repo._subparent = r
190 198 self._repo._subsource = state[0]
191 199
192 200 if create:
193 201 fp = self._repo.opener("hgrc", "w", text=True)
194 202 fp.write('[paths]\n')
195 203
196 204 def addpathconfig(key, value):
197 205 fp.write('%s = %s\n' % (key, value))
198 206 self._repo.ui.setconfig('paths', key, value)
199 207
200 208 defpath = _abssource(self._repo)
201 209 defpushpath = _abssource(self._repo, True)
202 210 addpathconfig('default', defpath)
203 211 if defpath != defpushpath:
204 212 addpathconfig('default-push', defpushpath)
205 213 fp.close()
206 214
207 215 def dirty(self):
208 216 r = self._state[1]
209 217 if r == '':
210 218 return True
211 219 w = self._repo[None]
212 220 if w.p1() != self._repo[r]: # version checked out change
213 221 return True
214 222 return w.dirty() # working directory changed
215 223
216 224 def commit(self, text, user, date):
217 self._repo.ui.debug("committing subrepo %s\n" % self._path)
225 self._repo.ui.debug("committing subrepo %s\n" % relpath(self))
218 226 n = self._repo.commit(text, user, date)
219 227 if not n:
220 228 return self._repo['.'].hex() # different version checked out
221 229 return node.hex(n)
222 230
223 231 def remove(self):
224 232 # we can't fully delete the repository as it may contain
225 233 # local-only history
226 self._repo.ui.note(_('removing subrepo %s\n') % self._path)
234 self._repo.ui.note(_('removing subrepo %s\n') % relpath(self))
227 235 hg.clean(self._repo, node.nullid, False)
228 236
229 237 def _get(self, state):
230 238 source, revision, kind = state
231 239 try:
232 240 self._repo.lookup(revision)
233 241 except error.RepoError:
234 242 self._repo._subsource = source
235 243 srcurl = _abssource(self._repo)
236 244 self._repo.ui.status(_('pulling subrepo %s from %s\n')
237 % (self._path, srcurl))
245 % (relpath(self), srcurl))
238 246 other = hg.repository(self._repo.ui, srcurl)
239 247 self._repo.pull(other)
240 248
241 249 def get(self, state):
242 250 self._get(state)
243 251 source, revision, kind = state
244 252 self._repo.ui.debug("getting subrepo %s\n" % self._path)
245 253 hg.clean(self._repo, revision, False)
246 254
247 255 def merge(self, state):
248 256 self._get(state)
249 257 cur = self._repo['.']
250 258 dst = self._repo[state[1]]
251 259 anc = dst.ancestor(cur)
252 260 if anc == cur:
253 self._repo.ui.debug("updating subrepo %s\n" % self._path)
261 self._repo.ui.debug("updating subrepo %s\n" % relpath(self))
254 262 hg.update(self._repo, state[1])
255 263 elif anc == dst:
256 self._repo.ui.debug("skipping subrepo %s\n" % self._path)
264 self._repo.ui.debug("skipping subrepo %s\n" % relpath(self))
257 265 else:
258 self._repo.ui.debug("merging subrepo %s\n" % self._path)
266 self._repo.ui.debug("merging subrepo %s\n" % relpath(self))
259 267 hg.merge(self._repo, state[1], remind=False)
260 268
261 269 def push(self, force):
262 270 # push subrepos depth-first for coherent ordering
263 271 c = self._repo['']
264 272 subs = c.substate # only repos that are committed
265 273 for s in sorted(subs):
266 274 if not c.sub(s).push(force):
267 275 return False
268 276
269 277 dsturl = _abssource(self._repo, True)
270 278 self._repo.ui.status(_('pushing subrepo %s to %s\n') %
271 (self._path, dsturl))
279 (relpath(self), dsturl))
272 280 other = hg.repository(self._repo.ui, dsturl)
273 281 return self._repo.push(other, force)
274 282
275 283 class svnsubrepo(object):
276 284 def __init__(self, ctx, path, state):
277 285 self._path = path
278 286 self._state = state
279 287 self._ctx = ctx
280 288 self._ui = ctx._repo.ui
281 289
282 290 def _svncommand(self, commands):
283 291 path = os.path.join(self._ctx._repo.origroot, self._path)
284 292 cmd = ['svn'] + commands + [path]
285 293 cmd = [util.shellquote(arg) for arg in cmd]
286 294 cmd = util.quotecommand(' '.join(cmd))
287 295 env = dict(os.environ)
288 296 # Avoid localized output, preserve current locale for everything else.
289 297 env['LC_MESSAGES'] = 'C'
290 298 write, read, err = util.popen3(cmd, env=env, newlines=True)
291 299 retdata = read.read()
292 300 err = err.read().strip()
293 301 if err:
294 302 raise util.Abort(err)
295 303 return retdata
296 304
297 305 def _wcrev(self):
298 306 output = self._svncommand(['info', '--xml'])
299 307 doc = xml.dom.minidom.parseString(output)
300 308 entries = doc.getElementsByTagName('entry')
301 309 if not entries:
302 310 return 0
303 311 return int(entries[0].getAttribute('revision') or 0)
304 312
305 313 def _wcchanged(self):
306 314 """Return (changes, extchanges) where changes is True
307 315 if the working directory was changed, and extchanges is
308 316 True if any of these changes concern an external entry.
309 317 """
310 318 output = self._svncommand(['status', '--xml'])
311 319 externals, changes = [], []
312 320 doc = xml.dom.minidom.parseString(output)
313 321 for e in doc.getElementsByTagName('entry'):
314 322 s = e.getElementsByTagName('wc-status')
315 323 if not s:
316 324 continue
317 325 item = s[0].getAttribute('item')
318 326 props = s[0].getAttribute('props')
319 327 path = e.getAttribute('path')
320 328 if item == 'external':
321 329 externals.append(path)
322 330 if (item not in ('', 'normal', 'unversioned', 'external')
323 331 or props not in ('', 'none')):
324 332 changes.append(path)
325 333 for path in changes:
326 334 for ext in externals:
327 335 if path == ext or path.startswith(ext + os.sep):
328 336 return True, True
329 337 return bool(changes), False
330 338
331 339 def dirty(self):
332 340 if self._wcrev() == self._state[1] and not self._wcchanged()[0]:
333 341 return False
334 342 return True
335 343
336 344 def commit(self, text, user, date):
337 345 # user and date are out of our hands since svn is centralized
338 346 changed, extchanged = self._wcchanged()
339 347 if not changed:
340 348 return self._wcrev()
341 349 if extchanged:
342 350 # Do not try to commit externals
343 351 raise util.Abort(_('cannot commit svn externals'))
344 352 commitinfo = self._svncommand(['commit', '-m', text])
345 353 self._ui.status(commitinfo)
346 354 newrev = re.search('Committed revision ([\d]+).', commitinfo)
347 355 if not newrev:
348 356 raise util.Abort(commitinfo.splitlines()[-1])
349 357 newrev = newrev.groups()[0]
350 358 self._ui.status(self._svncommand(['update', '-r', newrev]))
351 359 return newrev
352 360
353 361 def remove(self):
354 362 if self.dirty():
355 363 self._ui.warn(_('not removing repo %s because '
356 364 'it has changes.\n' % self._path))
357 365 return
358 366 self._ui.note(_('removing subrepo %s\n') % self._path)
359 367 shutil.rmtree(self._ctx.repo.join(self._path))
360 368
361 369 def get(self, state):
362 370 status = self._svncommand(['checkout', state[0], '--revision', state[1]])
363 371 if not re.search('Checked out revision [\d]+.', status):
364 372 raise util.Abort(status.splitlines()[-1])
365 373 self._ui.status(status)
366 374
367 375 def merge(self, state):
368 376 old = int(self._state[1])
369 377 new = int(state[1])
370 378 if new > old:
371 379 self.get(state)
372 380
373 381 def push(self, force):
374 382 # nothing for svn
375 383 pass
376 384
377 385 types = {
378 386 'hg': hgsubrepo,
379 387 'svn': svnsubrepo,
380 388 }
@@ -1,64 +1,64 b''
1 1 % Preparing the subrepository sub2
2 2 adding sub2/sub2
3 3 % Preparing the sub1 repo which depends on the subrepo sub2
4 4 updating to branch default
5 5 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
6 6 adding sub1/.hgsub
7 7 adding sub1/sub1
8 8 committing subrepository sub2
9 9 % Preparing the main repo which depends on the subrepo sub1
10 10 updating to branch default
11 11 pulling ...sub2
12 12 requesting all changes
13 13 adding changesets
14 14 adding manifests
15 15 adding file changes
16 16 added 1 changesets with 1 changes to 1 files
17 17 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
18 18 adding main/.hgsub
19 19 adding main/main
20 20 committing subrepository sub1
21 21 % Cleaning both repositories, just as a clone -U
22 22 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
23 23 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
24 24 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
25 25 % Clone main
26 26 updating to branch default
27 27 pulling ...sub1
28 28 requesting all changes
29 29 adding changesets
30 30 adding manifests
31 31 adding file changes
32 32 added 1 changesets with 3 changes to 3 files
33 33 pulling ...sub2
34 34 requesting all changes
35 35 adding changesets
36 36 adding manifests
37 37 adding file changes
38 38 added 1 changesets with 1 changes to 1 files
39 39 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 40 % Checking cloned repo ids
41 41 cloned 7f491f53a367 tip
42 42 cloned/sub1 fc3b4ce2696f tip
43 43 cloned/sub1/sub2 c57a0840e3ba tip
44 44 % debugsub output for main and sub1
45 45 path sub1
46 46 source ../sub1
47 47 revision fc3b4ce2696f7741438c79207583768f2ce6b0dd
48 48 path sub2
49 49 source ../sub2
50 50 revision c57a0840e3badd667ef3c3ef65471609acb2ba3c
51 51 % Modifying deeply nested sub2
52 52 committing subrepository sub1
53 committing subrepository sub2
53 committing subrepository sub1/sub2
54 54 % Checking modified node ids
55 55 cloned ffe6649062fe tip
56 56 cloned/sub1 2ecb03bf44a9 tip
57 57 cloned/sub1/sub2 53dd3430bcaf tip
58 58 % debugsub output for main and sub1
59 59 path sub1
60 60 source ../sub1
61 61 revision 2ecb03bf44a94e749e8669481dd9069526ce7cb9
62 62 path sub2
63 63 source ../sub2
64 64 revision 53dd3430bcaf5ab4a7c48262bcad6d441f510487
@@ -1,295 +1,295 b''
1 1 % first revision, no sub
2 2 adding a
3 3 % add first sub
4 4 adding a
5 5 parent: 0:f7b1eb17ad24 tip
6 6 0
7 7 branch: default
8 8 commit: 1 added, 1 subrepos
9 9 update: (current)
10 10 committing subrepository s
11 11 % add sub sub
12 12 parent: 1:7cf8cfea66e4 tip
13 13 1
14 14 branch: default
15 15 commit: 1 subrepos
16 16 update: (current)
17 17 committing subrepository s
18 18 committing subrepository ss
19 19 parent: 2:df30734270ae tip
20 20 2
21 21 branch: default
22 22 commit: (clean)
23 23 update: (current)
24 24 % bump sub rev
25 25 committing subrepository s
26 26 % leave sub dirty
27 27 committing subrepository s
28 28 changeset: 3:1c833a7a9e3a
29 29 tag: tip
30 30 user: test
31 31 date: Thu Jan 01 00:00:00 1970 +0000
32 32 summary: 4
33 33
34 34 % check caching
35 35 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
36 36 % restore
37 37 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 38 path s
39 39 source s
40 40 revision 1c833a7a9e3a4445c711aaf0f012379cd0d4034e
41 41 % new branch for merge tests
42 42 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 43 adding t/t
44 44 % 5
45 45 committing subrepository t
46 46 created new head
47 47 % 6
48 48 committing subrepository t
49 49 path s
50 50 source s
51 51 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
52 52 path t
53 53 source t
54 54 revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad
55 55 % 7
56 56 committing subrepository t
57 57 % 8
58 58 % merge tests
59 59 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 60 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 61 (branch merge, don't forget to commit)
62 62 path s
63 63 source s
64 64 revision fc627a69481fcbe5f1135069e8a3881c023e4cf5
65 65 path t
66 66 source t
67 67 revision 60ca1237c19474e7a3978b0dc1ca4e6f36d51382
68 68 created new head
69 69 searching for copies back to rev 2
70 70 resolving manifests
71 71 overwrite None partial False
72 72 ancestor 1f14a2e2d3ec local f0d2028bf86d+ remote 1831e14459c4
73 73 .hgsubstate: versions differ -> m
74 74 update: .hgsubstate 1/1 files (100.00%)
75 75 subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec
76 76 subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad:hg
77 77 getting subrepo t
78 78 resolving manifests
79 79 overwrite True partial False
80 80 ancestor 60ca1237c194+ local 60ca1237c194+ remote 6747d179aa9a
81 81 t: remote is newer -> g
82 82 update: t 1/1 files (100.00%)
83 83 getting t
84 84 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
85 85 (branch merge, don't forget to commit)
86 86 path s
87 87 source s
88 88 revision fc627a69481fcbe5f1135069e8a3881c023e4cf5
89 89 path t
90 90 source t
91 91 revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad
92 92 committing subrepository t
93 93 searching for copies back to rev 2
94 94 resolving manifests
95 95 overwrite None partial False
96 96 ancestor 1831e14459c4 local e45c8b14af55+ remote f94576341bcf
97 97 .hgsubstate: versions differ -> m
98 98 update: .hgsubstate 1/1 files (100.00%)
99 99 subrepo merge e45c8b14af55+ f94576341bcf 1831e14459c4
100 100 subrepo t: both sides changed, merge with t:7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4:hg
101 101 merging subrepo t
102 102 searching for copies back to rev 2
103 103 resolving manifests
104 104 overwrite None partial False
105 105 ancestor 6747d179aa9a local 20a0db6fbf6c+ remote 7af322bc1198
106 106 t: versions differ -> m
107 107 preserving t for resolve of t
108 108 update: t 1/1 files (100.00%)
109 109 picked tool 'internal:merge' for t (binary False symlink False)
110 110 merging t
111 111 my t@20a0db6fbf6c+ other t@7af322bc1198 ancestor t@6747d179aa9a
112 112 warning: conflicts during merge.
113 113 merging t failed!
114 114 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
115 115 use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon
116 116 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
117 117 (branch merge, don't forget to commit)
118 118 % should conflict
119 119 <<<<<<< local
120 120 conflict
121 121 =======
122 122 t3
123 123 >>>>>>> other
124 124 % clone
125 125 updating to branch default
126 126 pulling subrepo s from .../sub/t/s
127 127 requesting all changes
128 128 adding changesets
129 129 adding manifests
130 130 adding file changes
131 131 added 4 changesets with 5 changes to 3 files
132 pulling subrepo ss from .../sub/t/s/ss
132 pulling subrepo s/ss from .../sub/t/s/ss
133 133 requesting all changes
134 134 adding changesets
135 135 adding manifests
136 136 adding file changes
137 137 added 1 changesets with 1 changes to 1 files
138 138 pulling subrepo t from .../sub/t/t
139 139 requesting all changes
140 140 adding changesets
141 141 adding manifests
142 142 adding file changes
143 143 added 4 changesets with 4 changes to 1 files (+1 heads)
144 144 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
145 145 path s
146 146 source s
147 147 revision fc627a69481fcbe5f1135069e8a3881c023e4cf5
148 148 path t
149 149 source t
150 150 revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e
151 151 % push
152 152 committing subrepository t
153 153 pushing ...sub/t
154 154 pushing ...sub/t/s/ss
155 155 searching for changes
156 156 no changes found
157 157 pushing ...sub/t/s
158 158 searching for changes
159 159 no changes found
160 160 pushing ...sub/t/t
161 161 searching for changes
162 162 adding changesets
163 163 adding manifests
164 164 adding file changes
165 165 added 1 changesets with 1 changes to 1 files
166 166 searching for changes
167 167 adding changesets
168 168 adding manifests
169 169 adding file changes
170 170 added 1 changesets with 1 changes to 1 files
171 171 % push -f
172 172 committing subrepository s
173 173 abort: push creates new remote heads on branch 'default'!
174 174 pushing ...sub/t
175 175 pushing ...sub/t/s/ss
176 176 searching for changes
177 177 no changes found
178 178 pushing ...sub/t/s
179 179 searching for changes
180 180 (did you forget to merge? use push -f to force)
181 181 pushing ...sub/t
182 182 pushing ...sub/t/s/ss
183 183 searching for changes
184 184 no changes found
185 185 pushing ...sub/t/s
186 186 searching for changes
187 187 adding changesets
188 188 adding manifests
189 189 adding file changes
190 190 added 1 changesets with 1 changes to 1 files (+1 heads)
191 191 pushing ...sub/t/t
192 192 searching for changes
193 193 no changes found
194 194 searching for changes
195 195 adding changesets
196 196 adding manifests
197 197 adding file changes
198 198 added 1 changesets with 1 changes to 1 files
199 199 % update
200 200 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
201 201 committing subrepository t
202 202 % pull
203 203 pulling ...sub/t
204 204 searching for changes
205 205 adding changesets
206 206 adding manifests
207 207 adding file changes
208 208 added 1 changesets with 1 changes to 1 files
209 209 (run 'hg update' to get a working copy)
210 210 pulling subrepo t from .../sub/t/t
211 211 searching for changes
212 212 adding changesets
213 213 adding manifests
214 214 adding file changes
215 215 added 1 changesets with 1 changes to 1 files
216 216 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
217 217 blah
218 218 % bogus subrepo path aborts
219 219 abort: missing ] in subrepo source
220 220 % issue 1986
221 221 adding a
222 222 marked working directory as branch br
223 223 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
224 224 adding b
225 225 created new head
226 226 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
227 227 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
228 228 (branch merge, don't forget to commit)
229 229 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
230 230 adding c
231 231 created new head
232 232 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
233 233 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
234 234 (branch merge, don't forget to commit)
235 235 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
236 236 adding .hgsub
237 237 committing subrepository s
238 238 marked working directory as branch br
239 239 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
240 240 adding b
241 241 committing subrepository s
242 242 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
243 243 adding c
244 244 created new head
245 245 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
246 246 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
247 247 (branch merge, don't forget to commit)
248 248 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
249 249 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
250 250 adding d
251 251 committing subrepository s
252 252 created new head
253 253 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
254 254 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
255 255 adding e
256 256 committing subrepository s
257 257 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
258 258 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
259 259 (branch merge, don't forget to commit)
260 260 % test subrepo delete from .hgsubstate
261 261 adding testdelete/nested/foo
262 262 adding testdelete/nested2/foo
263 263 adding testdelete/.hgsub
264 264 committing subrepository nested2
265 265 committing subrepository nested
266 266 nested
267 267 % test repository cloning
268 268 adding nested_absolute/foo
269 269 adding nested_relative/foo2
270 270 adding main/.hgsub
271 271 committing subrepository nested_relative
272 272 committing subrepository nested_absolute
273 273 updating to branch default
274 274 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 275 [paths]
276 276 default = $HGTMP/test-subrepo/sub/mercurial/nested_absolute
277 277 [paths]
278 278 default = $HGTMP/test-subrepo/sub/mercurial/nested_relative
279 279 % issue 1977
280 280 adding a
281 281 adding .hgsub
282 282 committing subrepository s
283 283 updating to branch default
284 284 pulling subrepo s from .../sub/repo/s
285 285 requesting all changes
286 286 adding changesets
287 287 adding manifests
288 288 adding file changes
289 289 added 1 changesets with 1 changes to 1 files
290 290 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
291 291 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
292 292 created new head
293 293 committing subrepository s
294 294 abort: push creates new remote heads on branch 'default'!
295 295 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now