mercurial/localrepo.py
changeset 1781 284fc722c342
parent 1713 03ee100b8c21
child 1782 b9671b41e360
equal deleted inserted replaced
1715:40346aa66b0f 1781:284fc722c342
   950             cg = remote.changegroup(fetch)
   950             cg = remote.changegroup(fetch)
   951         else:
   951         else:
   952             cg = remote.changegroupsubset(fetch, heads)
   952             cg = remote.changegroupsubset(fetch, heads)
   953         return self.addchangegroup(cg)
   953         return self.addchangegroup(cg)
   954 
   954 
   955     def push(self, remote, force=False):
   955     def push(self, remote, force=False, revs=None):
   956         lock = remote.lock()
   956         lock = remote.lock()
   957 
   957 
   958         base = {}
   958         base = {}
   959         heads = remote.heads()
   959         heads = remote.heads()
   960         inc = self.findincoming(remote, base, heads)
   960         inc = self.findincoming(remote, base, heads)
   962             self.ui.warn(_("abort: unsynced remote changes!\n"))
   962             self.ui.warn(_("abort: unsynced remote changes!\n"))
   963             self.ui.status(_("(did you forget to sync? use push -f to force)\n"))
   963             self.ui.status(_("(did you forget to sync? use push -f to force)\n"))
   964             return 1
   964             return 1
   965 
   965 
   966         update = self.findoutgoing(remote, base)
   966         update = self.findoutgoing(remote, base)
   967         if not update:
   967         if revs is not None:
       
   968             msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
       
   969         else:
       
   970             bases, heads = update, self.changelog.heads()
       
   971 
       
   972         if not bases:
   968             self.ui.status(_("no changes found\n"))
   973             self.ui.status(_("no changes found\n"))
   969             return 1
   974             return 1
   970         elif not force:
   975         elif not force:
   971             if len(heads) < len(self.changelog.heads()):
   976             if len(bases) < len(heads):
   972                 self.ui.warn(_("abort: push creates new remote branches!\n"))
   977                 self.ui.warn(_("abort: push creates new remote branches!\n"))
   973                 self.ui.status(_("(did you forget to merge?"
   978                 self.ui.status(_("(did you forget to merge?"
   974                                  " use push -f to force)\n"))
   979                                  " use push -f to force)\n"))
   975                 return 1
   980                 return 1
   976 
   981 
   977         cg = self.changegroup(update)
   982         if revs is None:
       
   983             cg = self.changegroup(update)
       
   984         else:
       
   985             cg = self.changegroupsubset(update, revs)
   978         return remote.addchangegroup(cg)
   986         return remote.addchangegroup(cg)
   979 
   987 
   980     def changegroupsubset(self, bases, heads):
   988     def changegroupsubset(self, bases, heads):
   981         """This function generates a changegroup consisting of all the nodes
   989         """This function generates a changegroup consisting of all the nodes
   982         that are descendents of any of the bases, and ancestors of any of
   990         that are descendents of any of the bases, and ancestors of any of