Commits

Patrick Mézard  committed de62daa

amend: drop --branches, pick it from working directory

The amended changeset branch was picked either from --branch or from the
first parent, but the actual working directory branch was ignored. The
behaviour is changed so the amended revision branch is picked from the
intermediate revision, which branch comes from the usual working
directory rules. --branch is thus replaced by "hg branch".

  • Participants
  • Parent commits 4675d9c
  • Branches default

Comments (0)

Files changed (2)

File hgext/evolve.py

 
         user = commitopts.get('user') or old.user()
         date = commitopts.get('date') or None # old.date()
+        extra = dict(commitopts.get('extra', {}))
+        extra['branch'] = head.branch()
 
         new = context.memctx(repo,
                              parents=newbases,
                              filectxfn=filectxfn,
                              user=user,
                              date=date,
-                             extra=commitopts.get('extra') or None)
+                             extra=extra)
 
         if commitopts.get('edit'):
             new._text = cmdutil.commitforceeditor(repo, new, [])
      _('use text as commit message for this update')),
     ('c', 'change', '',
      _('specifies the changeset to amend'), _('REV')),
-    ('b', 'branch', '',
-     _('specifies a branch for the new.'), _('REV')),
     ('e', 'edit', False,
      _('edit commit message.'), _('')),
     ] + walkopts + commitopts + commitopts2,
     if change == '.':
         change = 'p1(p1())'
     old = scmutil.revsingle(repo, change)
-    branch = opts.get('branch')
-    if branch:
-        opts.setdefault('extra', {})['branch'] = branch
-    else:
-        if old.branch() != 'default':
-            opts.setdefault('extra', {})['branch'] = old.branch()
 
     lock = repo.lock()
     try:
             updatenodes = set(cl.nodesbetween(roots=[old.node()],
                                               heads=[head.node()])[0])
             updatenodes.remove(old.node())
-            okoptions = ['message', 'logfile', 'edit', 'user', 'branch']
+            okoptions = ['message', 'logfile', 'edit', 'user']
             if not updatenodes:
                 for o in okoptions:
                     if opts.get(o):

File tests/test-amend.t

+  $ cat >> $HGRCPATH <<EOF
+  > [defaults]
+  > amend=-d "0 0"
+  > [extensions]
+  > hgext.rebase=
+  > hgext.graphlog=
+  > EOF
+  $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH
+  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ hg ci -Am adda
+  adding a
+
+Test amend captures branches
+
+  $ hg branch foo
+  marked working directory as branch foo
+  (branches are permanent and global, did you want a bookmark?)
+  $ hg amend
+  $ hg branch
+  foo
+  $ hg branches
+  foo                            2:a34b93d251e4
+  default                        0:07f494440405 (inactive)
+  $ hg glog --template '{rev}@{branch} {desc|firstline}\n'
+  @  2@foo adda
+  
+