[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] [MERGE REQUEST] unify various commands around arch_

From: Colin Walters
Subject: Re: [Gnu-arch-users] [MERGE REQUEST] unify various commands around arch_fqvsn_from_tree_and_input
Date: Wed, 19 May 2004 22:23:41 -0400

On Wed, 2004-05-19 at 02:29, Aaron Bentley wrote:

> I think we may be duplicating effort. 

Sort of, as it turns out.

>  I've got a function 
> arch_determine_revision that determines a revision from a revision or 
> version name, and I've applied it to tag and sync-tree.  Extending it to 
> support patch-? is pretty natural.  Too sleepy right now, though.
> address@hidden/tlasrc--errors--3

Interesting.  Well I think we're actually solving somewhat different but
related problems.  Notice that we actually patched different sets of
commands (you patched tag and sync-tree, I patched delta, get-changeset,
and undo).

Let me describe my function arch_fqvsn_from_tree_and_input.  It's meant
to take any sort of user input (from a fully-qualified revision like
address@hidden/project--main--0--patch-32) to bare patchlevels like
patch-32.  If the input is already fully-qualified, just return that. 
The key difference with what arch_fqvsn_from_tree_and_input does is that
it uses the current tree version to disambiguate.  Actually this will
all probably be clear if I post the code, here it is:

/* Gather a fully-qualified revision name from the current tree
 * and input (e.g. patch-10)
t_uchar *
arch_fqvsn_from_tree_and_input (t_uchar *cmd, t_uchar * string)
  t_uchar * tree_root = 0;
  t_uchar * tree_version = 0;
  t_uchar * tree_arch = 0;
  t_uchar * ret = 0;
  if (arch_valid_package_name (string, arch_req_archive, arch_req_patch_level, 
    return str_save (0, string);

  tree_root = arch_tree_root (0, ".", 0);
  if (!tree_root)
      safe_printfmt (2, "%s: not in a project tree\n  dir: %s\n", cmd, 
directory_as_cwd ("."));
      exit (2);
  tree_version = arch_tree_version (tree_root);
  if (!tree_version)
      safe_printfmt (2, "%s: no tree-version set\n  tree: %s\n", cmd, 
      exit (2);
  tree_arch = arch_parse_package_name (arch_ret_archive, 0, tree_version);
  if (arch_valid_package_name (string, arch_maybe_archive, 
arch_req_patch_level, 0)) {
    ret = arch_fully_qualify (tree_arch, string);
  } else {
    ret = str_alloc_cat_many (0, tree_version, "--", string, str_end); 
    if (!arch_valid_package_name (ret, arch_req_archive, arch_req_patch_level, 
0)) {
      safe_printfmt (2, "%s: invalid revision or patch name (%s)\n", cmd, 
      exit (2);
  lim_free (0, tree_root);
  lim_free (0, tree_version); 
  lim_free (0, tree_arch); 
  return ret;

Now I'm pretty sure I'm on the right track with this thing because most
of my changesets consist of *deleting* code and replacing it with this,
with no loss in functionality or semantics, etc.  With the sole
exception of delta, and I'm about to fix that now.

Your function doesn't touch the tree version at all - instead it looks
at the default archive.  So I think both of them make sense.  Probably

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]