Fix geef_ref:lookup/2

Make use of the repo server intead of accepting a handle
This commit is contained in:
Carlos Martín Nieto
2013-04-21 17:14:36 +02:00
parent 353995a2da
commit 3adfa507c0
2 changed files with 11 additions and 4 deletions

View File

@@ -9,9 +9,9 @@ new(Handle) ->
Type = geef:reference_type(Handle), Type = geef:reference_type(Handle),
#ref{handle=Handle, type=Type}. #ref{handle=Handle, type=Type}.
-spec lookup(repo(), iolist()) -> {ok, ref()} | {error, term()}. -spec lookup(pid(), iolist()) -> {ok, ref()} | {error, term()}.
lookup(#repo{handle=Handle}, Refname) -> lookup(Repo, Refname) ->
case geef:reference_lookup(Handle, Refname) of case geef_repo:lookup_reference(Repo, Refname) of
{ok, Ref} -> {ok, Ref} ->
{ok, new(Ref)}; {ok, new(Ref)};
Other -> Other ->

View File

@@ -16,7 +16,7 @@
%% API %% API
-export([open/1, init/2, path/1, workdir/1, odb/1, is_bare/1, references/1, discover/1, -export([open/1, init/2, path/1, workdir/1, odb/1, is_bare/1, references/1, discover/1,
lookup_object/2, revwalk/1, stop/1]). lookup_object/2, lookup_reference/2, revwalk/1, stop/1]).
-include("geef_records.hrl"). -include("geef_records.hrl").
-record(state, {handle}). -record(state, {handle}).
@@ -81,6 +81,10 @@ references(Pid) ->
lookup_object(Pid, Oid) -> lookup_object(Pid, Oid) ->
gen_server:call(Pid, {lookup_object, Oid}). gen_server:call(Pid, {lookup_object, Oid}).
%% @private
lookup_reference(Pid, Name) ->
gen_server:call(Pid, {lookup_reference, Name}).
%% @doc Create a revision walker for the given repository. %% @doc Create a revision walker for the given repository.
revwalk(Pid) -> revwalk(Pid) ->
gen_server:call(Pid, revwalk). gen_server:call(Pid, revwalk).
@@ -115,6 +119,9 @@ handle_call(refs, _From, State = #state{handle=Handle}) ->
handle_call({lookup_object, Oid}, _From, State = #state{handle=Handle}) -> handle_call({lookup_object, Oid}, _From, State = #state{handle=Handle}) ->
Reply = geef:object_lookup(Handle, Oid), Reply = geef:object_lookup(Handle, Oid),
{reply, Reply, State}; {reply, Reply, State};
handle_call({lookup_reference, Name}, _From, State = #state{handle=Handle}) ->
Reply = geef:reference_lookup(Handle, Name),
{reply, Reply, State};
handle_call(stop, _From, State) -> handle_call(stop, _From, State) ->
{stop, normal, ok, State}; {stop, normal, ok, State};
handle_call(revwalk, _From, State = #state{handle=Handle}) -> handle_call(revwalk, _From, State = #state{handle=Handle}) ->