comparison fetch_command.py @ 179:a336e3e82648

Fetch: add a filemap argument for use in converting old repositories to Mercurial.
author Graham Booker <gbooker@cod3r.com>
date Sat, 03 Jan 2009 20:15:03 -0600
parents c4115b3918e9
children e37f9d3fd5e7
comparison
equal deleted inserted replaced
178:33ebdcb75bcd 179:a336e3e82648
23 23
24 @util.register_subcommand('pull') 24 @util.register_subcommand('pull')
25 def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None, 25 def fetch_revisions(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
26 tag_locations='tags', 26 tag_locations='tags',
27 authors=None, 27 authors=None,
28 filemap=None,
28 **opts): 29 **opts):
29 """Pull new revisions from Subversion. 30 """Pull new revisions from Subversion.
30 """ 31 """
31 svn_url = util.normalize_url(svn_url) 32 svn_url = util.normalize_url(svn_url)
32 old_encoding = merc_util._encoding 33 old_encoding = merc_util._encoding
48 hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path, 49 hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
49 ui_=ui, 50 ui_=ui,
50 subdir=svn.subdir, 51 subdir=svn.subdir,
51 author_host=author_host, 52 author_host=author_host,
52 tag_locations=tag_locations, 53 tag_locations=tag_locations,
53 authors=authors) 54 authors=authors,
55 filemap=filemap)
54 if os.path.exists(hg_editor.uuid_file): 56 if os.path.exists(hg_editor.uuid_file):
55 uuid = open(hg_editor.uuid_file).read() 57 uuid = open(hg_editor.uuid_file).read()
56 assert uuid == svn.uuid 58 assert uuid == svn.uuid
57 start = int(open(hg_editor.last_revision_handled_file, 'r').read()) 59 start = int(open(hg_editor.last_revision_handled_file, 'r').read())
58 else: 60 else:
491 else: 493 else:
492 branchprefix = branchpath + '/' 494 branchprefix = branchpath + '/'
493 for path, e in r.paths.iteritems(): 495 for path, e in r.paths.iteritems():
494 if not path.startswith(branchprefix): 496 if not path.startswith(branchprefix):
495 continue 497 continue
498 if not hg_editor._is_path_valid(branchprefix + path):
499 continue
496 kind = svn.checkpath(path, r.revnum) 500 kind = svn.checkpath(path, r.revnum)
497 path = path[len(branchprefix):] 501 path = path[len(branchprefix):]
498 if kind == 'f': 502 if kind == 'f':
499 files.append(path) 503 files.append(path)
500 elif kind == 'd': 504 elif kind == 'd':
558 562
559 def filectxfn(repo, memctx, path): 563 def filectxfn(repo, memctx, path):
560 if path == '.hgsvnexternals': 564 if path == '.hgsvnexternals':
561 if not externals: 565 if not externals:
562 raise IOError() 566 raise IOError()
563 return context.memfilectx(path=path, data=externals.write(), 567 return context.memfilectx(path=path, data=externals.write(),
564 islink=False, isexec=False, copied=None) 568 islink=False, isexec=False, copied=None)
565 return filectxfn2(repo, memctx, path) 569 return filectxfn2(repo, memctx, path)
566 570
567 extra = util.build_extra(r.revnum, b, svn.uuid, svn.subdir) 571 extra = util.build_extra(r.revnum, b, svn.uuid, svn.subdir)
568 if '' in files_touched: 572 if '' in files_touched:
569 files_touched.remove('') 573 files_touched.remove('')
574 removedFiles = []
575 for file in files_touched:
576 if not hg_editor._is_file_included(file):
577 removedFiles.append(file)
578 for file in removedFiles:
579 files_touched.remove(file)
570 if parentctx.node() != node.nullid or files_touched: 580 if parentctx.node() != node.nullid or files_touched:
571 # TODO(augie) remove this debug code? Or maybe it's sane to have it. 581 # TODO(augie) remove this debug code? Or maybe it's sane to have it.
572 for f in files_touched: 582 for f in files_touched:
573 if f: 583 if f:
574 assert f[0] != '/' 584 assert f[0] != '/'