Changeset 80 in tailor


Ignore:
Timestamp:
07/12/04 16:46:09 (9 years ago)
Author:
lele@…
Hash name:
20040712144609-97f81-59dee1a41a0bb8d859ad5877a3336bfb28e861a0
Message:

Follow the right CVS branch since the right time in the past
Here I assume that the most recent timestamp found in the CVS/Entries
is appropriate to be used as the range start for cvs log. This is
not proved right, yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/cvs.py

    r79 r80  
    2929 
    3030class CvsLog(SystemCommand): 
    31     COMMAND = "cvs log -N -S %(since)s" 
     31    COMMAND = "cvs log -N -S %(branch)s %(since)s" 
    3232        
    3333    def __call__(self, output=None, dry_run=False, **kwargs): 
    3434        since = kwargs.get('since') 
    3535        if since: 
    36             kwargs['since'] = "-d '%s<'" % str(since) 
     36            kwargs['since'] = "-d'%s<'" % since.isoformat(sep=' ') 
    3737        else: 
    3838            kwargs['since'] = '' 
     39 
     40        branch = kwargs.get('branch') 
     41        if branch: 
     42            kwargs['branch'] = "-r%s" % branch 
     43        else: 
     44            kwargs['branch'] = '' 
    3945             
    4046        return SystemCommand.__call__(self, output=output, 
     
    194200            if newentry: 
    195201                last.action_kind = last.ADDED 
     202         
    196203 
    197204class CvsWorkingDir(CvspsWorkingDir): 
     
    205212         
    206213        from os.path import join, exists 
    207           
    208         if sincerev: 
    209             sincerev = int(sincerev) 
    210  
    211             # XXX: derive the date from the revision 
    212             since = dosomethingsmart(sincerev) 
    213         else: 
    214             since = None 
    215              
     214 
     215        entries = CvsEntries(root) 
     216        latest = entries.getMostRecentEntry() 
     217        since = latest.timestamp 
     218 
     219        branch = '' 
     220        fname = join(root, 'CVS', 'Tag') 
     221        if exists(fname): 
     222            tag = open(fname).read() 
     223            if tag.startswith('T'): 
     224                branch=tag[1:-1] 
     225 
    216226        changesets = [] 
    217         log = cvslog(output=True, since=since) 
     227        log = cvslog(output=True, since=since, branch=branch) 
    218228        for cs in changesets_from_cvslog(log, sincerev): 
    219229            changesets.append(cs) 
     
    225235    """Collect the info about a file in a CVS working dir.""" 
    226236     
    227     __slots__ = ('filename', 'cvs_version', 'cvs_tag') 
     237    __slots__ = ('filename', 'cvs_version', 'timestamp', 'cvs_tag') 
    228238 
    229239    def __init__(self, entry): 
    230240        """Initialize a CvsEntry.""" 
    231          
    232         dummy, fn, rev, date, dummy, tag = entry.split('/') 
     241 
     242        from datetime import datetime 
     243        from time import strptime 
     244         
     245        dummy, fn, rev, ts, dummy, tag = entry.split('/') 
    233246        self.filename = fn 
    234247        self.cvs_version = rev 
     248        y,m,d,hh,mm,ss,d1,d2,d3 = strptime(ts, "%a %b %d %H:%M:%S %Y") 
     249        self.timestamp = datetime(y,m,d,hh,mm,ss) 
    235250        self.cvs_tag = tag 
    236251 
     
    313328            return None 
    314329 
    315  
     330    def getMostRecentEntry(self): 
     331        latest = None 
     332        for e in self.files.values(): 
     333            if not latest: 
     334                latest = e 
     335 
     336            if e.timestamp < latest.timestamp: 
     337                latest = e 
     338 
     339        for d in self.directories.values(): 
     340            e = d.getMostRecentEntry() 
     341             
     342            if not latest: 
     343                latest = e 
     344 
     345            if e.timestamp < latest.timestamp: 
     346                latest = e 
     347 
     348        return latest 
     349     
Note: See TracChangeset for help on using the changeset viewer.