3705 return |
3705 return |
3706 |
3706 |
3707 for backup in backups: |
3707 for backup in backups: |
3708 # Much of this is copied from the hg incoming logic |
3708 # Much of this is copied from the hg incoming logic |
3709 source = os.path.relpath(backup, encoding.getcwd()) |
3709 source = os.path.relpath(backup, encoding.getcwd()) |
3710 source, branches = urlutil.get_unique_pull_path( |
3710 path = urlutil.get_unique_pull_path_obj( |
3711 b'debugbackupbundle', |
3711 b'debugbackupbundle', |
3712 repo, |
|
3713 ui, |
3712 ui, |
3714 source, |
3713 source, |
3715 default_branches=opts.get(b'branch'), |
|
3716 ) |
3714 ) |
3717 try: |
3715 try: |
3718 other = hg.peer(repo, opts, source) |
3716 other = hg.peer(repo, opts, path) |
3719 except error.LookupError as ex: |
3717 except error.LookupError as ex: |
3720 msg = _(b"\nwarning: unable to open bundle %s") % source |
3718 msg = _(b"\nwarning: unable to open bundle %s") % path.loc |
3721 hint = _(b"\n(missing parent rev %s)\n") % short(ex.name) |
3719 hint = _(b"\n(missing parent rev %s)\n") % short(ex.name) |
3722 ui.warn(msg, hint=hint) |
3720 ui.warn(msg, hint=hint) |
3723 continue |
3721 continue |
|
3722 branches = (path.branch, opts.get(b'branch', [])) |
3724 revs, checkout = hg.addbranchrevs( |
3723 revs, checkout = hg.addbranchrevs( |
3725 repo, other, branches, opts.get(b"rev") |
3724 repo, other, branches, opts.get(b"rev") |
3726 ) |
3725 ) |
3727 |
3726 |
3728 if revs: |
3727 if revs: |
3741 continue |
3740 continue |
3742 if recovernode: |
3741 if recovernode: |
3743 with repo.lock(), repo.transaction(b"unbundle") as tr: |
3742 with repo.lock(), repo.transaction(b"unbundle") as tr: |
3744 if scmutil.isrevsymbol(other, recovernode): |
3743 if scmutil.isrevsymbol(other, recovernode): |
3745 ui.status(_(b"Unbundling %s\n") % (recovernode)) |
3744 ui.status(_(b"Unbundling %s\n") % (recovernode)) |
3746 f = hg.openpath(ui, source) |
3745 f = hg.openpath(ui, path.loc) |
3747 gen = exchange.readbundle(ui, f, source) |
3746 gen = exchange.readbundle(ui, f, path.loc) |
3748 if isinstance(gen, bundle2.unbundle20): |
3747 if isinstance(gen, bundle2.unbundle20): |
3749 bundle2.applybundle( |
3748 bundle2.applybundle( |
3750 repo, |
3749 repo, |
3751 gen, |
3750 gen, |
3752 tr, |
3751 tr, |
3753 source=b"unbundle", |
3752 source=b"unbundle", |
3754 url=b"bundle:" + source, |
3753 url=b"bundle:" + path.loc, |
3755 ) |
3754 ) |
3756 else: |
3755 else: |
3757 gen.apply(repo, b"unbundle", b"bundle:" + source) |
3756 gen.apply(repo, b"unbundle", b"bundle:" + path.loc) |
3758 break |
3757 break |
3759 else: |
3758 else: |
3760 backupdate = encoding.strtolocal( |
3759 backupdate = encoding.strtolocal( |
3761 time.strftime( |
3760 time.strftime( |
3762 "%a %H:%M, %Y-%m-%d", |
3761 "%a %H:%M, %Y-%m-%d", |
3763 time.localtime(os.path.getmtime(source)), |
3762 time.localtime(os.path.getmtime(path.loc)), |
3764 ) |
3763 ) |
3765 ) |
3764 ) |
3766 ui.status(b"\n%s\n" % (backupdate.ljust(50))) |
3765 ui.status(b"\n%s\n" % (backupdate.ljust(50))) |
3767 if ui.verbose: |
3766 if ui.verbose: |
3768 ui.status(b"%s%s\n" % (b"bundle:".ljust(13), source)) |
3767 ui.status(b"%s%s\n" % (b"bundle:".ljust(13), path.loc)) |
3769 else: |
3768 else: |
3770 opts[ |
3769 opts[ |
3771 b"template" |
3770 b"template" |
3772 ] = b"{label('status.modified', node|short)} {desc|firstline}\n" |
3771 ] = b"{label('status.modified', node|short)} {desc|firstline}\n" |
3773 displayer = logcmdutil.changesetdisplayer( |
3772 displayer = logcmdutil.changesetdisplayer( |