comparison svncommands.py @ 255:246aaefb1cc0

Add a basic incoming command.
author Nat Williams <nat.williams@gmail.com>
date Thu, 09 Apr 2009 22:08:06 -0500
parents c3d5c4ae9c7c
children 7932d098cb5f
comparison
equal deleted inserted replaced
254:9ba31af57e4b 255:246aaefb1cc0
93 tries += 1 93 tries += 1
94 ui.status('Got a 502, retrying (%s)\n' % tries) 94 ui.status('Got a 502, retrying (%s)\n' % tries)
95 else: 95 else:
96 raise hgutil.Abort(*e.args) 96 raise hgutil.Abort(*e.args)
97 util.swap_out_encoding(old_encoding) 97 util.swap_out_encoding(old_encoding)
98
99
100 def incoming(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
101 tag_locations='tags', authors=None, filemap=None, **opts):
102 """show incoming revisions from Subversion
103 """
104 svn_url = util.normalize_url(svn_url)
105
106 initializing_repo = False
107 user = opts.get('username', hgutil.getuser())
108 passwd = opts.get('password', '')
109 svn = svnwrap.SubversionRepo(svn_url, user, passwd)
110 author_host = "@%s" % svn.uuid
111 tag_locations = tag_locations.split(',')
112 hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
113 ui_=ui,
114 subdir=svn.subdir,
115 author_host=author_host,
116 tag_locations=tag_locations,
117 authors=authors,
118 filemap=filemap)
119 if os.path.exists(hg_editor.uuid_file):
120 uuid = open(hg_editor.uuid_file).read()
121 assert uuid == svn.uuid
122 start = hg_editor.last_known_revision()
123 else:
124 open(hg_editor.uuid_file, 'w').write(svn.uuid)
125 open(hg_editor.svn_url_file, 'w').write(svn_url)
126 initializing_repo = True
127 start = skipto_rev
128
129 if initializing_repo and start > 0:
130 raise hgutil.Abort('Revision skipping at repository initialization '
131 'remains unimplemented.')
132
133 rev_stuff = (('revision', 'revnum'),
134 ('user', 'author'),
135 ('date', 'date'),
136 ('message', 'message')
137 )
138
139 ui.status('incoming changes from %s\n' % svn_url)
140
141 for r in svn.revisions(start=start):
142 ui.status('\n')
143 for label, attr in rev_stuff:
144 l1 = label+':'
145 ui.status('%s%s\n' % (l1.ljust(13),
146 str(r.__getattribute__(attr)).strip(), ))
98 147
99 148
100 def push(ui, repo, hg_repo_path, svn_url, stupid=False, **opts): 149 def push(ui, repo, hg_repo_path, svn_url, stupid=False, **opts):
101 """push revisions starting at a specified head back to Subversion. 150 """push revisions starting at a specified head back to Subversion.
102 """ 151 """
376 'dcommit': push, 425 'dcommit': push,
377 'update': update, 426 'update': update,
378 'help': help, 427 'help': help,
379 'rebuildmeta': rebuildmeta, 428 'rebuildmeta': rebuildmeta,
380 'diff': diff, 429 'diff': diff,
430 'incoming': incoming,
381 } 431 }
382 432
383 table.update(utility_commands.table) 433 table.update(utility_commands.table)
384 434
385 435