[PATCH stable] bundle: add the revset expression to show bundle contents(issue3487)
Patrick Mézard
patrick at mezard.eu
Wed Oct 31 18:15:55 CDT 2012
Le 31/10/12 23:41, Tomasz Kleczek a écrit :
> # HG changeset patch
> # User Tomasz Kleczek <tkleczek at fb.com>
> # Date 1350426617 25200
> # Node ID c0a317d0d07800d93a35657332d6422259c10023
> # Parent 72c234081ae1350220132c69750f5a093902a1e7
> bundle: add the revset expression to show bundle contents(issue3487)
>
> bundle() revset expression returns all changes that are present
> in the bundle file (no matter whether they are in the repo or not).
>
> Bundle file should be specified via -R option.
We are currently in code freeze, could you resend once it is finished?
I have no opinion on the feature itself, but please see the comment below.
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -33,6 +33,7 @@
> self.basemap = {}
> n = len(self)
> chain = None
> + self.bundlenodes = []
> while True:
> chunkdata = bundle.deltachunk(chain)
> if not chunkdata:
> @@ -48,6 +49,7 @@
> start = bundle.tell() - size
>
> link = linkmapper(cs)
> + self.bundlenodes.append(node)
> if node in self.nodemap:
> # this can happen if two branches make the same change
> chain = node
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -422,6 +422,19 @@
> s = set(s)
> return [r for r in subset if r in s or repo[r].branch() in b]
>
> +def bundle(repo, subset, x):
> + """``bundle()``
> + Changesets in the bundle.
> +
> + Bundle must be specified by the -R option."""
> +
> + try:
> + bundlenodes = repo.changelog.bundlenodes
> + except AttributeError:
> + raise util.Abort(_("no bundle provided - specify with -R"))
> + revs = map(lambda n: repo[n].rev(), bundlenodes)
Don't you want to turn that into a set to avoid costly array lookups?
> + return [r for r in subset if r in revs]
> +
> def checkstatus(repo, subset, pat, field):
> m = None
> s = []
> @@ -1492,6 +1505,7 @@
> "bookmark": bookmark,
> "branch": branch,
> "branchpoint": branchpoint,
> + "bundle": bundle,
> "children": children,
> "closed": closed,
> "contains": contains,
--
Patrick Mézard
More information about the Mercurial-devel
mailing list