Skip to content

Commit c590aa1

Browse files
committed
svnbrowse: Use svn_ra_get_dir2() instead of svn_ra_list(); It allows us to skip
resolving revision (it would automatically fallback to HEAD if SVN_INVALID_REVNUM is passed). It also does not require a receiver callback and the resulting information is more specific. * subversion/svnbrowse/svnbrowse.c (list_cb): Remove function. (state_create): Use new API and walk the hashtable to put everything into an array; we cannot use the hashtable directly becuase we need it to be accessible by a numeric consecutive index (for selection). (view_draw): Don't treat first item as "go up"; we'll implement this later. git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1932746 13f79535-47bb-0310-9956-ffa450edef68
1 parent bbb57e4 commit c590aa1

1 file changed

Lines changed: 18 additions & 25 deletions

File tree

subversion/svnbrowse/svnbrowse.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,6 @@ typedef struct svn_browse__model_t {
7070
apr_pool_t *pool;
7171
} svn_browse__model_t;
7272

73-
static svn_error_t *
74-
list_cb(const char *relpath,
75-
svn_dirent_t *dirent,
76-
void *baton,
77-
apr_pool_t *scratch_pool)
78-
{
79-
svn_browse__state_t *state = baton;
80-
svn_browse__item_t *item = apr_pcalloc(state->pool, sizeof(*item));
81-
item->name = svn_dirent_basename(relpath, state->pool);
82-
item->dirent = svn_dirent_dup(dirent, state->pool);
83-
APR_ARRAY_PUSH(state->list, svn_browse__item_t *) = item;
84-
return SVN_NO_ERROR;
85-
}
86-
8773
static svn_error_t *
8874
state_create(svn_browse__state_t **state_p,
8975
svn_ra_session_t *session,
@@ -93,21 +79,30 @@ state_create(svn_browse__state_t **state_p,
9379
apr_pool_t *scratch_pool)
9480
{
9581
svn_browse__state_t *state = apr_pcalloc(result_pool, sizeof(*state));
96-
svn_revnum_t revnum;
82+
svn_revnum_t fetched_revnum;
83+
apr_hash_t *dirents;
84+
apr_hash_index_t *hi;
85+
86+
SVN_ERR(svn_ra_get_dir2(session, &dirents, &fetched_revnum, NULL, relpath,
87+
revision, SVN_DIRENT_ALL, scratch_pool));
9788

9889
state->relpath = apr_pstrdup(result_pool, relpath);
99-
state->revision = state->revision;
100-
state->list = apr_array_make(result_pool, 0, sizeof(svn_browse__item_t *));
90+
state->revision = fetched_revnum;
10191
state->selection = 0;
10292
state->pool = result_pool;
10393

104-
/* TODO: use svn_ra_get_dir2() as it automatically treats SVN_INVALID_REVNUM
105-
* as HEAD and returns a list directly. */
94+
state->list = apr_array_make(result_pool, 0, sizeof(svn_browse__item_t *));
95+
for (hi = apr_hash_first(scratch_pool, dirents); hi; hi = apr_hash_next(hi))
96+
{
97+
const char *name = apr_hash_this_key(hi);
98+
const svn_dirent_t *dirent = apr_hash_this_val(hi);
10699

107-
SVN_ERR(svn_ra_get_latest_revnum(session, &revnum, scratch_pool));
100+
svn_browse__item_t *item = apr_pcalloc(result_pool, sizeof(*item));
101+
item->name = apr_pstrdup(result_pool, name);
102+
item->dirent = svn_dirent_dup(dirent, result_pool);
108103

109-
SVN_ERR(svn_ra_list(session, relpath, revnum, NULL, svn_depth_immediates,
110-
SVN_DIRENT_ALL, list_cb, state, scratch_pool));
104+
APR_ARRAY_PUSH(state->list, svn_browse__item_t *) = item;
105+
}
111106

112107
*state_p = state;
113108
return SVN_NO_ERROR;
@@ -201,9 +196,7 @@ view_draw(svn_browse__view_t *view, apr_pool_t *pool)
201196
if (i == view->model->current->selection)
202197
standout();
203198

204-
if (i == 0)
205-
mvprintw(i + 1, 0, "../");
206-
else if (item->dirent->kind == svn_node_dir)
199+
if (item->dirent->kind == svn_node_dir)
207200
mvprintw(i + 1, 0, "%s/", item->name);
208201
else if (item->dirent->kind == svn_node_file)
209202
mvprintw(i + 1, 0, "%s", item->name);

0 commit comments

Comments
 (0)