[PATCH] Add -0,--print0 to manifest

Kevin Bullock kbullock+mercurial at ringworld.org
Tue Jun 5 10:35:10 CDT 2012


On Jun 4, 2012, at 10:28 PM, Kevin O. Grover wrote:

> I wondered why 'hg manifest' did not support -0/--print0 for use with xargs.
> 
> I decided to try to add it.  While testing, I noticed that several other commands did have it.  Now, manifest has it also.

Thanks for submitting a patch! We prefer patches be sent inline rather than as attachments, though, for easier on-list review. The full guidelines for submission are posted on the wiki:

http://mercurial.selenic.com/wiki/ContributingChanges

> # HG changeset patch
> # User Kevin O. Grover <kevin at kevingrover.net>
> # Date 1338866709 25200
> # Node ID 0047b77a03d357efb3a7a405555579872247891f
> # Parent  d566aa319d5f7c58c69b985b53ff7498f08e53c6
> Added -0,-print0 to manifest.

Standard commit message style would make this something like: "manifest: add -0/--print0"

> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4053,7 +4053,8 @@
>  
>  @command('manifest',
>      [('r', 'rev', '', _('revision to display'), _('REV')),
> -     ('', 'all', False, _("list files from all revisions"))],
> +     ('', 'all', False, _("list files from all revisions")),
> +     ('0', 'print0', None, _("separate output with NULs instead of newline"))],

This is a good short description, but doesn't match the --print0 option description on other commands. Would you be interested in submitting a follow-up patch to make the others match? This may warrant a bikeshedding session over wording...

>      _('[-r REV]'))
>  def manifest(ui, repo, node=None, rev=None, **opts):
>      """output the current or given revision of the project manifest
> @@ -4068,8 +4069,19 @@
>      If option --all is specified, the list of all files from all revisions
>      is printed. This includes deleted and renamed files.
>  
> +    Use -0, --print0 to separate file names with NUL (so you can pipe
> +    the results to xargs -0).
> +
>      Returns 0 on success.
>      """
> +
> +    eol = '\n'
> +    if opts.get('print0'):
> +        #if ui.debugflag or ui.verbose:
> +        #    raise util.Abort(\
> +        #       _("can't specify --debug or --verbose with --print0"))

Stray comments.

> +        eol = '\0'
> +
>      if opts.get('all'):
>          if rev or node:
>              raise util.Abort(_("can't specify a revision with --all"))
> @@ -4087,7 +4099,7 @@
>          finally:
>              lock.release()
>          for f in sorted(res):
> -            ui.write("%s\n" % f)
> +            ui.write(f, eol)
>          return
>  
>      if rev and node:
> @@ -4103,7 +4115,7 @@
>              ui.write("%40s " % hex(ctx.manifest()[f]))
>          if ui.verbose:
>              ui.write(decor[ctx.flags(f)])
> -        ui.write("%s\n" % f)
> +        ui.write(f, eol)
>  
>  @command('^merge',
>      [('f', 'force', None, _('force a merge with outstanding changes')),
> diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
> --- a/tests/test-debugcomplete.t
> +++ b/tests/test-debugcomplete.t
> @@ -255,7 +255,7 @@
>    import: strip, base, edit, force, no-commit, bypass, exact, import-branch, message, logfile, date, user, similarity
>    incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
>    locate: rev, print0, fullpath, include, exclude
> -  manifest: rev, all
> +  manifest: rev, all, print0
>    outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
>    parents: rev, style, template
>    paths: 

Super-extra bonus points for running the test suite before submitting your first contribution!

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock



More information about the Mercurial-devel mailing list