Ebbe Elsborg avatar Ebbe Elsborg committed b939109

branch: avoid that move auto-extends the spanned modules

review: Henrik Stuart

Comments (0)

Files changed (3)

repoman/commands.py

             if not branch.g:
                 raise util.Abort('branch is local, cannot move (see repo help localbranch).')
 
+            util.dict_trim(dirstate, set(branch))
             active = dict(x for x in
                     [(m, [y for y in f[m].branchheads(name) if f[m][dirstate[m]].ancestor(f[m][y]) != f[m][y]])
                         for m in dirstate] if x[1]
             if active:
                 ui.write_err('The following modules have unmerged heads on branch %s:\n' % name)
                 modtxt = '    %s(%%d heads)\n' % cmdutil.modstr_tmpl(ui, active)
-                ui.status(''.join([modtxt % (mod, len(active[mod])) for mod in sorted(active)]))
+                ui.status(''.join([modtxt % (mod, len(active[mod])) for mod in util.sortmodules(active)]))
                 return
             op = 'move'
             cmsg = 'Moved branch %s'
             f[mod].dirstate.setbranch(name)
     ui.write_header((cmsg % name) + ':\n')
     modtxt = cmdutil.modstr_tmpl(ui, dirstate) + '%s\n'
-    ui.status(''.join([modtxt % (mod, dirstate[mod][:12]) for mod in sorted(dirstate)]))
+    ui.status(''.join([modtxt % (mod, dirstate[mod][:12]) for mod in util.sortmodules(dirstate)]))
     ui.status('Working branch: %s\n' % f.branch)
 
 def merge(ui, f, name, dry_run=False, no_status=False, **opts):

tests/output/branch.py

 run('-R forest2 branch --extend core/staging')
 run('-R forest2 branch --extend core/new')
 
+# Check that modules spanned is invariant over branch moves
+# irrespective of any surplus modules in the forest.
+print '\nMoving a branch will not auto-extend module span.'
+run('-R forest2 branch --create core/zebranch -M a -M b -d "0 0"')
+run('-R forest2 up core/dev')
+append('forest2/a/foo', 'a new line added!\n')
+os.system('hg -R forest2/a ci -d "0 0" -m zechange')
+run('-R forest2 branch --move core/zebranch -d "0 0"')
+run('-R forest2 branch core/zebranch')
+
 try:
     shutil.rmtree('forest2')
 except:

tests/output/branch.py.out

 abort: branch already exists; use --extend or --move instead.
 Branch already contains all modules; nothing to do.
 abort: branch doesn't exist; use --create to create it instead.
+
+Moving a branch will not auto-extend module span.
+Restricting list of modules to 'a, b'
+Created branch core/zebranch:
+a  d7acfb931484
+b  11be38c2b8b7
+Working branch: core/zebranch
+Updating to core/dev:
+a  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+b  No update needed
+c  No update needed
+d  No update needed
+Moved branch core/zebranch:
+a  a233acb42baf
+b  11be38c2b8b7
+Working branch: core/dev
+Branch core/zebranch (created 1970-01-01 00:00:00 by Jane Do�)
+Modules: a, b
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.