Changeset 3 in tailor


Ignore:
Timestamp:
06/02/04 01:54:08 (9 years ago)
Author:
lele@…
Hash name:
20040601235408-97f81-040659e0708436c8e2843b831586be94d6fd9c66
Message:

Preliminary darcs support (bootstrap only)

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • cvsync/svn.py

    r2 r3  
    139139 
    140140     
     141class SvnCheckout(SystemCommand): 
     142    COMMAND = "svn co --quiet --revision %(revision)s %(repository)s %(wc)s" 
     143 
     144     
    141145def getHeadRevision(source, baserev): 
    142146    """Using ``svn log`` determine the HEAD revision of a source.""" 
     
    174178            return mayberel 
    175179 
     180    def checkout(self, uri): 
     181        if '@' in uri: 
     182            src,rev = uri.split('@') 
     183        else: 
     184            src = uri 
     185            rev = "HEAD" 
     186 
     187        svnco = SvnCheckout() 
     188        svnco(repository=src, wc=self.root, revision=rev) 
     189        return self.info(self.root) 
     190     
    176191    def log(self): 
    177192        """Return an object representation of the ``svn log`` thru HEAD.""" 
     
    200215                if name == 'logentry': 
    201216                    self.current = SvnRevisionLogEntry() 
    202                     self.current.revision = int(attributes['revision']) 
     217                    self.current.revision = attributes['revision'] 
    203218                elif name in ['author', 'date', 'msg']: 
    204219                    self.current_field = [] 
     
    268283        return res 
    269284 
    270     def copy(self, uri, dest, dry_run=False): 
    271         """Copy a source URI to dest.""" 
     285    def copy(self, uri, dest=None, dry_run=False): 
     286        """Copy an external source URI into the working copy.""" 
    272287 
    273288        from os.path import dirname, commonprefix 
     
    279294            rev = "HEAD" 
    280295 
     296        if not dest: 
     297            dest = self.root 
     298             
    281299        info = self.info(dirname(dest)) 
    282300        prefix = commonprefix([info['URL'], src]) 
  • cvsync/tailor.py

    r1 r3  
    2929from optparse import OptionParser, OptionError, OptionGroup, make_option 
    3030from cvsync.svn import SvnWorkingDir, getHeadRevision 
     31from cvsync.darcs import DarcsWorkingDir 
    3132 
    3233URI_PROPNAME = "bice:upstream-uri" 
     
    9798            do_commit = True 
    9899        else: 
     100            ## TODO: handle the --darcs option, executing a svn log 
     101            ##       and replaying the changeset into darcs 
     102             
    99103            if options.svn_update and not options.dry_run: 
    100104                self.wc.update() 
     
    109113            if do_commit: 
    110114                if options.commit: 
    111                     try: 
    112                         print 
    113                         raw_input(PRE_COMMIT_PROMPT) 
    114  
    115                         message = options.message or options.auto_message 
    116                         status = self.wc.commit(message=message) 
    117                     except KeyboardInterrupt: 
    118                         print "INTERRUPTED BY THE USER!" 
     115                    if options.darcs: 
     116                        self.registerUnderDarcs(patchname, options.message) 
     117                    else: 
     118                        try: 
     119                            print 
     120                            raw_input(PRE_COMMIT_PROMPT) 
     121 
     122                            message = options.message or options.auto_message 
     123                            status = self.wc.commit(message=message) 
     124                        except KeyboardInterrupt: 
     125                            print "INTERRUPTED BY THE USER!" 
    119126            else: 
    120127                print "No changes. Good!" 
     
    176183        Copy the upstream product and update the properties with 
    177184        the upstream information. 
    178         """ 
    179  
    180         if not options.dry_run: 
    181             info = self.wc.copy(self.uri, self.project) 
    182             if not options.dry_run: 
    183                 uri = info['Copied From URL'] 
    184                 rev = info['Copied From Rev'] 
    185                 self.updateUpstreamInfo(uri=uri, rev=rev) 
    186  
    187                 if not options.message: 
    188                     options.auto_message = "Tailorization of %s, " \ 
    189                                            "from revision %s" % (uri, rev) 
    190  
     185 
     186        If `options.darcs` is true, do a checkout instead of a copy, 
     187        and record the whole subtree under darcs. 
     188        """ 
     189 
     190        if options.dry_run: 
     191            return 
     192         
     193        if options.darcs: 
     194            info = self.wc.checkout(self.uri) 
     195            uri = info['URL'] 
     196            rev = info['Revision'] 
     197        else: 
     198            info = self.wc.copy(self.uri) 
     199            uri = info['Copied From URL'] 
     200            rev = info['Copied From Rev'] 
     201            self.updateUpstreamInfo(uri=uri, rev=rev) 
     202 
     203        if not options.message: 
     204            options.auto_message = "Tailorization of %s, " \ 
     205                                   "from revision %s" % (uri, rev) 
     206 
     207    def registerUnderDarcs(self, patchname, logmessage): 
     208        """ 
     209        Register the checked out tree under darcs. 
     210        """ 
     211 
     212        dwc = DarcsWorkingDir(self.project) 
     213        dwc.initialize() 
     214        dwc.record(patchname, logmessage) 
     215         
    191216    def diff(self): 
    192217        """ 
     
    229254                     "could happen.  The collected changelog, if any, " 
    230255                     "will be echoed on stdout too."), 
    231     make_option("-b", "--bootstrap", action="store_true", default=False, 
    232                 help="Bootstrap mode, that is the initial copy of the " 
    233                      "upstream tree, given as an URI possibly followed " 
    234                      "by a revision."), 
     256    make_option("--darcs", action="store_true", default=False, 
     257                help="Use a darcs repository for the tailorization."), 
    235258    make_option("-m", "--message", 
    236259                default="", # autogenerated 
     
    247270 
    248271ACTIONS = [ 
     272    make_option("-b", "--bootstrap", action="store_true", default=False, 
     273                help="Bootstrap mode, that is the initial copy of the " 
     274                     "upstream tree, given as an URI possibly followed " 
     275                     "by a revision."), 
    249276    make_option("--info", 
    250277                action="store_true", 
  • cvsync/tests/cvs.py

    r1 r3  
    4343        if not reposdir: 
    4444            from tempfile import mkdtemp 
    45             reposdir = mkdtemp(prefix="rep") 
     45            self.tmpdir = reposdir = mkdtemp(prefix="rep") 
     46        else: 
     47            self.tmpdir = None 
    4648             
    4749        self.reposdir = reposdir 
     
    4951        self.populateInitial() 
    5052 
    51     def cleanup(self): 
     53    def __del__(self): 
    5254        """Remove the repository from the filesystem. 
    5355        """ 
     
    108110        self.added_dirs = [] 
    109111        self.removed_dirs = []         
    110  
     112  
    111113        if not tmpdir: 
    112114            from tempfile import mkdtemp 
    113             tmpdir = mkdtemp(prefix="wc") 
     115            self.tmpdir = tmpdir = mkdtemp(prefix="wc") 
     116        else: 
     117            self.tmpdir = None 
    114118             
    115119        cocmd = CvsCheckout(working_dir=tmpdir) 
     
    118122         
    119123        self.wcdir = join(tmpdir, 'test') 
     124 
     125    def __del__(self): 
     126        """Cleanup the test working copy.""" 
     127 
     128        from shutil import rmtree 
     129 
     130        if self.tmpdir: 
     131            rmtree(self.tmpdir) 
    120132 
    121133    def commit(self, msg): 
  • tailor.py

    r1 r3  
    2020  $ tailor.py --bootstrap ~/svnwc/MyProduct http://svn.example.com/Product@10 
    2121 
     22  # Alternatively, use darcs for the tailorization 
     23  $ tailor.py --darcs --bootstrap ~/svnwc/MyProduct file:///repos/Product@10 
     24 
    2225  # Merge upstream changes since last update/bootstrap 
    23   $ tailor.py ~/svnwc/MyProducts 
     26  $ tailor.py ~/svnwc/MyProduct 
    2427 
    2528  # Show what's changed in current working directory 
  • cvsync/tests/svn.py

    r2 r3  
    2222 
    2323 
    24 class SvnCheckout(SystemCommand): 
    25     COMMAND = "svn co --quiet --revision 0 %(repository)s %(wc)s" 
    26  
    27      
    2824class TestRepository(object): 
    2925    """A simple wrapper to a svn repository.""" 
     
    4844             repository=self.repospath) 
    4945 
    50          
    51 class SvnLogTest(TestCase): 
    52     """Test `svn log` parse functionality.""" 
    5346 
     47class SvnBasicTest(TestCase): 
     48    """Test basic svn related functionalities.""" 
     49     
    5450    def __init__(self, methodName): 
    5551        TestCase.__init__(self, methodName) 
     
    5854        self.repos = TestRepository(repos) 
    5955        wc = '/tmp/cvsync.wc' 
    60         svnco = SvnCheckout() 
    61         svnco(repository=self.repos.reposurl, wc=wc) 
    6256        self.wc = SvnWorkingDir(wc) 
    6357 
     58    def testCheckout(self): 
     59        """Verify that svn checkout returns right info""" 
     60 
     61        info = self.wc.checkout(self.repos.reposurl+'@0') 
     62        self.assertEqual(info['URL'], self.repos.reposurl) 
     63        self.assertEqual(info['Revision'], '0') 
     64     
     65class SvnLogTest(TestCase): 
     66    """Test `svn log` parse functionality.""" 
     67 
     68    def __init__(self, methodName): 
     69        from os.path import exists 
     70         
     71        TestCase.__init__(self, methodName) 
     72 
     73        repos = '/tmp/cvsync.test' 
     74        self.repos = TestRepository(repos) 
     75        wc = '/tmp/cvsync.wc' 
     76        self.wc = SvnWorkingDir(wc) 
     77        if not exists(wc): 
     78            self.wc.checkout(self.repos.reposurl + '@0') 
     79         
    6480    def testLogParser(self): 
    6581        """Verify the `svn log` parser""" 
     
    6884        self.assertEqual(len(revisions), 3) 
    6985         
    70         self.assertEqual(revisions[0].revision, 1) 
     86        self.assertEqual(revisions[0].revision, '1') 
    7187        self.assertEqual(revisions[0].author, 'lele') 
    7288        self.assertEqual(revisions[0].date, '2004-05-31T14:38:46.210103Z') 
     
    7995            (u'/FileB.txt', u'A')]) 
    8096         
    81         self.assertEqual(revisions[1].revision, 2) 
     97        self.assertEqual(revisions[1].revision, '2') 
    8298        self.assertEqual(revisions[1].author, 'lele') 
    8399        self.assertEqual(revisions[1].date, '2004-05-31T14:40:58.583701Z') 
     
    87103            (u'/FileA.txt', u'M')]) 
    88104         
    89         self.assertEqual(revisions[2].revision, 3) 
     105        self.assertEqual(revisions[2].revision, '3') 
    90106        self.assertEqual(revisions[2].author, 'lele') 
    91107        self.assertEqual(revisions[2].date, '2004-06-01T13:52:35.711425Z') 
Note: See TracChangeset for help on using the changeset viewer.