Changeset 83 in tailor
- Timestamp:
- 07/12/04 19:41:23 (9 years ago)
- Hash name:
- 20040712174123-97f81-088445f4e9e4bde496f3631d2062543f7c62612a
- Location:
- vcpx
- Files:
-
- 2 edited
-
cvs.py (modified) (4 diffs)
-
tests/cvs.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vcpx/cvs.py
r81 r83 72 72 ## =====================================================================... 73 73 74 coll = ChangeSetCollector(log) 75 for cs in coll: 74 from datetime import timedelta 75 76 collected = ChangeSetCollector(log) 77 collapsed = [] 78 79 threshold = timedelta(seconds=180) 80 last = None 81 82 for cs in collected: 83 if not last: 84 last = cs 85 collapsed.append(cs) 86 else: 87 if last.author == cs.author and \ 88 last.log == cs.log and \ 89 abs(last.date - cs.date) < threshold: 90 last.entries.extend(cs.entries) 91 else: 92 last = cs 93 collapsed.append(cs) 94 95 for cs in collapsed: 76 96 yield cs 77 97 … … 96 116 return iter([self.changesets[k] for k in keys]) 97 117 118 def __getGlobalRevision(self, timestamp, author, changelog): 119 """ 120 CVS does not have the notion of a repository-wide revision number, 121 since it tracks just single files. 122 123 Here we could "count" the grouped changesets ala `cvsps`, 124 but that's tricky because of branches. Since right now there 125 is nothing that depends on this being a number, not to mention 126 a *serial* number, simply emit a (hopefully) unique signature... 127 """ 128 129 # NB: the _getUpstreamChangesets() below depends on this format 130 131 if len(changelog)>33: 132 msg = changelog[:30] + '...' 133 else: 134 msg = changelog 135 msg = msg.replace('\n', '') 136 return '%s; %s, "%s"' % (timestamp, author, msg) 137 98 138 def __collect(self, timestamp, author, changelog, entry, revision): 99 139 """Register a change set about an entry.""" … … 105 145 return self.changesets[key].addEntry(entry, revision) 106 146 else: 107 cs = Changeset(revision, timestamp, author, changelog) 147 cs = Changeset(self.__getGlobalRevision(timestamp, 148 author, 149 changelog), 150 timestamp, author, changelog) 108 151 self.changesets[key] = cs 109 152 return cs.addEntry(entry, revision) … … 128 171 129 172 day,time = info[0][6:].split(' ') 130 y,m,d = map(int, day.split( '/'))173 y,m,d = map(int, day.split(day[4])) 131 174 hh,mm,ss = map(int, time.split(':')) 132 175 date = datetime(y,m,d,hh,mm,ss) -
vcpx/tests/cvs.py
r79 r83 114 114 """ 115 115 116 COLLAPSE_TEST = """\ 117 RCS file: /usr/local/CVSROOT/PyObjC/Doc/libObjCStreams.tex,v 118 Working file: Doc/libObjCStreams.tex 119 head: 1.4 120 branch: 121 locks: strict 122 access list: 123 keyword substitution: kv 124 total revisions: 4; selected revisions: 4 125 description: 126 ---------------------------- 127 revision 1.4 128 date: 1997-12-21 23:01:28; author: lele; state: Exp; lines: +2 -8 129 Fake changelog 1 130 ---------------------------- 131 revision 1.3 132 date: 1996-10-18 13:48:36; author: lele; state: Exp; lines: +10 -3 133 Fake changelog 2 134 ---------------------------- 135 revision 1.2 136 date: 1996-10-14 13:56:50; author: lele; state: Exp; lines: +11 -19 137 Fake changelog 3 138 ---------------------------- 139 revision 1.1 140 date: 1996-10-07 18:32:11; author: lele; state: Exp; 141 Fake changelog 4 142 ============================================================================= 143 144 RCS file: /usr/local/CVSROOT/PyObjC/Doc/libPyObjC.tex,v 145 Working file: Doc/libPyObjC.tex 146 head: 1.4 147 branch: 148 locks: strict 149 access list: 150 keyword substitution: kv 151 total revisions: 4; selected revisions: 4 152 description: 153 ---------------------------- 154 revision 1.4 155 date: 1997-12-21 23:01:29; author: lele; state: Exp; lines: +2 -8 156 Fake changelog 1 157 ---------------------------- 158 revision 1.3 159 date: 1996-10-18 13:48:45; author: lele; state: Exp; lines: +7 -2 160 Fake changelog 2 161 ---------------------------- 162 revision 1.2 163 date: 1996-10-18 12:36:04; author: lele; state: Exp; lines: +7 -3 164 Fake changelog 3 165 ---------------------------- 166 revision 1.1 167 date: 1996-10-07 18:32:12; author: lele; state: Exp; 168 Fake changelog 4 169 ============================================================================= 170 """ 171 116 172 def testBasicBehaviour(self): 117 173 """Verify basic cvs log parser behaviour""" … … 188 244 entry = cset.entries[0] 189 245 self.assertEqual(entry.action_kind, entry.DELETED) 246 247 def testCollapsedChangeset(self): 248 """Verify the mechanism used to collapse related changesets""" 249 250 log = StringIO(self.COLLAPSE_TEST) 251 csets = changesets_from_cvslog(log) 252 253 cset = csets.next() 254 self.assertEqual(len(cset.entries), 2) 255 self.assertEqual(cset.date, datetime(1996, 10, 7, 18, 32, 11)) 256 257 cset = csets.next() 258 self.assertEqual(len(cset.entries), 1) 259 self.assertEqual(cset.date, datetime(1996, 10, 14, 13, 56, 50)) 260 entry = cset.entries[0] 261 self.assertEqual(entry.name, 'Doc/libObjCStreams.tex') 262 263 cset = csets.next() 264 self.assertEqual(len(cset.entries), 1) 265 self.assertEqual(cset.date, datetime(1996, 10, 18, 12, 36, 4)) 266 entry = cset.entries[0] 267 self.assertEqual(entry.name, 'Doc/libPyObjC.tex') 268 269 cset = csets.next() 270 self.assertEqual(len(cset.entries), 2) 271 self.assertEqual(cset.date, datetime(1996, 10, 18, 13, 48, 36)) 272
Note: See TracChangeset
for help on using the changeset viewer.
