[p4python] Change list numbers do not match up after p4 submit

Dennis Crowley Dennis.Crowley at factor5.com
Mon Jul 14 11:29:55 PDT 2008


This is standard perforce behavior.
 
Submitted changelist numbers are maintained in an ascending order.
So if you open a changelist, make some changes, and then submit...
If no one has submitted a changelist with a higher number in the
meantime, the current number will be used.
If there is already a higher number submitted, then changelist you are
submitting will get
a new number to insure that the number of your submission is higher
than the last.
 
Dennis.

>>> WilkenRivera <wrivera at nikondev.com> 7/14/2008 11:12 AM >>>
Hello Everyone,

I have recently come across a strange issue when calling the p4.run 
method to execute a submit for a pending change list.

I have a set of scripts that executes a number of p4 commands for 
opening and submitting files. In order to keep all file changes under 
one changelist I create a pending changelist by using the fetch_change

and save_change method to obtain a new change list and set the change 
list status to pending.

When I submit the pending change list I get a new change list number
for 
the existing change list. I am not sure how exactly this is happening 
but I do know that it does not occur all of the time. I have included 
snippets of code to show exactly how I am obtaining a change list and 
how I am submitting  the change list.

The issue is as follows:

I begin the process of fetching a changelist once the change has been 
fetch I update the description and status (set to pending) and execute
a p4.save_change. Once the changelist  has been saved I use regex to 
extract the actual changelist number created on Perforce.

     if UserLogin(p4c):
      try:
          print "Establishing New Changelist"
          p4c.new_change = p4c.fetch_change()
          p4c.new_change['Description'] = in_description
          change_no_result = p4c.save_change(p4c.new_change)
          rx = re.compile("[^\d]+");
          changelist_no = rx.sub("",change_no_result[0])
          print "Changelist Number %s" % changelist_no;
          p4c.new_change["Change"] = changelist_no
          p4c.new_change["Status"] = "pending"
      except p4.P4Error:
          pass
      else:
          p4c.save_change(p4c.new_change)
          UserLogout(p4c)
          return changelist_no

The code above successfully creates a new changelist and marks it as 
pending. The changlist_no at this point matches the actual changelist 
number in Perforce.

Once the new_change attribute has been updated with the corresponding 
change list information the script proceeds to checkout files for edit

       print "Opening %s for edit" % str(filepath)
       p4c.run_edit ( "-c", p4c.new_change["Change"], str(filepath) )


The files at this point are marked for edit within the pending change
list.


Finally, when I submit the pending change list the change list number
on 
the Perforce server is different from the actual change list number
that 
I obtained when I originally created the change.

      cmd = ["submit"]
      cmd.append ("-c")
      cmd.append (p4c.new_change["Change"])
      p4c.run(cmd)

Any help on  or explanation on why I am getting a new change list
number 
would be greatly appreciated.

Thanks in advance

best regards,

-- 
Wilken Rivera
Software Infrastructure Administrator, Nikon Inc.
1300 Walt Whitman Road, Melville, NY 11747-3064
Phone: +631-547-8615, Cell: +917-208-9046
URI: http://www.nikonusa.com/ 
Email: wrivera at nikondev.com 
_______________________________________________
p4python mailing list
p4python at perforce.com 
http://maillist.perforce.com/mailman/listinfo/p4python 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20080714/ae32f4dd/attachment-0001.html>


More information about the p4python mailing list