Changeset 1558 in tailor


Ignore:
Timestamp:
05/26/08 02:20:06 (5 years ago)
Author:
lele@…
Hash name:
20080526002006-97f81-2e3195fa9cd2b66dcaa7d4d3f572ef03bd0f04a6
Message:

New option 'split-initial-changeset-level' on darcs target
This let's avoid building a single huge patch at bootstrap, and
instead having a set of smaller changesets, one per directory, with a
tag to collect them as a whole.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vcpx/repository/darcs/__init__.py

    r1544 r1558  
    3232            self.init_options = None 
    3333        self.use_look_for_adds = cget(self.name, 'look-for-adds', 'False') 
     34        self.split_initial_import_level = int( 
     35            cget(self.name, 'split-initial-changeset-level', '0')) 
    3436        self.replace_badchars = eval(cget(self.name, 'replace-badchars', 
    3537                                          "{" 
  • README.rst

    r1556 r1558  
    899899            ``subdir`` different from ``.``. [#]_ 
    900900 
     901split-initial-changeset-level : integer 
     902  Sometime it's desiderable to avoid the impact of the huge patch 
     903  produced by the bootstrap step, that's basically a snapshot of the 
     904  *whole* working directory. This option controls that: if greater 
     905  than zero, the inital import will be splitted in multiple 
     906  changesets, one per directory not deeper than the specified level. A 
     907  value of 1 will build a changeset for the top level contents 
     908  (directories and files), then a changeset for each subtree. Finally, 
     909  a *tag* will comprehend all the changesets. 
     910 
     911  *0* by default. 
    901912 
    902913Big repositories 
     
    917928    done 
    918929 
     930When darcs is the *target*, consider setting a value of 1 or even 2 
     931for the option `split-initial-changeset-level`. 
    919932 
    920933git target 
  • vcpx/repository/darcs/target.py

    r1544 r1558  
    3030    A target working directory under ``darcs``. 
    3131    """ 
     32 
     33    def importFirstRevision(self, source_repo, changeset, initial): 
     34        from os import walk, sep 
     35        from os.path import join 
     36        from vcpx.dualwd import IGNORED_METADIRS 
     37 
     38        if not self.repository.split_initial_import_level: 
     39            super(DarcsTargetWorkingDir, self).importFirstRevision( 
     40                source_repo, changeset, initial) 
     41        else: 
     42            cmd = self.repository.command("add", "--case-ok", "--quiet") 
     43            add = ExternalCommand(cwd=self.repository.basedir, command=cmd) 
     44            cmd = self.repository.command("add", "--case-ok", "--recursive", 
     45                                          "--quiet") 
     46            addrecurs = ExternalCommand(cwd=self.repository.basedir, command=cmd) 
     47            for root, dirs, files in walk(self.repository.basedir): 
     48                subtree = root[len(self.repository.basedir)+1:] 
     49                if subtree: 
     50                    log = "Import of subtree %s" % subtree 
     51                    level = len(subtree.split(sep)) 
     52                else: 
     53                    log = "Import of first level" 
     54                    level = 0 
     55                for excd in IGNORED_METADIRS: 
     56                    if excd in dirs: 
     57                        dirs.remove(excd) 
     58                if level>self.repository.split_initial_import_level: 
     59                    while dirs: 
     60                        d = dirs.pop(0) 
     61                        addrecurs.execute(join(subtree, d)) 
     62                    filenames = [join(subtree, f) for f in files] 
     63                    if filenames: 
     64                        add.execute(*filenames) 
     65                else: 
     66                    dirnames = [join(subtree, d) for d in dirs] 
     67                    if dirnames: 
     68                        add.execute(*dirnames) 
     69                    filenames = [join(subtree, f) for f in files] 
     70                    if filenames: 
     71                        add.execute(*filenames) 
     72                self._commit(changeset.date, "tailor", "Initial import", 
     73                             log, isinitialcommit=initial) 
     74 
     75            cmd = self.repository.command("tag", "--author", "tailor") 
     76            ExternalCommand(cwd=self.repository.basedir, command=cmd).execute( 
     77                "Initial import from %s" % source_repo.repository) 
    3278 
    3379    def _addSubtree(self, subdir): 
Note: See TracChangeset for help on using the changeset viewer.