mercurial/localrepo.py
changeset 1736 50de0887bbcd
parent 1732 d3e6da334b85
child 1737 2c9872a4f3fd
equal deleted inserted replaced
1735:791405fe9991 1736:50de0887bbcd
   955         if not fetch:
   955         if not fetch:
   956             self.ui.status(_("no changes found\n"))
   956             self.ui.status(_("no changes found\n"))
   957             return 1
   957             return 1
   958 
   958 
   959         if heads is None:
   959         if heads is None:
   960             cg = remote.changegroup(fetch)
   960             cg = remote.changegroup(fetch, 'pull')
   961         else:
   961         else:
   962             cg = remote.changegroupsubset(fetch, heads)
   962             cg = remote.changegroupsubset(fetch, heads, 'pull')
   963         return self.addchangegroup(cg)
   963         return self.addchangegroup(cg)
   964 
   964 
   965     def push(self, remote, force=False):
   965     def push(self, remote, force=False):
   966         lock = remote.lock()
   966         lock = remote.lock()
   967 
   967 
   982                 self.ui.warn(_("abort: push creates new remote branches!\n"))
   982                 self.ui.warn(_("abort: push creates new remote branches!\n"))
   983                 self.ui.status(_("(did you forget to merge?"
   983                 self.ui.status(_("(did you forget to merge?"
   984                                  " use push -f to force)\n"))
   984                                  " use push -f to force)\n"))
   985                 return 1
   985                 return 1
   986 
   986 
   987         cg = self.changegroup(update)
   987         cg = self.changegroup(update, 'push')
   988         return remote.addchangegroup(cg)
   988         return remote.addchangegroup(cg)
   989 
   989 
   990     def changegroupsubset(self, bases, heads):
   990     def changegroupsubset(self, bases, heads, source):
   991         """This function generates a changegroup consisting of all the nodes
   991         """This function generates a changegroup consisting of all the nodes
   992         that are descendents of any of the bases, and ancestors of any of
   992         that are descendents of any of the bases, and ancestors of any of
   993         the heads.
   993         the heads.
   994 
   994 
   995         It is fairly complex as determining which filenodes and which
   995         It is fairly complex as determining which filenodes and which
   996         manifest nodes need to be included for the changeset to be complete
   996         manifest nodes need to be included for the changeset to be complete
   997         is non-trivial.
   997         is non-trivial.
   998 
   998 
   999         Another wrinkle is doing the reverse, figuring out which changeset in
   999         Another wrinkle is doing the reverse, figuring out which changeset in
  1000         the changegroup a particular filenode or manifestnode belongs to."""
  1000         the changegroup a particular filenode or manifestnode belongs to."""
       
  1001 
       
  1002         self.hook('preoutgoing', throw=True, source=source)
  1001 
  1003 
  1002         # Set up some initial variables
  1004         # Set up some initial variables
  1003         # Make it easy to refer to self.changelog
  1005         # Make it easy to refer to self.changelog
  1004         cl = self.changelog
  1006         cl = self.changelog
  1005         # msng is short for missing - compute the list of changesets in this
  1007         # msng is short for missing - compute the list of changesets in this
  1249                     # Don't need this anymore, toss it to free memory.
  1251                     # Don't need this anymore, toss it to free memory.
  1250                     del msng_filenode_set[fname]
  1252                     del msng_filenode_set[fname]
  1251             # Signal that no more groups are left.
  1253             # Signal that no more groups are left.
  1252             yield struct.pack(">l", 0)
  1254             yield struct.pack(">l", 0)
  1253 
  1255 
       
  1256             self.hook('outgoing', node=hex(msng_cl_lst[0]), source=source)
       
  1257 
  1254         return util.chunkbuffer(gengroup())
  1258         return util.chunkbuffer(gengroup())
  1255 
  1259 
  1256     def changegroup(self, basenodes):
  1260     def changegroup(self, basenodes, source):
  1257         """Generate a changegroup of all nodes that we have that a recipient
  1261         """Generate a changegroup of all nodes that we have that a recipient
  1258         doesn't.
  1262         doesn't.
  1259 
  1263 
  1260         This is much easier than the previous function as we can assume that
  1264         This is much easier than the previous function as we can assume that
  1261         the recipient has any changenode we aren't sending them."""
  1265         the recipient has any changenode we aren't sending them."""
       
  1266 
       
  1267         self.hook('preoutgoing', throw=True, source=source)
       
  1268 
  1262         cl = self.changelog
  1269         cl = self.changelog
  1263         nodes = cl.nodesbetween(basenodes, None)[0]
  1270         nodes = cl.nodesbetween(basenodes, None)[0]
  1264         revset = dict.fromkeys([cl.rev(n) for n in nodes])
  1271         revset = dict.fromkeys([cl.rev(n) for n in nodes])
  1265 
  1272 
  1266         def identity(x):
  1273         def identity(x):
  1308                     lookup = lookuprevlink_func(filerevlog)
  1315                     lookup = lookuprevlink_func(filerevlog)
  1309                     for chnk in filerevlog.group(nodeiter, lookup):
  1316                     for chnk in filerevlog.group(nodeiter, lookup):
  1310                         yield chnk
  1317                         yield chnk
  1311 
  1318 
  1312             yield struct.pack(">l", 0)
  1319             yield struct.pack(">l", 0)
       
  1320             self.hook('outgoing', node=hex(nodes[0]), source=source)
  1313 
  1321 
  1314         return util.chunkbuffer(gengroup())
  1322         return util.chunkbuffer(gengroup())
  1315 
  1323 
  1316     def addchangegroup(self, source):
  1324     def addchangegroup(self, source):
  1317 
  1325