Commits

Sune Foldager  committed c38cf45

pull: unbundle rather than pull bundles, to prevent phase problems

  • Participants
  • Parent commits 9d24d49

Comments (0)

Files changed (3)

File repoman/cmdutil.py

 import urllib2
 
 import mercurial.hg
+import mercurial.changegroup
 import mercurial.commands
 import mercurial.encoding
 from mercurial.i18n import _
             rebase_mod.rebase(ui, repo)
     return rv
 
+def unbundle(ui, repo, fname, **opts):
+    lock = repo.lock()
+    f = None
+    try:
+        f = open(fname, 'rb')
+        gen = mercurial.changegroup.readbundle(f, fname)
+        modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
+    finally:
+        if f:
+            f.close()
+        lock.release()
+    if opts.get('update'):
+        rv = mercurial.commands.postincoming(ui, repo, modheads, True, None)
+    else:
+        rv = modheads
+    return rv
+
 def pull_metadata(forest, source=None, terse=False):
     '''
     update global metadata by pulling in from the given (or default) source.

File repoman/commands.py

 
     modules = list(f)
     if usebundle:
+        if not incoming:
+            header = 'Unbundling'
         bundle = _forest.Bundle(source)
         bundlemd = f.GMD in bundle.modules
         modules = [mod for mod in modules if mod in bundle.modules]
     if branches:
         oldmaps = dict((b, f.read_branch(b)) for b in branches)
     repo = f.gmd_repo
+    bfile = None
     if bundle:
         if bundlemd:
             bfile = repo.join('unbundle.hg')
                     quiet_write()
             else:
                 prevlen = len(repo)
-                cmdutil.pull(ui, repo, src, **opts) 
+                if bundle:
+                    cmdutil.unbundle(ui, repo, bfile, **opts)
+                else:
+                    cmdutil.pull(ui, repo, src, **opts) 
                 if len(repo) > prevlen:
                     anymeta = prevlen
                     undo.append(f.GMD)
             header(mod)
         skip_ingoing = False
         repo = f[mod]
+        bfile = None
         if bundle:
             bfile = repo.join('unbundle.hg')
             bundle.get(mod, bfile)
                         quiet_write()
                 else:
                     lastrev = len(f[mod])
-                    skip_ingoing = cmdutil.pull(ui, f[mod], src, **opts) == 0
+                    if bundle:
+                        skip_ingoing = cmdutil.unbundle(ui, f[mod], bfile, **opts) == 0
+                    else:
+                        skip_ingoing = cmdutil.pull(ui, f[mod], src, **opts) == 0
                     if not skip_ingoing:
                         undo.append(mod)
                         anymods[mod] = lastrev

File tests/output/bundle.py.out

-adding bundletest
-% preview outgoing
-Outgoing changes to <ROOT>/forest1 (branch: core/dev)
-
-~~~ (metadata) ~~~
-changeset:   3:997a25584670
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-~~~ a ~~~
-changeset:   2:6587ad1b3198
-branch:      core/dev
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit a
-
-~~~ b ~~~
-changeset:   2:9e6d6bb14633
-branch:      core/dev
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-~~~ c ~~~
-no changes found
-
-Bundle these changes (y/yes/n/no)? n
-Bundle aborted.
-% bundle outgoing, no extension
-Bundling changes to <ROOT>/forest1 (branch: core/dev)
-(metadata in)   no changes found
-(metadata out)  1 changesets found
-a               1 changesets found
-b               1 changesets found
-c               no changes found
-Writing bundle file test.repo
-% rollback and view incoming
-Incoming changes from test.repo (all branches)
-
-~~~ (metadata) ~~~
-changeset:   3:997a25584670
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-~~~ a ~~~
-changeset:   2:6587ad1b3198
-branch:      core/dev
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit a
-
-~~~ b ~~~
-changeset:   2:9e6d6bb14633
-branch:      core/dev
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-% pull bundle
-Pulling changes from test.repo (all branches)
-
-~~~ (metadata) ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-~~~ a ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-~~~ b ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-% rollback, strip and try both in (with and without --log), and pull with missing node
-Incoming changes from test.repo (all branches)
-
-~~~ (metadata) ~~~
-changeset:   3:997a25584670
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-~~~ a ~~~
-bundle error: changeset 11be38c2b8b7 is missing locally
-
-~~~ b ~~~
-changeset:   2:9e6d6bb14633
-branch:      core/dev
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-Incoming changes from test.repo (all branches)
-~~~ (metadata) ~~~
-changeset:   3:997a25584670
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-a           bundle error: changeset 11be38c2b8b7 is missing locally
-b           1 new changesets
-Pulling changes from test.repo (all branches)
-
-~~~ (metadata) ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-~~~ a ~~~
-bundle error: changeset 11be38c2b8b7 is missing locally
-
-~~~ b ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-% in smaller forest
-Incoming changes from ../bundlef/test.repo (all branches)
-The module b in the bundle is not part of the (local) forest
-
-~~~ (metadata) ~~~
-changeset:   3:997a25584670
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit b
-
-~~~ a ~~~
-changeset:   2:6587ad1b3198
-branch:      core/dev
-tag:         tip
-user:        Jane Do� <jane.doe@rlyeh.org>
-date:        Thu Jan 01 00:00:00 1970 +0000
-summary:     commit a
-
-Pulling changes from ../bundlef/test.repo (all branches)
-The module b in the bundle is not part of the (local) forest
-
-~~~ (metadata) ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-~~~ a ~~~
-added 1 changesets with 1 changes to 1 files
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
-% test bundle --strip
-Restricting list of modules to 'c'
-Bundling changes to <ROOT>/forest1 (branches: core/a, core/c)
-(metadata in)   no changes found
-(metadata out)  5 changesets found
-c               6 changesets found
-Writing bundle file strip.bundle
-Stripping bundled changesets.... done
-@  changeset:   7:e2d6b153a588
-|  branch:      core/d
-|  tag:         tip
-|  user:        Jane Do� <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:00 1970 +0000
-|  summary:     leaf3
-|
-o    changeset:   6:c22d82c30934
-|\   branch:      core/c
-| |  parent:      3:1f0130e1caad
-| |  parent:      5:c35e172c7d45
-| |  user:        Jane Do� <jane.doe@rlyeh.org>
-| |  date:        Thu Jan 01 00:00:00 1970 +0000
-| |  summary:     merge
-| |
-| o  changeset:   5:c35e172c7d45
-|/   branch:      core/b
-|    parent:      3:1f0130e1caad
-|    user:        Jane Do� <jane.doe@rlyeh.org>
-|    date:        Thu Jan 01 00:00:00 1970 +0000
-|    summary:     p2
-|
-| o  changeset:   4:c6a63c835fcd
-|/   branch:      core/dev
-|    user:        Jane Do� <jane.doe@rlyeh.org>
-|    date:        Thu Jan 01 00:00:00 1970 +0000
-|    summary:     outer2
-|
-o  changeset:   3:1f0130e1caad
-|  branch:      core/dev
-|  user:        Jane Do� <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:00 1970 +0000
-|  summary:     outer1
-|
-o  changeset:   2:78d6124a005f
-|  branch:      core/dev
-|  user:        Jane Do� <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:00 1970 +0000
-|  summary:     base
-|
-o  changeset:   1:11be38c2b8b7
-|  branch:      core/dev
-|  user:        Jane Doe <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:30 1970 +0000
-|  summary:     initial core/dev
-|
-o  changeset:   0:8759c9b85d97
-   branch:      core/stable
-   user:        Jane Doe <jane.doe@rlyeh.org>
-   date:        Thu Jan 01 00:00:00 1970 +0000
-   summary:     initial core/stable
-
-Restricting list of modules to 'c'
-Bundling changes to <ROOT>/forest1 (branches: core/a, core/c, core/d)
-(metadata in)   no changes found
-(metadata out)  5 changesets found
-c               7 changesets found
-Writing bundle file strip.bundle
-Stripping bundled changesets.... done
-o  changeset:   4:c6a63c835fcd
-|  branch:      core/dev
-|  tag:         tip
-|  user:        Jane Do� <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:00 1970 +0000
-|  summary:     outer2
-|
-@  changeset:   3:1f0130e1caad
-|  branch:      core/dev
-|  user:        Jane Do� <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:00 1970 +0000
-|  summary:     outer1
-|
-o  changeset:   2:78d6124a005f
-|  branch:      core/dev
-|  user:        Jane Do� <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:00 1970 +0000
-|  summary:     base
-|
-o  changeset:   1:11be38c2b8b7
-|  branch:      core/dev
-|  user:        Jane Doe <jane.doe@rlyeh.org>
-|  date:        Thu Jan 01 00:00:30 1970 +0000
-|  summary:     initial core/dev
-|
-o  changeset:   0:8759c9b85d97
-   branch:      core/stable
-   user:        Jane Doe <jane.doe@rlyeh.org>
-   date:        Thu Jan 01 00:00:00 1970 +0000
-   summary:     initial core/stable
-
-% test incoming with and without -b
-Restricting list of modules to 'c'
-Incoming changes from strip.bundle (branches: core/d, core/c)
-(metadata)  5 new changesets
-c           4 new changesets
-Restricting list of modules to 'c'
-Incoming changes from strip.bundle (all branches)
-(metadata)  5 new changesets
-c           5 new changesets
+adding bundletest
+% preview outgoing
+Outgoing changes to <ROOT>/forest1 (branch: core/dev)
+
+~~~ (metadata) ~~~
+changeset:   3:997a25584670
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+~~~ a ~~~
+changeset:   2:6587ad1b3198
+branch:      core/dev
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit a
+
+~~~ b ~~~
+changeset:   2:9e6d6bb14633
+branch:      core/dev
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+~~~ c ~~~
+no changes found
+
+Bundle these changes (y/yes/n/no)? n
+Bundle aborted.
+% bundle outgoing, no extension
+Bundling changes to <ROOT>/forest1 (branch: core/dev)
+(metadata in)   no changes found
+(metadata out)  1 changesets found
+a               1 changesets found
+b               1 changesets found
+c               no changes found
+Writing bundle file test.repo
+% rollback and view incoming
+Incoming changes from test.repo (all branches)
+
+~~~ (metadata) ~~~
+changeset:   3:997a25584670
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+~~~ a ~~~
+changeset:   2:6587ad1b3198
+branch:      core/dev
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit a
+
+~~~ b ~~~
+changeset:   2:9e6d6bb14633
+branch:      core/dev
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+% pull bundle
+Unbundling changes from test.repo (all branches)
+
+~~~ (metadata) ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+~~~ a ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+~~~ b ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+% rollback, strip and try both in (with and without --log), and pull with missing node
+Incoming changes from test.repo (all branches)
+
+~~~ (metadata) ~~~
+changeset:   3:997a25584670
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+~~~ a ~~~
+bundle error: changeset 11be38c2b8b7 is missing locally
+
+~~~ b ~~~
+changeset:   2:9e6d6bb14633
+branch:      core/dev
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+Incoming changes from test.repo (all branches)
+~~~ (metadata) ~~~
+changeset:   3:997a25584670
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+a           bundle error: changeset 11be38c2b8b7 is missing locally
+b           1 new changesets
+Unbundling changes from test.repo (all branches)
+
+~~~ (metadata) ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+~~~ a ~~~
+transaction abort!
+rollback completed
+bundle error: changeset 11be38c2b8b7 is missing locally
+
+~~~ b ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+% in smaller forest
+Incoming changes from ../bundlef/test.repo (all branches)
+The module b in the bundle is not part of the (local) forest
+
+~~~ (metadata) ~~~
+changeset:   3:997a25584670
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit b
+
+~~~ a ~~~
+changeset:   2:6587ad1b3198
+branch:      core/dev
+tag:         tip
+user:        Jane Do� <jane.doe@rlyeh.org>
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     commit a
+
+Unbundling changes from ../bundlef/test.repo (all branches)
+The module b in the bundle is not part of the (local) forest
+
+~~~ (metadata) ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+~~~ a ~~~
+added 1 changesets with 1 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+% test bundle --strip
+Restricting list of modules to 'c'
+Bundling changes to <ROOT>/forest1 (branches: core/a, core/c)
+(metadata in)   no changes found
+(metadata out)  5 changesets found
+c               6 changesets found
+Writing bundle file strip.bundle
+Stripping bundled changesets.... done
+@  changeset:   7:e2d6b153a588
+|  branch:      core/d
+|  tag:         tip
+|  user:        Jane Do� <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     leaf3
+|
+o    changeset:   6:c22d82c30934
+|\   branch:      core/c
+| |  parent:      3:1f0130e1caad
+| |  parent:      5:c35e172c7d45
+| |  user:        Jane Do� <jane.doe@rlyeh.org>
+| |  date:        Thu Jan 01 00:00:00 1970 +0000
+| |  summary:     merge
+| |
+| o  changeset:   5:c35e172c7d45
+|/   branch:      core/b
+|    parent:      3:1f0130e1caad
+|    user:        Jane Do� <jane.doe@rlyeh.org>
+|    date:        Thu Jan 01 00:00:00 1970 +0000
+|    summary:     p2
+|
+| o  changeset:   4:c6a63c835fcd
+|/   branch:      core/dev
+|    user:        Jane Do� <jane.doe@rlyeh.org>
+|    date:        Thu Jan 01 00:00:00 1970 +0000
+|    summary:     outer2
+|
+o  changeset:   3:1f0130e1caad
+|  branch:      core/dev
+|  user:        Jane Do� <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     outer1
+|
+o  changeset:   2:78d6124a005f
+|  branch:      core/dev
+|  user:        Jane Do� <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     base
+|
+o  changeset:   1:11be38c2b8b7
+|  branch:      core/dev
+|  user:        Jane Doe <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:30 1970 +0000
+|  summary:     initial core/dev
+|
+o  changeset:   0:8759c9b85d97
+   branch:      core/stable
+   user:        Jane Doe <jane.doe@rlyeh.org>
+   date:        Thu Jan 01 00:00:00 1970 +0000
+   summary:     initial core/stable
+
+Restricting list of modules to 'c'
+Bundling changes to <ROOT>/forest1 (branches: core/a, core/c, core/d)
+(metadata in)   no changes found
+(metadata out)  5 changesets found
+c               7 changesets found
+Writing bundle file strip.bundle
+Stripping bundled changesets.... done
+o  changeset:   4:c6a63c835fcd
+|  branch:      core/dev
+|  tag:         tip
+|  user:        Jane Do� <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     outer2
+|
+@  changeset:   3:1f0130e1caad
+|  branch:      core/dev
+|  user:        Jane Do� <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     outer1
+|
+o  changeset:   2:78d6124a005f
+|  branch:      core/dev
+|  user:        Jane Do� <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     base
+|
+o  changeset:   1:11be38c2b8b7
+|  branch:      core/dev
+|  user:        Jane Doe <jane.doe@rlyeh.org>
+|  date:        Thu Jan 01 00:00:30 1970 +0000
+|  summary:     initial core/dev
+|
+o  changeset:   0:8759c9b85d97
+   branch:      core/stable
+   user:        Jane Doe <jane.doe@rlyeh.org>
+   date:        Thu Jan 01 00:00:00 1970 +0000
+   summary:     initial core/stable
+
+% test incoming with and without -b
+Restricting list of modules to 'c'
+Incoming changes from strip.bundle (branches: core/d, core/c)
+(metadata)  5 new changesets
+c           4 new changesets
+Restricting list of modules to 'c'
+Incoming changes from strip.bundle (all branches)
+(metadata)  5 new changesets
+c           5 new changesets