Mercurial > hgsubversion
comparison fetch_command.py @ 133:2242dd1163c6
hg_delta_editor: fix bad parent revision calculation in the case of a branch
recycling a name.
Also implemented marking branches as closed in both replay and stupid paths.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Wed, 10 Dec 2008 14:29:05 -0600 |
parents | 59f8603a6641 |
children | 9ffde8662967 |
comparison
equal
deleted
inserted
replaced
132:3a9d6cd18332 | 133:2242dd1163c6 |
---|---|
30 """ | 30 """ |
31 old_encoding = merc_util._encoding | 31 old_encoding = merc_util._encoding |
32 merc_util._encoding = 'UTF-8' | 32 merc_util._encoding = 'UTF-8' |
33 skipto_rev=int(skipto_rev) | 33 skipto_rev=int(skipto_rev) |
34 have_replay = not stupid | 34 have_replay = not stupid |
35 if have_replay and not callable(delta.svn_txdelta_apply(None, None, | 35 if have_replay and not callable( |
36 None)[0]): #pragma: no cover | 36 delta.svn_txdelta_apply(None, None, None)[0]): #pragma: no cover |
37 ui.status('You are using old Subversion SWIG bindings. Replay will not' | 37 ui.status('You are using old Subversion SWIG bindings. Replay will not' |
38 ' work until you upgrade to 1.5.0 or newer. Falling back to' | 38 ' work until you upgrade to 1.5.0 or newer. Falling back to' |
39 ' a slower method that may be buggier. Please upgrade, or' | 39 ' a slower method that may be buggier. Please upgrade, or' |
40 ' contribute a patch to use the ctypes bindings instead' | 40 ' contribute a patch to use the ctypes bindings instead' |
41 ' of SWIG.\n') | 41 ' of SWIG.\n') |
122 hg_editor.ui.status('.') | 122 hg_editor.ui.status('.') |
123 hg_editor.ui.flush() | 123 hg_editor.ui.flush() |
124 if p[-1] == '/': | 124 if p[-1] == '/': |
125 dirpath = p[len(rootpath):] | 125 dirpath = p[len(rootpath):] |
126 files_to_grab.update((dirpath + f for f,k in | 126 files_to_grab.update((dirpath + f for f,k in |
127 svn.list_files(dirpath, r.revnum) | 127 svn.list_files(dirpath, r.revnum) |
128 if k == 'f')) | 128 if k == 'f')) |
129 else: | 129 else: |
130 files_to_grab.add(p[len(rootpath):]) | 130 files_to_grab.add(p[len(rootpath):]) |
131 hg_editor.ui.status('\nFetching files...\n') | 131 hg_editor.ui.status('\nFetching files...\n') |
132 for p in files_to_grab: | 132 for p in files_to_grab: |
174 patchfile = patch.patchfile | 174 patchfile = patch.patchfile |
175 | 175 |
176 class mempatch(patchfile): | 176 class mempatch(patchfile): |
177 def __init__(self, ui, fname, opener, missing=False): | 177 def __init__(self, ui, fname, opener, missing=False): |
178 patchfile.__init__(self, ui, fname, None, False) | 178 patchfile.__init__(self, ui, fname, None, False) |
179 | 179 |
180 def readlines(self, fname): | 180 def readlines(self, fname): |
181 if fname not in parentctx: | 181 if fname not in parentctx: |
182 raise IOError('Cannot find %r to patch' % fname) | 182 raise IOError('Cannot find %r to patch' % fname) |
183 fctx = parentctx[fname] | 183 fctx = parentctx[fname] |
184 data = fctx.data() | 184 data = fctx.data() |
326 data = files_data[path] | 326 data = files_data[path] |
327 if islink: | 327 if islink: |
328 data = data[len('link '):] | 328 data = data[len('link '):] |
329 elif path in parentctx: | 329 elif path in parentctx: |
330 data = parentctx[path].data() | 330 data = parentctx[path].data() |
331 | 331 |
332 copied = copies.get(path) | 332 copied = copies.get(path) |
333 return context.memfilectx(path=path, data=data, islink=islink, | 333 return context.memfilectx(path=path, data=data, islink=islink, |
334 isexec=isexe, copied=copied) | 334 isexec=isexe, copied=copied) |
335 | 335 |
336 return list(touched_files), filectxfn | 336 return list(touched_files), filectxfn |
475 return files, filectxfn | 475 return files, filectxfn |
476 | 476 |
477 def stupid_svn_server_pull_rev(ui, svn, hg_editor, r): | 477 def stupid_svn_server_pull_rev(ui, svn, hg_editor, r): |
478 # this server fails at replay | 478 # this server fails at replay |
479 branches = hg_editor.branches_in_paths(r.paths) | 479 branches = hg_editor.branches_in_paths(r.paths) |
480 deleted_branches = {} | |
481 date = r.date.replace('T', ' ').replace('Z', '').split('.')[0] | |
482 date += ' -0000' | |
480 for b in branches: | 483 for b in branches: |
481 parentctx = hg_editor.repo[hg_editor.get_parent_revision(r.revnum, b)] | 484 parentctx = hg_editor.repo[hg_editor.get_parent_revision(r.revnum, b)] |
482 kind = svn.checkpath(branches[b], r.revnum) | 485 kind = svn.checkpath(branches[b], r.revnum) |
483 if kind != 'd': | 486 if kind != 'd': |
484 # Branch does not exist at this revision. Get parent revision and | 487 # Branch does not exist at this revision. Get parent revision and |
485 # remove everything. | 488 # remove everything. |
486 files_touched = parentctx.manifest().keys() | 489 deleted_branches[b] = parentctx.node() |
487 def filectxfn(repo, memctx, path): | 490 continue |
488 raise IOError() | |
489 else: | 491 else: |
490 try: | 492 try: |
491 files_touched, filectxfn = stupid_diff_branchrev( | 493 files_touched, filectxfn = stupid_diff_branchrev( |
492 ui, svn, hg_editor, b, r, parentctx) | 494 ui, svn, hg_editor, b, r, parentctx) |
493 except BadPatchApply, e: | 495 except BadPatchApply, e: |
494 # Either this revision or the previous one does not exist. | 496 # Either this revision or the previous one does not exist. |
495 ui.status("fetching entire rev: %s.\n" % e.message) | 497 ui.status("fetching entire rev: %s.\n" % e.message) |
496 files_touched, filectxfn = stupid_fetch_branchrev( | 498 files_touched, filectxfn = stupid_fetch_branchrev( |
497 svn, hg_editor, b, branches[b], r, parentctx) | 499 svn, hg_editor, b, branches[b], r, parentctx) |
498 | 500 |
499 date = r.date.replace('T', ' ').replace('Z', '').split('.')[0] | |
500 date += ' -0000' | |
501 extra = {} | 501 extra = {} |
502 if b: | 502 if b: |
503 extra['branch'] = b | 503 extra['branch'] = b |
504 if '' in files_touched: | 504 if '' in files_touched: |
505 files_touched.remove('') | 505 files_touched.remove('') |
520 ha = hg_editor.repo.commitctx(current_ctx) | 520 ha = hg_editor.repo.commitctx(current_ctx) |
521 hg_editor.add_to_revmap(r.revnum, b, ha) | 521 hg_editor.add_to_revmap(r.revnum, b, ha) |
522 hg_editor._save_metadata() | 522 hg_editor._save_metadata() |
523 ui.status('committed as %s on branch %s\n' % | 523 ui.status('committed as %s on branch %s\n' % |
524 (node.hex(ha), b or 'default')) | 524 (node.hex(ha), b or 'default')) |
525 for b, parent in deleted_branches.iteritems(): | |
526 if parent == node.nullid: | |
527 continue | |
528 parentctx = hg_editor.repo[parent] | |
529 if parentctx.children(): | |
530 continue | |
531 files_touched = parentctx.manifest().keys() | |
532 def filectxfn(repo, memctx, path): | |
533 raise IOError() | |
534 closed = node.nullid | |
535 if 'closed-branches' in hg_editor.repo.branchtags(): | |
536 closed = hg_editor.repo['closed-branches'].node() | |
537 parents = (parent, closed) | |
538 current_ctx = context.memctx(hg_editor.repo, | |
539 parents, | |
540 r.message or '...', | |
541 files_touched, | |
542 filectxfn, | |
543 '%s%s' % (r.author, | |
544 hg_editor.author_host), | |
545 date, | |
546 {'branch': 'closed-branches'}) | |
547 ha = hg_editor.repo.commitctx(current_ctx) | |
548 ui.status('Marked branch %s as closed.' % (b or 'default')) | |
549 hg_editor._save_metadata() | |
525 | 550 |
526 class BadPatchApply(Exception): | 551 class BadPatchApply(Exception): |
527 pass | 552 pass |