comparison mercurial/localrepo.py @ 2019:ced2d3620f95

add merge command. means same thing as "update -m". repo.addchangegroup method now returns number of heads modified and added, so command line can tell whether update or merge needed. this makes tiny change to ssh wire protocol, but change is backwards compatible. pull command now returns 0 if no changes to pull.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 29 Mar 2006 10:27:16 -0800
parents 65cc17ae9649
children 00925397236c
comparison
equal deleted inserted replaced
2015:1a09814a5b1f 2019:ced2d3620f95
962 else: 962 else:
963 fetch = self.findincoming(remote, force=force) 963 fetch = self.findincoming(remote, force=force)
964 964
965 if not fetch: 965 if not fetch:
966 self.ui.status(_("no changes found\n")) 966 self.ui.status(_("no changes found\n"))
967 return 1 967 return 0
968 968
969 if heads is None: 969 if heads is None:
970 cg = remote.changegroup(fetch, 'pull') 970 cg = remote.changegroup(fetch, 'pull')
971 else: 971 else:
972 cg = remote.changegroupsubset(fetch, heads, 'pull') 972 cg = remote.changegroupsubset(fetch, heads, 'pull')
1338 self.hook('outgoing', node=hex(nodes[0]), source=source) 1338 self.hook('outgoing', node=hex(nodes[0]), source=source)
1339 1339
1340 return util.chunkbuffer(gengroup()) 1340 return util.chunkbuffer(gengroup())
1341 1341
1342 def addchangegroup(self, source): 1342 def addchangegroup(self, source):
1343 """add changegroup to repo.
1344 returns number of heads modified or added + 1."""
1343 1345
1344 def csmap(x): 1346 def csmap(x):
1345 self.ui.debug(_("add changeset %s\n") % short(x)) 1347 self.ui.debug(_("add changeset %s\n") % short(x))
1346 return cl.count() 1348 return cl.count()
1347 1349
1348 def revmap(x): 1350 def revmap(x):
1349 return cl.rev(x) 1351 return cl.rev(x)
1350 1352
1351 if not source: 1353 if not source:
1352 return 1354 return 0
1353 1355
1354 self.hook('prechangegroup', throw=True) 1356 self.hook('prechangegroup', throw=True)
1355 1357
1356 changesets = files = revisions = 0 1358 changesets = files = revisions = 0
1357 1359
1421 if changesets > 0: 1423 if changesets > 0:
1422 self.hook("changegroup", node=hex(self.changelog.node(cor+1))) 1424 self.hook("changegroup", node=hex(self.changelog.node(cor+1)))
1423 1425
1424 for i in range(cor + 1, cnr + 1): 1426 for i in range(cor + 1, cnr + 1):
1425 self.hook("incoming", node=hex(self.changelog.node(i))) 1427 self.hook("incoming", node=hex(self.changelog.node(i)))
1428
1429 return newheads - oldheads + 1
1426 1430
1427 def update(self, node, allow=False, force=False, choose=None, 1431 def update(self, node, allow=False, force=False, choose=None,
1428 moddirstate=True, forcemerge=False, wlock=None): 1432 moddirstate=True, forcemerge=False, wlock=None):
1429 pl = self.dirstate.parents() 1433 pl = self.dirstate.parents()
1430 if not force and pl[1] != nullid: 1434 if not force and pl[1] != nullid:
1622 cf = "" 1626 cf = ""
1623 if f in merge: 1627 if f in merge:
1624 cf = _(" (resolve)") 1628 cf = _(" (resolve)")
1625 self.ui.status(" %s%s\n" % (f, cf)) 1629 self.ui.status(" %s%s\n" % (f, cf))
1626 self.ui.warn(_("aborting update spanning branches!\n")) 1630 self.ui.warn(_("aborting update spanning branches!\n"))
1627 self.ui.status(_("(use update -m to merge across branches" 1631 self.ui.status(_("(use 'hg merge' to merge across branches"
1628 " or -C to lose changes)\n")) 1632 " or '-C' to lose changes)\n"))
1629 return 1 1633 return 1
1630 branch_merge = True 1634 branch_merge = True
1631 1635
1632 # get the files we don't need to change 1636 # get the files we don't need to change
1633 files = get.keys() 1637 files = get.keys()