mercurial/subrepo.py
changeset 18967 88d1b59f6906
parent 18964 ca480d710fe6
child 19012 811e253226c3
equal deleted inserted replaced
18966:5572f688e0a9 18967:88d1b59f6906
   421             archiver.addfile(os.path.join(prefix, self._path, name),
   421             archiver.addfile(os.path.join(prefix, self._path, name),
   422                              mode, symlink, self.filedata(name))
   422                              mode, symlink, self.filedata(name))
   423             ui.progress(_('archiving (%s)') % relpath, i + 1,
   423             ui.progress(_('archiving (%s)') % relpath, i + 1,
   424                         unit=_('files'), total=total)
   424                         unit=_('files'), total=total)
   425         ui.progress(_('archiving (%s)') % relpath, None)
   425         ui.progress(_('archiving (%s)') % relpath, None)
       
   426         return total
   426 
   427 
   427     def walk(self, match):
   428     def walk(self, match):
   428         '''
   429         '''
   429         walk recursively through the directory tree, finding all files
   430         walk recursively through the directory tree, finding all files
   430         matched by the match function
   431         matched by the match function
   578                                % (inst, subrelpath(self)))
   579                                % (inst, subrelpath(self)))
   579 
   580 
   580     @annotatesubrepoerror
   581     @annotatesubrepoerror
   581     def archive(self, ui, archiver, prefix, match=None):
   582     def archive(self, ui, archiver, prefix, match=None):
   582         self._get(self._state + ('hg',))
   583         self._get(self._state + ('hg',))
   583         abstractsubrepo.archive(self, ui, archiver, prefix, match)
   584         total = abstractsubrepo.archive(self, ui, archiver, prefix, match)
   584 
       
   585         rev = self._state[1]
   585         rev = self._state[1]
   586         ctx = self._repo[rev]
   586         ctx = self._repo[rev]
   587         for subpath in ctx.substate:
   587         for subpath in ctx.substate:
   588             s = subrepo(ctx, subpath)
   588             s = subrepo(ctx, subpath)
   589             submatch = matchmod.narrowmatcher(subpath, match)
   589             submatch = matchmod.narrowmatcher(subpath, match)
   590             s.archive(ui, archiver, os.path.join(prefix, self._path), submatch)
   590             total += s.archive(
       
   591                 ui, archiver, os.path.join(prefix, self._path), submatch)
       
   592         return total
   591 
   593 
   592     @annotatesubrepoerror
   594     @annotatesubrepoerror
   593     def dirty(self, ignoreupdate=False):
   595     def dirty(self, ignoreupdate=False):
   594         r = self._state[1]
   596         r = self._state[1]
   595         if r == '' and not ignoreupdate: # no state recorded
   597         if r == '' and not ignoreupdate: # no state recorded
  1381                 shutil.rmtree(path)
  1383                 shutil.rmtree(path)
  1382             else:
  1384             else:
  1383                 os.remove(path)
  1385                 os.remove(path)
  1384 
  1386 
  1385     def archive(self, ui, archiver, prefix, match=None):
  1387     def archive(self, ui, archiver, prefix, match=None):
       
  1388         total = 0
  1386         source, revision = self._state
  1389         source, revision = self._state
  1387         if not revision:
  1390         if not revision:
  1388             return
  1391             return total
  1389         self._fetch(source, revision)
  1392         self._fetch(source, revision)
  1390 
  1393 
  1391         # Parse git's native archive command.
  1394         # Parse git's native archive command.
  1392         # This should be much faster than manually traversing the trees
  1395         # This should be much faster than manually traversing the trees
  1393         # and objects with many subprocess calls.
  1396         # and objects with many subprocess calls.
  1404                 data = info.linkname
  1407                 data = info.linkname
  1405             else:
  1408             else:
  1406                 data = tar.extractfile(info).read()
  1409                 data = tar.extractfile(info).read()
  1407             archiver.addfile(os.path.join(prefix, self._path, info.name),
  1410             archiver.addfile(os.path.join(prefix, self._path, info.name),
  1408                              info.mode, info.issym(), data)
  1411                              info.mode, info.issym(), data)
       
  1412             total += 1
  1409             ui.progress(_('archiving (%s)') % relpath, i + 1,
  1413             ui.progress(_('archiving (%s)') % relpath, i + 1,
  1410                         unit=_('files'))
  1414                         unit=_('files'))
  1411         ui.progress(_('archiving (%s)') % relpath, None)
  1415         ui.progress(_('archiving (%s)') % relpath, None)
       
  1416         return total
  1412 
  1417 
  1413 
  1418 
  1414     @annotatesubrepoerror
  1419     @annotatesubrepoerror
  1415     def status(self, rev2, **opts):
  1420     def status(self, rev2, **opts):
  1416         rev1 = self._state[1]
  1421         rev1 = self._state[1]