bundle: add revset expression to show bundle contents (issue3487)
authorTomasz Kleczek <tkleczek@fb.com>
Wed, 31 Oct 2012 16:23:23 -0700
changeset 17913 03e552aaae67
parent 17908 42f8ee0e04ac
child 17914 d8ad046ea4e5
bundle: add 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.
mercurial/bundlerepo.py
mercurial/revset.py
tests/test-bundle.t
--- a/mercurial/bundlerepo.py	Wed Oct 24 23:09:31 2012 +0200
+++ b/mercurial/bundlerepo.py	Wed Oct 31 16:23:23 2012 -0700
@@ -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
--- a/mercurial/revset.py	Wed Oct 24 23:09:31 2012 +0200
+++ b/mercurial/revset.py	Wed Oct 31 16:23:23 2012 -0700
@@ -442,6 +442,19 @@
     bumped = obsmod.getrevs(repo, 'bumped')
     return [r for r in subset if r in bumped]
 
+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 = set(repo[n].rev() for n in bundlenodes)
+    return [r for r in subset if r in revs]
+
 def checkstatus(repo, subset, pat, field):
     m = None
     s = []
@@ -1513,6 +1526,7 @@
     "branch": branch,
     "branchpoint": branchpoint,
     "bumped": bumped,
+    "bundle": bundle,
     "children": children,
     "closed": closed,
     "contains": contains,
--- a/tests/test-bundle.t	Wed Oct 24 23:09:31 2012 +0200
+++ b/tests/test-bundle.t	Wed Oct 31 16:23:23 2012 -0700
@@ -444,6 +444,33 @@
   added 1 changesets with 1 changes to 1 files
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
+View full contents of the bundle
+  $ hg -R test bundle --base null -r 3  ../partial.hg
+  4 changesets found
+  $ cd test
+  $ hg -R ../../partial.hg log -r "bundle()"
+  changeset:   0:f9ee2f85a263
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     0.0
+  
+  changeset:   1:34c2bf6b0626
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     0.1
+  
+  changeset:   2:e38ba6f5b7e0
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     0.2
+  
+  changeset:   3:eebf5a27f8ca
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     0.3
+  
+  $ cd ..
+
 test for 540d1059c802
 
 test for 540d1059c802