Changeset 8 in tailor
- Timestamp:
- 06/03/04 00:57:51 (9 years ago)
- Hash name:
- 20040602225751-97f81-1c36a93fad42a806dc78c71fb57407335ad81be1
- Location:
- cvsync
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cvsync/svn.py
r6 r8 19 19 20 20 class SvnUpdate(SystemCommand): 21 COMMAND = "svn update -- quiet --revision %(revision)s %(entry)s"21 COMMAND = "svn update --revision %(revision)s %(entry)s" 22 22 23 23 … … 248 248 249 249 def update(self, revision="HEAD"): 250 """Bring this directory up to its HEAD revision in the repository.""" 250 """ 251 Bring this directory up to its HEAD revision in the 252 repository. Return a dictionary of changed items, grouped by 253 kind of change. 254 """ 251 255 252 256 svnup = SvnUpdate() 253 svnup(entry=self.root, revision=revision) 257 out = svnup(output=True, entry=self.root, revision=revision) 258 259 result = {} 260 for line in out: 261 if len(line)>2 and line[0] in 'ADUCG' and line[1] == ' ': 262 try: result[line[0]].append(line[2:-1]) 263 except KeyError: result[line[0]] = [line[2:-1]] 264 265 return result 254 266 255 267 def commit(self, logfile=None, message=None): … … 342 354 343 355 def merge(self, uri, startrev, endrev, dest, dry_run=False): 344 """Perform the merge.""" 356 """ 357 Perform the merge and return a dictionary of changed items, 358 grouped by kind of change.""" 345 359 346 360 svnm = SvnMerge() … … 348 362 source=uri, dest=dest, dry_run=dry_run) 349 363 350 merged = False364 result = {} 351 365 if not dry_run: 352 366 for line in out: 353 if l ine.startswith('C '):354 print "CONFLICT:", line355 merged = True356 357 return merged367 if len(line)>2 and line[0] in 'ADUCG' and line[1] == ' ': 368 try: result[line[0]].append(line[2:-1]) 369 except KeyError: result[line[0]] = [line[2:-1]] 370 371 return result 358 372 359 373 def diff(self, uri, rev): -
cvsync/tailor.py
r6 r8 140 140 if options.svn_update and not options.dry_run: 141 141 self.wc.update() 142 142 143 return self.merge(options) 143 144 … … 179 180 path,action = event 180 181 oldpath = action[1] 181 if pathactions.get(oldpath) == u'D':182 if pathactions.get(oldpath) == 'D': 182 183 dwc.rename(oldpath, path) 183 184 done[path] = done[oldpath] = True … … 190 191 if done.get(path): continue 191 192 192 if action == u'D':193 if action == 'D': 193 194 dwc.remove(path) 194 195 … … 308 309 Fetch the upstream info and perform a merge of the eventual changes, 309 310 then update the properties. 311 312 Return True if there something to commit, False otherwise. 310 313 """ 311 314 … … 317 320 head = getHeadRevision(uri, rev) 318 321 if rev <> head: 319 merged = self.wc.merge(uri, rev, head, 320 self.project, dry_run=options.dry_run) 322 changes = self.wc.merge(uri, rev, head, 323 self.project, dry_run=options.dry_run) 324 325 conflicts = changes.get('C') 326 if conflicts: 327 print "CONFLICT:", conflicts 328 329 merged = len(changes)<>0 321 330 if merged: 322 331 self.updateUpstreamInfo(rev=head) -
cvsync/tests/svn.py
r4 r8 26 26 27 27 def __init__(self, path): 28 from os.path import abspath, join,exists28 from os.path import abspath, exists 29 29 30 30 self.repospath = path … … 51 51 TestCase.__init__(self, methodName) 52 52 53 repos = '/tmp/ cvsync.test'53 repos = '/tmp/basic.rep' 54 54 self.repos = TestRepository(repos) 55 wc = '/tmp/ cvsync.wc'55 wc = '/tmp/basic.wc' 56 56 self.wc = SvnWorkingDir(wc) 57 57 58 def __del__(self): 59 from shutil import rmtree 60 from os.path import exists 61 62 if exists(self.repos.repospath): rmtree(self.repos.repospath) 63 if exists(self.wc.root): rmtree(self.wc.root) 64 58 65 def testCheckout(self): 59 66 """Verify that svn checkout returns right info""" … … 62 69 self.assertEqual(info['URL'], self.repos.reposurl) 63 70 self.assertEqual(info['Revision'], '0') 64 71 72 def testInfoA_update(self): 73 """Verify update return right info""" 74 75 changes = self.wc.update(revision='1') 76 self.assertEqual(len(changes), 1) 77 self.assertEqual(len(changes['A']), 6) 78 79 def testInfoB_merge(self): 80 """Verify merge return right info""" 81 82 changes = self.wc.merge(self.repos.reposurl, '1', '2', self.wc.root) 83 self.assertEqual(len(changes), 1) 84 self.assertEqual(len(changes['U']), 3) 85 86 def testInfoC_update(self): 87 """Verify update after merge return right info""" 88 89 changes = self.wc.update(revision='2') 90 self.assertEqual(len(changes), 1) 91 self.assertEqual(len(changes['G']), 3) 92 65 93 class SvnLogTest(TestCase): 66 94 """Test `svn log` parse functionality.""" 67 95 68 96 def __init__(self, methodName): 97 TestCase.__init__(self, methodName) 98 99 repos = '/tmp/log.rep' 100 self.repos = TestRepository(repos) 101 wc = '/tmp/log.wc' 102 self.wc = SvnWorkingDir(wc) 103 self.wc.checkout(self.repos.reposurl + '@0') 104 105 def __del__(self): 106 from shutil import rmtree 69 107 from os.path import exists 70 108 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') 109 if exists(self.repos.repospath): rmtree(self.repos.repospath) 110 if exists(self.wc.root): rmtree(self.wc.root) 79 111 80 112 def testLogParser(self):
Note: See TracChangeset
for help on using the changeset viewer.
