<commit_before>package tchannel

import (
	"time"

	"golang.org/x/net/context"
)

type contextKey int

const (
	contextKeyUnknown contextKey = iota
	contextKeyTracing
	contextKeyCall
)

// IncomingCall exposes properties for incoming calls through the context.
type IncomingCall interface {
	// CallerName returns the caller name from the CallerName transport header.
	CallerName() string
}

// NewContext returns a new root context used to make TChannel requests.
func NewContext(timeout time.Duration) (context.Context, context.CancelFunc) {
	tctx, cancel := context.WithTimeout(context.Background(), timeout)
	ctx := context.WithValue(tctx, contextKeyTracing, NewRootSpan())
	return ctx, cancel
}

// WrapContextForTest returns a copy of the given Context that is associated with the call.
// This should be used in units test only.
func WrapContextForTest(ctx context.Context, call IncomingCall) context.Context {
	return context.WithValue(ctx, contextKeyCall, call)
}

// newIncomingContext creates a new context for an incoming call with the given span.
func newIncomingContext(call IncomingCall, timeout time.Duration, span *Span) (context.Context, context.CancelFunc) {
	tctx, cancel := context.WithTimeout(context.Background(), timeout)
	ctx := context.WithValue(tctx, contextKeyTracing, span)
	ctx = context.WithValue(ctx, contextKeyCall, call)
	return ctx, cancel
}

// CurrentCall returns the current incoming call, or nil if this is not an incoming call context.
func CurrentCall(ctx context.Context) IncomingCall {
	return CurrentCallWithKey(ctx, contextKeyCall)
}

// CurrentCall given a key, returns the current incoming call, or nil if this is not an incoming call context.
func CurrentCallWithKey(ctx context.Context, key interface{}) IncomingCall {
	if v := ctx.Value(key); v != nil {
		return v.(IncomingCall)
	}
	return nil
}<commit_msg>Fix a bad merge<commit_after>package tchannel

import (
	"time"

	"golang.org/x/net/context"
)

type contextKey int

const (
	contextKeyUnknown contextKey = iota
	contextKeyTracing
	contextKeyCall
)

// IncomingCall exposes properties for incoming calls through the context.
type IncomingCall interface {
	// CallerName returns the caller name from the CallerName transport header.
	CallerName() string
}

// NewContext returns a new root context used to make TChannel requests.
func NewContext(timeout time.Duration) (context.Context, context.CancelFunc) {
	tctx, cancel := context.WithTimeout(context.Background(), timeout)
	ctx := context.WithValue(tctx, contextKeyTracing, NewRootSpan())
	return ctx, cancel
}

// WrapContextForTest returns a copy of the given Context that is associated with the call.
// This should be used in units test only.
func WrapContextForTest(ctx context.Context, call IncomingCall) context.Context {
	return context.WithValue(ctx, contextKeyCall, call)
}

// newIncomingContext creates a new context for an incoming call with the given span.
func newIncomingContext(call IncomingCall, timeout time.Duration, span *Span) (context.Context, context.CancelFunc) {
	tctx, cancel := context.WithTimeout(context.Background(), timeout)
	ctx := context.WithValue(tctx, contextKeyTracing, span)
	ctx = context.WithValue(ctx, contextKeyCall, call)
	return ctx, cancel
}

// CurrentCall returns the current incoming call, or nil if this is not an incoming call context.
func CurrentCall(ctx context.Context) IncomingCall {
	if v := ctx.Value(contextKeyCall); v != nil {
		return v.(IncomingCall)
	}
	return nil
}
{'fraction_non_alphanumeric': 0.08424068767908309, 'fraction_numerical': 0.0, 'mean_word_length': 5.092495636998255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5844354', 'n_tokens_mistral': 993, 'n_tokens_neox': 981, 'n_words': 357}