3818 |
3818 |
3819 default = not (num or id or branch or tags or bookmarks) |
3819 default = not (num or id or branch or tags or bookmarks) |
3820 output = [] |
3820 output = [] |
3821 revs = [] |
3821 revs = [] |
3822 |
3822 |
3823 if source: |
3823 peer = None |
3824 source, branches = hg.parseurl(ui.expandpath(source)) |
3824 try: |
3825 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo |
3825 if source: |
3826 repo = peer.local() |
3826 source, branches = hg.parseurl(ui.expandpath(source)) |
3827 revs, checkout = hg.addbranchrevs(repo, peer, branches, None) |
3827 # only pass ui when no repo |
3828 |
3828 peer = hg.peer(repo or ui, opts, source) |
3829 fm = ui.formatter(b'identify', opts) |
3829 repo = peer.local() |
3830 fm.startitem() |
3830 revs, checkout = hg.addbranchrevs(repo, peer, branches, None) |
3831 |
3831 |
3832 if not repo: |
3832 fm = ui.formatter(b'identify', opts) |
3833 if num or branch or tags: |
3833 fm.startitem() |
3834 raise error.InputError( |
3834 |
3835 _(b"can't query remote revision number, branch, or tags") |
3835 if not repo: |
3836 ) |
3836 if num or branch or tags: |
3837 if not rev and revs: |
3837 raise error.InputError( |
3838 rev = revs[0] |
3838 _(b"can't query remote revision number, branch, or tags") |
3839 if not rev: |
3839 ) |
3840 rev = b"tip" |
3840 if not rev and revs: |
3841 |
3841 rev = revs[0] |
3842 remoterev = peer.lookup(rev) |
3842 if not rev: |
3843 hexrev = fm.hexfunc(remoterev) |
3843 rev = b"tip" |
3844 if default or id: |
3844 |
3845 output = [hexrev] |
3845 remoterev = peer.lookup(rev) |
3846 fm.data(id=hexrev) |
3846 hexrev = fm.hexfunc(remoterev) |
3847 |
3847 if default or id: |
3848 @util.cachefunc |
3848 output = [hexrev] |
3849 def getbms(): |
3849 fm.data(id=hexrev) |
3850 bms = [] |
3850 |
3851 |
3851 @util.cachefunc |
3852 if b'bookmarks' in peer.listkeys(b'namespaces'): |
3852 def getbms(): |
3853 hexremoterev = hex(remoterev) |
3853 bms = [] |
3854 bms = [ |
3854 |
3855 bm |
3855 if b'bookmarks' in peer.listkeys(b'namespaces'): |
3856 for bm, bmr in pycompat.iteritems( |
3856 hexremoterev = hex(remoterev) |
3857 peer.listkeys(b'bookmarks') |
3857 bms = [ |
|
3858 bm |
|
3859 for bm, bmr in pycompat.iteritems( |
|
3860 peer.listkeys(b'bookmarks') |
|
3861 ) |
|
3862 if bmr == hexremoterev |
|
3863 ] |
|
3864 |
|
3865 return sorted(bms) |
|
3866 |
|
3867 if fm.isplain(): |
|
3868 if bookmarks: |
|
3869 output.extend(getbms()) |
|
3870 elif default and not ui.quiet: |
|
3871 # multiple bookmarks for a single parent separated by '/' |
|
3872 bm = b'/'.join(getbms()) |
|
3873 if bm: |
|
3874 output.append(bm) |
|
3875 else: |
|
3876 fm.data(node=hex(remoterev)) |
|
3877 if bookmarks or b'bookmarks' in fm.datahint(): |
|
3878 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark')) |
|
3879 else: |
|
3880 if rev: |
|
3881 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn') |
|
3882 ctx = scmutil.revsingle(repo, rev, None) |
|
3883 |
|
3884 if ctx.rev() is None: |
|
3885 ctx = repo[None] |
|
3886 parents = ctx.parents() |
|
3887 taglist = [] |
|
3888 for p in parents: |
|
3889 taglist.extend(p.tags()) |
|
3890 |
|
3891 dirty = b"" |
|
3892 if ctx.dirty(missing=True, merge=False, branch=False): |
|
3893 dirty = b'+' |
|
3894 fm.data(dirty=dirty) |
|
3895 |
|
3896 hexoutput = [fm.hexfunc(p.node()) for p in parents] |
|
3897 if default or id: |
|
3898 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)] |
|
3899 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty)) |
|
3900 |
|
3901 if num: |
|
3902 numoutput = [b"%d" % p.rev() for p in parents] |
|
3903 output.append(b"%s%s" % (b'+'.join(numoutput), dirty)) |
|
3904 |
|
3905 fm.data( |
|
3906 parents=fm.formatlist( |
|
3907 [fm.hexfunc(p.node()) for p in parents], name=b'node' |
3858 ) |
3908 ) |
3859 if bmr == hexremoterev |
3909 ) |
3860 ] |
3910 else: |
3861 |
3911 hexoutput = fm.hexfunc(ctx.node()) |
3862 return sorted(bms) |
3912 if default or id: |
3863 |
3913 output = [hexoutput] |
3864 if fm.isplain(): |
3914 fm.data(id=hexoutput) |
3865 if bookmarks: |
3915 |
3866 output.extend(getbms()) |
3916 if num: |
3867 elif default and not ui.quiet: |
3917 output.append(pycompat.bytestr(ctx.rev())) |
|
3918 taglist = ctx.tags() |
|
3919 |
|
3920 if default and not ui.quiet: |
|
3921 b = ctx.branch() |
|
3922 if b != b'default': |
|
3923 output.append(b"(%s)" % b) |
|
3924 |
|
3925 # multiple tags for a single parent separated by '/' |
|
3926 t = b'/'.join(taglist) |
|
3927 if t: |
|
3928 output.append(t) |
|
3929 |
3868 # multiple bookmarks for a single parent separated by '/' |
3930 # multiple bookmarks for a single parent separated by '/' |
3869 bm = b'/'.join(getbms()) |
3931 bm = b'/'.join(ctx.bookmarks()) |
3870 if bm: |
3932 if bm: |
3871 output.append(bm) |
3933 output.append(bm) |
3872 else: |
3934 else: |
3873 fm.data(node=hex(remoterev)) |
3935 if branch: |
3874 if bookmarks or b'bookmarks' in fm.datahint(): |
3936 output.append(ctx.branch()) |
3875 fm.data(bookmarks=fm.formatlist(getbms(), name=b'bookmark')) |
3937 |
3876 else: |
3938 if tags: |
3877 if rev: |
3939 output.extend(taglist) |
3878 repo = scmutil.unhidehashlikerevs(repo, [rev], b'nowarn') |
3940 |
3879 ctx = scmutil.revsingle(repo, rev, None) |
3941 if bookmarks: |
3880 |
3942 output.extend(ctx.bookmarks()) |
3881 if ctx.rev() is None: |
3943 |
3882 ctx = repo[None] |
3944 fm.data(node=ctx.hex()) |
3883 parents = ctx.parents() |
3945 fm.data(branch=ctx.branch()) |
3884 taglist = [] |
3946 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':')) |
3885 for p in parents: |
3947 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark')) |
3886 taglist.extend(p.tags()) |
3948 fm.context(ctx=ctx) |
3887 |
3949 |
3888 dirty = b"" |
3950 fm.plain(b"%s\n" % b' '.join(output)) |
3889 if ctx.dirty(missing=True, merge=False, branch=False): |
3951 fm.end() |
3890 dirty = b'+' |
3952 finally: |
3891 fm.data(dirty=dirty) |
3953 if peer: |
3892 |
3954 peer.close() |
3893 hexoutput = [fm.hexfunc(p.node()) for p in parents] |
|
3894 if default or id: |
|
3895 output = [b"%s%s" % (b'+'.join(hexoutput), dirty)] |
|
3896 fm.data(id=b"%s%s" % (b'+'.join(hexoutput), dirty)) |
|
3897 |
|
3898 if num: |
|
3899 numoutput = [b"%d" % p.rev() for p in parents] |
|
3900 output.append(b"%s%s" % (b'+'.join(numoutput), dirty)) |
|
3901 |
|
3902 fm.data( |
|
3903 parents=fm.formatlist( |
|
3904 [fm.hexfunc(p.node()) for p in parents], name=b'node' |
|
3905 ) |
|
3906 ) |
|
3907 else: |
|
3908 hexoutput = fm.hexfunc(ctx.node()) |
|
3909 if default or id: |
|
3910 output = [hexoutput] |
|
3911 fm.data(id=hexoutput) |
|
3912 |
|
3913 if num: |
|
3914 output.append(pycompat.bytestr(ctx.rev())) |
|
3915 taglist = ctx.tags() |
|
3916 |
|
3917 if default and not ui.quiet: |
|
3918 b = ctx.branch() |
|
3919 if b != b'default': |
|
3920 output.append(b"(%s)" % b) |
|
3921 |
|
3922 # multiple tags for a single parent separated by '/' |
|
3923 t = b'/'.join(taglist) |
|
3924 if t: |
|
3925 output.append(t) |
|
3926 |
|
3927 # multiple bookmarks for a single parent separated by '/' |
|
3928 bm = b'/'.join(ctx.bookmarks()) |
|
3929 if bm: |
|
3930 output.append(bm) |
|
3931 else: |
|
3932 if branch: |
|
3933 output.append(ctx.branch()) |
|
3934 |
|
3935 if tags: |
|
3936 output.extend(taglist) |
|
3937 |
|
3938 if bookmarks: |
|
3939 output.extend(ctx.bookmarks()) |
|
3940 |
|
3941 fm.data(node=ctx.hex()) |
|
3942 fm.data(branch=ctx.branch()) |
|
3943 fm.data(tags=fm.formatlist(taglist, name=b'tag', sep=b':')) |
|
3944 fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name=b'bookmark')) |
|
3945 fm.context(ctx=ctx) |
|
3946 |
|
3947 fm.plain(b"%s\n" % b' '.join(output)) |
|
3948 fm.end() |
|
3949 |
3955 |
3950 |
3956 |
3951 @command( |
3957 @command( |
3952 b'import|patch', |
3958 b'import|patch', |
3953 [ |
3959 [ |
4289 if opts.get(b'bookmarks'): |
4295 if opts.get(b'bookmarks'): |
4290 source, branches = hg.parseurl( |
4296 source, branches = hg.parseurl( |
4291 ui.expandpath(source), opts.get(b'branch') |
4297 ui.expandpath(source), opts.get(b'branch') |
4292 ) |
4298 ) |
4293 other = hg.peer(repo, opts, source) |
4299 other = hg.peer(repo, opts, source) |
4294 if b'bookmarks' not in other.listkeys(b'namespaces'): |
4300 try: |
4295 ui.warn(_(b"remote doesn't support bookmarks\n")) |
4301 if b'bookmarks' not in other.listkeys(b'namespaces'): |
4296 return 0 |
4302 ui.warn(_(b"remote doesn't support bookmarks\n")) |
4297 ui.pager(b'incoming') |
4303 return 0 |
4298 ui.status(_(b'comparing with %s\n') % util.hidepassword(source)) |
4304 ui.pager(b'incoming') |
4299 return bookmarks.incoming(ui, repo, other) |
4305 ui.status(_(b'comparing with %s\n') % util.hidepassword(source)) |
|
4306 return bookmarks.incoming(ui, repo, other) |
|
4307 finally: |
|
4308 other.close() |
4300 |
4309 |
4301 repo._subtoppath = ui.expandpath(source) |
4310 repo._subtoppath = ui.expandpath(source) |
4302 try: |
4311 try: |
4303 return hg.incoming(ui, repo, source, opts) |
4312 return hg.incoming(ui, repo, source, opts) |
4304 finally: |
4313 finally: |
4961 return 0 |
4971 return 0 |
4962 |
4972 |
4963 if opts.get(b'bookmarks'): |
4973 if opts.get(b'bookmarks'): |
4964 dest = path.pushloc or path.loc |
4974 dest = path.pushloc or path.loc |
4965 other = hg.peer(repo, opts, dest) |
4975 other = hg.peer(repo, opts, dest) |
4966 if b'bookmarks' not in other.listkeys(b'namespaces'): |
4976 try: |
4967 ui.warn(_(b"remote doesn't support bookmarks\n")) |
4977 if b'bookmarks' not in other.listkeys(b'namespaces'): |
4968 return 0 |
4978 ui.warn(_(b"remote doesn't support bookmarks\n")) |
4969 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest)) |
4979 return 0 |
4970 ui.pager(b'outgoing') |
4980 ui.status(_(b'comparing with %s\n') % util.hidepassword(dest)) |
4971 return bookmarks.outgoing(ui, repo, other) |
4981 ui.pager(b'outgoing') |
|
4982 return bookmarks.outgoing(ui, repo, other) |
|
4983 finally: |
|
4984 other.close() |
4972 |
4985 |
4973 repo._subtoppath = path.pushloc or path.loc |
4986 repo._subtoppath = path.pushloc or path.loc |
4974 try: |
4987 try: |
4975 return hg.outgoing(ui, repo, dest, opts) |
4988 return hg.outgoing(ui, repo, dest, opts) |
4976 finally: |
4989 finally: |
5677 branches = (path.branch, opts.get(b'branch') or []) |
5690 branches = (path.branch, opts.get(b'branch') or []) |
5678 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest)) |
5691 ui.status(_(b'pushing to %s\n') % util.hidepassword(dest)) |
5679 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev')) |
5692 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev')) |
5680 other = hg.peer(repo, opts, dest) |
5693 other = hg.peer(repo, opts, dest) |
5681 |
5694 |
5682 if revs: |
5695 try: |
5683 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)] |
5696 if revs: |
5684 if not revs: |
5697 revs = [repo[r].node() for r in scmutil.revrange(repo, revs)] |
|
5698 if not revs: |
|
5699 raise error.InputError( |
|
5700 _(b"specified revisions evaluate to an empty set"), |
|
5701 hint=_(b"use different revision arguments"), |
|
5702 ) |
|
5703 elif path.pushrev: |
|
5704 # It doesn't make any sense to specify ancestor revisions. So limit |
|
5705 # to DAG heads to make discovery simpler. |
|
5706 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev) |
|
5707 revs = scmutil.revrange(repo, [expr]) |
|
5708 revs = [repo[rev].node() for rev in revs] |
|
5709 if not revs: |
|
5710 raise error.InputError( |
|
5711 _(b'default push revset for path evaluates to an empty set') |
|
5712 ) |
|
5713 elif ui.configbool(b'commands', b'push.require-revs'): |
5685 raise error.InputError( |
5714 raise error.InputError( |
5686 _(b"specified revisions evaluate to an empty set"), |
5715 _(b'no revisions specified to push'), |
5687 hint=_(b"use different revision arguments"), |
5716 hint=_(b'did you mean "hg push -r ."?'), |
5688 ) |
5717 ) |
5689 elif path.pushrev: |
5718 |
5690 # It doesn't make any sense to specify ancestor revisions. So limit |
5719 repo._subtoppath = dest |
5691 # to DAG heads to make discovery simpler. |
5720 try: |
5692 expr = revsetlang.formatspec(b'heads(%r)', path.pushrev) |
5721 # push subrepos depth-first for coherent ordering |
5693 revs = scmutil.revrange(repo, [expr]) |
5722 c = repo[b'.'] |
5694 revs = [repo[rev].node() for rev in revs] |
5723 subs = c.substate # only repos that are committed |
5695 if not revs: |
5724 for s in sorted(subs): |
5696 raise error.InputError( |
5725 result = c.sub(s).push(opts) |
5697 _(b'default push revset for path evaluates to an empty set') |
5726 if result == 0: |
5698 ) |
5727 return not result |
5699 elif ui.configbool(b'commands', b'push.require-revs'): |
5728 finally: |
5700 raise error.InputError( |
5729 del repo._subtoppath |
5701 _(b'no revisions specified to push'), |
5730 |
5702 hint=_(b'did you mean "hg push -r ."?'), |
5731 opargs = dict( |
|
5732 opts.get(b'opargs', {}) |
|
5733 ) # copy opargs since we may mutate it |
|
5734 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', [])) |
|
5735 |
|
5736 pushop = exchange.push( |
|
5737 repo, |
|
5738 other, |
|
5739 opts.get(b'force'), |
|
5740 revs=revs, |
|
5741 newbranch=opts.get(b'new_branch'), |
|
5742 bookmarks=opts.get(b'bookmark', ()), |
|
5743 publish=opts.get(b'publish'), |
|
5744 opargs=opargs, |
5703 ) |
5745 ) |
5704 |
5746 |
5705 repo._subtoppath = dest |
5747 result = not pushop.cgresult |
5706 try: |
5748 |
5707 # push subrepos depth-first for coherent ordering |
5749 if pushop.bkresult is not None: |
5708 c = repo[b'.'] |
5750 if pushop.bkresult == 2: |
5709 subs = c.substate # only repos that are committed |
5751 result = 2 |
5710 for s in sorted(subs): |
5752 elif not result and pushop.bkresult: |
5711 result = c.sub(s).push(opts) |
5753 result = 2 |
5712 if result == 0: |
|
5713 return not result |
|
5714 finally: |
5754 finally: |
5715 del repo._subtoppath |
5755 other.close() |
5716 |
|
5717 opargs = dict(opts.get(b'opargs', {})) # copy opargs since we may mutate it |
|
5718 opargs.setdefault(b'pushvars', []).extend(opts.get(b'pushvars', [])) |
|
5719 |
|
5720 pushop = exchange.push( |
|
5721 repo, |
|
5722 other, |
|
5723 opts.get(b'force'), |
|
5724 revs=revs, |
|
5725 newbranch=opts.get(b'new_branch'), |
|
5726 bookmarks=opts.get(b'bookmark', ()), |
|
5727 publish=opts.get(b'publish'), |
|
5728 opargs=opargs, |
|
5729 ) |
|
5730 |
|
5731 result = not pushop.cgresult |
|
5732 |
|
5733 if pushop.bkresult is not None: |
|
5734 if pushop.bkresult == 2: |
|
5735 result = 2 |
|
5736 elif not result and pushop.bkresult: |
|
5737 result = 2 |
|
5738 |
|
5739 return result |
5756 return result |
5740 |
5757 |
5741 |
5758 |
5742 @command( |
5759 @command( |
5743 b'recover', |
5760 b'recover', |