mercurial/localrepo.py
changeset 9467 4c041f1ee1b4
parent 9437 1c4e4004f3a6
child 9476 a0e69510018b
equal deleted inserted replaced
9466:1214c64c592b 9467:4c041f1ee1b4
   525                 l.append((mf, fn, params))
   525                 l.append((mf, fn, params))
   526             self.filterpats[filter] = l
   526             self.filterpats[filter] = l
   527 
   527 
   528         for mf, fn, cmd in self.filterpats[filter]:
   528         for mf, fn, cmd in self.filterpats[filter]:
   529             if mf(filename):
   529             if mf(filename):
   530                 self.ui.debug(_("filtering %s through %s\n") % (filename, cmd))
   530                 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
   531                 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
   531                 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
   532                 break
   532                 break
   533 
   533 
   534         return data
   534         return data
   535 
   535 
   722                         crev = manifest2[cfname]
   722                         crev = manifest2[cfname]
   723                         newfparent = fparent1
   723                         newfparent = fparent1
   724 
   724 
   725             # find source in nearest ancestor if we've lost track
   725             # find source in nearest ancestor if we've lost track
   726             if not crev:
   726             if not crev:
   727                 self.ui.debug(_(" %s: searching for copy revision for %s\n") %
   727                 self.ui.debug(" %s: searching for copy revision for %s\n" %
   728                               (fname, cfname))
   728                               (fname, cfname))
   729                 for ancestor in self['.'].ancestors():
   729                 for ancestor in self['.'].ancestors():
   730                     if cfname in ancestor:
   730                     if cfname in ancestor:
   731                         crev = ancestor[cfname].filenode()
   731                         crev = ancestor[cfname].filenode()
   732                         break
   732                         break
   733 
   733 
   734             self.ui.debug(_(" %s: copy %s:%s\n") % (fname, cfname, hex(crev)))
   734             self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
   735             meta["copy"] = cfname
   735             meta["copy"] = cfname
   736             meta["copyrev"] = hex(crev)
   736             meta["copyrev"] = hex(crev)
   737             fparent1, fparent2 = nullid, newfparent
   737             fparent1, fparent2 = nullid, newfparent
   738         elif fparent2 != nullid:
   738         elif fparent2 != nullid:
   739             # is one parent an ancestor of the other?
   739             # is one parent an ancestor of the other?
  1285             while unknown:
  1285             while unknown:
  1286                 n = unknown.pop(0)
  1286                 n = unknown.pop(0)
  1287                 if n[0] in seen:
  1287                 if n[0] in seen:
  1288                     continue
  1288                     continue
  1289 
  1289 
  1290                 self.ui.debug(_("examining %s:%s\n")
  1290                 self.ui.debug("examining %s:%s\n"
  1291                               % (short(n[0]), short(n[1])))
  1291                               % (short(n[0]), short(n[1])))
  1292                 if n[0] == nullid: # found the end of the branch
  1292                 if n[0] == nullid: # found the end of the branch
  1293                     pass
  1293                     pass
  1294                 elif n in seenbranch:
  1294                 elif n in seenbranch:
  1295                     self.ui.debug(_("branch already found\n"))
  1295                     self.ui.debug("branch already found\n")
  1296                     continue
  1296                     continue
  1297                 elif n[1] and n[1] in m: # do we know the base?
  1297                 elif n[1] and n[1] in m: # do we know the base?
  1298                     self.ui.debug(_("found incomplete branch %s:%s\n")
  1298                     self.ui.debug("found incomplete branch %s:%s\n"
  1299                                   % (short(n[0]), short(n[1])))
  1299                                   % (short(n[0]), short(n[1])))
  1300                     search.append(n[0:2]) # schedule branch range for scanning
  1300                     search.append(n[0:2]) # schedule branch range for scanning
  1301                     seenbranch.add(n)
  1301                     seenbranch.add(n)
  1302                 else:
  1302                 else:
  1303                     if n[1] not in seen and n[1] not in fetch:
  1303                     if n[1] not in seen and n[1] not in fetch:
  1304                         if n[2] in m and n[3] in m:
  1304                         if n[2] in m and n[3] in m:
  1305                             self.ui.debug(_("found new changeset %s\n") %
  1305                             self.ui.debug("found new changeset %s\n" %
  1306                                           short(n[1]))
  1306                                           short(n[1]))
  1307                             fetch.add(n[1]) # earliest unknown
  1307                             fetch.add(n[1]) # earliest unknown
  1308                         for p in n[2:4]:
  1308                         for p in n[2:4]:
  1309                             if p in m:
  1309                             if p in m:
  1310                                 base[p] = 1 # latest known
  1310                                 base[p] = 1 # latest known
  1315                             req.add(p)
  1315                             req.add(p)
  1316                 seen.add(n[0])
  1316                 seen.add(n[0])
  1317 
  1317 
  1318             if r:
  1318             if r:
  1319                 reqcnt += 1
  1319                 reqcnt += 1
  1320                 self.ui.debug(_("request %d: %s\n") %
  1320                 self.ui.debug("request %d: %s\n" %
  1321                             (reqcnt, " ".join(map(short, r))))
  1321                             (reqcnt, " ".join(map(short, r))))
  1322                 for p in xrange(0, len(r), 10):
  1322                 for p in xrange(0, len(r), 10):
  1323                     for b in remote.branches(r[p:p+10]):
  1323                     for b in remote.branches(r[p:p+10]):
  1324                         self.ui.debug(_("received %s:%s\n") %
  1324                         self.ui.debug("received %s:%s\n" %
  1325                                       (short(b[0]), short(b[1])))
  1325                                       (short(b[0]), short(b[1])))
  1326                         unknown.append(b)
  1326                         unknown.append(b)
  1327 
  1327 
  1328         # do binary search on the branches we found
  1328         # do binary search on the branches we found
  1329         while search:
  1329         while search:
  1332             for n, l in zip(search, remote.between(search)):
  1332             for n, l in zip(search, remote.between(search)):
  1333                 l.append(n[1])
  1333                 l.append(n[1])
  1334                 p = n[0]
  1334                 p = n[0]
  1335                 f = 1
  1335                 f = 1
  1336                 for i in l:
  1336                 for i in l:
  1337                     self.ui.debug(_("narrowing %d:%d %s\n") % (f, len(l), short(i)))
  1337                     self.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i)))
  1338                     if i in m:
  1338                     if i in m:
  1339                         if f <= 2:
  1339                         if f <= 2:
  1340                             self.ui.debug(_("found new branch changeset %s\n") %
  1340                             self.ui.debug("found new branch changeset %s\n" %
  1341                                               short(p))
  1341                                               short(p))
  1342                             fetch.add(p)
  1342                             fetch.add(p)
  1343                             base[i] = 1
  1343                             base[i] = 1
  1344                         else:
  1344                         else:
  1345                             self.ui.debug(_("narrowed branch search to %s:%s\n")
  1345                             self.ui.debug("narrowed branch search to %s:%s\n"
  1346                                           % (short(p), short(i)))
  1346                                           % (short(p), short(i)))
  1347                             newsearch.append((p, i))
  1347                             newsearch.append((p, i))
  1348                         break
  1348                         break
  1349                     p, f = i, f * 2
  1349                     p, f = i, f * 2
  1350                 search = newsearch
  1350                 search = newsearch
  1359             if force:
  1359             if force:
  1360                 self.ui.warn(_("warning: repository is unrelated\n"))
  1360                 self.ui.warn(_("warning: repository is unrelated\n"))
  1361             else:
  1361             else:
  1362                 raise util.Abort(_("repository is unrelated"))
  1362                 raise util.Abort(_("repository is unrelated"))
  1363 
  1363 
  1364         self.ui.debug(_("found new changesets starting at ") +
  1364         self.ui.debug("found new changesets starting at " +
  1365                      " ".join([short(f) for f in fetch]) + "\n")
  1365                      " ".join([short(f) for f in fetch]) + "\n")
  1366 
  1366 
  1367         self.ui.debug(_("%d total queries\n") % reqcnt)
  1367         self.ui.debug("%d total queries\n" % reqcnt)
  1368 
  1368 
  1369         return base.keys(), list(fetch), heads
  1369         return base.keys(), list(fetch), heads
  1370 
  1370 
  1371     def findoutgoing(self, remote, base=None, heads=None, force=False):
  1371     def findoutgoing(self, remote, base=None, heads=None, force=False):
  1372         """Return list of nodes that are roots of subsets not in remote
  1372         """Return list of nodes that are roots of subsets not in remote
  1379         """
  1379         """
  1380         if base is None:
  1380         if base is None:
  1381             base = {}
  1381             base = {}
  1382             self.findincoming(remote, base, heads, force=force)
  1382             self.findincoming(remote, base, heads, force=force)
  1383 
  1383 
  1384         self.ui.debug(_("common changesets up to ")
  1384         self.ui.debug("common changesets up to "
  1385                       + " ".join(map(short, base.keys())) + "\n")
  1385                       + " ".join(map(short, base.keys())) + "\n")
  1386 
  1386 
  1387         remain = set(self.changelog.nodemap)
  1387         remain = set(self.changelog.nodemap)
  1388 
  1388 
  1389         # prune everything remote has from the tree
  1389         # prune everything remote has from the tree
  1600 
  1600 
  1601     def changegroupinfo(self, nodes, source):
  1601     def changegroupinfo(self, nodes, source):
  1602         if self.ui.verbose or source == 'bundle':
  1602         if self.ui.verbose or source == 'bundle':
  1603             self.ui.status(_("%d changesets found\n") % len(nodes))
  1603             self.ui.status(_("%d changesets found\n") % len(nodes))
  1604         if self.ui.debugflag:
  1604         if self.ui.debugflag:
  1605             self.ui.debug(_("list of changesets:\n"))
  1605             self.ui.debug("list of changesets:\n")
  1606             for node in nodes:
  1606             for node in nodes:
  1607                 self.ui.debug("%s\n" % hex(node))
  1607                 self.ui.debug("%s\n" % hex(node))
  1608 
  1608 
  1609     def changegroupsubset(self, bases, heads, source, extranodes=None):
  1609     def changegroupsubset(self, bases, heads, source, extranodes=None):
  1610         """Compute a changegroup consisting of all the nodes that are
  1610         """Compute a changegroup consisting of all the nodes that are
  1986         - more heads than before: 1+added heads (2..n)
  1986         - more heads than before: 1+added heads (2..n)
  1987         - less heads than before: -1-removed heads (-2..-n)
  1987         - less heads than before: -1-removed heads (-2..-n)
  1988         - number of heads stays the same: 1
  1988         - number of heads stays the same: 1
  1989         """
  1989         """
  1990         def csmap(x):
  1990         def csmap(x):
  1991             self.ui.debug(_("add changeset %s\n") % short(x))
  1991             self.ui.debug("add changeset %s\n" % short(x))
  1992             return len(cl)
  1992             return len(cl)
  1993 
  1993 
  1994         def revmap(x):
  1994         def revmap(x):
  1995             return cl.rev(x)
  1995             return cl.rev(x)
  1996 
  1996 
  2032             self.ui.status(_("adding file changes\n"))
  2032             self.ui.status(_("adding file changes\n"))
  2033             while 1:
  2033             while 1:
  2034                 f = changegroup.getchunk(source)
  2034                 f = changegroup.getchunk(source)
  2035                 if not f:
  2035                 if not f:
  2036                     break
  2036                     break
  2037                 self.ui.debug(_("adding %s revisions\n") % f)
  2037                 self.ui.debug("adding %s revisions\n" % f)
  2038                 fl = self.file(f)
  2038                 fl = self.file(f)
  2039                 o = len(fl)
  2039                 o = len(fl)
  2040                 chunkiter = changegroup.chunkiter(source)
  2040                 chunkiter = changegroup.chunkiter(source)
  2041                 if fl.addgroup(chunkiter, revmap, trp) is None:
  2041                 if fl.addgroup(chunkiter, revmap, trp) is None:
  2042                     raise util.Abort(_("received file revlog group is empty"))
  2042                     raise util.Abort(_("received file revlog group is empty"))
  2065         finally:
  2065         finally:
  2066             del tr
  2066             del tr
  2067 
  2067 
  2068         if changesets > 0:
  2068         if changesets > 0:
  2069             # forcefully update the on-disk branch cache
  2069             # forcefully update the on-disk branch cache
  2070             self.ui.debug(_("updating the branch cache\n"))
  2070             self.ui.debug("updating the branch cache\n")
  2071             self.branchtags()
  2071             self.branchtags()
  2072             self.hook("changegroup", node=hex(cl.node(clstart)),
  2072             self.hook("changegroup", node=hex(cl.node(clstart)),
  2073                       source=srctype, url=url)
  2073                       source=srctype, url=url)
  2074 
  2074 
  2075             for i in xrange(clstart, clend):
  2075             for i in xrange(clstart, clend):
  2114                 name, size = l.split('\0', 1)
  2114                 name, size = l.split('\0', 1)
  2115                 size = int(size)
  2115                 size = int(size)
  2116             except (ValueError, TypeError):
  2116             except (ValueError, TypeError):
  2117                 raise error.ResponseError(
  2117                 raise error.ResponseError(
  2118                     _('Unexpected response from remote server:'), l)
  2118                     _('Unexpected response from remote server:'), l)
  2119             self.ui.debug(_('adding %s (%s)\n') % (name, util.bytecount(size)))
  2119             self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size)))
  2120             # for backwards compat, name was partially encoded
  2120             # for backwards compat, name was partially encoded
  2121             ofp = self.sopener(store.decodedir(name), 'w')
  2121             ofp = self.sopener(store.decodedir(name), 'w')
  2122             for chunk in util.filechunkiter(fp, limit=size):
  2122             for chunk in util.filechunkiter(fp, limit=size):
  2123                 ofp.write(chunk)
  2123                 ofp.write(chunk)
  2124             ofp.close()
  2124             ofp.close()